akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        int N = Reader.Int();
        var A = Reader.IntArray(N * 3);
        Array.Sort(A);
        long ans = A.Skip(N).Where((v, i) => i % 2 == 0).Sum(a => (long)a);
        Console.WriteLine(ans);
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

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

struct Node
{
	std::list<int> edges, rev_edges;
	bool visited{};
	int num{-1};
};

std::vector<Node> graph;
std::vector<int> topology;
std::vector<std::vector<int>> sorted;

bool solve();
void back_track(int);
void sort(int, std::vector<int> &);
bool sc_success(std::vector<int> &, bool);

int main()
{
	if (solve())
		printf("POSSIBLE\n");
	else
		printf("IMPOSSIBLE\n");

	return 0;
}

bool solve()
{
	int n;
	scanf("%d", &n);
	graph.resize(n);
	for (int i{}; i < n; i++)
	{
		int p;
		scanf("%d", &p);
		p--;
		graph[p].edges.push_back(i);
		graph[i].rev_edges.push_back(p);
	}

	for (int i{}; i < n; i++)
		back_track(i);
	for (int i{}; i < n; i++)
		graph[i].visited = false;
	for (int i{n - 1}; i >= 0; i--)
	{
		if (graph[topology[i]].visited)
			continue;
		sorted.push_back({});
		sort(topology[i], sorted.back());
	}
	for (auto scv{sorted.rbegin()}; scv != sorted.rend(); scv++)
	{
		if (scv->size() == 1)
		{
			int &index{scv->front()};
			if (graph[index].edges.size() == 0)
				graph[index].num = 0;
			else
			{
				std::vector<int> to;
				for (auto &e : graph[index].edges)
					to.push_back(graph[e].num);
				std::sort(to.begin(), to.end());
				to.push_back(1 << 30);
				int num{};
				for (auto &e : to)
				{
					if (e > num)
						break;
					if (e == num)
						num++;
				}
				graph[index].num = num;
			}
		}
		else
		{
			if (sc_success(*scv, false))
				return true;
			for (auto &e : *scv)
				graph[e].num = -1;
			if (sc_success(*scv, true))
				return true;
			return false;
		}
	}
	return true;
}

void back_track(int index)
{
	if (graph[index].visited)
		return;
	graph[index].visited = true;
	for (auto &e : graph[index].edges)
		back_track(e);
	topology.push_back(index);
	return;
}

void sort(int index, std::vector<int> &scv)
{
	if (graph[index].visited)
		return;
	graph[index].visited = true;
	scv.push_back(index);
	for (auto &e : graph[index].rev_edges)
		sort(e, scv);
	return;
}

bool sc_success(std::vector<int> &scv, bool plus)
{
	std::vector<int> to;
	for (auto &e : graph[scv.front()].edges)
		to.push_back(graph[e].num);
	std::sort(to.begin(), to.end());
	int num{};
	for (auto &e : to)
	{
		if (num < e)
			break;
		if (num == e)
			num++;
	}
	if (plus)
		num++;
	graph[scv.front()].num = num;
	for (unsigned int i{1}; i < scv.size(); i++)
	{
		to.clear();
		num = 0;
		for (auto &e : graph[scv[i]].edges)
			to.push_back(graph[e].num);
		std::sort(to.begin(), to.end());
		for (auto &e : to)
		{
			if (num < e)
				break;
			if (num == e)
				num++;
		}
		graph[scv[i]].num = num;
	}
	if (!plus && graph[scv.front()].num != graph[scv.back()].num)
		return true;
	if (plus && graph[scv.front()].num == graph[scv.back()].num + 1)
		return true;
	return false;
}

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

