akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <regex>
#ifdef _DEBUG
#include "debug.h"
#endif
#define int ll
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define all(v) (v).begin(),(v).end()
#define mkpr make_pair
#define mktp make_tuple
#define tv(tp, i) get<(i)>(tp)
#define CLEAR(obj) obj = decltype(obj)()
#define var auto
#define OUT(type) type &
#define IN(type) const type &
#define self (*this)
#define in :
#define True true
#define False false
using namespace std; using int32 = int32_t; using str = string; using cstr = const str;
using ll = long long; using ull = unsigned long long; using cint = const int; using cll = const ll;
using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>;
using vb = vector<bool>; using vvb = vector<vb>; using vd = vector<double>; using vvd = vector<vd>;
using vc = vector<char>; using vvc = vector<vc>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<double, double>; using psl = pair<string, ll>;
using tiii = tuple<int, int, int>; using tlll = tuple<ll, ll, ll>;
static const int MGN = 10; static const int ARYSZ_MAX = (int)1e7;
static const ll LINF = LLONG_MAX/2;
#ifdef int
static const int INF = LINF;
#else
static const int INF = INT_MAX/2;
#endif
static double EPS = 1e-9;
#define FASTCIN() cin.tie(0);ios::sync_with_stdio(false);
#ifdef IMPORT_SAMPLE
#define DEBUG_IMPORT(file) vs args(argv, argv+argc);str sample = make_sample(args, file);ifstream ifs(sample); cin.rdbuf(ifs.rdbuf());
#else
#define DEBUG_IMPORT(file)
#endif
static inline bool DBLEQ(double a, double b) {return abs(a - b) < EPS;}
static inline void EPR(str msg) {cerr << msg << endl;}
static inline void AST(bool exp, str msg) {if(!exp){EPR(msg);} assert(exp);}
static inline void TAST(bool exp, str msg) {if(!exp){EPR(msg);} while(!exp){}}


