akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <chrono>
#include <numeric>
#include <set>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <iomanip>
#include <list>
#include <limits>

using namespace std;

class cCountingSort
{
	int mn, mk;
	vector<int> m_va, m_vb;
public:
	cCountingSort(int n, vector<int> &va, int k)
		: mn(n), mk(k)
	{
		m_va = va;
		m_vb.resize(mn);
		fill(m_vb.begin(), m_vb.end(), -1);
	}

	void sort();
	void output();
};

void cCountingSort::sort()
{
	vector<int> vc;
	for (int i = 0; i <= mk; ++i)
	{
		vc.push_back(0);
	}

	for (int j = 0; j < mn; ++j)
	{
		vc[m_va[j]]++;
	}

	for (int i = 1; i <= mk; ++i)
	{
		vc[i] = vc[i] + vc[i - 1];
	}

	for (int j = mn - 1; j >= 0; --j)
	{
		m_vb[vc[m_va[j]] - 1] = m_va[j];
		vc[m_va[j]]--;
	}
}

void cCountingSort::output()
{
	for (int i = 0; i < mn - 1; ++i)
	{
		cout << m_vb[i] << " ";
	}
	cout << m_vb[mn - 1] << endl;
}

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

	int n;
	cin >> n;
	cin.ignore();

	int a;
	vector<int> va;
	for (int i = 0; i < n; ++i)
	{
		cin >> a;
		va.push_back(a);
	}

	cCountingSort ccs(n, va, *max_element(va.begin(), va.end()));
	ccs.sort();
	ccs.output();

	return 0;
}

Measured memory_bytes: 26464
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

void printAns(long long a) { cout << a << endl; }

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//ll INF = 10000000;
//ll mod = 1000000007;//10^9+7

//using Graph = vector<vector<pair<int, int>>>;
//Graph G(100100);