int main(int argc, char const *argv[]) {
  string S;
  cin >> S;

  int ans_0 = 0;
  int ans_1 = 0;

  int length = S.length();
  if (length == 1) {
    cout << 0 << "\n";
    return 0;
  }

  for (int i = 0; i < length; i++) {
    if (i % 2 == 0) {
      ans_0 += S[i] == '0' ? 0 : 1;
      ans_1 += S[i] == '1' ? 0 : 1;
    } else {
      ans_0 += S[i] == '1' ? 0 : 1;
      ans_1 += S[i] == '0' ? 0 : 1;
    }
  }

  int ans = ans_0 < ans_1 ? ans_0 : ans_1;

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 512
import java.io.*
import java.util.*

fun solve(S: String){
    println("2018" + S.slice(4 until S.length))
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val S = sc.next()
    solve(S)
}



Measured memory_bytes: 31400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n;cin>>n;
  vector<ll>a(n);
  for(int i=0;i<n;++i){
    cin>>a[i];
  }
  ll cnt=0;
  for(int i=0;i<n;++i){
    if(a[i]%2==0){
      ++cnt;
      a[i]/=2;
      --i;
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 384
X = int(input())


def primes():
    """
    素数のジェネレータ
    """
    d = {}
    q = 2
    while True:
        if q not in d:
            yield q
            d[q * q] = [q]
        else:
            for p in d[q]:
                d.setdefault(p + q, []).append(p)
            del d[q]
        q += 1


for p in primes():
    if p >= X:
        print(p)
        exit(0)


Measured memory_bytes: 47596
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> P;
struct pos {
  int row;
  int column;
};
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1 << 30;
const ll MOD = 1000000007;
struct Phrase {
  int min;
  int max;
  int point;
};
int main(void) {
  int P_SIZE, M_SIZE;
  Phrase ph[400];
  int ml[400];
  cin >> P_SIZE;
  rep(i, P_SIZE) { cin >> ph[i].min >> ph[i].max >> ph[i].point; }
  cin >> M_SIZE;
  rep(i, M_SIZE) { cin >> ml[i]; }

  vector<int> result;

  rep(i, M_SIZE) {
    int melo = ml[i];
    int dp[401][401];
    memset(dp, 0, sizeof(dp));
    rep(p, P_SIZE) {
      auto phra = ph[p];
      for (int m = 0; m <= melo; m++) {
        if (phra.min > m) {
          dp[p + 1][m] = dp[p][m];
        } else {
          dp[p + 1][m] =
              max(dp[p + 1][m],
                  max(dp[p][m], dp[p + 1][m - phra.min] + phra.point));
        }
      }
    }

    if (dp[P_SIZE][melo] == 0) {
      cout << -1 << endl;
      return 0;
    } else {
      result.push_back(dp[P_SIZE][melo]);
    }
  }

  rep(i, result.size()) { cout << result[i] << endl; }

  return 0;
}


Measured memory_bytes: 3788
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  map<pair<string, string>, int> mp;
  for (int mask = 0; mask < (1 << n); mask++) {
    string t, r;
    for (int i = 0; i < n; i++) {
      if (mask & (1 << i)) t += s[i];
      else r += s[i];
    }
    reverse(r.begin(), r.end());
    mp[{t, r}]++;
  }
  long long ans = 0;
  for (int mask = 0; mask < (1 << n); mask++) {
    string t, r;
    for (int i = 0; i < n; i++) {
      if (mask & (1 << i)) t += s[i + n];
      else r += s[i + n];
    }
    reverse(t.begin(), t.end());
    if (mp.count({t, r})) ans += mp[{t, r}];
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 43648
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <queue>
using namespace std;
#define lol long long

pair<int, int> a[110000];

int main()
{
	lol N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a, a + N);
	int iti = 0;
	int ans = 0;
	while (K > 0) {
		K -= a[iti].second;
		ans = a[iti].first;
		iti++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;
#define INF 1 << 29
typedef pair< int , int > Pi;
int h, w;
char mas[50][50];
int graph[11][11];
int min_cost[50][50];
Pi gomi[11];
int gomi_size, uoo;
int memo[12][1 << 11];
const int dy[] = { 1, 0, 0, -1}, dx[] = { 0, 1, -1, 0};

int rec(int idx, int used)
{
  if(used == (1 << gomi_size) - 1) return 0;
  if(memo[idx][used]) return memo[idx][used];

  int ret = INF;
  for(int i = 0; i < gomi_size; i++){
    if(!(used & (1 << i)) && graph[idx][i] != -1){
      ret = min(ret, rec(i, used | (1 << i)) + graph[idx][i]);
    }
  }

  return memo[idx][used] = ret;
}


int bfs(Pi a, Pi b)
{
  memset( min_cost, -1, sizeof(min_cost));
  queue< Pi > que;
  que.push(a);
  min_cost[a.first][a.second] = 0;
  while(!que.empty()){
    Pi p = que.front(); que.pop();
    if(p == b) return min_cost[p.first][p.second];
    for(int i = 0; i < 4; i++){
      int ny = p.first + dy[i], nx = p.second + dx[i];
      if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
      if(mas[ny][nx] != 'x' && min_cost[ny][nx] == -1){
        min_cost[ny][nx] = min_cost[p.first][p.second] + 1;
        que.push( Pi( ny, nx));
      }
    }
  }
  return -1;
}

int main()
{
  while(cin >> w >> h, w){
gomi_size = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> mas[i][j];
      if(mas[i][j] == '*' || mas[i][j] == 'o'){
        gomi[gomi_size++] = Pi( i, j);
        if(mas[i][j] == 'o') uoo = gomi_size - 1;
      }
    }
  }
  for(int i = 0; i < gomi_size; i++){
    for(int j = i + 1; j < gomi_size; j++){
      graph[i][j] = graph[j][i] = bfs(gomi[i], gomi[j]);
    }
  }

  //巡回セールスマン！！
  //さのぴーさんよろしく
memset( memo, 0, sizeof(memo));
  int ret = rec( uoo, 1 << uoo);

  if(ret != INF) cout << ret << endl;
  else cout << -1 << endl;
}
  return(0);
}

Measured memory_bytes: 1328
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i<n; i++){
            list.add(sc.nextInt());
        }

        int answer =0;
        for (int i = 0; i < n-2; i++){
            if (secondIsMedium(list.get(i), list.get(i+1), list.get(i+2))){
                answer++;
            }
        }

        System.out.println(answer);
    }

    private static boolean secondIsMedium(int one, int two, int three){
        return (one < two && two < three) || (one > two && two > three);
    }
}

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL,LL> PLL;
typedef map<int,int> MII;
typedef queue<int> QI;
typedef queue<PII> QPII;
typedef stack<int> SI;
typedef stack<PII> SPII;
typedef deque<int> DI;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<double> VD;
typedef vector<VD> VVD;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef vector<PII> VPII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define PF push_front
#define POB pop_back()
#define POF pop_front()
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REPR(i,n) RFOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = INT_MAX;
const LL LINF = LLONG_MAX;
const LL MOD = 1e9+7;
const LL MODD = 998244353;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