int32 main(int32 argc, char* argv[]) {
    FASTCIN();
    DEBUG_IMPORT("sample-1");


    int N, M;
    cin >> N >> M;
    vi W(N), V(N);
    REP(i, N) cin >> W[i] >> V[i];

    int VMAX = 1000;
    var dp = vvi(N + 1, vi(VMAX * N + 4, INF));
    // dp[i][j] := [0,i) の品で、価値 j 以上とできる重さの最小値

    REP(i, N)
        dp[i][0] = 0;

    REP(i, N) {
        REP(j, VMAX * N + 1) {
            if (j <= V[i])
                dp[i + 1][j] = min(dp[i + 1][j], W[i]);
            else if (V[i] < j)
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - V[i]] + W[i]);

            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
        }
    }

    int ans = 0;
    REP(j, VMAX *N + 1) {
        if (dp[N][j] <= M)
            ans = max(ans, j);
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 80256
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#define N 2000000
#define MAX 10001
using namespace std;

void CountingSort(int *A, int *B, int k)
{
    int C[MAX] = {0};
    for (int j = 0; j < MAX; j++)
    {
        C[j] = 0;
    }

    for (int j = 1; j <= k; j++)
    {
        C[A[j]] = C[A[j]] + 1;
    }

    for (int j = 1; j < MAX; j++)
    {
        C[j] = C[j - 1] + C[j];
    }

    for (int j = k; j > 0; j--)
    {
        B[C[A[j]]]  = A[j];
        C[A[j]] = C[A[j]] - 1;

    }

}

int main(int argc, char *argv[])
{
    int *A = (int*)malloc(sizeof(int) * N);
    int *B = (int*)malloc(sizeof(int) * N);


    int k;
    scanf("%d", &k);
    for (int i = 1; i <= k; i++)
    {
        scanf("%d", &A[i]);
    }
    CountingSort(A, B, k);
    printf("%d", B[1]);
    for (int i = 2; i <= k; i++)
    {
        printf(" %d", B[i]);
    }
    printf("\n");

    return 0;
}



Measured memory_bytes: 18876
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<int, int>;
using Pc = pair<double, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

//////////////////////////////////

vector<vector<int>> bingo(3, vector<int>(3));
vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;

	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i - 1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

int main() {

	ll N;
	cin >> N;

	ll ans = 0;
	for (ll i = 1; i <= N;++i) {
		if (i % 3 != 0 && i % 5 != 0) {
			ans += i;
		}
	}

	cout << ans << endl;
}



Measured memory_bytes: 5420
a = []
for i in range(3):
    a1, a2, a3 = map(int, input().split())
    a.append(a1)
    a.append(a2)
    a.append(a3)

l = [0]*9
n = int(input())

for i in range(n):
    b = int(input())
    if b in a:
        l[a.index(b)] += 1

if l[0] == 1 and l[1] == 1 and l[2] == 1:
    print('Yes')
elif l[3] == 1 and l[4] == 1 and l[5] == 1:
    print('Yes')
elif l[6] == 1 and l[7] == 1 and l[8] == 1:
    print('Yes')
elif l[0] == 1 and l[3] == 1 and l[6] == 1:
    print('Yes')
elif l[1] == 1 and l[4] == 1 and l[7] == 1:
    print('Yes')
elif l[2] == 1 and l[5] == 1 and l[8] == 1:
    print('Yes')
elif l[0] == 1 and l[4] == 1 and l[8] == 1:
    print('Yes')
elif l[2] == 1 and l[4] == 1 and l[6] == 1:
    print('Yes')
else:
    print('No')

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll r, g, b;

	cin >> r >> g >> b;

	if ((g * 10 + b) % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

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

//{{{
/********************************************************************/
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define reps(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) reps(i, 0, n)
#define REPS(i, a, b) reps(i, a, b)
#define REP(i, n) rep(i, n)
#define deps(i, a, b) for (int i = a; i >= b; --i)
#define dep(i, n) deps(i, n, 0)
#define DEPS(i, a, b) deps(i, a, b)
#define DEP(i, n) dep(i, n)

#define pf push_front
#define pb push_back
#define mp make_pair
#define fst first
#define FST fst
#define sec second
#define SEC sec
#define sz(obj) ((int)(obj).size())
#define all(v) (v).begin(), (v).end()
#define ALL(v) all(v)

const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

//vector<string> split(const string &s, char delim) {
//  vector<string> elems;
//  string item;
//  for (char ch: s) {
//    if (ch == delim) {
//      if (!item.empty()) elems.push_back(item);
//      item.clear();
//    }
//    else item += ch;
//  }
//  if (!item.empty()) elems.push_back(item);
//  return elems;
//}

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T> void print(T x) { std::cout << x << '\n'; }

/****************************************************************/
//}}}

signed main()
{
  string str[4] = {"erase", "dream", "dreamer", "eraser"};
  string s;
  cin >> s;
  while (true) {
    string tmp, t;
    bool ope = true;
    if (sz(s) >= 7) {
      tmp = s.substr(sz(s) - 7, 7);
      if (tmp == str[2] and ope) {
        t = s.substr(0, sz(s) - 7);
        s = t;
        ope = false;
      }
    }
    if (sz(s) >= 6) {
      tmp = s.substr(sz(s) - 6, 6);
      if (tmp == str[3] and ope) {
        t = s.substr(0, sz(s) - 6);
        s = t;
        ope = false;
      }
    }
    if (sz(s) >= 5) {
      tmp = s.substr(sz(s) - 5, 5);
      if ((tmp == str[1] or tmp == str[0]) and ope) {
        t = s.substr(0, sz(s) - 5);
        s = t;
        ope = false;
      }
    }
    if (ope) break;
  }
  if (sz(s)) print("NO");
  else print("YES");

  return (0);
}

Measured memory_bytes: 620
from heapq import heappush, heappop
from collections import defaultdict

n, m, s, t = map(int, input().split())
y = 10**15


class Graph(object):
    def __init__(self):
        self.graph = defaultdict(list)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))


class Dijkstra(object):
    def __init__(self, graph, start):
        self.g = graph.graph

        self.dist = defaultdict(lambda: float('inf'))
        self.dist[start] = 0

        self.Q = []
        heappush(self.Q, (self.dist[start], start))

        while self.Q:
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, weight in self.g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    heappush(self.Q, (alt, v))


yen_g = Graph()
sno_g = Graph()
for _ in range(m):
    u, v, a, b = map(int, input().split())
    yen_g.add_edge(u, v, a)
    yen_g.add_edge(v, u, a)
    sno_g.add_edge(u, v, b)
    sno_g.add_edge(v, u, b)

cost = [0] * n
yen_d = Dijkstra(yen_g, s)
sno_d = Dijkstra(sno_g, t)
for i in range(1, n + 1):
    cost[i - 1] = y - (yen_d.dist[i] + sno_d.dist[i])

ans = [y] * n
ans[n - 1] = cost[n - 1]
for i in range(n - 2, -1, -1):
    ans[i] = max(ans[i + 1], cost[i])

for a in ans:
    print(a)


Measured memory_bytes: 103452
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define mod 1000000007
#define INF 1000000000
#define LLINF 2000000000000000000LL

#define SIZE 500000

int n;
vector<pair<int,int> > point;
int x,y;

