akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1e9+7;

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

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

template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
///////////////////////////////////////////////
/*(._.)*/
int main(){
	int N; cin >> N;
	vector<ll> v(N);
	REP(i,N){
	    cin >> v[i];
	}

	sort(ALL(v));

	double ans = (double)((v[0] + v[1])) / 2;
	REP(i,N-2){
		ans = (double)(((double)v[i+2] + ans) / 2);
	}

	cout << ans << "\n";



}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>
#include <numeric>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

#define TR ","
#define TS " "
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define rpt(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

ll waz = 76543217;

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

int main()
{
    IO;

    ll N; cin >> N;
    vl a(N);
    rep(i, N) cin >> a[i];

    cout << accumulate(all(a),0) - N << endl;
}

Measured memory_bytes: 3212
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
string s;
int s_size;
int Count;
int ans;
int main()
{
	cin>>s;
	s_size=s.size();
	rep(i,s_size)
	{
		if(s[i]=='S')Count++;
		else
		{
			if(Count>0)Count--;
			else ans++;
		}
	}
	ans+=Count;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextssort(n,a){return a?cin.slice(cid,cid+=n).map(a=>+a).sort((a,b)=>b-a):cin.slice(cid,cid+=n).map(a=>+a).sort((a,b)=>a-b);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}
var streams=[];function print(s){streams.push(s);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));
if(streams.length)console.log(streams.join("\n"));

function main(){
  var n = next();
  var x = nextm(n,2);
  x.sort((a,b)=>a[0]-b[0]);
  var ans = 0;
  var u = x[0], d = x[0];
  for(var i = 1; i < n; i++){
    var t = x[i];
    if(ans < solve(u,t))ans = solve(u,t);
    if(ans < solve(d,t))ans = solve(d,t);
    if(u[0]+u[1] > t[0]+t[1])u = t;
    if(d[1]-d[0] < t[1]-t[0])d = t;
  }
  return ans;
}
function solve(a,b){
  return Math.abs(a[0]-b[0]) + Math.abs(a[1]-b[1]);
}

Measured memory_bytes: 109028
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int a = sc.nextInt();
        int ans =  0;
        
        while(h > 0){
            h = h -a;
            ans++;
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int target = int.Parse(Reader.ReadLine());
        StringBuilder ans = new StringBuilder();

        ans.AppendLine("1");
        long current = 1;
        for (int i = 1; i < target; i++) {
            current = GetAns(++current);
            ans.AppendLine(current.ToString());
        }
        Console.Write(ans.ToString());
    }


    private long GetAns(long baseNum) {
        string numStr = baseNum.ToString();
        int keta = numStr.Length;


        long maxSi = long.Parse(string.Empty.PadLeft(keta, '9'));
        long maxBo = 9 * keta;
        List<long> boList = new List<long>();
        List<long> siList = new List<long>();
        for (int i = 0; i <= keta; i++) {
            string tmp = numStr.Substring(0, keta - i) + string.Empty.PadLeft(i, '9');
            long si = long.Parse(tmp);
            long bo = tmp.Select(a => long.Parse(a.ToString())).Sum();

            while(boList.Count > 0 && si*boList.Last() < siList.Last()*bo) {
                boList.RemoveAt(boList.Count - 1);
                siList.RemoveAt(siList.Count - 1);
            }

            if(si*maxBo <= maxSi*bo) {
                boList.Add(bo);
                siList.Add(si);
            }
        }
        return siList.First();
    }

    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"
 
 
10
 
 
";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}

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

#ifndef __TOPCYBERFLOWER
#define debug(...) 0
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif

#define TYPEMAX(type)   numeric_limits<type>::max()
#define TYPEMIN(type)   numeric_limits<type>::min()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
bool is_tri(ll x, ll y, ll z){
    if(x==y || x==z || y==z) return false;
    if(x>=y+z) return false;
    if(y>=x+z) return false;
    if(z>=x+y) return false;
    return true;
}
int main(void){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n; cin>>n;
    vl arr(n);
    for(int i=0;i<n;i++) cin>>arr[i];
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(is_tri(arr[i],arr[j],arr[k])) ans++;
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  string s;
  cin >> s;
  int N = (int)s.size();
  int P = 0;
  for (int i=0; i<N; i++) {
    if (s[i]=='p') P++;
  }
  cout << N/2-P << endl;
  return 0;
}

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

int main() {
  int N,M;
  cin>>N>>M;
  if(N>12){
    cout<<M;
  }
  else if(N>5){
    cout<<M/2;
  }
  else{
    cout<<0;
  }
  //cout << << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.LinkedList;

public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        char a[][] = new char[H + 2][W + 2];
        String A[] = new String[H];
        for (int i = 0; i < H; i++) {
            A[i] = sc.next();
        }
        for (int i = 0; i < W+2; i++) {
            System.out.print("#");
        }
        System.out.println("");
        for (int i = 0; i < H; i++) {
            System.out.println("#" + A[i] + "#");
        }
        for (int i = 0; i < W+2; i++) {
            System.out.print("#");
        }
    }
}

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