VI dx = {1,0,-1,0,1,1,-1,-1};
VI dy = {0,1,0,-1,1,-1,1,-1};

LL Gcd(LL a, LL b) {
  return __gcd(a,b);
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(N == 0) {
    return 0;
  }
  
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}


int main() {
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N,M;
  cin >> N >> M;
  
  int ans = N*(N-1)/2 + M*(M-1)/2;
  
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;
using LL = long long;

constexpr int N = 1e5 + 5;

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

    int a, b;
    cin >> a >> b;
    cout << (a == b? "Yes" : "No");
}

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

int main(){//A
/*
    char a;
    cin>>a;
    if(isupper(a)) cout<<'A'<<endl;
    else cout<<'a'<<endl;
    */
   //B
   int n,k;
   cin>>n>>k;
   vector<int> p(n);
   rep(i,0,n) cin>>p[i];
   sort(p.begin(),p.end());
   int ans =0;
   rep(i,0,k) ans+=p[i];
   cout<<ans<<endl;
}

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

int main(){
  int A,B,C,D;cin>>A>>B>>C>>D;
  while(A>0&&C>0){//どちらかのHPが0以下になるまで繰り返す
    A-=D;
    C-=B;
  }
  cout<<(C<=0?"Yes":"No")<<endl;
}

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

int main() {
    int n; cin >> n;
    if (n < 1200) return !(cout << "ABC" << endl);
    if (n < 2800) return !(cout << "ARC" << endl);
    cout << "AGC" << endl;
    return 0;
}


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