int main(){
    
    scanf("%d",&n);
    
    for(int i=0;i<n;i++){
        scanf("%d%d",&x,&y);
        point.push_back({x,y});
    }
    
    sort(point.begin(),point.end());
    
    int ans = INF;
    
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(ans > (point[i].first-point[j].first)*(point[i].first-point[j].first))
                ans = min(ans,(point[i].first-point[j].first)*(point[i].first-point[j].first)
                          +(point[i].second-point[j].second)*(point[i].second-point[j].second));
            else
                break;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 7224
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define per(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define enter cout << endl
#define siz(x) ((int)x.size())
typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi ;
typedef pair <int, int> pii ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 100010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
void print(int x) { cout << x << endl ; exit(0) ; }
void PRINT(string x) { cout << x << endl ; exit(0) ; }
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }

int n, ans ;
int a[N][4], dp[N][4] ; // dp[i][j]表示玩到第i天，当天玩的是j项目的最大值

signed main(){
	scanf("%d", &n) ;
	for (int i = 1; i <= n; i++) scanf("%d%d%d", &a[i][1], &a[i][2], &a[i][3]) ;
	for (int i = 1; i <= n; i++) dp[i][1] = dp[i][2] = dp[i][3] = -iinf ;
	for (int i = 1; i <= 3; i++) dp[1][i] = a[1][i] ;
	for (int i = 1; i < n; i++)
	for (int j = 1; j <= 3; j++)
	for (int k = 1; k <= 3; k++)
	if (j != k)
	dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[i + 1][k]) ;
	for (int i = 1; i <= 3; i++) ans = max(ans, dp[n][i]) ;
	printf("%d\n", ans) ;
	return 0 ;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
*/


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define M 1000000007
#define N 100001
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

int t, n, a, b;
vector<int> p;
/*
The formula for the Manhattan distance is  |x1−x2|+|y1−y2| , which is the same as  |x1+y1|−|x2+y2| . 
We need to find the greatest of these distances, so the solution would be to minimize  (x1,y1)  and maximize  (x2,y2) 
*/
int main() {
    //scanf("%d", &t);
    t = 1;
    int plusMax = INT_MIN, plusMin = INT_MAX, subMax = INT_MIN, subMin = INT_MAX;
    while(t--) {
        scanf("%d", &n);    //p.resize(n);  
        for(int i=0; i<n; i++) {
            scanf("%d %d", &a, &b);
            
            if(a + b > plusMax) plusMax = a + b;
            if(a + b < plusMin) plusMin = a + b;
            if(a - b > subMax) subMax = a - b;
            if(a - b < subMin) subMin = a - b;
        }
/*
haan krega..abs ko hata do cases ban jaenge

max(x+y) - min(x+y) and max(x-y) - min(x-y)
*/
        int ans = max(plusMax - plusMin, subMax - subMin);

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


Measured memory_bytes: 3660
from collections import Counter
input()
A = Counter(list(map(int, input().split()))+[0]*4)
A = [(a[0], a[1]) for a in A.most_common()  if a[1]>1]
A.sort(key=lambda l: -l[0])
print(A[0][0]**2 if A[0][1]>3 else A[0][0]*A[1][0])

Measured memory_bytes: 25904
#include <bits/stdc++.h>
#include <stdio.h>
#include <ios>     
#include <iomanip> 

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  int N; cin >> N;
  vector<int> a(N);
  map<int,int> m;
  for(int i=0; i<N; i++){ cin >> a[i]; }
  
  //main
  int ans = 1;
  for(int i=0; i<N; i++){
    for(int j=-1; j<=1; j++){
      if(m.find(a[i]+j) != m.end()){
        m[a[i]+j] ++;
        ans = max(ans, m[a[i]+j]);
      }else{
        m[a[i]+j] = 1;
      }
    }
  }
  
  // output
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 5120
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main (String [] args){
		List <Integer> list = new ArrayList<Integer>();
		HashMap <Integer, Integer>hm = new HashMap<Integer, Integer>();
		int v1 = Integer.parseInt(sc.next());
		int v2 = Integer.parseInt(sc.next());
//		String s2 = sc.next();		
		String ans_str = "";
		int ans_int = 0;
		
		v2 = v2+(v1*3);
		ans_int = v2 / 2;
		
		System.out.println(ans_int);
		System.out.flush();
		sc.close();
	}
}

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

int main() {
	int n;
	cin >> n;

	while (n != 0) {
		if (n % 10 == 7) {
			cout << "Yes";
			return 0;
		}

		n /= 10;
	}
	

	cout << "No";
	
	return 0;
}
	

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

using namespace std;

int main() {
    int n;
    cin >> n;
    int a[n];
    vector<vector<pair<int,int>>> xy(n);

    for (int i = 0; i < n; i++) {
        cin >> a[i];
        xy[i].resize(a[i]);
        for (int j = 0; j < a[i]; j++) {
            cin >> xy[i][j].first >> xy[i][j].second;
            xy[i][j].first--;
        }
    }

    int count = 0;
    for (int i = 1; i < (1 << n); i++) {
        bool ok = true;
        for (int j = 0; j < n; j++) {
            if (!(i & (1 << j))) continue;
            for (int k = 0; k < a[j]; k++) {
                if (((i >> xy[j][k].first) & 1) ^ xy[j][k].second) ok = false;
            }
        }
        if (ok) {
            count = max(count, __builtin_popcount(i));
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int A, B;
	int sum;
	char buf[128];
	
	fgets(buf,128,stdin);
	sscanf(buf,"%d %d",&A,&B);
	
	sum = A + B;
	
	if(sum%3 == 0 || A%3 == 0 || B%3 == 0) {
		printf("Possible");
	} else {
		printf("Impossible");
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
 
using namespace std;
using std::cout;
using ll =long long;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int ab(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  int n,m;
  cin >> n>> m ;
  int k[n];
  int a[n][m];
  for(int i=0; i<n; i++){
    cin>>k[i];
    for(int j=0; j<k[i];j++){
      cin >>a[i][j];
    }
  }
  int ans =0;
  int num[31]={0};
  for(int i=0;i<n;i++){
    for(int j=0;j<k[i];j++){
      num[ a[i][j] ]  ++;
    }
  }
  for(int i=1;i<=m ;i++){
    if(num[i]==n){
      ans ++;
    }
  }
  cout <<ans<<endl;


}

Measured memory_bytes: 256
/*{{{*/
//#include<iostream>
//#include<vector>
//#include<cmath>
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll w,h;
  cin >> w >> h;
  vector<pll> p(w+h);
  REP(i,w) {
    ll pi;
    cin >> pi;
    p[i] = make_pair(pi,0);
  }
  REP(i,h) {
    ll pi;
    cin >> pi;
    p[w+i] = make_pair(pi,1);
  }
  sort(p.begin(),p.end());
  ll n = w+h;
  h++;
  w++;
  ll ans = 0;
  REP(i,n){
    if(p[i].second==1){
      ans += p[i].first * w;
      h--;
    }else{
      ans += p[i].first * h;
      w--;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;

int main(void){
    int N,M;
    cin >> N >> M;
    vector<int> H;
    vector< vector<int> > A;
    for(int i =0; i < N; i++){
        int h;
        cin >> h;
        H.push_back(h);
    }

    int d;

    vector<int> flags(N,1);
    for(int i =0; i < M; i++){
        int A,B;
        cin >> A >> B;
        if(H[A-1] > H[B-1]){
            flags[B - 1] = 0;
        }else if(H[A-1] < H[B-1]){
            flags[A - 1] = 0;
        }else if(H[A-1] == H[B-1]){
            flags[A - 1] = 0;
            flags[B - 1] = 0;
        }
    }
    int sum =0;
   
    for(int i =0; i < N; i++){
        sum += flags[i];
    }

    cout << sum << endl;

    return 0;

}

Measured memory_bytes: 4220
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {

	Scanner sc = new Scanner(System.in);

	int A = sc.nextInt();
	int B = sc.nextInt();
	int C = sc.nextInt();

		if (A + B >= C) {
		System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

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

ll a[200009],b[200009];
ll n,ans;
int main()
{
    scanf("%lld",&n);
    ll x;
    for(ll i=1;i<=n;i++)
    {
        scanf("%lld",&x);
        b[i]=b[i-1]^x;
        a[i]=a[i-1]+x;
    }
    ll l=1,r=1;
    for(r=1;r<=n;r++)
    {
        while((a[r]-a[l-1])!=(b[r]^b[l-1]))
        {
           l++;
        }
        //l++;
        ans+=(r-l+1);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	ll n,a,b; cin >> n >> a >> b;
	if(abs(a-b)%2==0){
		cout << abs(a-b)/2 << endl;
	}
	else{
		ll ans=min(b-1,n-a);
		ans=min(ans,max(0LL,(b-a-1)/2+a));
		ans=min(ans,max(0LL,(b-a-1)/2+(n-b)+1));
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int ch = sc.nextInt();
        if(ch >= 65 && ch <= 90)
            System.out.println(1);
        else if(ch >= 97 && ch <= 122)
            System.out.println(2);
        else
            System.out.println(0);
    }
}


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

int main()
{
  int n;
  int m = 100000;
  cin >> n;
  for(int i = 0; i < n; i++){
    m += m / 20;
    if(m % 1000){
      m += 1000 - m % 1000;
    }
  }
  cout << m << endl;
}

Measured memory_bytes: 1160
f = lambda : map(int, input().split())
n, m = f()
ll = [[0]*n for i in range(m)]
for i in range(m):
  k, *t = f()
  for j in range(k):
    ll[i][t[j]-1] = 1
lp = list(f())

import itertools as it
lt = [p for p in it.product([0,1], repeat=n)]

ans = 0
for p in lt:
  lj = []
  for l in ll:
    lj.append(sum(a*b for a, b in zip(p,l))%2)
  if lp == lj:
    ans += 1

print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define endl '\n'
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define fr1(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define input(a,n) fr(i,0,n)cin>>a[i]
#define output(a,n) fr(i,0,n)cout<<a[i]<<" "
#define dbg cout<<"hurr"<<endl;
#define dbg2 cout<<"hurr2"<<endl;
#define md 1000000007
#define inf 100000000000000000
#define sp << " " <<
#define pi 3.14159265358979323846
#define fixd(x) cout << fixed << setprecision(x);

ll arr[22][22],ans=0,n;
unordered_map <ll,ll> dp;

ll feel(ll curr)
{
    if(dp.count(curr))
        return dp[curr];
    if(curr==0)
        return 1;
    ll temp=0;
    fr(i,0,n)
    {
        if((curr&(1<<i)) && arr[n-__builtin_popcount(curr)][i])
        {
            temp+=feel(curr^(1<<i));
            temp%=md;
        }
    }
    dp[curr]=temp;
    return temp;
}

int main()
{
    fast;
    cin >> n;
    fr(i,0,n)fr(j,0,n)cin >> arr[i][j];
    cout << feel((ll)pow(2,n)-1);
}

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

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s,pre="";
	char ch;
	ll q,qno,r=0,i;
	cin>>s;
	cin>>q;
	while(q--) {
		cin>>qno;
		if(qno==1) r=r^1;
		else {
			cin>>qno>>ch;
			if((r==0 && qno==1)||(r==1 && qno==2)) pre+=ch;
			else s+=ch;
		}
	}
	if(r==0) {
		for(i=pre.length()-1;i>=0;i--) cout<<pre[i];
		cout<<s;
	} else {
		for(i=s.length()-1;i>=0;i--) cout<<s[i];
		cout<<pre;
	}
		
}

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

const double PI = 3.14159265358979323846;

int main()
{
    ll a;
    string b;
    cin >> a >> b;
    int bb = (b[0] - '0') * 100 + (b[2] - '0') * 10 + (b[3] - '0');
    cout << a * bb / 100 << endl;
    return 0;
}

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

int main() {
    int N;
    cin >> N;

    bool prime[55556] = {false};
    for (int i = 2; i * i <= 55555; i++) {
        if (!prime[i]) {
            for (int j = i + i; j <= 55555; j += i) {
                prime[j] = true;
            }
        }
    }

    int x = 2;
    while (N > 0) {
        if (!prime[x] && x % 5 == 1) {
            cout << x << " ";
            N--;
        }
        x++;
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 998244353
#define maxn 1000005
using namespace std;
typedef long long LL;
int read()
{
    char c=getchar();int f=1,sum=0;
    while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0' && c<='9'){sum=sum*10+c-'0';c=getchar();}
    return sum*f;
}
int n,m;
LL fac[maxn],inv[maxn],ans;
LL ksm(LL a,LL b){LL ret=1;while(b){if(b&1) ret=ret*a%mod;a=a*a%mod;b>>=1;}return ret;}
void init(int x)
{
	fac[0]=1;
	for(int i=1;i<=x;i++) fac[i]=fac[i-1]*i%mod;
	inv[x]=ksm(fac[x],mod-2);
	for(int i=x;i>=1;i--) inv[i-1]=inv[i]*i%mod;
}
LL calc(LL x,LL y){return fac[x+y]*inv[x]%mod*inv[y]%mod;}
int main()
{
	n=read();m=read();
	if(n>m) swap(n,m);
	init(n+m);
	for(int i=1;i<=n;i++) ans+=calc(i,i)*calc(n-i,m-i)%mod;
    ans=ans%mod*ksm(calc(n,m)<<1,mod-2)%mod;
    printf("%lld\n",(ans+m)%mod);
	return 0;
}


Measured memory_bytes: 15872
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

template <class T> void swap(T& a, T& b) { T t = std::move(a); a = std::move(b); b = std::move(t); }

int main(void)
{
    ll N, i=1, a;
    string s;

    cin >> N;

    if(N==0) s.push_back('0');

    while(N!=0){
        a = pow(2,i);

        if(N % a == 0){
            s.push_back('0');
        }
        else{
            s.push_back('1');
            N -= pow(-2,i-1);
        }

        i++;
    }
    
    reverse(s.begin(), s.end());

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>b){
        cout<<(2*a)-1<<endl;
    }
    else if(b>a){
        cout<<(2*b)-1<<endl;
    }
    else{
    int r=a+b;
    cout<<r<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, a[55], res;

signed main() {
	cin >> n;
	rep(i,n) cin >> a[i];
	while (1) {
		bool fin = 1;
		rep(i,n) if (a[i]>=n) {
			int t = a[i]/n;
			a[i] -= t*n;
			rep(j,n) if (j!=i) a[j] += t;
			res += t;
			fin = 0;
		}
		if (fin) break;
	}
	cout << res << endl;
}

Measured memory_bytes: 256
a,b = map(int, input().split())
c = []
for _ in range(a):
    aa = list(map(int, input().split()))
    c.append(aa)
d = []
for i in range(a+1,a+b+1):
    bb = int(input())
    d.append(bb)

for n in range(a):
    x = 0
    y = 0
    for j in range(b):
        y = d[j] * c[n][j]
        x = x + y
    print(x)


Measured memory_bytes: 6008
K = gets.chomp.to_i
hash = {
  1 => 1,
  2 => 1,
  3 => 1,
  4 => 2,
  5 => 1,
  6 => 2, 
  7 => 1,
  8 => 5,
  9 => 2,
  10 => 2,
  11 => 1,
  12 => 5,
  13 => 1,
  14 => 2,
  15 => 1,
  16 => 14,
  17 => 1,
  18 => 5,
  19 => 1,
  20 => 5,
  21 => 2,
  22 => 2,
  23 => 1,
  24 => 15,
  25 => 2,
  26 => 2,
  27 => 5,
  28 => 4,
  29 => 1,
  30 => 4,
  31 => 1,
  32 => 51}

puts hash[K]


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
	static int W, H;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		W = sc.nextInt();
		H = sc.nextInt();
		int N = sc.nextInt();
		int[]x = new int[N];
		int[]y = new int[N];
		int[]a = new int[N];
		for(int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			a[i] = sc.nextInt();
		}
		sc.close();
		int[][]c = new int[H][W];
		for(int i = 0; i < N; i++) {
			paint(x[i], y[i], a[i], c);
		}
		int cnt = 0;
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				if(c[i][j] == 0) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
	static void paint(int x, int y, int n, int[][]c) {
		if(n == 1) {
			for(int i = 0; i < H; i++) {
				for(int j = 0; j < x; j++) {
					c[i][j] = 1;
				}
			}
		}else if(n == 2) {
			for(int i = 0; i < H; i++) {
				for(int j = x; j < W; j++) {
					c[i][j] = 1;
				}
			}
		}else if(n == 3) {
			for(int i = 0; i < y; i++) {
				for(int j = 0; j < W; j++) {
					c[i][j] = 1;
				}
			}
		}else {
			for(int i = y; i < H; i++) {
				for(int j = 0; j < W; j++) {
					c[i][j] = 1;
				}
			}
		}
	}
}

Measured memory_bytes: 23252
N, A, B = gets.split(' ').map{|s| s.to_i}
ret = 0
1.upto(N) do |n|
    n0 = n.div(10000)
    n1 = n.div(1000) % 10
    n2 = n.div(100) % 10
    n3 = n.div(10) % 10
    n4 = n % 10
    sum = n0 + n1 + n2 + n3 + n4
    ret += n if sum >= A && sum <= B
end
print(ret)

Measured memory_bytes: 1916
/*
	watch me go
*/
#pragma GCC optimize("O3")
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define d long double
#define pii pair<int,int>
#define pb push_back
#define inf (int)1e18
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod=998244353;
int const mod1=1000000007;
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 #define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// ******** Using PBDS ********
// typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//                 os; 
// ******** Using PBDS ********
int modexp(int x, int n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}
 
int modinv(int n)
{
	return modexp(n,mod-2);
}


signed main()
{
    haha
   int n,k;
   cin>>n>>k;
   int ans=n;
   int n1=n%k;
   if(n%k==0)
   ans=0;
   for(int i=0;i<1000000;i++)
   {
       n=abs(n-k);
       
       ans=min(ans,n);
       ans=min(ans,n%k);
   }
   for(int i=0;i<1000000;i++)
   {
       n1=abs(n1-k);
       
       ans=min(ans,n1);
       ans=min(ans,n1%k);
   }
   cout<<ans;
}




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

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

   sort(a.rbegin(), a.rend());

   cout << a[0] * 10 + a[1] + a[2] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int A, B, C, D; cin >> A >> B >> C >> D;
  int result = max(0, min(B, D)-max(A, C));
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(),m = sc.nextInt();
        int inf = Integer.MAX_VALUE/2-10;
        int[][] dist = new int[n+1][n+1];
        for(int i=0;i<=n;i++) Arrays.fill(dist[i],inf);
        for(int i=0;i<=n;i++) dist[i][i] = 0;
        Edge[] dic = new Edge[m];
        for(int i=0;i<m;i++){
            int a = sc.nextInt(), b=sc.nextInt(), c = sc.nextInt();
            dic[i] = new Edge(a,b,c);
            dist[a][b] = Math.min(dist[a][b],c);
            dist[b][a] = Math.min(dist[b][a],c);
        }
        // run Floyd-Warshall
        for(int mid=1;mid<=n;mid++){
            for(int i=1;i<=n;i++){
                for(int j=1;j<=n;j++) dist[i][j] = Math.min(dist[i][j], dist[i][mid]+dist[mid][j]);
            }
        }
        int ans = 0;
        for(Edge e:dic){
            if(dist[e.left][e.right]<e.length) ans++;
        }
        System.out.println(ans);
    }
    static class Edge{
        int left,right,length;
        public Edge(int l, int r, int len){
            left = l;
            right = r;
            length = len;
        }
    }
}


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

using namespace std;

int sm(const string &s){
    int n=s.length(),buf=1,res=0;
    for(int i=0;i<n;++i){
        if(s[i]>='0' && s[i]<='9'){
            buf=s[i]-'0';
            continue;
        }
        else if(s[i]=='m')res+=1000*buf;
        else if(s[i]=='c')res+=100*buf;
        else if(s[i]=='x')res+=10*buf;
        else if(s[i]=='i')res+=buf;
        buf=1;
    }
    return res;
}

string ms(int n){
    string res;
    int m,c,x,i;
    m=n/1000;
    n-=m*1000;
    c=n/100;
    n-=c*100;
    x=n/10;
    n-=x*10;
    i=n;
    if(m>=1){
        if(m>1)res+='0'+m;
        res+='m';
    }
    if(c>=1){
        if(c>1)res+='0'+c;
        res+='c';
    }
    if(x>=1){
        if(x>1)res+='0'+x;
        res+='x';
    }
    if(i>=1){
        if(i>1)res+='0'+i;
        res+='i';
    }
    return res;
}

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;++i){
        string s1,s2;
        cin>>s1>>s2;
        cout<<ms(sm(s1)+sm(s2))<<endl;
    }
}

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

# define ll long long 
# define VI vector<int>
# define VLL vector<ll>
# define PII pair<int,int> 
#define mp make_pair
#define pb push_back
# define PI acos(-1)
# define ld long double
const int MxN = 200001 ; 
# define FOR(i,a,b) for(int i = a ; i < b ; ++i)
# define RFOR(i,a,b) for(int i = a ; i >= b ; --i)

/* VARIABLES */
int n , k ; 
VI a(MxN) ; 

/* END OF VARIABLES */



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

	cin >> n >> k ; 
	FOR(i,0,n)
		cin >> a[i] ; 
	if(k>=3*log2((ld)n))
	{
		FOR(i,0,n)
			cout<<n<<' ';
		return 0;
	}
	FOR(i,0,k) {
		VI tmp(n+1) ; 
		FOR(j,0,n) {
			int l = max(0,j-a[j])  ; 
			int r = min(n-1,j+a[j]) ; 
			tmp[l]++;
			if(r+1 < n) 
				tmp[r+1]--;
		}
		FOR(j,1,n) {
			tmp[j] += tmp[j-1] ; 
		}
		FOR(j,0,n){
			a[j] = tmp[j] ; 
		}
	}
	
	FOR(i,0,n) 
	cout << a[i] << " " ;
	
	return 0 ; 
}



Measured memory_bytes: 4884
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, intmax_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, intmax_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N; cin >> N;

    vector<int> h(N);
    for (auto &hi: h) cin >> hi;

    vector<int> dp(N);

    dp[1] = abs(h[1] - h[0]);
    for (size_t i = 2; i < N; ++i) {
        int value1 = abs(h[i] - h[i - 1]) + dp[i - 1];
        int value2 = abs(h[i] - h[i - 2]) + dp[i - 2];
        dp[i] = min(value1, value2);
    }

    cout << dp[N - 1] << "\n";

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

bool solve(){
  ll n,m;cin>>n>>m;
  ll k;cin>>k;
  vector<ll>A(n),B(m);
  vector<ll>sumA(n+1,0),sumB(m+1,0);
  rep(i,n)cin>>A[i];
  rep(i,m)cin>>B[i];

  rep(i,n)sumA[i+1]=sumA[i]+A[i];
  rep(i,m)sumB[i+1]=sumB[i]+B[i];
  ll ans=0;
  rep(i,n+1){
    ll K=k;
    K-=sumA[i];
    // cout<<K<<endl;
    if(K<0)break;
    ll num=i;
    auto itr=upper_bound(all(sumB),K)-sumB.begin()-1;
    // cout<<"sum"<<itr<<endl;
    chmax(ans,num+itr);
  }
  cout<<ans<<endl;

  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(30);
  solve();
}


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

#define int long long
typedef pair <int, int> pii;

const int N = 3e5 + 10;
int x, y, z, dpl[N], dpr[N];
multiset <pii> st;

struct ms {
	int a, b, c;
	
	ms() {
		a = b = c = 0;
	}
	
	ms(int x, int y, int z) {
		a = x;
		b = y;
		c = z;
	}
} ar[N];

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> x >> y >> z;
	for (int i = 0; i < x + y + z; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		ar[i] = ms(a, b, c);
	}
	sort(ar, ar + x + y + z, [&] (ms a, ms b) { return a.b + b.c > a.c + b.b; });
	
//	cout << endl << endl;
//	for (int i = 0; i < x + y + z; i++)
//		cout << ar[i].a << ' ' << ar[i].b << ' ' << ar[i].c << endl;
//	cout << endl;
	
	int ansx = 0, ansy = 0;
	pii last;
	for (int i = 0; i < y; i++) {
		st.insert({ar[i].a - ar[i].b, ar[i].b});
		ansy += ar[i].b;
	}
	last = *st.rbegin();
	dpl[y - 1] = ansy;
	
	for (int i = y; i < x + y; i++) {
		int tmp = ar[i].a - ar[i].b, ty = ar[i].b;
		if (tmp >= last.first) {
			st.insert({tmp, ty});
			ansx += ar[i].a;
		}
		else {
			st.insert({tmp, ty});
			auto it = st.lower_bound(last);
			assert(it != st.begin());
			it--;
			ansy += ty;
			ansy -= last.second;
			ansx += last.second + last.first;
			last = *it;
		}
		dpl[i] = ansx + ansy;
	}
	
	
	int ansz = 0;
	ansx = 0;
	st.clear();
	for (int i = x + y + z - 1; i >= x + y; i--) {
		st.insert({ar[i].a - ar[i].c, ar[i].c});
		ansz += ar[i].c;
	}
	last = *st.rbegin();
	dpr[x + y] = ansz;
	
	for (int i = x + y - 1; i >= y; i--) {
		int tmp = ar[i].a - ar[i].c, tz = ar[i].c;
		if (tmp >= last.first) {
			st.insert({tmp, tz});
			ansx += ar[i].a;
		}
		else {
			st.insert({tmp, tz});
			auto it = st.lower_bound(last);
			assert(it != st.begin());
			it--;
			ansz += tz;
			ansz -= last.second;
			ansx += last.second + last.first;
			last = *it;
		}
		dpr[i] = ansx + ansz;
	}
	
//	for (int i = 0; i < x + y + z; i++)
//		cout << dpl[i] << '\n';
//	cout << endl;
//	for (int i = 0; i < x + y + z; i++)
//		cout << dpr[i] << '\n';
//	cout << endl;
	
	int ans = 0;
	for (int i = y - 1; i < x + y; i++)
		ans = max(ans, dpl[i] + dpr[i + 1]);
	cout << ans;
}

Measured memory_bytes: 16768
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>
using namespace std;




int main(int argc, const char * argv[]) {
    #ifdef __APPLE__
        freopen("/Users/danya.smelskiy/Documents/Danya/Resources/input.txt","r",stdin);
        //freopen("/Users/danya.smelskiy/Documents/Danya/Danya/output.out", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long long n, m;
    cin >> n >> m;
    long long res = 1;
    for (long long i = 2; i * i <= m; ++i) if (m % i == 0) {
        int c = 0;
        while (m % i == 0) {
            m /= i;
            ++c;
        }
        c /= n;
        for (int j = 1; j <= c; ++j)
            res *= i;
    }
    if (n == 1) res *= m;
    cout << res << '\n';
    return 0;
    
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const LL INF=(LL)1<<50;
const LL MAX=1e9+7;

void array_show(int *a,int n,char middle=' '){
	for(int i=0;i<n;i++)printf("%d%c",a[i],(i!=n-1?middle:'\n'));
}
void array_show(LL *a,int n,char middle=' '){
	for(int i=0;i<n;i++)printf("%lld%c",a[i],(i!=n-1?middle:'\n'));
}
LL dp[5005][5005];
int t[5005];

int main(){
	int a,b,c;
	int n;
	int i,j,k;
	int p,q;
	cin>>n;
	cin>>p>>q;
	for(i=0;i<n;i++){
		cin>>t[i];
	}
	for(i=0;i<=n;i++){
		for(j=0;j<=n;j++)dp[i][j]=INF;
	}
	dp[0][0]=0;
	for(i=0;i<=n;i++){
		for(j=0;j<n;j++){
			if(i==t[j])continue;
			if(i>t[j])dp[i][j+1]=min(dp[i][j+1],dp[i][j]+q);
			else{
				dp[i][j+1]=min(dp[i][j+1],dp[i][j]+p);
				dp[t[j]][j+1]=min(dp[t[j]][j+1],dp[i][j]);
			}
		}
	}
	LL s=INF;
	for(i=0;i<=n;i++){
		s=min(s,dp[i][n]);
	}
	cout<<s<<endl;
}


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

int main(){
  long long h, m;
  cin >> h >> m;
  
  long long ans = 0;
  vector<int> dx = {1, -1, 0};
  vector<int> dy = {1, -1, 0};
  if(h >= 3 && m >= 3) ans =(h-2) * (m-2);
  else if(h >= 3 || m >= 3){
    if(min(h, m) % 2) ans = max(h, m) - 2;
  }
  else{
    vector<vector<int>> card(h, vector<int>(m));
    for(int i = 0; i < h; i++){
      for(int j = 0; j < m; j++){
        for(int x = 0; x < 3; x++){
          for(int y = 0; y < 3; y++){
            int nx = j+dx.at(x), ny = i+dy.at(y);
            if(nx >= 0 && nx < m && ny >= 0 && ny < h) card.at(ny).at(nx)++;
          }
        }
      }
    }
    for(int i = 0; i < h; i++){
      for(int j = 0; j < m; j++){
        if(card.at(i).at(j) % 2) ans++;
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256