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

int main()
{
 int a,b,t;
 int total = 0;
  cin >> a >> b >> t;
  t = t + 0.5;
  while(t >= a)
  {
    t -= a;
    total += b;
  }
  
  cout << total;
  return 0;
}
  
  

Measured memory_bytes: 764
K = gets.to_i
lun2 = (1 .. 9).to_a
i = 0
until lun2.size >= K
  a = lun2[i]
  d = a % 10
  if d == 0
    lun2 << a * 10
    lun2 << a * 10 + 1
  elsif d == 9
    lun2 << a * 10 + 8
    lun2 << a * 10 + 9
  else
    lun2 << a * 10 + d - 1
    lun2 << a * 10 + d
    lun2 << a * 10 + d + 1
  end
  i += 1
end
puts lun2[K - 1]


Measured memory_bytes: 4092
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
    int n;
    string s;
    cin >> n;
    set<int> st;
    REP(i,n){
        int x;
        cin >> x;
        if (st.count(x)) st.erase(x);
        else st.insert(x);
    }
    cout << st.size() << endl;

    return 0;
}

Measured memory_bytes: 4864
#include <iostream>

using namespace std;

int main () {
    int h, w;

    while (true) {
        cin >> h >> w;

        if (h == 0 && w == 0) break;

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) cout << '#';
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }



struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};


int main() {
    int N, M;
    while (cin >> N >> M) {
        UnionFind uf(N);
        for (int i = 0; i < M; ++i) {
            int a, b;
            cin >> a >> b;
            --a, --b;
            uf.merge(a, b);
        }
        int res = 0;
        for (int i = 0; i < N; ++i) if (uf.root(i) == i) ++res;
        cout << res - 1 << endl;
    }
}

















Measured memory_bytes: 3784
#include <iostream>
#include <cmath>

int main(int argc, char const *argv[])
{	
	double const pi = 3.14159265358;
	int a,b;double rad;
	std::cin >> a >> b >> rad;
	rad = rad*pi/180;
	double s,h,l;
	s = a * b * std::sin(rad)/2;
	h = b * std::sin(rad);
	l = a + b + std::sqrt( a*a + b*b - 2 * a * b * std::cos(rad));
	printf("%lf\n%lf\n%lf\n",s,l,h);
	return 0;
}

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
LL a[55],b[55],c[55],d[55];
LL x[55];
LL n,m,q;
LL mx;
void f(LL p,LL pr)
{
    if(p==n+1)
    {
        LL s=0;
//        cout<<endl;
//        for(LL i=1;i<=n;i++)
//            cout<<x[i]<<" ";
//        cout<<endl;
        for(LL i=1;i<=q;i++)
        {
            if(x[b[i]]-x[a[i]]==c[i])s+=d[i];
        }
//        cout<<s<<endl;
        mx=max(mx,s);
        return ;
    }
    for(LL i=pr;i<=m;i++)
    {
        x[p]=i;
        f(p+1,i);
    }
}
int main()
{
    cin>>n>>m>>q;
    for(LL i=1;i<=q;i++)
    {
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    f(1,1);
    cout<<mx;

}


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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define int long long int
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

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

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) //bit計算
{
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void)
{
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++)
    {
        if (!prime[i])
        {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i)
        {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}
vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i - 1);
            if (i * i != n)
            {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}