const int maxn = 50 + 5, sigma = 26;
int cnt[maxn][sigma];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n; for (int i = 0; i < n; ++i) {
        string s; cin >> s;
        for (int j = 0; j < s.length(); ++j) cnt[i][s[j] - 'a']++;
    }
    for (int i = 0; i < sigma; ++i) {
        int Min = maxn + 1;
        for (int j = 0; j < n; ++j) Min = min(Min, cnt[j][i]);
        while (Min--) cout << (char)(i + 'a');
    }
    return 0;
}

Measured memory_bytes: 384
import java.util.*;
 
class Main{
    public static void main(String[] args){
		
		Scanner scan = new Scanner(System.in);
		int[] arr = new int[6];
		for(int i=0; i<6; i++){
			arr[i] = scan.nextInt();
		}
		Dice xai = new Dice(arr);
		char[] dere = scan.next().toCharArray();
		for(char ch: dere){
			xai.roll(ch);
		}
		System.out.println(xai.showTop());
    }
}

class Dice{
	int[] dice;
	public Dice(int[] a){
		dice = new int[6];
		for(int i=0; i<6; i++){
			dice[i] = a[i];
		}
	}
	public void roll(char c){
		int tmp = 0;
		switch(c){
			case 'N':
				tmp = dice[0];
				dice[0] = dice[1];
				dice[1] = dice[5];
				dice[5] = dice[4];
				dice[4] = tmp;
				break;
			case 'W':
				tmp = dice[0];
				dice[0] = dice[2];
				dice[2] = dice[5];
				dice[5] = dice[3];
				dice[3] = tmp;
				break;
			case 'S':
				tmp = dice[0];
				dice[0] = dice[4];
				dice[4] = dice[5];
				dice[5] = dice[1];
				dice[1] = tmp;
				break;
			case 'E':
				tmp = dice[0];
				dice[0] = dice[3];
				dice[3] = dice[5];
				dice[5] = dice[2];
				dice[2] = tmp;
				break;
		}
	}
	public int showTop(){
		return dice[0];
	}
}

Measured memory_bytes: 26344
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())

signed main(){

	lli a,b;
	cin>>a>>b;

	if(a<10 && b<10){
		cout<<a*b<<endl;
	}
	else cout<<-1<<endl;

	return 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)