void solve(long long L, long long R, long long d){
  long long count = 0;
  for(long long i = L; i <= R; i++){
    if(i % d == 0){
      count++;
    }
  }

  cout << count << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long L;
  scanf("%lld",&L);
  long long R;
  scanf("%lld",&R);
  long long d;
  scanf("%lld",&d);
    solve(L, R, d);
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#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;
using uif=uint_fast64_t;
using ll=long long int;
using tTree=__gnu_pbds::tree< ll , __gnu_pbds::null_type, less< ll >, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  string s;
  cin>>s;
  
  ll b=0;
  ll ans=0;

  for(auto c:s){
    if(c=='W') ans+=b;
    else b++;
  }

  cout << ans << endl;

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

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

typedef long long LL;
typedef pair<LL, LL> PII;
typedef vector<LL> VI;

#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(LL i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(LL i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

const double PI = acos(-1.0);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const LL INF = 1000 * 1000 * 1000;
const LL MAX = 2000 * 1000 + 5;
const LL MAX2 = 1000 * 1000 + 2;
const LL MAX20 = MAX2 * 10;
LL dp[40][40][40];
int n;
int a[40][40];
int main()
{
	//ios_base::sync_with_stdio(0);
	scanf("%d" , &n);
	n *= 2;
	
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			scanf("%1d" , &a[i][j]);
			//cout << a[i][j];
		}
		//cout << endl;
	}
	
	for(int i = 0; i < n; i++)
		dp[i][i][i] = 1;
	for(int len = 2; len <= n; len++)
		for(int l = 0; l < n - len + 1; l++)
		{
			int r = l + len - 1;
			for(int c = l; c <= r; c++)
				for(int c1 = l; c1 < c; c1++)
					for(int r1 = c1; r1 < c; r1++)
					{
						int l2 = r1 + 1;
						for(int r2 = c; r2 < r; r2++)
						{
							int l3 = r2 + 1;
							for(int c2 = l3; c2 <= r; c2++)
							{
								if(!a[c1][c2])
									continue;
								dp[l][c][r] += dp[l][c1][r1] * dp[l2][c][r2] * dp[l3][c2][r];
							}
						}
					}
		}
	LL ans = 0;
	for(int i = 1; i < n; i++)
		if(a[0][i])
			ans += dp[1][i][n - 1];
	cout << ans;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main()
{
    jaldi
    char c;
    cin>>c;
    cout<<char(c+1);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define max(a,b) a>b?a:b

int LCS(char x[],char y[]);

int main()
{
  int n,i;
  char x[1001],y[1001];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%s%s",x,y);
      printf("%d\n",LCS(x,y));
    }
  return 0;
}

int LCS(char x[],char y[])
{
  int i,j;
  int l1=strlen(x),l2=strlen(y);
  int lcs[1001][1001];
 
  for(i=0;i<=l1;i++)lcs[i][0]=0;
  for(i=1;i<=l2;i++)lcs[0][i]=0;
  for(i=1;i<=l1;i++)
    {
      for(j=1;j<=l2;j++)
	{
	  if(x[i-1]==y[j-1])lcs[i][j]=lcs[i-1][j-1]+1;
	  else lcs[i][j]=max(lcs[i-1][j],lcs[i][j-1]);
	}
    }
  return lcs[l1][l2];
}