signed main()
{
    int K, X;
    cin >> K >> X;
    if (K * 500 >= X)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

#define mod 1e9+7
#define ll long long int
#define epsilon 1e-7



int main(void){
    int c[3][3];
    for(int i = 0;i < 3;i++){
        for(int j = 0;j < 3;j++){
            scanf("%d", &c[i][j]);
        }
    }
    if(c[0][0]-c[0][1] == c[1][0]-c[1][1] && c[1][0]-c[1][1] == c[2][0]-c[2][1] && c[2][2]-c[2][1] == c[1][2]-c[1][1] && c[1][2]-c[1][1] == c[2][2]-c[2][1])printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 128
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
//#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 2e5;
int pos[N + 5];
int ST[2][2 * N + 5];
int arr[N + 5];

void build(int k,int idx,int l,int r) {
	if(l == r) {
		ST[k][idx] = arr[2 * l + k];
		return ;
	}
	int mid = (l + r) / 2;
	build(k, 2 * idx, l, mid), build(k, 2 * idx + 1,mid + 1, r);
	ST[k][idx] = min(ST[k][2 * idx], ST[k][2 * idx + 1]);
}

priority_queue<pair<pair<int,int>, pair<int,int> > > pq;
int n;

int query(int k,int idx,int l,int r,int le,int ri) {
	if(r < le || ri < l) return 1e9;
	if(le <= l && r <= ri) return ST[k][idx];
	int mid = (l + r) / 2;
	return min(query(k, 2 * idx, l, mid, le, ri), query(k, 2 * idx + 1,mid + 1, r, le, ri));
}

void insert(int l,int r) {
	int flag = l % 2;
	int rhs = r;
	if(flag != rhs % 2) rhs--;
	int rl = query(flag, 1, 0, n / 2 - 1, l / 2, rhs / 2);
	rhs = r;
	int rr = query(1 ^ flag, 1, 0, n / 2 - 1, (pos[rl] + 1) / 2, rhs / 2);
	pq.push({{-rl, -rr}, {l, r} });
}

void solve(int l,int r) {
	vector<int> res;
	int rl = query(0, 1, 0, n / 2 - 1, l / 2, r / 2);
	int rr = query(1, 1, 0, n / 2 - 1, pos[rl] / 2, r / 2);
	pq.push({{-rl, -rr}, {l, r}});
	while(!pq.empty()) {
		int rl = -pq.top().FI.FI;
		int rr = -pq.top().FI.SE;
		int l = pq.top().SE.FI;
		int r = pq.top().SE.SE;
		pq.pop();
		res.PB(rl), res.PB(rr);
		int pl = pos[rl];
		int pr = pos[rr];
		if(l < pl - 1) {
			insert(l, pl - 1);
		}
		if(pl + 1 < pr - 1) {
			insert(pl + 1, pr - 1);
		}
		if(pr + 1 < r) {
			insert(pr + 1, r);
		}
	}
	for(int i = 0;i < n;i++) {
		if(i) cout<<" ";
		cout<<res[i];
	}
	cout<<endl;
}

void hora(int tc) {
	cin>>n;
	for(int i = 0;i < n;i++) {
		cin>>arr[i];
		pos[arr[i]] = i;
	}
	build(0, 1, 0, n / 2 - 1);
	build(1, 1, 0, n / 2 - 1);
	solve(0, n - 1);
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}


Measured memory_bytes: 7540
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
#include <random>
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)
#define rrep(i,n) for(int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for(int i=(a)-1;i>=b;--i)
#define range(i,a,b,c) for(int i=a;\
                    c>0?i<b:\
                    i>b;\
                    i+=c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define int long long
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif
 
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 1 << 28;
const ll INFL = (ll)1 << 58;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real& r) { return (r > eps) - (r < -eps); }
int sgn(const Real& a, const Real &b) { return sgn(a - b); }
 
//.....................
const int MAX = (int)2e5 + 5;
 
vector<string> split(const string &str, char sep) {
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}
 
template<class InputIterator>
int sum(InputIterator begin, InputIterator end) {
	return accumulate(begin, end, 0ll);
}

int N;
int a[MAX];
int b[MAX];

void solve() {
	cin >> N;
	rep(i, N) cin >> a[i] >> b[i];
	int cur = 0;
	rrep(i, N) {
		int v = (a[i] + cur) % b[i];
		if (v != 0) {
			cur += b[i] - v;
		}
		dump(cur);
	}
	cout << cur << endl;
}