//番号ズレ注意！！
int main() {
    string S;
    cin >> S;
    int N = S.size();
    int ans = 0;
    int length = 0;
    REP(i, N) {
        if (S[i] != 'A' && S[i] != 'T' && S[i] != 'G' && S[i] != 'C') {
            chmax(ans, length);
            length = 0;
            continue;
        } else {
            length++;
        }
        if(i==N-1){chmax(ans, length);}
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(N):
    ans += B[A[i]-1]
    if i > 0:
        if A[i] == A[i-1] + 1:
            ans += C[A[i-1]-1]
print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 10007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
struct edge{
  int v, c;
  edge(int v, int c) : v(v), c(c) {}
};
typedef vector<edge> node;

int main(){
  int N;
  while(cin>>N && N){
    vector<node> G(N);
    REP(i, N){
      REP(iter, 2){
        int v, c;
        cin>>v>>c;
        G[i].push_back(edge(v, c));
      }
    }
    int s = 0;
    vector<int> color(N, -1);
    REP(i, N) if(color[i] == -1){
      queue<int> que;
      que.push(i);
      color[i] = s;
      while(!que.empty()){
        int u = que.front(); que.pop();
        REP(i, G[u].size()){
          edge e = G[u][i];
          if(color[e.v] == -1){
            que.push(e.v);
            color[e.v] = s;
          }
        }
      }
      s += 1;
    }
    ll ans = 1;
    REP(c, s){
      int max_c = -INF;
      REP(i, N) if(color[i] == c) REP(j, G[i].size()) max_c = max(max_c, G[i][j].c);
      int cnt = 0;
      REP(i, N) if(color[i] == c) REP(j, G[i].size()) if(G[i][j].c == max_c) cnt++;
      cnt /= 2;
      ans = (ans * cnt) % MOD;
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

int main() {
 int N,T=0;
 cin >> N;
 vector<string> s(N);
 vector<int> t(N);
 for(int i=0;i<N;i++){
    cin >> s.at(i) >> t.at(i);
 }
 string X;
 cin >> X;
 for(int i=0;i<N;i++){
     if(s.at(i)==X){
         for(int j=i+1;j<N;j++){
             T = T + t.at(j);
         }
         break;
     }
 }
 cout << T << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){

  int N;
  cin>>N;
  vector<int>a(3*N);
  for(int i=0;i<=3*N-1;i++){
  
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  long long int ans=0;
  int count=0;
  for(int i=3*N-2;i>=0;i-=2){
  
    ans+=a[i];
    count++;
    if(count==N)break;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 4552
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------
vector<vector<int>> G;
vector<int> ans;
vector<int> ans2;
vector<bool> dist;
bool sec = false;
void dfs(int v){
    dist[v] = true;
    for(int nv : G[v]){
        if(dist[nv]) continue;
        if(sec){
            ans2.push_back(nv);
        }else{
            ans.push_back(nv);
        }
        dfs(nv);
        break;
    }
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M;
    cin >> N >> M;
    G.resize(N);
    dist.resize(N);
    for(int i=0; i<M; i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(0);
    sec = true;
    dfs(0);
    reverse(ans.begin(),ans.end());
    cout << ans.size()+1+ans2.size() << endl;
    for(int i=0; i<ans.size(); i++){
        if(i){
            cout << " ";
        }
        cout << ans[i]+1;
    }
    cout << " 1 ";
    for(int i=0; i<ans2.size(); i++){
        cout << ans2[i]+1 << (i != ans2.size()-1 ? " " : "\n");
    }
    return 0;
}

Measured memory_bytes: 13944
#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long
#define mod 1000000007
long long exp(long long taban, long long us) {
    long long carpan = taban;
    long long temp = us;
    long long res = 1;
    while(temp > 0){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}
ll ebob(ll a, ll b){
	if(!a)return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (((a*b)%mod)*(exp(ebob(a,b), (ll)mod-2))) % mod;
}
/*int level[100005];
int parent[100005][20];
vector<vector<int>> vec(100005);
void fonk(int cur, int dont){
	level[cur] = level[dont] + 1;
	parent[cur][0] = dont;
	for(int i = 1; i < 20; i++){
		parent[cur][i] = parent[parent[cur][i - 1]][i-1];
	}
	for(int i = 0; i < vec[cur].size(); i++){
		if(vec[cur][i] != dont) fonk(vec[cur][i], cur);
	}
}

int lca(int n1, int n2){
	int ans = -1;
	if(level[n2] > level[n1]){
		swap(n1, n2);
	}
	while(level[n1] > level[n2]){
		for(int i = 0; i < 20; i++){
			if(level[parent[n1][i]] >= level[n2]){
				n1 = parent[n1][i];
			}else break;
		}
	}
	if(n1 == n2) return n1;
	while(parent[n1][0] != parent[n2][0]){
		int tmp1, tmp2;
		for(int i = 0; i < 20; i++){
			if(parent[n1][i] != parent[n2][i]){
				tmp1 = parent[n1][i];
				tmp2 = parent[n2][i];
			}else break;
		}
		n1 = tmp1, n2 = tmp2;
	}
	return parent[n1][0];
}

int dist(int n1, int n2){
	return level[n1] + level[n2] - 2*level[lca(n1, n2)];
}*/
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
	bool check = true;
	while(n--){
		int sayi; cin>>sayi;
		if(sayi % 2 == 0 && (sayi % 3 && sayi % 5)) check = false;
	}
	check ? cout<<"APPROVED" : cout<<"DENIED";
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <cmath>

using namespace std;

int main(){
	int n;
	double x[100] = {0},y[100] = {0},p_1 = 0,p_2 = 0,p_3 = 0,p_infinity = -1;
	scanf("%d",&n);
	for(int i = 0; i < n; i++) scanf("%lf",&x[i]);
	for(int i = 0; i < n; i++) scanf("%lf",&y[i]);

	for(int i = 0; i < n; i++){
		p_1 += abs(x[i] - y[i]);
		p_2 += (x[i] - y[i])*(x[i] - y[i]);
		p_3 += abs((x[i] - y[i])*(x[i] - y[i])*(x[i] - y[i]));
		p_infinity = (p_infinity >= abs(x[i] - y[i]))? p_infinity:abs(x[i] - y[i]);
 	}
	printf("%.6lf\n",p_1);
	printf("%.6lf\n",sqrt(p_2));
	printf("%.6f\n",cbrt(p_3));
	printf("%.6lf\n",p_infinity);

}



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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    char c;
    cin >> c;
    if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
        printf("vowel\n");
        return 0;
    }
    printf("consonant\n");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n, i, j, res, sum;

    while(1){
        scanf("%d", &n);
        if(n == 0){
            return 0;
        }

        sum = 0;
        for(i=1; i < n; i++){
            res = 0;
            j = i;
            while(res < n && j < n){
                res += j;
                j++;
                if(res == n){
                    sum++;
                    break;
                }
            }
        }
        printf("%d\n", sum);
    }

    return 0;
}

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int n;
    string s;
    cin >> n >> s;

    // n = 1 のコーナーケースに気をつける


    vector<vector<int>> c(9, vector<int>(9, 0));
    for(int i = 0; i < n - 1; ++i)
        ++c[s[i] - '1'][s[i + 1] - '1'];

    vector<int> t(9, 0);
    iota(t.begin(), t.end(), 0);
    vector<int> ans_v = t;
    i64 ans = INF;
    do{
        i64 sum = 0;
        for(int i = 0; i < 9; ++i){
            for(int j = 0; j < 9; ++j){
                int x = t[i];
                int y = t[j];

                int i_x = i % 3;
                int i_y = i / 3;
                int j_x = j % 3;
                int j_y = j / 3;
                int cost = abs(i_x - j_x) + abs(i_y - j_y);
                sum += cost * c[x][y];
            }
        }
        if(ans > sum){
            ans = sum;
            ans_v = t;
        }
    }while(next_permutation(t.begin(), t.end()));

    for(int i = 0; i < 9; ++i){
        cout << ans_v[i] + 1;
        if(i % 3 == 2)
            cout << endl;
    }

                       /*
    // dp[i]: iの集合まで見た時のほげ
    vector<vector<int>> dp(1 << 9, vector<int>(9, MOD));
    vector<vector<vector<int>>> v(1 << 9, vector<vector<int>>(9));

    for(int i = 0; i < n; ++i){
        dp[1 << i][i] = 0;
        v[1 << i][i].emplace_back(i);
    }
    for(int i = 0; i < (1 << 9); ++i){
        for(int j = 0; j < 9; ++j)
            for(int k = 0; k < 9; ++k)
                // 遷移できる
                if(~i & (1 << k)){
                    int bef = dp[i | (1 << k)][k];
                    int aft = dp[i][j] + c[j][k];
                    if(bef > aft){
                        dp[i | (1 << k)][k] = aft;
                        auto vv = v[i][j];
                        vv.emplace_back(k);
                        v[i | (1 << k)][k] = vv;
                    }
                    if(bef == aft){
                        auto vv = v[i][j];
                        vv.emplace_back(k);
                        v[i | (1 << k)][k] = min(v[i | (1 << k)][k], vv);
                    }
                }
    }
    pair<int,vector<int>> ans(dp.back()[0], v.back()[0]);
    for(int i = 1; i < 9; ++i){
        ans = min(ans, make_pair(dp.back()[i], v.back()[i]));
    }
                       */
}



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

int main()
{
  string S; cin >> S;
  int one, two;
  one = stoi(S.substr(0, 2));
  two = stoi(S.substr(2, 2));
  string ans;

  if (1 <= one and one <= 12) {
    if (1 <= two and two <= 12) {
      ans = "AMBIGUOUS";
    }
    else ans = "MMYY";
  }
  else {
    if (1 <= two and two <= 12) {
      ans = "YYMM";
    }
    else ans = "NA";
  }

  cout << ans << endl;
}

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

typedef long long ll;

void solve() {
    ll H, W, N, a, b;
    cin >> H >> W >> N;
    map<pair<ll, ll>, ll> m;
    ll ans[10];
    rep(i,10) ans[i] = 0;
    ans[0] = (H - 2) * (W - 2);
    rep(i, N) {
        cin >> a >> b;
        for (int v = a - 1; v < a + 2; v++) {
            if (v < 2 || v > H - 1) continue;
            for (int w = b - 1; w < b + 2; w++) {
                if (w < 2 || w > W - 1) continue;
                int black = 0;
                for (int x = v - 1; x < v + 2; x++) {
                    for (int y = w - 1; y < w + 2; y++) {
                        black += m[make_pair(x, y)];
                    }
                }
                ans[black]--;
                ans[black + 1]++;
            }
        }
        m[make_pair(a, b)] = 1;
    }
    rep(i,10) cout << ans[i] << endl;
    return;
}

int main() {
    solve();
}

Measured memory_bytes: 156544
package main

import (
	"fmt"
)

func main() {
	var c1, c2 string
	fmt.Scan(&c1, &c2)

	if c1[0] == c2[2] && c1[1] == c2[1] && c1[2] == c2[0] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		scan.close();
		int check=0;
		for(int i=s.length()-1;i>=2;i--) {
			int cnt=0;
			if(i%2==0) {
				for(int j=0;j<i/2;j++) {
					if(s.charAt(j) == s.charAt(i/2+j)) {
						check=i;
						cnt++;
					}else break;
				}
			}
			if(cnt==i/2)break;
		}
		System.out.println(check);
	}
}

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

int main() {

  int N;
  int K;
  int x;
  int ans=0;
  int a;
  cin >> N >> K;
  int people[N];
  for(int i=0;i<N;i++){
   people[i]=0; 
  }
 for(int i=0; i<K;i++){
   cin >> x;
   for(int j=0; j<x;j++){
     a=0;
     cin >>a;
     people[a-1]=people[a-1]+1;
   }   
 }
  
  for(int i=0;i<N;i++){
   if(people[i]==0){
     ans=ans+1;
   }
  }
  cout<< ans<<endl;
  return 0;

}


Measured memory_bytes: 3620
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#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 DSORT(c, type) sort(ALL(c), greater<type>())

#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SUM(v) accumulate(ALL(v), 0)
#define AVE(v) SUM(v) / (v).size()
// 入力eと同じ値の要素の数
#define COUNT(v, e) count(ALL(v), e)

using namespace std;


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

  int n;
  cin >> n;
  string s;
  cin >> s;
  int k;
  cin >> k;

  char c = s[k-1];
  for(int i=0; i<n; ++i) 
    if(s[i] != c)
      s[i] = '*';

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())

if X > Y:
    p = min((Y*C*2 + (X-Y)*A), X*C*2)
else:
    p = min((X*C*2 + (Y-X)*B), Y*C*2)

q = A*X + B*Y

print(min(p, q))

Measured memory_bytes: 3060
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n, m;
    cin >> n;
    map<string, int> scnt, tcnt;
    vector<string> s(n);
    rep(i, n) {
        cin >> s[i];
        scnt[s[i]] ++;
    }
    cin >> m;
    vector<string> t(m);
    rep(i, m) {
        cin >> t[i];
        tcnt[t[i]] ++;
    }
    int ans = 0;
    rep(i, n) {
        chmax(ans, scnt[s[i]] - tcnt[s[i]]);
    }
    rep(i, m) {
        chmax(ans, scnt[t[i]] - tcnt[t[i]]);
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
// 解法理解したのでコードだけまねた。
 // 素数判定の時間計算量は√N！！！
 #include <bits/stdc++.h>
 using namespace std;
 #define rep(i,N) for(int i=0;i<int(N);++i)
 using ll = long long;
 const int INF = 2147483647;

int main() {
    string s;
    cin >> s;
    int num;
    if(s=="SUN") num=0;
    else if(s=="MON") num=1;
    else if(s=="TUE") num=2;
    else if(s=="WED") num=3;
    else if(s=="THU") num=4;
    else if(s=="FRI") num=5;
    else if(s=="SAT") num=6;
    cout << 7-num << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);
// priority_queue<ll, vector<ll>, greater<ll>> pq;


int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    vector<ll> s(n);
    s[0] = a[0];
    rep(i, n-1){
        s[i+1] = (s[i] + a[i+1]) % MOD;
    }
    rep(i, n-1){
        ll tmp = (((s[n-1]-s[i] + MOD) % MOD)*a[i]) % MOD;
        ADD(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6424
N = int(input())
counter = 0
ans = False
for i in [0] * N:
    input_list = list(map(int,input().split()))
    if input_list[0] is input_list[1]:
        counter += 1
        if counter >= 3:
            ans = True
    else:
        counter = 0
if ans:
    print("Yes")
else:
    print("No")


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

int main()
{
  int w,d;
  for(;cin>>w>>d,w;)
    {
      int h1[w],h2[d];
      for (int i=0; i < w; i++) {
        cin>>h1[i];
      }
      for (int i=0; i < d; i++) {
        cin>>h2[i];
      }
      int sum=0;
      int i=0,j=0;
      sort(h1,h1+w);
      sort(h2,h2+d);
      while(i<w||j<d)
        {
          if(i>=w)
            {
              sum+=h2[j];
              j++;
            }
          else if(j>=d)
            {
              sum+=h1[i];
              i++;
            }
          else
            {
              if(h1[i]==h2[j])
                {
                  sum+=h1[i];
                  i++;
                  j++;
                }
              else if(h1[i]<h2[j])
                {
                  sum+=h1[i];
                  i++;
                }
              else
                {
                  sum+=h2[j];
                  j++;
                }
            }
        }
      cout<<sum<<endl;

    }

}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
int main(void){
  string s;
  int c=0;
  cin>>s;
  for(int i=1;i<s.length();i++){
    if(s[i]==s[i-1]){
      s[i]=(s[i-1]=='0')?'1':'0';
      c++;
    }
  }
  cout<<c;
  return 0;
}

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

int main() {
  ll a,b;
  cin >> a >> b;
  ll ans = 0;
  
  if(a>b){
    ans = b;
  	rep(i, a-1){
      b *= 10;
      ans += b;
    }
  }
  else{
    ans = a;
    rep(i, b-1){
      a *= 10;
      ans += a;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int n,cnt(0);
double k;
cin>>n>>k;
for(int i=0; i<n; ++i)
{
double a,b;
cin>>a>>b;
if((double)sqrt(a*a+b*b)<=k)
++cnt;
}
cout<<cnt;
return 0;
}

Measured memory_bytes: 3740
import sys
input = sys.stdin.readline
#n = int(input())
#l = list(map(int, input().split()))
'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

x, y = map(int, input().split())

if (x+y)%3!=0 or x<1 or y<1:
    print(0)
    sys.exit()

m=(2*x-y)//3
n=x-2*m

def comb(n, r):
    #mod入り二項係数
    mod = 10**9+7
    N = 10**6 # 調整
    g1 = [1, 1]
    g2 = [1, 1]
    inverse = [0, 1]
    for i in range(2, N + 1):
        g1.append((g1[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

print(comb(n+m,n))

Measured memory_bytes: 128328
(a, b, c, wanted_a, wanted_b) = (int(tok) for tok in input().split())

res = wanted_a * a + wanted_b * b
for both in range(max(wanted_a, wanted_b) * 2 + 1):
  left_a = wanted_a - both // 2
  left_b = wanted_b - both // 2
  cost = both * c + max(0, left_a) * a + max(0, left_b) * b
  res = min(res, cost)

print(res)


Measured memory_bytes: 3060
cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S", "H", "C", "D"]
N = int(input())
for i in range(N):
    ch,rank = input().split()
    rank = int(rank)
    cards[pattern.index(ch)][rank-1] = True
for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print(pattern[i], j+1)


Measured memory_bytes: 5604
N, K = gets.chop.split.map(&:to_i)
Values = gets.chop.split.map(&:to_i)

ans = 0
0.upto([N, K].min) do |left_pop|
  0.upto([N, K].min - left_pop) do |right_pop|
    vals= Values[0...left_pop] + Values.reverse[0...right_pop]
    vals = vals.sort.reverse
    (K - left_pop - right_pop).times do
      break if vals.empty? || vals[-1] >= 0
      vals.pop
    end
    ans = [ans, vals.inject(0, &:+)].max
  end
end
puts ans


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


def main():
    A = {1, 3, 5, 7, 8, 10, 12}
    B = {4, 6, 9, 11}
    C = {2}
    xy = set(map(int, input().split()))
    if xy <= A or xy <= B or xy <= C:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()

Measured memory_bytes: 9064
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)
int main(){
    int H,N;
    ll A[1000],B[1000];
    cin>>H>>N;
    rep(i,N) cin>>A[i]>>B[i];
    ll consume[10001];
    ll temp,ans;
    rep(i,H+1) consume[i]=0;
    Rep(i,H){
        if(i<A[0]) ans=B[0];
        else ans=B[0]+consume[i-A[0]];
        Rep(j,N-1){
            if(i<A[j]) temp=B[j];
            else temp=B[j]+consume[i-A[j]];
            ans=min(ans,temp);
        }
        consume[i]=ans;
        // cout<<i<<" "<<ans<<endl;
    }
    cout<<consume[H]<<endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand rng
using namespace std; void solve();
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;

struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
  int main(){solve_dbg();}
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

using P = pair<int,int>;
constexpr int MOD = 998244853;
mt19937_64 rng(58);
template<typename T>inline T ceil(T a,T b){return (a + b - 1) / b;}
/////////

void solve(){
  inl(N);
  out(N * (N - 1) / 2);

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader scanner = new BufferedReader(new InputStreamReader(System.in));
		ArrayDeque<Integer> ad = new ArrayDeque<Integer>();
		String l[];
		int n = Integer.parseInt(scanner.readLine());
		for (int i = 0; i < n; i++) {
			l = scanner.readLine().split(" ");
			String c = l[0];
			if (c.equals("insert")) {
				ad.addFirst(Integer.parseInt(l[1]));
			} else if (c.equals("delete")) {
				ad.remove(Integer.parseInt(l[1]));
			} else if (c.equals("deleteFirst")) {
				ad.removeFirst();
			} else if (c.equals("deleteLast")) {
				ad.removeLast();
			}
		}
		System.out.print(ad.poll());
		for (int t : ad) {
			System.out.print(" " + t);
		}
		System.out.println();
	}
}



Measured memory_bytes: 192236
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n, m;
	cin >> n >> m;
	//ll a = n/2;
	ll ans = 1;
	if (m != 1 && n != 1) {
	 ans = (m/2)*(n/2) + (m - (m/2))*(1 + (n - 1)/2); 
    }
	cout << ans;
}

























Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    long long int A, B, K; cin >> A >> B >> K;
    if (A >= K && A >= 1) {
        A -= K;
        printf("%lld %lld", A, B);
    }
    else {
        K -= A;
        if (B >= K && B >= 1) {
            B -= K;
            printf("%lld %lld", 0, B);
        }
        else {
            printf("%lld %lld", 0, 0);
        }
    }
}


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

int main(){
    int n,m,q;
    cin>>n>>m>>q;
    int a[55],b[55],c[55],d[55];
    for(int i=0;i<q;i++){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--;
        b[i]--;
    }
    vector<int> v(n+m-1,1);
    for(int i=0;i<m-1;i++)v[i]=0;
    int ans=0;
    do{
        int zcnt=0;
        int score=0;
        vector<int> A;
        for(int i=0;i<n+m;i++){
            if(v[i]==0)zcnt++;
            else A.push_back(zcnt+1);
        }
        for(int i=0;i<q;i++){
            if(A[b[i]]-A[a[i]]==c[i])score+=d[i];
        }
        ans=max(ans,score);
    }while(next_permutation(v.begin(),v.end()));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3544
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int N, Q;
int arr[500005];
int c[500005];
int ans[500005];

struct SegmentTree {
  vector<int> Tree[20];

  void init() {
    for(int i=0;i<20;++i) {
      Tree[i].resize((1<<i), 0);
    }
  }

  void add(int x) {
    if(arr[c[x]]==-1) {
      arr[c[x]] = x;
      for(int i=19;i>=0;--i) {
        Tree[i][x]++;
        x /= 2;
      }
    }
    else {
      int tmp = arr[c[x]];
      for(int i=19;i>=0;--i) {
        Tree[i][tmp]--;
        tmp /= 2;
      }
      arr[c[x]] = x;
      for(int i=19;i>=0;--i) {
        Tree[i][x]++;
        x /= 2;
      }
    }
  }

  int solve(int ql, int qr, int pos1=0, int pos2=0, int sl=0, int sr=(1<<19)) {
    if(sr<=ql || qr<=sl) return 0;
    if(ql<=sl && sr<=qr) return Tree[pos1][pos2];
    return solve(ql, qr, pos1+1, 2*pos2, sl, (sl+sr)/2)+solve(ql, qr, pos1+1, 2*pos2+1, (sl+sr)/2, sr);
  }

  void check() {
    for(int i=16;i<19;++i) {
      for(int j=0;j<(1<<(i-16));++j) {
        cout<<Tree[i][j]<<" ";
      }
      cout<<endl;
    }
  }
};

int main() {
  cin>>N>>Q;
  for(int i=0;i<N;++i) arr[i] = -1;
  for(int i=0;i<N;++i) {
    cin>>c[i];
    c[i]--;
  }
  int l, r;
  vector<tuple<int, int, int> > query(Q);
  for(int i=0;i<Q;++i) {
    cin>>l>>r;
    l--;
    query[i] = mt(r, l, i);
  }
  sort(query.begin(), query.end());
  int index;
  int tmpind=0;

  SegmentTree tree;tree.init();
  for(int i=0;i<Q;++i) {
    l = get<1>(query[i]);
    r = get<0>(query[i]);
    index = get<2>(query[i]);
    for(int j=tmpind;j<r;++j) {
      tree.add(j);
    }
    tmpind = r;
    ans[index] = tree.solve(l, r);
  }
  for(int i=0;i<Q;++i) cout<<ans[i]<<endl;
}



Measured memory_bytes: 19504
sx,sy,tx,ty = gets.split.map(&:to_i)
path1 = "U"*(ty - sy) + "R"*(tx - sx)
path2 = "D"*(ty - sy) + "L"*(tx - sx)
path3 = "L" + "U"*(ty - sy + 1) + "R"*(tx - sx + 1) + "D"
path4 = "R" + "D"*(ty - sy + 1) + "L"*(tx - sx + 1) + "U"
puts path1+path2+path3+path4


Measured memory_bytes: 14320
n=int(input())
li=list(map(int,input().split()))
li.sort()
a=[]
b=[]
for i in range(n):
  if n%2==1:
    if i%2==0:
      a.append(li[i])
    else:
      b.append(li[i])
  else:
    if i%2==0:
      b.append(li[i])
    else:
      a.append(li[i])
print(sum(a)-sum(b))

Measured memory_bytes: 3064
from sys import stdin
input = stdin.readline
N,M = map(int, input().split())
H = [0] + list(map(int, input().split()))
L = [0] + [1]*N
for m in range(M):
    A,B = map(int, input().split())
    if H[A] > H[B]:
        L[B] = 0
    elif H[A] < H[B]:
        L[A] = 0
    else:
        L[A], L[B] = 0, 0
print(sum(L))

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

string solve() {
    ll H, W;
    cin >> H >> W;
    string s, ans;
    for ( int h = 0; h < H; h++ ) {
        for ( int w = 0; w < W; w++ ) {
            cin >> s;
            if ( s == "snuke" ) {
                ans = (char)('A' + w) + to_string(h+1);
            }
        }
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MAX 1000000
/// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=666933#1
int main(){
    bool num[MAX];
    for(int i =2; i<MAX; i++) num[i] =true;

    for(int i=2; i*i < MAX; i++){
        for(int j=i; i*j <MAX;j++){
            num[i*j] =false;
        }
    }
    for(int n, count =0; cin >> n; cout << count <<endl, count=0){
        for(int i=2; i<=n; i++){
            if(num[i]) count++;
        }
    }
}



Measured memory_bytes: 3996
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main()
{
    int N;
    cin >> N;
    if (N%1000 == 0){
        cout << 0 << endl;
    }else{
        cout << 1000 * (N / 1000 + 1) - N << endl;
    }
}

Measured memory_bytes: 3668
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int p[17],y[17],c[17];
int n,g;
bool sf[17];
int ans=99999999;
int r[100007];
bool cmp(int qaq,int qwq){return qaq>qwq;}
void run()
{
    int k=0;
    long long now=0;
    int toc=0;
    for(int i=1;i<=n;++i)
    {
        if(sf[i]){k+=p[i];now+=p[i]*y[i]+c[i];}
        else
        {
            int j=p[i]-1;
            while(j)
            {
                r[++toc]=y[i];
                j--;
            }
        }
    }
    sort(r+1,r+toc+1,cmp);
    int i=0;
    while(now<g&&i<toc)
    {
        k++;
        now+=r[++i];
    }
    //cout<<k<<endl;
    if(now>=g)ans=min(ans,k);
    return;
}
void search(int d)
{
    sf[d]=0;
    if(d==n)run();
    else search(d+1);
    sf[d]=1;
    if(d==n)run();
    else search(d+1);
    return;
}
int main()
{
    scanf("%d%d",&n,&g);
    for(int i=1;i<=n;++i)
    {
        scanf("%d%d",&p[i],&c[i]);
        y[i]=i*100;
    }
    search(1);
    cout<<ans;
    return 0;
}

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

int N,M;

int DFS(vector<vector<int>> &load, int now, vector<bool> visited){
    
    bool end=true;
    
    //ベースケース
    for(int i=1; i<=N; i++){
        if(visited[i]==false){
            end=false;
        }
    }
    if(end) return 1;
    
    int ret=0;
    for(int i:load[now]){
        
        //道が無い、探索済
        if(visited[i]) continue;
        
        visited[i]=true;
        ret += DFS(load, i, visited);
        visited[i]=false;
        
    }
    return ret;
}


int main(){
    
    cin >> N >> M;
    
    vector<vector<int>> load(N+1,vector<int>());
    rep(z,M){
        int a,b;
        cin >> a >> b;
        load[a].push_back(b);
        load[b].push_back(a);
    }
    
    vector<bool> visited(N+1,false);
    visited[1] = true;
    int ans = DFS(load, 1, visited);
    cout << ans << endl;
    
}


Measured memory_bytes: 3616
S=input()
all=[]
for i in range(len(S)):
    if S[i]=="A" or S[i]=="C" or S[i]=="G" or S[i]=="T":
        all.append(i)
max=0
test=0
try:
    mae=all[0]
except:
    print("0")
    quit()
del all[0]
for j in all:
    if (j-1)==mae:
        test+=1;
    else:
        max=test
        test=0
    mae=j
else:
    if max<test:
        max=test;
    else:
        pass
print(str(max+1))
    

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


int main(){
  int n; 
  while(true){
    cin >> n;
    if(n == 0) break;

    vector<int64_t> a(5010), sum(5010, 0); 
    for(int i=1; i<=n; i++){
      cin >> a[i];
      sum[i] = sum[i-1] + a[i];
    }

    int64_t ans = -99999999;
    for(int i=0; i<=n; i++){
      for(int j=i+1; j<=n; j++){
        ans = max(ans, sum[j]-sum[i]);
      }
    }
    cout << ans << endl;
  }
}
  
  


Measured memory_bytes: 3200
namespace ABC125_B
{
    using static System.Console;
    using System.Linq;
    using System.Collections.Generic;

    public class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInputAsInt();
            var v = ReadInputsAsInt().ToList();
            var c = ReadInputsAsInt().ToList();
            WriteLine(Solve(n, v, c));
        }



        public static int Solve(int n, List<int> v, List<int> c)
            => v.Zip(c, (vitem, citem) => new { C = citem, V = vitem })
                .Select(x => x.V - x.C)
                .Where(x => x > 0)
                .Sum();
        static int ReadInputAsInt() => int.Parse(ReadLine());
        static IEnumerable<int> ReadInputsAsInt() => ReadLine().Split(' ').Select(x => int.Parse(x));
    }
}

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

using namespace std;

int main(){
   int N,M;
   cin >> N >> M;
   vector<int>x(M),y(M);
   vector<bool>red(N,false);
   red[0] = true;
   vector<int>num(N,1);
   for(int i=0;i<M;i++)cin >> x[i] >> y[i];
   for(int i=0;i<M;i++)x[i]--,y[i]--;
   for(int i=0;i<M;i++){
      if(red[x[i]]) red[y[i]] = true;
      num[x[i]]--;
      num[y[i]]++;
      if(num[x[i]]==0)red[x[i]] = false;
   }
   int ans = 0;
   for(int i=0;i<N;i++){
      if(red[i]){
         ans++;
      }
   }
   cout << ans << endl;
   return 0;
}


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

int main(){
    ll n,m; cin >> n >> m;
    if(n*2>=m) cout << m/2 << endl;
    else{
        ll ans = n;
        m -= 2*n;
        n = 0;
        ans += m/4;
        cout << ans << endl;
    }
}

Measured memory_bytes: 3548
let readIntArray () =
    stdin.ReadLine().Split(" ") |> Array.map int

readIntArray ()

readIntArray ()
|> fun x ->
    let len = x |> Array.length |> (-) <| 2
    let a = x |> Array.take len
    let b = x |> Array.tail |> Array.take len

    let c =
        x |> Array.tail |> Array.tail |> Array.take len

    Array.zip3 a b c
|> Array.filter (fun (x, y, z) -> (x > y && y > z) || (z > y && y > x))
|> Array.length
|> printfn "%d"


Measured memory_bytes: 30044
N,M=map(int,input().split())
Like=[0 for i in range(M)]
A=[[] for i in range(N)]
for i in range(N):
  A[i]=[int(x) for x in input().split()]
for i in range(N):
  for j in range(1,A[i][0]+1):
    Like[A[i][j]-1]=Like[A[i][j]-1]+1
print(Like.count(N))

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

typedef struct node{
	int key;
	struct node *parent;
	struct node *left;
	struct node *right;
} Node, Tree;

void insert(Tree **T, int key)
{
	Node *pre = NULL;
	Node *curr = *T;
	Node *newNode = NULL;
	
	newNode = (Node*)malloc(sizeof(Node));
	newNode->key = key;
	newNode->left = NULL;
	newNode->right = NULL;
	
	while (curr != NULL) {
		pre = curr;
		if (key > curr->key) {
			curr = curr->right;
		} else {
			curr = curr->left;
		}
	}
	
	newNode->parent = pre;
	
	//如果根结点存在，则pre一定不为空，反之pre为空 
	if (pre == NULL) {
		*T = newNode;
	} else {
		if (key > pre->key) {
			pre->right = newNode;
		} else {
			pre->left = newNode;
		}
	}
}

void Inorder(Tree *T)
{
	if (T == NULL)
		return;
		
	Inorder(T->left);
	cout << " " << T->key;
	Inorder(T->right);
}

void Preorder(Tree *T)
{
	if (T == NULL)
		return;
		
	cout << " " << T->key;	
	Preorder(T->left);
	Preorder(T->right);
}

bool find(Tree *T, int key)
{
	Node *curr = T;
	if (T == NULL)
		return false;
		
	while (curr != NULL) {
		if (key == curr->key)
			return true;
		else if (key > curr->key) {
			curr = curr->right;
		} else {
			curr = curr->left;
		}
	}
		
	return false;
}

void print(Tree *T)
{
	Inorder(T);
	cout << '\n';
	Preorder(T);
	cout << '\n';
}

int main(void)
{
	Tree *T = NULL;
	int n;
	int key;
	string cmd;
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> cmd;
		if (cmd == "insert") {
			cin >> key;
			insert(&T, key);
		} else if (cmd == "print"){
			print(T);
		} else if (cmd == "find") {
			cin >> key;
			if (find(T, key) == true) {
				cout << "yes\n";
			} else {
				cout << "no\n";
			}
		}
	}
	
	
	return 0;
}


Measured memory_bytes: 21900
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
const int MAX_N = 110;
const int MAX_V = 1000 * MAX_N;

int N, W;
ll w[MAX_N];
ll v[MAX_N];

ll dp[MAX_N][MAX_V]; // dp[i][j] := 品物 i まで使って合計価値 j を実現する重さの最小値

void _main()
{
    cin >> N >> W;
    rep(i, 0, N) cin >> w[i] >> v[i];

    rep(i, 0, MAX_N) rep(j, 0, MAX_V) dp[i][j] = inf;

    dp[0][0] = 0;

    rep(i, 0, N)
    {
        rep(value, 0, MAX_V)
        {
            chmin(dp[i + 1][value], dp[i][value]);
            chmin(dp[i + 1][value + v[i]], dp[i][value] + w[i]);
        }
    }

    rrep(value, MAX_V - 1, 0)
    {
        if (dp[N][value] <= W)
        {
            cout << value << endl;
            return;
        }
    }
}


Measured memory_bytes: 94848
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
    public static void main(String[] args) throws IOException {
        try (PrintWriter writer = new PrintWriter(System.out); InputReader reader = new InputReader(System.in)) {
            solve(writer, reader);
        }
    }

    private static void solve(PrintWriter writer, InputReader reader) throws IOException {
        int[] ints = reader.readIntsSplitByDelimiter(" ");
        String ans = (ints[0] == 2 || ints[1] == 2) ? "No" : "Yes";
        writer.println(ans);
        writer.flush();
    }
}

class InputReader implements Closeable, AutoCloseable {
    private final BufferedReader br;

    InputReader(InputStream inputStream) {
        this.br = new BufferedReader(new InputStreamReader(inputStream));
    }

    String readLine() throws IOException {
        return this.br.readLine();
    }

    int readInt() throws IOException {
        return Integer.parseInt(this.readLine());
    }

    long readLong() throws IOException {
        return Long.parseLong(this.readLine());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(this.readLine());
    }

    String[] readStringsSplitByDelimiter(String delimiter) throws IOException {
        return this.readLine().split(delimiter);
    }

    int[] readIntsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readStringsSplitByDelimiter(delimiter);

        int stringsLength = strings.length;
        int[] ints = new int[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }

        return ints;
    }

    long[] readLongsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readStringsSplitByDelimiter(delimiter);

        int stringsLength = strings.length;
        long[] longs = new long[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            longs[i] = Long.parseLong(strings[i]);
        }

        return longs;
    }

    double[] readDoublesSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readStringsSplitByDelimiter(delimiter);

        int stringsLength = strings.length;
        double[] doubles = new double[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            doubles[i] = Double.parseDouble(strings[i]);
        }

        return doubles;
    }

    @Override
    public void close() throws IOException {
        this.br.close();
    }
}


Measured memory_bytes: 21204