Measured memory_bytes: 5656
#include<bits/stdc++.h>
using namespace std;
int mypow(int x,int y){
  int r=1;
  for(int i=0;i<y;i++)r*=x;
  return r;
}
int main(){
  int D,N;cin>>D>>N;
  int n=0;
  int ans=0;
  while(n<N){
    ans+=mypow(100,D);
    if(ans%mypow(100,D)==0 &&ans%mypow(100,D+1)!=0){
      n++;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long a[100010],n,sisi1,sisi2;
int main() {
cin>>n;
for(int i=1;i<=n;i++) {
	cin>>a[i];
}
sort(a+1,a+n+1);
for(int i=n;i>=2;i--) {
	if(a[i]==a[i-1]) {
		sisi1=i;
		break;
	}
}
for(int i=sisi1-2;i>=2;i--) {
	if(a[i]==a[i-1]) {
		sisi2=i;
		break;
	}
}
cout<<a[sisi1]*a[sisi2]<<endl;
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;
using P = pair<int, int>;
int main() {
    int n, m;
    cin >> n >> m;
    vector<int> dis(n, INF<int>);
    vector<map<int, int>> com(n);
    vector<vector<P>> G(n);
    for (int i = 0; i < m; ++i) {
        int p, q, c;
        scanf("%d %d %d", &p, &q, &c);
        G[p-1].emplace_back(q-1, c);
        G[q-1].emplace_back(p-1, c);
    }
    dis[0] = 0;
    GPQ<P> Q;
    Q.emplace(0, 0);
    while (!Q.empty()){
        int cost;
        int i;
        tie(cost, i) = Q.top(); Q.pop();
        i = -i;
        if(dis[i] < cost) continue;
        for (auto &&e : G[i]) {
            int cost2 = cost + (com[i][e.second] == 0);
            if(dis[e.first] < cost2) continue;
            if(dis[e.first] > cost2) {
                dis[e.first] = cost2;
                com[e.first].clear();
                Q.emplace(cost2, -e.first);
            }
            com[e.first][e.second]++;
        }
    }
    cout << (dis[n-1] >= INF<int> ? -1 : dis[n-1]) << "\n";
     return 0;
}


Measured memory_bytes: 32892
N = input()
S = input()


L = len(S)
SS = list(S) 
count = 0


for i in range(L-2):
    if SS[i] == "A":
        if SS[i+1] == "B":
            if SS[i+2] == "C":
                count = count + 1
         

print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    string C1,C2; cin >> C1 >> C2;
    if(C1[0]==C2[2] && C1[1]==C2[1] && C1[2]==C2[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


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

using namespace std;

#define ll       long long

#define  sci(x)   scanf("%d", &x)
#define  scl(x)   scanf("%lld", &x)
#define  scd(x)   scanf("%lf", &x)

#define  pfi(x)   printf("%d", x)
#define  pfl(x)   printf("%lld", x)
#define  pfd(x)   printf("%lf", x)
#define  pfc(x)   printf("Case %d: ", x++)
#define  ps       printf(" ")
#define  pn       printf("\n")

#define  pb       push_back
#define  ppb      pop_back
#define  pf       push_front
#define  ppf      pop_front
#define  In       insert
#define  All(a)   a.begin(), a.end()

int dp[1005][1005], h, w, mod = 1000000007;
char s[1005][1005];

int solve(int i, int j)
{
	if(i >= h || j >= w || s[i][j] == '#')
		return 0;
	if(i == h - 1 && j == w - 1)
		return 1;
	ll ret = dp[i][j];

	if(ret != -1)
		return ret;

	ret = solve(i + 1, j) + solve(i, j + 1);
	ret %= mod;
	//cout << i <<' ' << j << ' ' << ret << endl;
	return dp[i][j] = ret;
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    memset(dp, -1, sizeof dp);
    sci(h), sci(w);

    for(int i = 0; i < h; i++)
    	scanf(" %s", s[i]);
    cout << solve(0, 0);
    return 0;
}

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

int main()
{
  uint64_t n, m, k;
  std::cin >> n >> m >> k;
  std::vector<uint64_t> A(n + 1);
  A[0] = 0;
  for (uint64_t i = 1; i <= n; ++i)
  {
    uint64_t tmp;
    std::cin >> tmp;
    A[i] = A[i - 1] + tmp;
  
  }
  std::vector<uint64_t> B(m + 1);
  B[0] = 0;
  for (uint64_t i = 1; i <= m; ++i)
  {
    uint64_t tmp;
    std::cin >> tmp;
    B[i] = B[i - 1] + tmp;  
  }
  uint64_t aIndex = n;
  uint64_t ans = 0;
  for (uint64_t bIndex = 0; bIndex <= m; ++bIndex)
  {
    while(A[aIndex] + B[bIndex] > k && aIndex > 0)
    {
      aIndex--;
    }
    if (A[aIndex] + B[bIndex] <= k)
    {
      ans = std::max(ans, aIndex + bIndex);
    }
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 6356
N, M = map(int, input().split(' '))

K = [list(map(int, input().split(' '))) for i in range(M)]
P = list(map(int, input().split(' ')))

ans = 0
for i in range(2 ** N) :
    add = True
    for j in range(M) :
        k = K[j]
        cnt = 0
        for s in k[1:] :
            if (1 << (s - 1)) & i > 0 :
                cnt += 1
        if cnt % 2 == P[j] :
            pass
        else :
            add = False
            break
    if add :
        ans += 1

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	int start=a*60+b, end=c*60+d;
	end-=start;
	end-=e;
	cout << end << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    vector<int> a(n);
    vector<int> num(pow(10,5),0);
    for(int i=0;i<n;i++){
        cin>>a[i];
        num[a[i]]++;
    }
    sort(a.begin(),a.end());
    long long kazu=0;
    long long ans=num[0]+num[1];
    for(long long i=1;i<=a[n-1]-1;i++){
        kazu=num[i-1]+num[i]+num[i+1];
        ans=max(ans,kazu);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
            int K = sc.nextInt();
            int S = sc.nextInt();
            int K2 = K * 2;

            int count = 0;
            for(int X = 0;X <= K;X++){
                if(K2 + X >= S){
                    for(int Y = 0;Y <= K;Y++){
                        int sxy = S - X -Y;
                        
                        if(0 <= sxy && sxy <= K){
                            //System.out.println("X"+X+"Y"+Y+"sxy"+sxy);
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

char s[555];
int n;
int main() {
	scanf("%s", s);
	for (n=0;s[n];n++) {
		if (n<4 && "YAKI"[n] != s[n]) {
			printf("No\n");
			return 0;
		}
	}
	printf("%s\n", n>=4 ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<utility>
#include<algorithm>
#include<queue>
#define llong long long
using namespace std;

const int N = 5e5;
struct SegmentTree
{
	struct SgTNode
	{
		int val;
	} sgt[(N<<2)+2];
	void pushup(int pos) {sgt[pos].val = max(sgt[pos<<1].val,sgt[pos<<1|1].val);}
	void modify(int pos,int le,int ri,int lrb,int val)
	{
		if(le==lrb && ri==lrb) {sgt[pos].val = val; return;}
		int mid = (le+ri)>>1;
		if(lrb<=mid) {modify(pos<<1,le,mid,lrb,val);}
		else if(lrb>mid) {modify(pos<<1|1,mid+1,ri,lrb,val);}
		pushup(pos);
	}
	int querymax(int pos,int le,int ri,int lb,int rb)
	{
		if(lb<=le && rb>=ri) {return sgt[pos].val;}
		int mid = (le+ri)>>1;
		int ret = 0;
		if(rb>mid) {ret = max(ret,querymax(pos<<1|1,mid+1,ri,lb,rb));}
		if(lb<=mid) {ret = max(ret,querymax(pos<<1,le,mid,lb,rb));}
		return ret;
	}
} smt;
struct Edge
{
	int v,nxt;
} e[(N<<1)+2];
int a[N+3];
int b[N+3];
int ind[N+3];
int fe[N+3];
priority_queue<pair<int,int> > pq;
pair<int,int> ans[N+3];
int fans[N+3];
int n,m,en;

void addedge(int u,int v)
{
//	printf("addedge%d %d\n",u,v);
	en++; e[en].v = v; ind[v]++;
	e[en].nxt = fe[u]; fe[u] = en;
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1; i<=n; i++) {int x; scanf("%d",&b[i]); a[b[i]] = i;}
	for(int i=1; i<=n; i++)
	{
		ans[i].second = a[i];
		int x = smt.querymax(1,0,n,max(a[i]-m+1,0),a[i]);
		int y = smt.querymax(1,0,n,a[i],min(a[i]+m-1,n));
		if(x) {addedge(i,x);}
		if(y) {addedge(i,y);}
//		printf("iquery %d %d %d\n",i,max(0,a[i]-m+1),min(n,a[i]+m-1));
//		printf("imodify %d %d %d\n",i,ans[i].second,ans[i].first);
		smt.modify(1,0,n,ans[i].second,i);
//		printf("ans%d %d %d\n",i,ans[i].first,ans[i].second);
	}
	for(int i=1; i<=n; i++) if(ind[i]==0) {pq.push(make_pair(a[i],i));}
	int j = 0;
	while(!pq.empty())
	{
		pair<int,int> tmp = pq.top(); pq.pop();
		j++; b[j] = tmp.first; int u = tmp.second;
		for(int i=fe[u]; i; i=e[i].nxt)
		{
			ind[e[i].v]--;
			if(ind[e[i].v]==0)
			{
				pq.push(make_pair(a[e[i].v],e[i].v));
			}
		}
	}
	for(int i=1; i<n+1-i; i++) swap(b[i],b[n+1-i]);
	for(int i=1; i<=n; i++) fans[b[i]] = i;
	for(int i=1; i<=n; i++) printf("%d\n",fans[i]);
	return 0;
}

Measured memory_bytes: 31092
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
//cout << fixed << setprecision(10) << ans << endl;
//int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main(){
    string s;
    cin >> s;
    if(s[0]!=s[s.size()-1]){
        if(s.size()%2==1){
            cout << "First" << endl;
            return 0; 
        }
        else {
            cout << "Second" << endl;
            return 0; 
        }
    }
    else {
        if(s.size()%2==0){
            cout << "First" << endl;
            return 0; 
        }
        else {
            cout << "Second" << endl;
            return 0; 
        }
    }



    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
int main() {
 
    int a,b,c,d,e,f;
    
    cin >>  a >> b >> c;
    d = a+b;
   
    cout << d*c/2 << endl;
    
    
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

class Sched {
	public:
	Sched(int D): D(D) {
		c = vector<int>(26);
		for (int i = 0 ; i < 26 ; i++) {
			cin >> c[i];
		}
		s = vector<vector<int>> (D, vector<int>(26));
		for (int i = 0 ; i < D ; i++) {
			for (int j = 0 ; j < 26 ; j++) {
				cin >> s[i][j];
			}
		}
	}

	vector<int> choose() {
		vector<int> choice(D);
		vector<int> l(26);
		for (int d = 0 ; d < D ; d++) {
			int best = 0;
			for (int i = 0 ; i < 26 ; i++) {
				int dm = c[i] * (d + 1 - l[i]) - s[d][i];
				if (dm < best) {
					best = dm;
					choice[d] = i;
				}
			}
			l[choice[d]] = d + 1;
		}
		return choice;
	}

	ll score(vector<int>& contest) {
		ll score = 0;
		vector<int> l(26);
		for (int d = 0 ; d < D ; d++) {
			l[contest[d]] = d + 1;
			score += s[d][contest[d]];
			for (int i = 0 ; i < 26 ; i++) {
				score -= c[i] * (d + 1 - l[i]);
			}
		}
		return score;
	}

	private:
	vector<int> c;
	vector<vector<int>> s;
	int D;

};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int D;
	cin >> D;
	Sched scheduler(D);
	auto c = scheduler.choose();
	ll score = scheduler.score(c);
	for (int i = 0 ; i < 10000 ; i++) {
		int b = c[i % D];
		for (int j = 0 ; j < 26 ; j++) {
			if (j != b) {
				c[i % D] = j;
				ll score2 = scheduler.score(c);
				if (score2 > score) {
					b = j;
					score = score2;
				}
			}
		}
		c[i % D] = b;
	}
	for (auto r : c) {
		cout << r + 1 << "\n";
	}
	cerr << score << endl;
	return 0;
}


Measured memory_bytes: 3708
package main

import (
	"fmt"
	"sort"
)

type restaurant struct {
	id    int
	name  string
	score int
}

type guidebook []restaurant

func (b guidebook) Len() int {
	return len(b)
}
func (b guidebook) Swap(i, j int) {
	b[i], b[j] = b[j], b[i]
}
func (b guidebook) Less(i, j int) bool {
	if b[i].name == b[j].name {
		return b[i].score > b[j].score
	} else {
		return b[i].name < b[j].name
	}
}

func main() {
	var n int
	fmt.Scan(&n)

	r := make([]restaurant, n)
	for i := 0; i < n; i++ {
		r[i].id = i + 1
		fmt.Scan(&r[i].name, &r[i].score)
	}

	sort.Sort(guidebook(r))
	for _, v := range r {
		fmt.Println(v.id)
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int y, m, d;
  scanf("%d/%d/%d", &y, &m, &d);

  if(m < 4 || (m == 4 && d <= 30)) cout << "Heisei" << endl;
  else cout << "TBD" << endl;

  return 0;
}


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

class Tree():
    def __init__(self, n, edge):
        self.n = n
        self.tree = [[] for _ in range(n)]
        for e in edge:
            self.tree[e[0] - 1].append(e[1] - 1)
            self.tree[e[1] - 1].append(e[0] - 1)

    def setroot(self, root):
        self.root = root
        self.parent = [None for _ in range(self.n)]
        self.parent[root] = -1
        self.depth = [None for _ in range(self.n)]
        self.depth[root] = 0
        stack = [root]
        while stack:
            node = stack.pop()
            for adj in self.tree[node]:
                if self.parent[adj] is None:
                    self.parent[adj] = node
                    self.depth[adj] = self.depth[node] + 1
                    stack.append(adj)

N = int(input())
E = [tuple(map(int, input().split())) for _ in range(N - 1)]

Tf = Tree(N, E)
Tf.setroot(0)

Ts = Tree(N, E)
Ts.setroot(N - 1)

fennec = 0
snuke = 0

for i in range(N):
    if Tf.depth[i] <= Ts.depth[i]:
        fennec += 1
    else:
        snuke += 1

if fennec > snuke:
    print('Fennec')
else:
    print('Snuke')

Measured memory_bytes: 62336
from sys import stdin

N  = int(input())
S,T = stdin.readline().rstrip().split()

S_ = list(S)
T_ = list(T)

U = []

for i in range(N):
    U.append(S_[i])
    U.append(T_[i])


U_ = ','.join(U)
print(U_.replace(',',''))

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

int main() {
    int n;
    cin>>n;
    int dp[n+1];
    fill(dp,dp+n+1,n);
    dp[0]=0;
    for (int i=1;i<=n;i++) {
        for (int j=1;j<=i;j*=6)
            dp[i]=min(dp[i],dp[i-j]+1);
        for (int j=1;j<=i;j*=9)
            dp[i]=min(dp[i],dp[i-j]+1);
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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



	int dp0 = 0;
	int dp1 = 1e9;

	const int cm = 1 << 17;
	char C[cm], *ci = C;
	fread(C, 1, cm, stdin);
	char c = C[0];
	while (c >= '0') {

		rep(i, cm) {
			c = *ci++;
			if (c < '0') break;

			int s = c - '0';

			int tmp0 = min(dp0, dp1 + 1) + s;
			dp1 = min(dp1, dp0 + 1) + 9 - s;
			dp0 = tmp0;
		}
		fread(C, 1, cm, stdin);
		ci = C;
	}

	printf("%d\n", min(dp0, dp1 + 1));

	Would you please return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
  string A, B, C;
  cin >> A >> B >> C;
  if ((A[A.length()-1]==B[0]) && (B[B.length()-1]==C[0])) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 3532
import math
import time
from collections import defaultdict,deque
from sys import stdin,stdout
from bisect import bisect_left,bisect_right
n,k=map(int,stdin.readline().split())
ans=n
done=defaultdict(lambda:False)
for _ in range(k):
    d=int(input())
    a=list(map(int,stdin.readline().split()))
    for i in a:
        if(i not in done):
            ans-=1
            done[i]=True
print(ans)


Measured memory_bytes: 68312
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pradyumn
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextIntArray(n);
            int count = 0;
            for (int i = 0; i < n; ) {
                int j = i;
                while (j < n && a[j] == a[i]) ++j;
                count += (j - i) / 2;
                i = j;
            }
            out.println(count);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int pnumChars;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        private int pread() {
            if (pnumChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= pnumChars) {
                curChar = 0;
                try {
                    pnumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (pnumChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = pread();
            while (isSpaceChar(c))
                c = pread();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = pread();
            }
            int res = 0;
            do {
                if (c == ',') {
                    c = pread();
                }
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = pread();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n) {
            int[] array = new int[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextInt();
            }
            return array;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define sz(a) int((a).size())
#define int long long
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define bitcnt(n) __builtin_popcountll(n)
#define tr(container , s ) for(auto x : container ){cout << x << s;} cout<<endl;
#define one(x) cerr<<#x<<" : "<<x<<endl;
#define two(x,y) cerr<<#x<<" : "<<x<<" , "<<#y<<" : "<<y<<endl;
#define three(x,y,z) cerr<<#x<<" : "<<x<<" , "<<#y<<" : "<<y<<" , "<<#z<<" : "<<z<<endl;
#define PI acos(-1)
const int M = 1000000007;
const int N=3e5+5;
bool prime[N+1];
void sieve()
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=N; p++)
    {
        // If prime[p] is not changed, then it is a prime
        if (prime[p])
        {
            // Update all multiples of p greater than or
            // equal to the square of it
            // numbers which are multiple of p and are
            // less than p^2 are already been marked.
            for (int i=p*p; i<=N; i += p)
                prime[i] = false;
        }
    }
}
signed main()
{
    int x ;
    cin >>x;
    sieve();
    for(int i=x ; ; i++)
    {
        if(prime[i]){
            cout << i << endl;
            break;
        }

    }
}



Measured memory_bytes: 512
#[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 , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[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 ) * } } ; }
#[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 ) * } } ; }

fn main() {
    input! {
        N: usize
    }
    let mut count: Vec<i32> = vec![0; N + 1];
    for i in 1..=N {
        for j in 1..=N / i {
            count[i * j] += 1;
        }
    }
    count[0] = 0;
    let ret = count.iter().enumerate()
        .filter(|(i, &val)| {
            (i % 2 == 1) && (val == 8)
        })
        .count();
    println!("{}", ret);
}


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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define VEC vector

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				Vint;
typedef vector<Vint>			VV;

template<typename T>string join(const v(T)&v)
{stringstream s;REP(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		400010

const ll LINF = (ll)9e18+7;		//
const int INF = 100100100;			//2,147,483,647 (Max int)
const ll MOD = 1e9+7;
// テンプレ終了
//====================================================================//

// int DP[MAX];


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

	ll ans = 0;

	int r=0,g=0,b=0;

	REP(i,S.size()){
		if(S[i]=='R')r++;
		else if(S[i]=='B')b++;
		else g++;
	}

	ans = (ll)r * b * g;
	int L = S.size();

	REP(i,L){
		REPS(j,1,L){
			if(i+2*j >= L)break;
			if(S[i]!=S[i+j] && S[i]!=S[i+2*j] && S[i+j] != S[i+2*j] )ans--;
		}
	}

	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 3640