s1 = s[0:(n-1)//2]
s1r = s[(n-1)//2-1::-1]
s2 = s[(n+3)//2 - 1:]
s2r = s[:(n+3)//2 - 2:-1]

if s == s[::-1] and s1 == s1r and s2 == s2r:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#!/usr/bin/env python3

_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

input = int(input())
index = input - 1

print(_list[index])

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int arr[n][3];
    for(int i=0;i<n;i++) cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    long long dp[n][3];
    memset(dp,0,sizeof(dp));
    dp[0][0]=arr[0][0],dp[0][1]=arr[0][1],dp[0][2]=arr[0][2];
    for(int i=1;i<n;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(j!=k){
                    dp[i][k]=max(dp[i][k],dp[i-1][j]+arr[i][k]);
                }
            }
        }
    }
    long long ans=0;
    ans=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

vector<vector<P>> g;
VI ans;

void dfs(int v_col, int v, int p){
    int col = 0;
    for(P e: g[v]){
        int d = e.first, i = e.second;
        if (d == p) continue;
        if (ans[i] != -1) continue;
        if (col == v_col) col++;
        ans[i] = col;
        dfs(col, d, v);
        col++;
    }
}

int main(){
    int n;
    cin >> n;
    g.resize(n);
    rep(i,n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].emplace_back(b, i);
        g[b].emplace_back(a, i);
    }

    ans.resize(n-1, -1);
    dfs(-1, 0, -1);

    int k = 0;
    rep(i,n-1) chmax(k, ans[i]);
    cout << k + 1 << endl;
    rep(i,n-1){
        cout << ans[i] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 10992
#include <bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  char c[h+2][w+2];
  for(int i=0;i<h+2;i++){
    for(int j=0;j<w+2;j++){
      c[i][j]='#';
    }
  }
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin>>c[i][j];
    }
  }
  for(int i=0;i<h+2;i++){
    for(int j=0;j<w+2;j++){
      cout<<c[i][j];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
A, B = map(int, raw_input().split())
S = raw_input()
passed = True
for i in range(A+B+1):
    if i == A:
        if S[i] != '-':
            passed = False
            break
    else:
        if S[i] == '-':
            passed = False
            break
print "Yes" if passed else "No"

Measured memory_bytes: 2568
// ABC178F.cpp

#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <string>

#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P = pair<int, char>;
using Pi = pair<int, int>;
int main()
{
    int n;
    cin >> n;
    vector<P>a(n), b(n);
    vector<P>c(n * 2);
    vector<int>count(200005);
    int num;
    int num_mx = 0;
    rep(i, n) {
        cin >> num;
        a[i].first = num;
        a[i].second = 'A';
        c[i] = a[i];
        count[num]++;
        if (i == n - 1) num_mx = num;
    }
    rep(i, n) {
        cin >> num;
        b[i].first = num;
        b[i].second = 'B';
        c[n + i] = b[i];
        count[num]++;
        if (i == n - 1) num_mx = max(num, num_mx);
    }
    int mx = 0;
    for (int i = 1; i <= num_mx; i++) {
        mx = max(mx, count[i]);
    }
    // 同じ数が半分以上あるとき、作れない
    if (mx > n) {
        cout << "No" << endl;
        return 0;
    }
    sort(c.begin(), c.end());

    vector<P> d(n), e(n);
    rep(i, n) {
        d[i] = c[i];
        e[i] = c[i + n];
    }
    vector<int>aal,bbl,abl,bal;

    rep(i, n) {
        if (d[i].second == 'A' && e[i].second == 'A') aal.push_back(i);
        if (d[i].second == 'B' && e[i].second == 'B') bbl.push_back(i);
    }

// AAの組み合わせの時は、bbの組とeを入れ替えるか、eとdを入れ替える
    rep(i, aal.size()) {
        if (d[aal[i]].first != e[bbl[i]].first) {
            swap(e[aal[i]], e[bbl[i]]);
            continue;
        }
        if (d[aal[i]].first == e[bbl[i]].first) {
            swap(e[aal[i]], d[bbl[i]]);
            continue;
        }
        if (d[bbl[i]].first != e[aal[i]].first) {
            swap(e[aal[i]], e[bbl[i]]);
            continue;
        }
        if (d[bbl[i]].first == e[aal[i]].first) {
            swap(d[aal[i]], e[bbl[i]]);
            continue;
        }
    }

    cout << "Yes" << endl;
    vector<Pi>f;
    rep(i, n) {
        if (d[i].second == 'A') f.emplace_back(d[i].first, e[i].first);
        if(e[i].second=='A') f.emplace_back(e[i].first, d[i].first);
    }
    sort(f.begin(), f.end());

    rep(i, n) {
        cout << f[i].second << " ";
    }
    cout << endl;
}
/*
6
1 1 2 2 2 3
1 2 2 2 3 3
*/


Measured memory_bytes: 15912
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int X,A,B;

int main(){
    cin>>X>>A>>B;
    if((B-A)<=0){
        out("delicious");
    }
    else if((B-A)<=X){
        out("safe");
    }
    else{
        out("dangerous");
    }
}

Measured memory_bytes: 256
N = int(input())
Monster = list(map(int, input().split()))
Brave = list(map(int, input().split()))
cnt = 0
amari = 0

for i in range(N):

    cnt += min(amari, Monster[i])
    Monster[i] = max(0, Monster[i]-amari)
    cnt += min(Monster[i], Brave[i])
    amari = max(0, Brave[i]-Monster[i])

cnt += min(amari, Monster[N])
print(cnt)

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    bool second = true;
    for(int i = 0; i < n; i++){
        long long a;
        cin >> a;
        if(a%2 != 0) second = false;
    }
    if(second) cout << "second" << endl;
    else cout << "first" << endl;
    return 0;
}

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

#define CIN1(a) long long a;cin >> a;
#define CIN2(a,b) long long a,b;cin >> a >> b;
#define CIN3(a,b,c) long long a,b,c;cin >> a >> b >> c;
#define rep(i,n) for(int i=0,i##_len=(n); i<i##_len; ++i)

int main(){
    CIN1(n) 
    vector<int> v(n);
    rep(i,n) cin >> v[i];

    int ans = accumulate(v.begin(),v.end(),0) - *max_element(v.begin(),v.end())/2;
    
    cout << ans << endl;
}

Measured memory_bytes: 256
P,S=print,sorted
n,k,*t=map(int,open(i:=0).read().split())
l=S([a<1<exit(P(-1)),a-1,i:=i+1]for a in t)[::-1]
*_,b=r=[*zip(*l)][2]
while k:
 for t in S(l)[::-1]:
  if t[2]-b:t[1]or exit(P(-1));t[1]-=1;r+=t[2],
 b=r[-1];k-=1
P(len(r),*r)

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

int main(){
    int n, m;
    cin >> n >> m;
    int master_l = 1, master_r = n;
    for(int i = 0; i < m; i++){
        int l, r;
        cin >> l >> r;
        if(master_l < l) master_l = l;
        if(master_r > r) master_r = r;
    }
    int ans = master_r - master_l + 1;
    if(ans < 0) cout << 0 << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long a[1001],b[1001],c[1001];
long long x,y,z,k;
vector<long long> v;
vector<long long> ans;

long long FUN2(long long l)
{
    int nr=0, lastj = z;
    for(int i=0;i<v.size();i++)
    {
        for(int j=lastj;j > 0;j--, lastj--)
        {
            if(v[i]+c[j]<l)
                break;
        }
        nr+=z-lastj;
    }
    return nr;
}

long long cautbin()
{
    long long l=1,r=30000000000LL;
    long long mid;
    while(l!=r)
    {
        mid=(l+r+1)/2;
        if(FUN2(mid)<k)
            r=mid-1;
        else l=mid;
    }
    return l;
}

void afisare(long long l=cautbin())
{
    for(int i=0;i<v.size();i++)
    {
        for(int j=z;j>=1;j--)
        {
            if(v[i]+c[j]>l)
                ans.push_back(v[i]+c[j]);
            else break;
        }
    }
    while(ans.size()<k)
    {
        ans.push_back(l);
    }
    sort(ans.begin(),ans.end(),greater<long long>());
    for(auto i:ans)
        cout<<i<<"\n";
}

int main()
{
    cin>>x>>y>>z>>k;
    for(int i=1;i<=x;i++)
        cin>>a[i];
    for(int i=1;i<=y;i++)
        cin>>b[i];
    for(int i=1;i<=z;i++)
        cin>>c[i];

    sort(c+1,c+1+z);

    for(int i=1;i<=x;i++)
    {
        for(int j=1;j<=y;j++)
        {
            v.push_back(a[i]+b[j]);
        }
    }
    sort(v.begin(),v.end());
    afisare();
    return 0;

}


Measured memory_bytes: 10476
#include <iostream>
#include <algorithm>
using namespace std;
int n=0, k=0, a[200000] = {}, sam, b[100000] = {}, roop = 0, save[100000] = {0}, ans[100000] = {}, w = 0;
int main(void){
	while (1){
	  	//int n=0, k=0, a[100000] = {}, sam, b[100000] = {}, roop = 0, save[100000] = {0}, ans[100000] = {}, w = 0;
		cin >> n >> k;
		if (n == 0 || k == 0)
		  return 0;
		for (int i = 0; i<k; i++){
			cin >> a[i];
		}
		
		sort(a, a + k);
		for (int i = 0; i<k; i++){
			if (a[i + 1] - a[i] == 1){
				sam++;
			}
			else if (a[i + 1] - a[i] != 1){
				b[roop] = sam+1;
				if(a[0]==0){
					if (a[i + 1] - a[i] == 2){
						save[w] = roop;
						w++;
					}
				}
				sam = 0;
				roop++;
			}
		}
		for (int i = 0; i <= roop; i++){
			if (save[i] != 0){
				ans[i] = b[save[i]];
				ans[i]+= b[save[i] + 1] + 1;
			}
		}
		sort(b, b + roop+1);
		sort(ans, ans + roop+1);
		if (ans[roop]>b[roop])
		cout << ans[roop] << endl;
		if (ans[roop] <= b[roop]){
			if(a[0]==0){
		       	cout << b[roop]+1 << endl;
			}
			else{
			cout << b[roop] << endl;
			}
		}
		
	}
	return 0;
}

Measured memory_bytes: 1684
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

int n;
int a[200000];
vector<int> G[200000];


struct LIS{
		int n;
		vector<int> a, dp;
		LIS(vector<int> a): a(a){
				n = a.size();
				dp.resize(n, INF);
		}
		int calc(){
				for(int i = 0; i < n; i++){
						*lower_bound(dp.begin(), dp.end(), a[i]) = a[i];
				}
				return lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
		}
};

int dp[200000];
int ans[200000];

void dfs(int v, int pre){
	int cidx = lower_bound(dp, dp + n, a[v]) - dp;
	int cpre = dp[cidx];
	dp[cidx] = a[v];
	ans[v] = lower_bound(dp, dp + n, INF) - dp;
	for(auto u : G[v]){
		if(u == pre) continue;
		dfs(u, v);
	}
	dp[cidx] = cpre;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin >> n;
	REP(i, n) cin >> a[i];
	REP(i, n - 1){
		int u, v;
		cin >> u >> v;
		u--; v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	REP(i, n) dp[i] = INF;
	dfs(0, -1);
	REP(i, n){
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 33620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	void solve() throws IOException {
		int n = ni();
		int ans =0;
		for (int i=1; i<=n; i+=2)
			if (cal(i)==3) {
				ans ++;
//				Helper.tr(i);
			}
		out.println(ans);
	}

	private int cal(int n) {
		int cnt = 0;
		for (int i=2;i<=Math.sqrt(n);i++) {
			if (n%i==0) {
				int p = n/i;
				if (p!=i)
					cnt++;
			}
		}
		return cnt;
	}

	String ns() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine(), " ");
		}
		return tok.nextToken();
	}

	int ni() throws IOException {
		return Integer.parseInt(ns());
	}

	long nl() throws IOException {
		return Long.parseLong(ns());
	}

	double nd() throws IOException {
		return Double.parseDouble(ns());
	}

	String[] nsa(int n) throws IOException {
		String[] res = new String[n];
		for (int i = 0; i < n; i++) {
			res[i] = ns();
		}
		return res;
	}

	int[] nia(int n) throws IOException {
		int[] res = new int[n];
		for (int i = 0; i < n; i++) {
			res[i] = ni();
		}
		return res;
	}

	long[] nla(int n) throws IOException {
		long[] res = new long[n];
		for (int i = 0; i < n; i++) {
			res[i] = nl();
		}
		return res;
	}

	public static void main(String[] args) throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		tok = new StringTokenizer("");
		Main main = new Main();
		main.solve();
		out.close();
	}
}

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

int main(){
  int n;
  string s;
  bool s1,s2,s3,s4;
  s1=false;
  s2=false;
  s3=false;
  s4=false;
 
  cin >> n;
  while(n){
    cin >> s;
    if(s=="P")s1=true;
	if(s=="Y")s2=true;
	if(s=="G")s3=true;
	if(s=="W")s4=true;
  n--;
  }
  cout << (s1+s2+s3+s4 == 3 ? "Three" : "Four") << endl;
}
    
    

Measured memory_bytes: 256
n,m = map(int,input().split())

cut  = []
for _ in range(m):
  a,b = map(int,input().split())
  cut.append((a,b))

cut.sort()

b_min = cut[0][1]
count = 0

for a,b in cut[1:]:
  if b_min > b:
    b_min = b
    continue
  if b_min <= a:
    count += 1
    b_min = b

print(count+1)



Measured memory_bytes: 17468
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

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

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

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

fn main() {
    input!{
        n: usize,
        s: chars,
        k: usize1,
    }
    let w = s[k];
    for i in 0..n {
        print!("{}", if s[i] != w { '*' } else { s[i] });
    }
    println!("");
}


Measured memory_bytes: 4352
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        string t =Console.ReadLine();
        char[] cs = s.ToCharArray();
        char[] ct = t.ToCharArray();
        int res = -1;


        for (int i = cs.Length - 1 - ct.Length + 1; i >= 0; i--)
        {
            int j = 0;

            while (true)
            {
                if(j==ct.Length)
                {
                    res = i;
                    break;
                }

                if (cs[i + j] == '?')
                {
                    j++;
                }
                else if(cs[i+j] == ct[j])
                {
                    j++;
                }
                else
                {
                    break;
                }
            }


            if (res >= 0) break;
        }

        if(res==-1)
        {
            Console.WriteLine("UNRESTORABLE");
        }
        else
        {
            for (int i = 0; i < res;i++)
            {
                if(cs[i] == '?')
                {
                    Console.Write('a');
                }
                else
                {
                    Console.Write(cs[i]);
                }
            }

            for (int i = 0; i < ct.Length;i++)
            {
                Console.Write(ct[i]);
            }

            for (int i = res + ct.Length; i < cs.Length;i++)
            {
				if (cs[i] == '?')
				{
					Console.Write('a');
				}
				else
				{
					Console.Write(cs[i]);
				}
            }
        }

        Console.WriteLine();

    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
bool m[10010][10010];
int n, x[3010], y[3010];
void solve() {
	for0(i, 5001)for0(j, 5001)m[i][j] = 0;
	for1(i, n) {
		cin >> x[i] >> y[i];
		m[x[i]][y[i]] = 1;
	}
	int ans = 0;
	for1(i, n)for1(j, n)
		if (m[x[i] + abs(y[j] - y[i])][y[i] + abs(x[j] - x[i])] && m[x[j] + abs(y[j] - y[i])][y[j] + abs(x[j] - x[i])])ans = max(ans, (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
	cout << ans << endl;
}
signed main() {
	while (cin >> n, n)solve();
}


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

int main()
{
    int a,b;
    cin>>a>>b;

    if(a>b)
    {
        for(int i=0;i<a;i++)cout<<b;
    }
    else if(b>a)
    {
        for(int i=0;i<b;i++)cout<<a;
    }
    else
    {
        for(int i=0;i<a;i++)cout<<a;
    }

    cout<<endl;
}


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

using vi = vector<int>;
#define f(i,a,b) for (int i = a; i < b; i++)
#define pb push_back

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	int n,m;
	cin>>n>>m;
	string s; cin>>s;
	vi adj[n];
	int p[n][2];
	f(i,0,n) p[i][0] = p[i][1] = 0;
	f(i,0,m) {
		int a,b;
		cin>>a>>b;
		adj[--a].pb(--b);
		adj[b].pb(a);
		p[a][s[b]-'A']++;
		p[b][s[a]-'A']++;
	}
	vi pq;
	vi marked(n,0);
	f(i,0,n) if (!p[i][0] || !p[i][1]) {
		pq.pb(i);
		marked[i] = 1;
	}
	while (pq.size()) {
		int v = pq.back(); pq.pop_back();	
		for (int w : adj[v]) if (!marked[w] && !--p[w][s[v]-'A']) {
			pq.pb(w);
			marked[w] = 1;
		}
	}
	bool found = 0;
	f(i,0,n) if (!marked[i]) found = 1;
	cout << (found?"Yes":"No") << endl;

#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	
	return 0;
}



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

using ll=long long;
using ld=long double;

void solve(){
	string s;
	cin>>s;
	int ans=0;
	if(s[0]=='R' && s[1]=='R' && s[2]=='R')
		ans=3;
	else if ((s[0]=='R' && s[1]=='R') || (s[1]=='R' && s[2]=='R'))
		ans=2;
	else if(s[0]=='R' || s[1]=='R' || s[2]=='R')
		ans=1;
	cout<<ans<<'\n';
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}
// }}}
/* vim:set foldmethod=marker: */

int main(int argc, char const* argv[])
{
    int n,m;
    cin >> n >> m;
    map<int,int> mp;
    for (int i = 0; i < m; i++) {
        int a,b;
        cin >> a >> b;
        mp[a]++;
        mp[b]++;
    }

    for (int i = 0; i < n; i++) {
        cout << mp[i+1] << endl;
    }
    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	string S;
	cin >> S;
	if (S.size() % 2 == 1) {
		cout << "No";
		return 0;
	}
	for (int i = 0; i < S.size() - 1; i++) {
		if (S[i] == 'h' && S[i + 1] == 'i') {
			i++;
		}
		else {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 256
/*
 *
 * Author: r3gz3n
 * 
 * 3b 13 12 9 56 4e
 * 6 56 a a 5f f
 * 6 56 47 18 56 d
 * 13 46 14 1f 13 27
 * 52 52 a 5a 47 1
 * 1d 13 b 1b 49 17
 *
 */


#include <bits/stdc++.h>

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

using namespace std;


#define fi first
#define se second


#define alli(a, n, k) (a+k),(a+n+k)
#define rep(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)


#define endl '\n'


typedef pair<int, int> pii;


class Solution {
public:
    const int static MAX = 2e5 + 5;
    pii pl[MAX], pr[MAX];
    void solve(std::istream& in, std::ostream& out) {
		int n, q, l, r, x, d;
        in >> n >> q;
        rep(i, 0, n, 1) {
            in >> l >> r >> x;
            pl[i].fi = l-x;
            pl[i].se = x;
            pr[i].fi = r-x;
            pr[i].se = x;
        }
        sort(alli(pl, n, 0));
        sort(alli(pr, n, 0));
        multiset<int> s;
        multiset<int>::iterator it;
        l = 0, r = 0;
        rep(i, 0, q, 1) {
            in >> d;
            while (l < n and pl[l].fi <= d) {
                s.insert(pl[l].se);
                l++;
            }
            while (r < n and pr[r].fi <= d) {
                s.erase(s.find(pr[r].se));
                r++;
            }
            if (s.empty()) out << -1 << endl;
            else out << *s.begin() << endl;
        }
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




Measured memory_bytes: 13824
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

/*考察
こういうシンプルな問題好き...だけどなんだこれ。なんだこれ？
制約敵にO(n^2)が許されないのとても厳しくないか
単純に題意のiとjの選び方はnC2なので実際にやるとO(n^2)だから間に合わない
同じ字が連続してるところなんか怪しいから実験する
aa   ->1
aat  ->3 aat()=(1,2)  taa(1,3)  ata(2,3)
aatt ->5 上のaat taa ataの後ろにtをつけたものと
            taaとataの区間右端を3から4に変えた2つ、合わせて5
わからん

次に考えたこと
答えのベースはnC2+1、（すべての字から2個選ぶ総数となにも操作しない1）
ここから反転により他の文字とダブるようなものだけ引いて答えにできないか
つまいり、反転すると他とダブるようなものに規則性とか特徴があって
計算できるのではないか
ある2通りの(i,j)の選び方(a,b)と(c,d)があって
(a,b)について題意の操作をした文字列sと(c,d)について操作した文字列t
がだぶるとき、ってこれさ
abcdefbとかのときb~bをreverseするときとcdefをreverseするとき
だぶるけど他ないやんね同じ字で挟めるとき、その同じ字を両端にしたやつと
同じ字二つの内側のやつで反転させたやつでダブる
同じ字連続してるやつはそれを選ぶと元とだぶるから文字ごとカウントしばけるね


 */

ll c2(ll m){
    if(m%2==0)  return (m/2)*(m-1);
    else        return ((m-1)/2)*m;
}
int main(){
    string a;
    cin>>a;
    ll n=a.size();
    ll alp[26]={};
    rep(i,n){
        alp[a[i]-'a']++;
    }

    // //小さいの確認用
    // set<string> s;
    // s.insert(a);
    // set<string> dab;
    // for(int i=0;i<n;i++){
    //     for(int j=i+1;j<=n;j++){
    //         string tmp=a;
    //         reverse(tmp.begin()+i,tmp.begin()+j);
    //         if(s.count(tmp)){dab.insert(tmp);}
    //         s.insert(tmp);
    //     }
    // }
    // cout<<s.size()<<endl;
    // for(auto x:dab){cout<<x<<endl;}
    ll ans=c2(n)+1;
    rep(i,26){
        if(alp[i]<2) continue;
        ans-=c2(alp[i]);
    }

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

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char const *argv[]) {
  int n,c=0,keta=0;

  scanf("%d", &n);

  for (int i = n; i > 0; i = i/10) {
    keta++;
  }

  if (keta == 6) {
    c += 9 + 900 + 90000;
  } else if (keta == 5) {
    c += 9 + 900 + (n - 10000 + 1);
  } else if (keta == 4) {
    c += 9 + 900;
  } else if (keta == 3) {
    c += 9 + (n - 100 + 1);
  } else if (keta == 2) {
    c += 9;
  } else if (keta == 1) {
    c += n;
  }

  printf("%d\n", c);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  string S;
  cin>>S;
  
  if(N%2!=0){
    cout<<"No"<<endl;
  }
  
  else if(N%2==0){
    
    bool ok = true;
    
    for(int i=0;i<(S.size())/2;i++){
      
      if(S.at(i)!=S.at(S.size()/2+i)){
        ok=false;
        break;
      }
    }
         
         if(ok){
           cout<<"Yes"<<endl;
         }
         else{
           cout<<"No"<<endl;
         }
  }
         return 0;
         
}

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

int main(void)
{
    int n, m;
    cin >> n >> m;
    vector<set<int>> st(m);
    rep(i, 0, n)
    {
        int x;
        cin >> x;
        rep(j, 0, x)
        {
            int y;
            cin >> y;
            st[--y].insert(i);
        }
    }
    int ans = 0;
    rep(i, 0, m) if (st[i].size() == n) ans++;
    cout << ans << endl;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    map<ll, ll> mp;
    vector<ll> A;
    A.push_back(0);
    A.push_back(0);

    rep(i, N) {
        int a;
        cin >> a;
        mp[a]++;
        if (mp[a] % 2 == 0) A.push_back(a);
    };

    sort(A.rbegin(), A.rend());
    cout << A[0] * A[1] << endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
using ll=long long;
const ll MOD=1000000007,MOD2=998244353;



int main() {
    ll N;
    cin>>N;
    ll ans=N*(N+1)/2;
    rep(i,N/3){
        ans-=3*(i+1);
    }
    rep(i,N/5){
        ans-=5*(i+1);
    }
    rep(i,N/15){
        ans+=15*(i+1);
    }
    cout<<ans<<endl;
}


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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	int X = (a - b) * (a - b);
	int Y = (b - c) * (b - c);
	int Z = (c - a) * (c - a);
	int D = d * d;

	if (Z <= D)
		cout << "Yes" << endl;

	else {
		if (X <= D && Y <= D)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
}

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

#define YESNO(x) x ? printf("YES") : printf("NO")
#define YesNo(x) x ? printf("Yes") : printf("No")
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define scani(x) scanf("%d", &x)
#define scanll(x) scanf("%lld", &x)
#define printi(x) printf("%d", x)
#define printll(x) printf("%lld", x)
typedef long long ll;
using namespace std;

long long GCD(long long x, long long y) {
	return y ? GCD(y, x % y) : x;
}

long long LCM(long long x, long long y) {
	return x * y / GCD(x, y);
}

int Main() {
	string s, t;
	cin >> s >> t;

	t.pop_back();
	YesNo(s == t);
	return 0;
}

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


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

int main() {
  int K, X;
  cin >> K >> X;

  for (int i = X - K + 1; i < K + X; i++) {
    cout << i << " ";
  }
  return 0;
}

Measured memory_bytes: 3612
package main

import (
	"bufio"
	"fmt"
	"os"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	s := next()
	n := len(s)

	ans := 0
	for i, a := 0, 0; i < n; {
		if s[i] == 'A' {
			a++
			i++
			continue
		}
		if i+2 > n || s[i:i+2] != "BC" {
			a = 0
			i++
			continue
		}
		bc := 0
		for i+2 <= n && s[i:i+2] == "BC" {
			bc++
			i += 2
		}
		ans += a * bc
	}

	puts(ans)
}


Measured memory_bytes: 1280
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion


#pragma region Dijkstra
struct edge {
  ll to, cost;
  edge(ll to, ll cost) : to(to), cost(cost) {
  }
};

typedef pair<ll, int> P;  // <最短距離, 頂点の番号>

void Dijkstra(int V, int E, vector<vector<edge>>& G, vector<ll>& dist, int s) {
  priority_queue<P, vector<P>, greater<P>> que;
  fill(dist.begin(), dist.end(), LINF);
  dist[s] = 0;
  que.push(P(0, s));

  while (!que.empty()) {
    P p = que.top();
    que.pop();
    int v = p.second;
    if (dist[v] < p.first)
      continue;

    for (int i = 0; i < G[v].size(); ++i) {
      edge e = G[v][i];
      if (dist[e.to] > dist[v] + e.cost) {
        dist[e.to] = dist[v] + e.cost;
        que.push(P(dist[e.to], e.to));
      }
    }
  }
}
#pragma endregion Dijkstra


signed main() {
  int N;
  cin >> N;
  vector<int> a(N - 1), b(N - 1);

  int V = N, E = N - 1;
  vector<vector<edge>> G(N);
  rep(i, N - 1) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
    G[a[i]].pb(edge(b[i], 1));
    G[b[i]].pb(edge(a[i], 1));
  }

  vector<int> distF(N), distS(N);
  Dijkstra(V, E, G, distF, 0);
  Dijkstra(V, E, G, distS, N - 1);

  int F = 0, S = 0;
  rep(i, N) {
    (distF[i] <= distS[i] ? F : S)++;
  }

  if (F > S)
    cout << "Fennec" << endl;
  else
    cout << "Snuke" << endl;
}

Measured memory_bytes: 11280
package main

import (
	"bufio"
	"fmt"
	"os"
)

var bw = bufio.NewWriter(os.Stdout)

func isOdd(n int) bool { return n%2 != 0 }

func printf(format string, a ...interface{}) { fmt.Fprintf(bw, format, a...) }

func main() {
	defer bw.Flush()
	var s string
	fmt.Scan(&s)
	n := len(s)
	ans := make([]int, n)
	ctR := 0
	for i := 0; i < n; i++ {
		if s[i] == 'R' {
			ctR++
		} else {
			ans[i-1] += (ctR + 1) / 2
			ans[i] += ctR / 2
			ctR = 0
		}
	}
	ctL := 0
	for i := n - 1; i >= 0; i-- {
		if s[i] == 'L' {
			ctL++
		} else {
			ans[i] += ctL / 2
			ans[i+1] += (ctL + 1) / 2
			ctL = 0
		}
	}
	for i := 0; i <= len(ans)-2; i++ {
		printf("%v ", ans[i])
	}
	printf("%v\n", ans[len(ans)-1])
}


Measured memory_bytes: 3200
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		boolean[][] card = new boolean[4][13];
		for(int i = 0; i<4; i++){
			for(int j = 0; j<13 ;j++){
				card[i][j] = false;
			}
		}

		while(n-->0){
			String head = scan.next();
			int figure = 0;
			if(head.equals("S")){
				figure = 0;
			} else if(head.equals("H")){
				figure = 1;
			}else if(head.equals("C")){
				figure = 2;
			}else if(head.equals("D")){
				figure = 3;
			}
			int number = scan.nextInt();
			card[figure][number-1]=true;
		}
		for(int i = 0; i<4; i++){
			for(int j = 0; j<13; j++){
				if(card[i][j]!=true){
					if(i==0){
						System.out.println("S"+" "+(j+1));
					}else if(i==1){
						System.out.println("H"+" "+(j+1));
					}else if(i==2){
						System.out.println("C"+" "+(j+1));
					}else if(i==3){
						System.out.println("D"+" "+(j+1));
					}

				}
			}
		}
	}
}

Measured memory_bytes: 26116
function Main(input) {
	input = input.split("\n");
	tmp = input[0].split("");
	
	var len = tmp.length;
	for (var i = 0; i < len; i++) {
	tmp[i] = parseInt(tmp[i], 10);
	}
	
	var sum = 0;
	var len = tmp.length;
	for (var i = 0; i < len; i++) {
	sum += tmp[i];
	}
	
	if  (sum % 9 == 0) {
	var result = "Yes";
	} else {
	var result = "No";
	}
	
	console.log(result);
	}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 34748