signed main() {
	cout << fixed << setprecision(20);
	while(true) {
		char s[MAX];
		if (scanf("%s", s) == EOF) break;
		int n = strlen(s);
		for (int i = n - 1; i > -1; i--) {
			ungetc(s[i], stdin);
		}
		solve();
	}
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n;
    cin >> n;
    vstr s(n);
    vint t(n);
    rep(i, n) cin >> s[i] >> t[i];

    string x;
    cin >> x;

    int ans = 0;
    bool f = false;
    rep(i, n) {
        if (f) ans += t[i];
        if (s[i] == x) {
            f = true;
        } 
    }

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

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

int main () {

  int N, l, r;
  int sum = 0;
  cin >> N;
  
  for (int i =0; i<N; i++) {
      cin >> l >> r;
    sum += r-l+1;
  }
      cout << sum << endl;
}

      

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n, m = [int(x) for x in input().strip().split()]
d = sorted([tuple([int(x) for x in input().strip().split()]) for _ in range(m)], key=lambda x: x[1])
ans = 0
p = d[0][1]
# print(d)
for l, r in d:
    if l < p:
        continue
    ans += 1
    p = r
else:
    ans += 1
print(ans)

Measured memory_bytes: 19008
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int main() {
  int N, M;
  float A[110];
  float sum = 0;
  int c = 0;
  cin >> N >> M;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    sum += A[i];
  }
  sort(A, A+N, greater<int>());
  for(int i = 0; i < N; i++){
    if(A[i] >= (float)sum/(4*M)) c++;
  }
  if(c >= M) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3696
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;


int main() {
    string s; cin >> s;
    /* dangerous case
     rep(i, 100000) s += "S";
     rep(i, 100000) s += "T";
     */
    int ss = 0;
    int ans = 0;
    rep(i, s.size()) {
        if (s[i] == 'S') {
            ss++;
        } else {
            if (ss) {ans++; ss--;}
        }
    }
    cout << s.size() - 2 * ans << endl;
}




Measured memory_bytes: 640
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

quickSortVec l u arr
  | l >= u    = return ()
  | otherwise = do
      VM.unsafeSwap arr l ((u+l)`div`2)
      t <- VM.unsafeRead arr l
      let i = l
          j = u + 1
      nj <- loopVec t u i j arr
      VM.unsafeSwap arr l nj
      quickSortVec l (nj-1) arr
      quickSortVec (nj+1) u arr

loopVec !t !u !i !j arr = do
  ni <- doWhile i (+1)         (< t)
  nj <- doWhile j (subtract 1) (> t)
  if ni > nj
    then return nj
    else do VM.unsafeSwap arr ni nj
            loopVec t u ni nj arr
              where
                {-# INLINE doWhile #-}
                doWhile k op p
                  | nk > u    = return nk
                  | otherwise = do
                      x <- VM.unsafeRead arr nk
                      if p x then
                        doWhile nk op p
                        else
                        return nk
                        where
                          nk = op k

main = do
  n <- getInt
  as <- getIntVec n
  as' <- V.thaw as
  quickSortVec 0 (n-1) as'

  a0 <- VM.read as' 0

  let countFreq :: Int -> Int -> Int -> [Int] -> IO [Int]
      countFreq a i c cs
        | i == n = return $ if c > 0 then c:cs else cs
        | otherwise = do
            ai <- VM.read as' i
            if ai == a
              then countFreq a (i+1) (c+1) cs
              else countFreq ai (i+1) 1 (c:cs)

  fs <- countFreq a0 0 0 []

  let n2eat = sum $ map (\x -> x - 1) fs
      ans = n - (n2eat + (n2eat .&. 1))

  print ans

Measured memory_bytes: 6012
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  ll a[n];
  rep(i,n) R a[i];
  ll c[62][2];
  mem(c);
  ll ans=0;
  rep(i,n) {
    rep(j,62) {
      ll t=a[i]&(1LL<<j);
      if(t) t=1;
      ans+=(1LL<<j)%MAX*c[j][t^1];
      ans%=MAX;
      c[j][t]++;
    }
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s, t;
  cin >> s >> t;
  int count = 0;
  for(int i = 0; i<s.size(); i++){
    if(s.at(i) != t.at(i))
      count++;
  }
  cout << count << endl;
}

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

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int dp[n];
    dp[0] = 0;
    dp[1] = abs(a[1]-a[0]);
    for (int i = 2; i < n; i++) {
        dp[i] = min(dp[i-1] + abs(a[i]-a[i-1]), dp[i-2] + abs(a[i]-a[i-2]));
    }
    cout << dp[n-1] << endl;
}

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

using namespace std;

using int64 = long long;

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

  int a, b, c;
  cin >> a >> b >> c;
  int answer = b + min(c, a + b + 1);
  cout << answer << endl;
}

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

const int N = 100005;
vector <int> e[N];
bool inq[N];
int main () {
	int n, m; cin >> n >> m;
	while (m--) {
		int u, v, w; cin >> u >> v >> w;
		e[u].push_back (v);
		e[v].push_back (u);
	}
	set <int> S;
	for (int i = 1; i <= n; ++i) S.insert (i);
	int ans = 0;
	queue <int> q; 
	while (!S.empty()) {
		int u = *S.begin(); S.erase(u);
		q.push (u); inq[u] = true;
		++ans;
		while (!q.empty()) {
			int u = q.front(); q.pop();
			for (auto &v : e[u]) {
				if (S.count(v)) q.push(v);
				S.erase(v); inq[v] = true;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11128
// Kyoto University Programming Contest 2016
// A - バリケード / A Barricade

#include <cstdio>
using namespace std;


int N, A, B;
int ans;

int main() {

  int t;

  scanf("%d%d%d", &N, &A, &B);
  ans = N;
  for (int i = 0; i < N; i++) {
    scanf("%d", &t);
    if (A <= t && t < B) {
      ans--;
    }
  }

  printf("%d\n", ans);

  return 0;

}




Measured memory_bytes: 128
N,M,C = map(int,input().split())
B = list(int(i) for i in input().split())  
A = []
count = 0
for i in range(N):
  A = list(int(k) for k in input().split())  
  value = 0
  for j in range(M):
    value += A[j] * B[j]
  if value + C > 0:
    count += 1
print(count)


Measured memory_bytes: 3060
#include <cstdio>

using namespace std;

char s[109];

int main() {
  scanf("%s", s);
  for (int i = 0; s[i]; ++i) {
    if (i % 2 == 0 && s[i] == 'L') {
      puts("No");
      return 0;
    }
    if (i % 2 == 1 && s[i] == 'R') {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
}


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime> 
#include <cassert>
#include <queue>
#include <stack>
#include <bitset>
#include <iomanip>
#define y1 y11
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define skip continue
#define all(x) x.begin(), x.end()
#define NAME "code"

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef pair<pii, ll> piii;

const ld pi = 2 * acos(0.0);
const ll prime = 31;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll maxn = 3e5 + 11;
const ll dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const ll dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

ll n, a[maxn], b[maxn], f[maxn], ans;

int main(){

ios_base::sync_with_stdio(0);
cin.tie(NULL);

cin >> n;

for(int i = 1; i <= n; ++i){
	cin >> a[i];
}

for(int i = 1; i <= n; ++i){
	cin >> b[i];
}

for(int i = n; i >= 1; --i)
	f[i] = f[i + 1] + b[i];

for(ll i = 1, cnt = 0; i <= n; ++i){
	cnt += a[i];
	ans = max(ans, cnt + f[i]);
}

cout << ans;

return 0;
}

Measured memory_bytes: 4480
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

int main() {
	int N;
	cin >> N;
	
	int l, r;
	int ans = 0;
	REP(i, N) {
		cin >> l >> r;

		ans += (r - l + 1);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
if __name__=="__main__":
    # Problem A
    S_name = input()
    T_name = input()
    flag = "Yes"

    if len(T_name) == len(S_name) + 1:
        pass
    else:
        flag = "No"

    for idx, s_char in enumerate(S_name):
        if T_name[idx] == s_char:
            pass
        else:
            flag = "No"
    print(flag)


Measured memory_bytes: 8920
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    string s;
    cin >> s;
    ll n = (ll)s.size();
    ll ans = n;
    rep(i, 0, n-1) if (s[i+1] != s[i]) chmin(ans, max(i+1, n-i-1));
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
int main() {
    int i,j,H,W;
    while(1) {
        scanf("%d %d",&H,&W);
            if(H == 0 && W == 0){
                break;
            }
            for (i = 0; i < H; i++) {
                for (j = 0; j < W; j++) {
                    if ((i != 0 && i != H - 1) && (j > 0 && j < W - 1)) {
                        printf(".");
                    } else {
                        printf("#");
                    }
                }
                printf("\n");
            }
        printf("\n");
        }
    return 0;
}


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

int main(){
	VVI c(3, VI(3));
    rep(i,3)rep(j,3) cin >> c[i][j];

    bool flag = true;
    VI a(3), b(3);
    a[0] = 0;
    b[0] = c[0][0];
    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];
    b[1] = c[0][1];
    b[2] = c[0][2];

    rep(i,3)rep(j,3){
        if(c[i][j] != a[i] + b[j]) flag = false;
    }

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

bool solve(int N, map<int,int>& m){
  if(m.size() >= 3) return false;

  if(m.size() == 1){
    int x;
    FOR(it,m){
      x = it->first;
    }
    if((1<=x && x<=N/2) || x==N-1) return true;
    return false;
  }

  vector<pair<int,int>> v;
  FOR(it,m){
    v.push_back(make_pair(it->first, it->second));
  }
  if(abs(v[0].first - v[1].first) != 1) return false;
  if(!(1<=v[0].first && v[0].first<N)) return false;

  int mn = v[0].first;
  int mx = v[1].first;

  int a = max(1, mx - (N - mx));
  int b = N - (N - mn);

  if(a<=v[0].second && v[0].second<=b && v[0].second + v[1].second == N) return true;
  return false;
}


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

  map<int,int> m;
  rep(i, N){
    int a;
    cin >> a;
    m[a]++;
  }

  if(solve(N, m)) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


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

int main() {
	// your code goes here
	int n,m;
	cin>>n>>m;
	while(n!=0||m!=0){
		int a[100100];
		for(int i=0;i<n;i++){
			int aa;
			cin>>aa;
			a[i]=aa;
		}
		int sum=0;
		int max=0;
		for(int i=0;i<m;i++){
		 sum=sum+a[i];
			
		}
		//cout<<sum<<endl;
		max=sum;
		for(int i=0;i<n-m;i++){
		sum=sum-a[i]+a[m+i]	;
		//cout<<sum<<endl;
		if(sum>max) max=sum;
		//cout<<max<<endl;
		}
		cout<<max<<endl;
		cin>>n>>m;
	}
	return 0;
}

Measured memory_bytes: 1552
#include<bits/stdc++.h>
using namespace std;
inline void ChMax(int& a, int b){ a = max(a, b); }

const int dy[] = {-1, 0, 0, 1}, dx[] = {0, -1, 1, 0};
const int bitMask = (1 << 12) - 1;
int H, W, K;
char S[50][50];
int dp[50][50][1 << 12];
bool Visited[1 << 12];



int main()
{
  memset(dp, -1, sizeof(dp));
  for (int i = 0; i < (1 << 12); i++) {
    int nx = 0, ny = 0, bit = i;
    for(int j = 0; j < 6; j++, bit >>= 2) {
      nx -= dx[bit & 3], ny -= dy[bit & 3];
      if (nx == 0 && ny == 0) {
        Visited[i] = true;
        break;
      }
    }
  }

  cin >> H >> W >> K;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> S[i][j];
    }
  }

  dp[0][0][bitMask] = 0;

  for(int m = K; m >= 0; m--) {
    int notnext = m == 0;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        for (int k = 0; k < (1 << 12); k++) {
          if (dp[i][j][k] == -1) continue;
          int Get = 0;
          if (isdigit(S[i][j]) && !Visited[k]) Get += S[i][j] - '0';
          for (int l = notnext << 1; l < 4; l++) {
            int ny = i + dy[l], nx = j + dx[l];
            if (ny < 0 || nx < 0 || ny >= H || nx >= W) continue;
            if (S[ny][nx] == '#')                       continue;
            ChMax(dp[ny][nx][bitMask & (k << 2) | l], dp[i][j][k] + Get);
          }
        }
      }
    }
  }
  cout << *max_element(dp[H - 1][W - 1], dp[H - 1][W]) << endl;
}

Measured memory_bytes: 41172
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
int N;
cin>>N;
int w_tmp;
int W[N];
int cur=0;
int total=0;
for(int i=0;i<N;++i){
  cin>>w_tmp;
  cur+=w_tmp;
  total+=w_tmp;
  W[i]=cur;
}
int ans=100000;
for(int i=0;i<N;++i){
  w_tmp=total-2*W[i];
  if(w_tmp<0){
    w_tmp=(-w_tmp);
  }
  ans=min(ans,w_tmp);
}
cout<<ans<<"\n";
return 0;
}

Measured memory_bytes: 256
// Dmitry _kun_ Sayutin (2020)

#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;
using std::queue;

using std::pair;
using std::make_pair;

using std::tuple;
using std::make_tuple;
using std::get;

using std::min;
using std::abs;
using std::max;
using std::swap;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    // code here
    int a, b, c, d, k;
    cin >> a >> b >> c >> d >> k;

    cout << (c - a) * 60 + (d - b) - k << "\n";

    return 0;
}


Measured memory_bytes: 3656
def rotation(str)
    (str + str)[1...str.size + 1]
end

# puts rotation("abc")

base_str = gets.chomp
target_str = gets.chomp

current_str = base_str
result = "No"
base_str.size.times do
    current_str = rotation(current_str)
    if current_str === target_str
        result = "Yes"
        break
    end
end

puts result


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int a,b,c; 
int main()
{
	cin>>a>>b>>c;
	if(b*c>=a)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3644
#include<iostream>
using namespace std;
int main(){
    string s1,s2;
    char c;
    int i,count;
    count = 0;
    cin >> s1 >> s2;
    for(i=0;i<3;i++){
        if(s1[i] == s2[2-i]) count++;
    }
    cout << (count==3?"YES":"NO") << endl;
}

Measured memory_bytes: 256
from collections import defaultdict,deque

graph = defaultdict(list)
N, *AB = map(int, open(0).read().split())
for a, b in zip(*[iter(AB)] * 2):
    graph[a].append(b)


stack = deque([1])
C = [0] * (N + 1)
while stack:
    v = stack.popleft()
    c = 0
    for w in graph[v]:
        c += 1 + (c + 1 == C[v])
        C[w] = c
        stack.append(w)
        
print(max(C))
print("\n".join(str(C[b]) for b in AB[1::2]))

Measured memory_bytes: 34212
#include <iostream>
#include <iomanip>
#include <cstdio>
using namespace std;

void call(int n)
{
	for(int i = 1;i <= n;i++){
		int x = i;
		if(x % 3 == 0){
			 cout << " " << x;
			}else{
				 while(1){
				 	if(x % 10 == 3) {
				 		cout << " " << i; break;
				 	}else if(x >= 10) x /= 10;
				 	 else break;
				 }
				}
	}
}
				
			
			
	
	
	
int main()
{
	int n;
	cin >> n;
	call(n);
	cout << endl;
	return 0;
}

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

typedef vector <long long> vi;
typedef vector <vi> vvi;
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define ll long long
#define MAX 3005

long double p[MAX], dp[MAX][MAX][2];
long double coin(ll n, ll r, ll t)
{
    if (r < 0)
        return 0;
    if (n == 0)
    {
        if (r != 0)
            return 1;
        else
            return p[n];
    }

    if (dp[n][r][t] == -1)
            dp[n][r][t] = (coin(n - 1, r, 1) * (p[n]) + coin(n - 1, r - 1, 0) * (1 - p[n]));
    return dp[n][r][t];
}

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

    for (int i = 0; i < MAX; i++)
        for (int j = 0; j < MAX; j++)
            for (int k = 0; k < 2; k++)
                dp[i][j][k] = -1;

    for (int i = 0; i < n; i++)
        cin >> p[i];

    ll r = n / 2;
    if (n % 2 == 0)
        r--;
    
    long double ans = coin(n - 1, r, 1);
    printf("%.10Lf\n", ans); 
}

Measured memory_bytes: 282624
#include <bits/stdc++.h>  // ver1.9.5
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

bool prime(int n)  //  素数判定
{if(n<2)return false;else if(n==2)return true;else if(n%2==0)return false;
double s=sqrt(n);for(int i=3;i<=s;i+=2){if(n%i==0){return false;}}return true;}

signed main() {
  cout << fixed << setprecision(8);
  int n,p;
  cin >> n >>p;
  if(n==1) {cout<< p <<endl;return 0;}
  
  int ans = 1;
  int ct = 0,now;
  rep(i,1,1000000){
    if(!prime(i)) continue;
    ct = 0;
    now = p;
    while(now%i==0){
      now /= i;
      ct++;
    }
    rep(j,0,ct/n){
      ans *= i;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# モジュールのインポート
import collections

# 標準入力の取得
N = int(input())
A = list(map(int, input().split()))

# 求解処理
left = {}
result = 0
for j in range(N):
    r = -A[j] + j
    result += left.get(r, 0)
    l = A[j] + j
    left[l] = left.get(l, 0) + 1

# 結果出力
print(result)


Measured memory_bytes: 40448
# -*- coding:utf-8 -*-

def solve():
    """ TLE """
    X, Y, Z, K = list(map(int, input().split(" ")))
    A = list(map(int, input().split(" ")))
    B = list(map(int, input().split(" ")))
    C = list(map(int, input().split(" ")))
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)

    ans = []

    for x in range(X):
        for y in range(Y):
            ab = A[x] + B[y]
            for z in range(Z):
                if (x+1)*(y+1)*(z+1) > K:
                    break

                ans.append(ab + C[z])

    ans.sort(reverse=True)              
    
    for i in range(0, K):
        print(ans[i])


if __name__ == "__main__":
    solve()


Measured memory_bytes: 8720
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#define MAXN 100000


long long a[MAXN + 1];
long long rez[MAXN + 3];
int main() {
    long long n;
    long long ans = 0;
    std::cin >> n;
    for (int i = 1; i <= n; i++) {
        std::cin >> a[i];
    }
    std::sort(a + 1, a + n + 1);
    long long p;
    bool ok = 0;
    if (n % 2 != 0) {
        ok = 1;
        p = a[n / 2 + 1];
        for (int i = n / 2 + 1; i < n; i++)
            a[i] = a[i + 1];
        n--;
    }
    int ind1 = n / 2;
    int ind2 = n / 2;
    bool l = 0;
    rez[n / 2] = a[1];
    for (int i = 2; i <= n / 2; i++) {
        if (l == 0) {
            ind1 = ind1 + 2;
            rez[ind1] = a[i];
        }
        else {
            ind2 = ind2 - 2;
            rez[ind2] = a[i];
        }
        l = 1 - l;
    }
    rez [n / 2 + 1] = a[n];
    ind1 = n / 2 + 1;
    ind2 = n / 2 + 1;
    l = 0;
    for (int i = n - 1; i >= n / 2 + 1; i--) {
        if (l == 0) {
            ind1 = ind1 - 2;
            rez[ind1] = a[i];
        }
        else {
            ind2 = ind2 + 2;
            rez[ind2] = a[i];
        }
        l = 1 - l;
    }
    if (ok == 1) {
        if(abs(p - rez[1]) < abs(p - rez[n])) {
            rez[n + 1] = p;
            for (int i = 1; i <= n; i++) {
                ans += abs(rez[i] - rez[i + 1]);
            }
        }
        else {
            rez[0] = p;
            for (int i = 0; i <= n - 1; i++) {
                ans += abs(rez[i] - rez[i + 1]);
            }
        }
    }
    else {
        for (int i = 1; i <= n - 1; i++) {
            ans += abs(rez[i] - rez[i + 1]);
        }
    }
    std::cout << ans;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i=0; i<n; ++i)

int main(){
    double pi = 3.1415;
    double r;
    std::cin >> r;
    
    double ans;
    ans = 2 * pi * r;

    std::cout << ans << std::endl;
}

Measured memory_bytes: 3784
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#define MAX 30
using namespace std;

int main(void) {
    int n, m;
    int k, ai;
    int  a[MAX][MAX];
    int likes[MAX] = {};
    int ans = 0;
    scanf("%d %d", &n, &m);
    for(int i=0; i<n; i++ ) {
        scanf("%d", &k);   
        for(int j=0; j<k; j++) {

            scanf("%d", &ai);
            likes[ai-1] ++;
        }
    }



    for(int i=0; i<m; i++) {
        if (likes[i] == n) ans ++;
    }

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


Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto s = readln.chomp;
  (s.count('+').to!int - s.count('-').to!int).writeln;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        n: usize,
        v: [i32; n],
    }

    let (ans, t) = selection_sort(v);

    for i in 0..n {
        print!("{}", ans[i]);
        if i != n-1 {
            print!(" ");
        }
    }
    println!("");
    println!("{}", t);
}

fn selection_sort(mut v: Vec<i32>) -> (Vec<i32>, u32) {
    let mut tmp;
    let mut t:u32 = 0;

    for i in 0..v.len()-1 {
        let mut mini = i;
        for j in i..v.len() {
            if v[j] < v[mini] {
                mini = j
            }
        }
        if i != mini {
            tmp = v[mini];
            v[mini] = v[i];
            v[i] = tmp;
            t += 1;
        }
    }
    (v, t)
}



Measured memory_bytes: 5028
#include <iostream>

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

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    cout << min(c, a + b + 1) + b << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String args[]) throws Exception{
		Scanner cin= new Scanner(System.in);
		int N= cin.nextInt();
		
		int min= (int)Math.pow(10d,9d);
		int MaxProfit= -min;
		int Rate;
		
		int i;
		for(i=0;i<N;i++){
			Rate= cin.nextInt();
			if(i==0){
				min= Rate;
			}
			else{
				if( Rate-min > MaxProfit ){
					MaxProfit= Rate-min;
				}
				if( Rate<min ){
					min= Rate;
				}
			}
		}
		System.out.println(MaxProfit);
	}
}

Measured memory_bytes: 94304
fun main (args : Array<String>) {
	val (h, n) = readLine()!!.split(" ")
	val l = readLine()!!.split(" ")
	var list : MutableList<Int> = mutableListOf()
	var result : Int = 0
	var flag : Boolean = false
	for (i in l) {
		list.add(i.toInt())
	}
	for (i in 0..list.size - 1) {
		result += list[i]
		if (result >= h.toInt()) {
			flag = true
			break
		}
	}
	if (flag) {
		return println("Yes")
	} else {
		return println("No")
	}
}

Measured memory_bytes: 49480
import sys
sys.setrecursionlimit(10000)
def f(x,y):
    global w,h,c
    if x<0 or x>=h or y<0 or y>=w or c[x][y]==0:
        return
    c[x][y]=0
    for a in [-1,0,1]:
        for b in [-1,0,1]:
            if a==0 and b==0:
                continue
            f(x+a,y+b)
while True:
    w,h = map(int,input().split())
    if w+h==0:
        break
    c = [list(map(int,input().split())) for _ in range(h)]
    ans = 0
    for x in range(h):
        for y in range(w):
            if c[x][y]==1:
                ans+=1
                f(x,y)
    print(ans)


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

#define MAX_N 100

using namespace std;

int n;
int t[109];
int v[109];

long double rez;

struct elem
{
    int st, dr, vx;
};

int k;
elem r[MAX_N + 2 + 1];

long double getV(long double t)
{
    long double rez = 999.9D;
    int i;
    long double ld = 1.0D;
    for(i = 1; i <= k; i ++)
    {
        if(r[i].st <= t && t <= r[i].dr)
            rez = min(rez, r[i].vx * ld);

        else
            if(t < r[i].st)
                rez = min(rez, ld * r[i].vx + ld * (r[i].st - t));

        else
            if(t > r[i].dr)
                rez = min(rez, ld * r[i].vx + ld * (t - r[i].dr));
    }

    return rez;
}

int main()
{
    int s = 0;
    cin >> n;
    for(int i = 1; i <= n; i ++)
    {
        cin >> t[i];
        s += t[i];
    }

    for(int i = 1; i <= n; i ++)
        cin >> v[i];

    r[++ k] = {0, 0, 0};
    r[++ k] = {s, s, 0};

    int j;
    int tcr = 0;
    for(int i = 1; i <= n; i ++)
    {
        r[++ k] = {tcr, tcr + t[i], v[i]};

        tcr += t[i];
    }

    long double i;
    long double epsilon = 0.0001D;
    for(i = 0; i < s; i += 0.5D)
    {
        long double vi = getV(i);
        long double v5 = getV(i + 0.5);

        if(fabsl(vi - v5) <= epsilon)
            rez += vi * 0.5D;

        else
        {
            long double a = (v5 - vi) / 0.5D;

            rez += 1.0D / (2.0D * a) * (v5 * v5 - vi * vi);
        }

      //  cout << fixed << setprecision(3) << i << " " << vi << " " << rez << "\n";
    }
    //cout << "\n";

    cout << fixed << setprecision(10) << rez << "\n";

    return 0;
}


Measured memory_bytes: 256
NMAX = 100005
n,k = map(int,input().split())

array = [0] * NMAX

for i in range(n):
    a,b = map(int,input().split())
    array[a] += b

for i in range(1,NMAX,1):
    if k <= array[i]:
        print(i)
        exit()
    k -= array[i]

Measured memory_bytes: 11636
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define RREP(i, a, n) for(int i=n-1; i>=a; i--)
#define ll long long

int main()
{
	int N;
	vector<ll> a;
	ll sum = 0;
	cin >> N;
	REP(i, 0, N) {
		ll aa;
		cin >> aa;
		a.push_back(aa);

		sum += aa;
	}

	ll ans = 1000000000000000;
	ll x = 0, y;
	REP(i, 0, a.size() - 1) {
		x += a[i];
		y = sum - x;
		ans = min(ans, llabs(x - y));
	}

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

Measured memory_bytes: 2420
#include <iostream>
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
using namespace std;

int main(void){
	int n;
	int a;
	int m1,m2;
	while(cin>>n,n){
		m1=-1;
		m2=9999;
		while(n--){
			int sum=0;
			for(int i=0;i<5;i++)cin>>a,sum+=a;
			m1=MAX(m1,sum);
			m2=MIN(m2,sum);
		}
		cout<<m1<<" "<<m2<<endl;
	}
	return 0;
}

Measured memory_bytes: 3084