akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

std::string f(long n, long keta, long b)
{
  std::string result;
  for (b /= 26; b >= 26; b /= 26) {
    auto x = n / b;
    result.push_back('a' + x);
    n %= b;
  }
  result.push_back('a' + n % 26);
  return result;
}

std::string solve(long n)
{
  long a = 26;
  long b = 26;
  for (long i = 0;; ++i) {
    if (n <= a) {
      return f(n - (a + 1 - b), i + 1, b);
    }
    b *= 26;
    a += b;
  }
}

int main()
{
  long n;
  std::cin >> n;

  std::cout << std::setprecision(20);
  std::cout << solve(n) << std::endl;
}


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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <queue>
#include <stack>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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 gcd(int a, int b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));}

int lcm(int a, int b)
{return a * b / gcd(a, b);}

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

int main(void){
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> to[n];
  REP(i, m){
    int a, b;
    cin >> a >> b;
    a--;b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  vector<int> depth(n, -1);
  depth[0] = 0;
  vector<int> next(n, -1);
  queue<int> que;
  que.push(0);
  while (!que.empty()){
    int from = que.front();
    que.pop();
    for (int v : to[from]){
      if (depth[v] == -1){
        depth[v] = depth[from] + 1;
        next[v] = from;
        que.push(v);
      }
    }
  }
  cout << "Yes" << endl;
  FOR(i, 1, n) cout << next[i] + 1 << endl;
  return 0;
}



Measured memory_bytes: 10656
from math import sqrt

def is_prime(n):
  max_factor = int(sqrt(n))
  for i in range(2, max_factor+1):
    if n % i == 0:
      return False
  return True

X=int(input())

for x in range(X, 10*X+1):
  if is_prime(x):
    print(x)
    break

Measured memory_bytes: 9176
#include <iostream>
#include <iomanip>
#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() {
  ll N, A, B; cin >> N >> A >> B;
  ll X[N]; rep(i, N) cin >> X[i];

  ll result = 0;
  for(int i=1; i<N; i++) {
    result += min((X[i]-X[i-1])*A, B);
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n, m;
	cin >> n >> m;
	vector<int> done(n);
	vector<int> pen(n);
	for (int i = 0; i < m; ++i) {
		int num;
		string s;
		cin >> num >> s;
		--num;
		if (!done[num]) {
			if (s == "AC") {
				done[num] = 1;
			} else {
				++pen[num];
			}
		}
	}
	int answer = 0, penalty = 0;
	for (int i = 0; i < n; ++i) {
		if (done[i]) {
			++answer;
			penalty += pen[i];
		}
	}
	cout << answer << ' ' << penalty << '\n';
 	return 0;
}


Measured memory_bytes: 1024
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <iostream>
#include <string>

#include <algorithm>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define PB push_back
#define MP make_pair

#define FOR(i, b, e) for(int i=(b);i<(e);i++)
#define REP(i, n) FOR(i,0,n)

#define ALL(v) (v).begin(),(v).end()

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VPII;

const int MOD = 1000000007;
const int INF = 1e9;

const double EPS = 1e-9;
const double PI = acos(-1.0);

const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

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

int main() {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<string.h>
#include <iostream>
using namespace std;

int main(){

	int a,b,c;

	cin >> a;
	cin >> b;
	cin >> c;
	
	if(a<=c && b>=c){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,i,j,divisor=0,temp;
	scanf("%d",&n);
	if(n<105)
	printf("0\n");
	else
	{
		for(i=105;i<=n;i+=2)
		{
			temp=0;
			for(j=1;j<=i;j++)
			{
				if(i%j==0)
				temp++;
				
			}
			if(temp==8)
			divisor+=1;
			
		}
		printf("%d\n",divisor);
		
	}
	
	
	return 0;
	
}

Measured memory_bytes: 128
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
#include <map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>
 
std::string s;
 
int main(void){
    std::cin >> s;

    if ((s.size() % 2 == 0 && s[0] == s[s.size()-1]) ||
        (s.size() % 2 == 1 && s[0] != s[s.size()-1])
    ) {
        std::cout << "First" << std::endl;
    } else {
        std::cout << "Second" << std::endl;
    }
    
    return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


// dpテーブル
double dp[310][310][310];

// 入力用, solve内でも使うので、グローバル変数にしている
int n;

double solve(int i, int j, int k) {
    if(dp[i][j][k] != -1) return dp[i][j][k];
    if (i == 0 && j == 0 && k == 0) return 0.0; // 最後まで到達した時

    double ret = 0.0;
    if(i > 0) ret += solve(i-1,j,k) * i;
    if(j > 0) ret += solve(i+1,j-1,k) * j;
    if(k > 0) ret += solve(i,j+1,k-1) * k;
    ret += n;
    ret *= 1.0 / (i + j + k);
    dp[i][j][k] = ret;

    return ret;
}

int main() {
    cin >> n;
    int one = 0, two = 0, three = 0;
    rep(i, n) {
        int tmp; cin >> tmp;
        if(tmp == 1) one++;
        else if(tmp == 2) two++;
        else three++;
    }

    // dpテーブルを初期化
    rep(i, 310) rep(j, 310) rep(k, 310) {
        dp[i][j][k] = -1;
    }


    double ans = solve(one, two, three);

    cout << std::setprecision(10) << ans << endl;

    return 0;
}


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

#define REP(i, x, n) for(ll i=x; i<(ll)n; ++i)
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()

int main(){
    int N, X;
    cin >> N >> X;
    vll l(N);
    rep(i, N){
        cin >> l[i];
    }
    ll count = 1;
    ll current = 0;
    rep(i, N){
        current += l[i];
        if(current>X) break;
        ++count;
    }
    cout << count << endl;
}


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

int main ()
{
    int N;
    long M, Q;
  	cin >> N >> M >> Q;
    typedef pair<int,int> pair;
    vector<pair> LR;
    vector<pair> pq;
    int AN[509][509];
    long SUM[509][509];
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N;j++){
            AN[i][j]=0;//syokika
        }
    }
    int tmp,tmp2;
    for(long i=0;i<M;i++){
        cin >> tmp >> tmp2;
        AN[tmp][tmp2]++;
    }
    
    //2jigenruisekiwa
    
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) AN[i][j] += AN[i][j - 1]; 
        
    }
	for (int i = 1; i <= N; i++) {
	    for (int j = 1; j <= N; j++) AN[i][j] += AN[i - 1][j];
    }
  
 	int L,R;
    for(long i=0;i<Q;i++){
        cin >> L >> R;
        cout << AN[R][R] + AN[L - 1][L - 1] - AN[L - 1][R] - AN[R][L - 1] << endl;
    }
    return 0;
}








Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int N, K, X[101010];
vector<int> mi, pr;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> K;
    rep(i, 0, N) cin >> X[i];

    mi.push_back(0);
    pr.push_back(0);
    rep(i, 0, N) {
        if (X[i] <= 0) mi.push_back(-X[i]);
        else pr.push_back(X[i]);
    }
    sort(all(mi));
    sort(all(pr));

    int n = mi.size();
    int m = pr.size();
    
    int ans = inf * 2;
    rep(i, 0, n) {
        int j = K - i;
        if (0 <= j and j < m) chmin(ans, mi[i] * 2 + pr[j]);
    }
    rep(i, 0, m) {
        int j = K - i;
        if (0 <= j and j < n) chmin(ans, pr[i] * 2 + mi[j]);
    }
    cout << ans << endl;
}

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

#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define F first
#define S second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using pii = pair <int, int>;
using pll = pair <ll, ll>;
using ld = long double;
// mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int mod = 1e9 + 7;
// const int mod = 998244353;
const ll inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-7;

const int N = 2e5 + 66;

int cnt[N];

int binpow (ll a, int b, int mod) {
	ll res = 1;
	for (; b ; b >>= 1, (a *= a) %= mod) {
		if (b & 1) {
			(res *= a) %= mod;
		}
	}
	return res;
}

ll p[N];

ll SSS (int n, int mod, string s) {
	ll ans = 0;
	for (int i = 0 ; i < n ; ++ i) {
		int dig = s[i] - '0';
		if (dig % mod == 0) {
			ans += i + 1;
		}
	}
	return ans;
}

void solve () {
	int n, mod; string s;
	cin >> n >> mod >> s;
	if (mod == 2 || mod == 5) {
		cout << SSS (n, mod, s);
		return;
	}
	ll ans = 0;
	cnt[0]++;
	for (int i = 1 ; i <= n ; ++ i) {
		int dig = s[i - 1] - '0';
		p[i] = (p[i - 1] * 10 + dig) % mod;
		int cur = p[i] * binpow (10, n - i + 1, mod) % mod;
		ans += cnt[cur];
		cnt[cur]++;
	}
	cout << ans;
}

int main () {
	ios;
	// double start_time = clock();
	// cout << fixed << setprecision (10);
	int tt = 1;
	// cin >> tt;
	while (tt--) {
		solve();
		cout << "\n";
	}
	// cerr << (clock() - start_time) / CLOCKS_PER_SEC;
}


Measured memory_bytes: 2324
#include <stdio.h> 
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int main () {
    int A,B,C;
    cin >> A >> B >> C ;
    string ans="No";
    if (A==B && A!=C) ans="Yes";
    if (A==C && A!=B) ans="Yes";
    if (B==C && B!=A) ans ="Yes";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool is_digit(char ch) {
  return '0' <= ch && ch <= '9';
}

bool check(int a, int b, string s)
{
  for (int i = 0; i < a; i++) {
    if (!is_digit(s[i])) {
      return false;
    }
  }
  if (s[a] != '-') {
    return false;
  }
  for (int i = a + 1; i < a + b + 1; i++) {
    if (!is_digit(s[i])) {
      return false;
    }
  }
  return true;
}

int main()
{
  int a, b;
  cin >> a >> b;
  string s;
  cin >> s;
  
  cout << (check(a, b, s) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int v[] = new int[n];
		for(int i = 0; i < n; ++i)
		v[i] = sc.nextInt();
		sc.close();
		Arrays.sort(v);
		long w = 1;
		double ans = 0.0;
		for(int i = n - 1; i > 0; --i){
			w <<= 1;
			int tmp = v[i];
			ans += (double)tmp / (double)w;
		}
		ans += (double)v[0] / (double)w;
		System.out.println(ans);
	}
}


Measured memory_bytes: 22868
#include <iostream>

using namespace std;

int main(){
    int W, H, x, y, r;
    cin >> W;
    cin >> H;
    cin >> x;
    cin >> y;
    cin >> r;

    if((0 <= x - r) and (0 <= y - r) and (x + r <= W) and (y + r <= H)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3120
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  int n;
  while(cin >> str){
    if(str=="-") break;
    cin >> n;
    for(int i=0,h;i<n;i++){
      cin >> h;
      string cat = str.substr(0,h);
      str.erase(0,h);
      str+=cat;
    }
    cout << str << endl;
  }
}


Measured memory_bytes: 3220
n, m, x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]
ans = float("inf")
for i in range(2**n):
    flag = True
    achive = [0]*m
    cost = 0
    for j in range(n):
        if i >> j & 1 == 1:
            cost += ca[j][0]
            for k in range(m):
                achive[k] += ca[j][k+1]

    for item in achive:
        if item < x:
            flag = False
    if flag:
        ans = min(ans, cost)
if ans == float("inf"):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 68424
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int N, A, B;
  cin >> N >> A >> B;
  string S;
  cin >> S;
  int domesticranking = 0, oversearanking = 0;
  REP(i, N) {
    char c = S[i];
    if (c == 'a') {
      if (domesticranking+oversearanking < A + B) {
        puts("Yes");
        domesticranking++;
      } else {
        puts("No");
      }
      
    } else if (c == 'b') {
      if (domesticranking+oversearanking < A + B && oversearanking < B) {
        puts("Yes");
        oversearanking++;
      } else {
        puts("No");
      }
     
    } else {
      puts("No");
    }
  }
}

Measured memory_bytes: 896
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

//const double PI = 3.1415926535897932384626433832795;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int ans = b / a >= c ? c : b / a;
  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 256
/* Coached by rainboy */
#include <stdio.h>

long long max(long long a, long long b) {
	return a > b ? a : b;
}

int main() {
	int n;
	long long a, b;

	scanf("%d", &n);
	a = b = 1;
	while (n--) {
		int c, d;
		long long x;

		scanf("%d%d", &c, &d);
		x = max((a + (c - 1)) / c, (b + (d - 1)) / d);
		a = c * x;
		b = d * x;
	}
	printf("%lld\n", a + b);
	return 0;
}


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

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define int long long

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>

#define vi vector<int>

#define vpi vector< pi >

#define mi map<int,int>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int md = 1e9+7;
const int MX = 2e5+5;
const int INF = 1e18; 


int power_md(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res=(res%md*a%md)%md;
  a=(a%md*a%md)%md;
  n/=2;
}
res%=md;
return res;
}

int power(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a=a*a;
  n/=2;
}
return res;
}

int abst(int a)
{
 return ((a<0)?(-1*a):(a));
}

class cmp_set{
public:
	bool operator() (int a, int b){
		return a > b;
	}
};

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

int32_t main()
{
    int n,m;
    cin>>n>>m;
    map< int,int > mp;
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        int k;
        cin>>k;
        for(int j=0;j<k;j++)
        {
            int x;
            cin>>x;
            mp[x]++;
            if(mp[x]==n)
             cnt++;
        }
    }
    cout<<cnt<<"\n";
    return 0;
}

Measured memory_bytes: 256
S = input()

setList = []
RFlag = False
Lcount = 0
Rcount = 0

for i in range(len(S)) :
    if RFlag :
        if S[i] == 'L' :
            setList.append([i, Rcount])
            Rcount = 0
            index = i
            RFlag = False
            Lcount += 1
            if i == len(S) - 1 :
                setList[-1].append(Lcount)
        else :
            Rcount += 1
    else :
        if S[i] == 'L' :
            Lcount += 1
            if i == len(S) - 1 :
                setList[-1].append(Lcount)
        else :
            Rcount += 1
            if len(setList) != 0 :
                setList[-1].append(Lcount)
                Lcount = 0
            RFlag = True


#print(setList)

ansList = [0] * len(S)

for i in range(len(setList)) :
    Lnum1 = setList[i][1] // 2
    Rnum1 = setList[i][1] - Lnum1

    Rnum2 = setList[i][2] // 2
    Lnum2 = setList[i][2] - Rnum2

    ansList[setList[i][0] - 1] = Rnum1 + Rnum2
    ansList[setList[i][0]] = Lnum1 + Lnum2

for i in range(len(S)) :
    print(ansList[i], end=' ')


Measured memory_bytes: 13120
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>

using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n) 

class Team{
  public:
  string name;
  int win;
  int lose;
  bool operator <(const Team& o) const
  {
    if(win > o.win) return true;
    if(win < o.win) return false;
    if(lose < o.lose) return true;
    return false;
  }
};

int main(void){  
  int n;
  while(cin >> n,n){
    vector<Team> t(n);
    REP(i,n){
      t[i].win = 0;
      t[i].lose = 0;
    }
    int bf;
    REP(i,n){
      cin >> t[i].name;
      REP(j,n-1){
        cin >> bf;
        if(bf==0) t[i].win++;
        if(bf==1) t[i].lose++;
      }
    }
    sort(t.begin(),t.end());
    REP(i,n)
      cout << t[i].name << endl;
  }
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long count = 0;
		if(n%2 == 0) {
			long five = 5;
			while(five <= n) {
				count += (n/five)/2;
				five = five * 5;
			}
		}else if(n%2 == 1){
			count = 0;
		}
		System.out.println(count);
		sc.close();
	}
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n);
    for (auto &x: a) cin >> x;
    vector<int> ans(n);
    int inf = (int) 1e9 + 20;
    vector<int> lis(n+1, inf); lis[0] = 0;
    vector<array<int, 2>> pr(n);
    vector<vector<int>> e(n);
    for (int i = 1; i < n; i++) {
        int u, v; cin >> u >> v; u--, v--;
        e[u].emplace_back(v);
        e[v].emplace_back(u);
    }
    int len = 0;
    auto f = [&](auto f, int curr, int prev) -> void {
        int x = a[curr];
        int i = lower_bound(lis.begin(), lis.end(), x) - lis.begin();
        pr[curr] = {i, lis[i]};
        lis[i] = x; 
        if (len < i) len = i;
        ans[curr] = len;
        for (auto &to: e[curr]) {
            if (prev == to) continue;
            f(f, to, curr);
        }
        lis[pr[curr][0]] = pr[curr][1];
        if (pr[curr][1] == inf) len--;
    };
    f(f, 0, -1);
    for (int i = 0; i < n; i++) cout << ans[i] << "\n";
    return 0;
}

Measured memory_bytes: 40900
# include "cstdio"
# include "algorithm"
# include "iostream" 

using namespace std;

const int maxm=5000+10;

string 
	s, 
	ans[maxm<<3];

int
	tot, 
	k, 
	l;

int main(){
	cin>>s;l=s.size(); 
	scanf("%d",&k); 
	register int i,j;
	for(i=0;i<l;i++){
		ans[++tot]=s[i];
		int now=min(k,l-i);
		for(int j=1;j<now;j++,tot++) ans[tot+1]=ans[tot]+s[i+j];
	}
	sort(ans+1,ans+tot+1);
	unique(ans+1,ans+tot+1);
	cout<<ans[k];
	return 0; 
} 

Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
 
int n,len;
char t[300];
 
int checkA(){
  if(t[len-1]!='~')return 0;
  int i=2,j=len-2; 
  while(i<j){
    if(t[i]!='=')return 0;
    if(t[j]!='=')return 0;
    i++;
    j--;
  }
  if(t[i]=='#')return 1;
  else return 0;
}
 
int checkB(){
  if(t[len-2]!='~')return 0;
  if(t[len-1]!='~')return 0;
  int i;
  for(i=2;i<len-2;i+=2){
    if(t[i]!='Q')return 0;
    if(t[i+1]!='=')return 0;
  }
  return 2;
}
 
int solve(){
  if(len<6 || len%2==1)return 0;
  if(t[0]=='>'&&t[1]=='\'')return checkA();
  if(t[0]=='>'&&t[1]=='^')return checkB();
  return 0;
}
 
int main(){
  scanf("%d",&n);
  while(n>0){
    n--;
    scanf("%s",t);
    len=strlen(t);
    int ans=solve();
    if(ans==0)printf("NA\n");
    if(ans==1)printf("A\n");
    if(ans==2)printf("B\n");
  }
  return 0;
}

Measured memory_bytes: 1012
import java.util.Scanner;

public class Main{
    public static void main(String[]arg){
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H==0 && W==0) break;
            else{
                for(int i=0;i<H;i++){
                    for(int j=0;j<W;j++){
                        if(i==0 || i==H-1 || j==0 || j==W-1){
                            System.out.printf("#");
                        }else{
                            System.out.printf(".");
                        }
                    }
                    System.out.printf("\n");
                }
                System.out.printf("\n");
            }
        }
    }
}


Measured memory_bytes: 60256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
char s[1005];
int main(){
	scanf("%s",s);
	int len=strlen(s);
	printf("%s",s);
	if(s[len-1]=='s') printf("es\n");
	else printf("s\n");
	return 0;
}

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

int a, b, k;
bool barret[205];
int main(void) {
	scanf("%d%d%d", &a, &b, &k);
	if (b - a + 1 < 2 * k) {
		for(int i = a; i <= b; ++i) printf("%d\n", i);
	}
	else {
		for(int i = 1; i <= k; ++i) {
			printf("%d\n", a+i-1);
		}
		for(int i = k; i >= 1; --i) {
			printf("%d\n", b-i+1);
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;


public class Main{
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int[] k = new int[n];
		for(int i = 0; i < n; i++)
			k[i] = sc.nextInt();
		
		boolean act = true;
		int cnt = 1, ans = 0;
		while(act) {
			act = false;
			boolean before = true;
			for(int i = 0; i < k.length; i++) {
				if (k[i] < cnt)
					before = true;
				else if (before)  {
					ans++;
					act = true;
					before = false;
				} 
			}
			cnt++;
		}
		out.println(ans);
		
		out.close();
	}

	static class FastScanner {
	    private final InputStream in = System.in;
	    private final byte[] buffer = new byte[1024];
	    private int ptr = 0;
	    private int buflen = 0;
	    private boolean hasNextByte() {
	        if (ptr < buflen) {
	            return true;
	        }else{
	            ptr = 0;
	            try {
	                buflen = in.read(buffer);
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            if (buflen <= 0) {
	                return false;
	            }
	        }
	        return true;
	    }
	    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
	    public String next() {
	        if (!hasNext()) throw new NoSuchElementException();
	        StringBuilder sb = new StringBuilder();
	        int b = readByte();
	        while(isPrintableChar(b)) {
	            sb.appendCodePoint(b);
	            b = readByte();
	        }
	        return sb.toString();
	    }
	    public long nextLong() {
	        if (!hasNext()) throw new NoSuchElementException();
	        long n = 0;
	        boolean minus = false;
	        int b = readByte();
	        if (b == '-') {
	            minus = true;
	            b = readByte();
	        }
	        if (b < '0' || '9' < b) {
	            throw new NumberFormatException();
	        }
	        while(true){
	            if ('0' <= b && b <= '9') {
	                n *= 10;
	                n += b - '0';
	            }else if(b == -1 || !isPrintableChar(b)){
	                return minus ? -n : n;
	            }else{
	                throw new NumberFormatException();
	            }
	            b = readByte();
	        }
	    }
	    public int nextInt() {
	        long nl = nextLong();
	        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
	        return (int) nl;
	    }
	    public double nextDouble() { return Double.parseDouble(next());}
	}
}





Measured memory_bytes: 21332
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>

typedef long long LL;
using namespace std;

map <LL, int> cnt;
int n, m;
int main() 
{
	scanf("%d%d", &n, &m);
	LL res = 0, ans = 0; cnt[0] = 1;
	for (int i = 1; i <= n; i++) {
		int x; scanf("%d", &x);
		ans = (ans + x) % m;
		res += cnt[ans];
		cnt[ans]++;
	}
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 4224
#include<iostream>
using namespace std;
bool judge(int k)
{
	for(int i=0;i<30;i++)
	{
		for(int j=0;j<20;j++)
		{
			if(i*4+j*7==k)
			{
				return 1;
			}
		}
	}
	return 0;
}
int main()
{
	int k;
	int f=1;
	cin>>k;
	if(judge(k))
	printf("Yes\n");
	else
	printf("No\n");
}

Measured memory_bytes: 256
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_C&lang=jp
# Breadth First Search: python3
#  2018.12.06 yonezawa

import sys
input = sys.stdin.readline
from collections import deque

class node:
    def __init__(self):
        n = self.n = int(input())
        self.cnt = 0
        self.discover = [-1] * n
        self.pos = [1] * n
        self.nmap = [[0 for i in range(n)] for i in range(n)]
    
        for _ in range(n):
            l = list(map(int,input().split()))
            a = l[0] - 1
            for i in l[2:]:
                self.nmap[a][i-1] = 1
    def printMap(self):
        for i in self.nmap:
            print (*i)

    def printResult(self):
        for i in range(self.n):
            print(i+1,self.discover[i])

    def bfs(self,u):
        self.pos[u] = 0
        self.discover[u] = self.cnt
        t = deque()
        t.append(u)
        while t:
            n = t.popleft()
            for i in range(self.n):
                if (self.nmap[n][i] == 1 and self.pos[i] == 1 ):
                    t.append(i)
                    self.pos[i] = 0
                    self.discover[i] = self.discover[n] + 1
                
def main():
    a = node()
    a.bfs(0)
    a.printResult()
    #a.printMap()
if __name__ == '__main__':
    main()



Measured memory_bytes: 6076
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<iterator>
#include<queue>
#include<algorithm>
#include<functional>

typedef long long ll;
typedef std::map<char, int> string_type;
typedef std::map<string_type, int> type_occurences;

struct tokiomarine2020_a {
	std::string run(std::string s) {
		return s.substr(0, 3);
	}
};

int main(void) {
	tokiomarine2020_a solver;
	std::string s;

	std::cin >> s;

	std::cout << solver.run(s) << std::endl;

	return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
#define REP(i,n) for(int i = 0; i< n; i++)
int main(){
     int n;
    cin >> n ;
    string s;
    cin >> s;
    
    string sd,sd2;
    if(n%2 == 1){
        cout << "No" << endl;
        return 0;
    }else{
        for(int i = 0; i< n/2; i++){
            sd += s.at(i);
        }
        for(int i = n/2;i<n; i++){
            sd2 += s.at(i);
        }
        if(sd == sd2){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }


}

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

using namespace std;

int main(void){
    long long W,H,x,y;
    cin>>W>>H>>x>>y;
    bool flag=false;
    if(2*x==W&&2*y==H) flag=true;
    cout<<fixed;
    cout<<setprecision(9)<<(double)W*(double)H/2.0<<" ";
    cout<<flag<<endl;
    return 0;
}

Measured memory_bytes: 256
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)

double dp[3009][3009];
ll n;
double a[3009];

double ans(ll pos,ll cnt)
{
    if(dp[pos][cnt]!=-1.0)
    {
        return dp[pos][cnt];
    }
    if(pos==n)
    {
        if(cnt>n/2)
            return dp[pos][cnt] = 1.0;
        else dp[pos][cnt] = 0.0;
    }
    dp[pos][cnt] = 0;
    dp[pos][cnt] += a[pos]*ans(pos+1,cnt+1);
    dp[pos][cnt] += (1.0-a[pos])*ans(pos+1,cnt);

    return dp[pos][cnt];

}

int main()
{
    ll i,t,k,j,x=0,y=0,m;
    FAST
    cin>>n;
    rep0(i,n)
    {
        cin>>a[i];
    }
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=n;j++)
            dp[i][j] = -1.0;
    }
    cout<<fixed<<setprecision(10)<<ans(0,0)<<endl;
    return 0;
}



Measured memory_bytes: 71040
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }


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

  if( (a*b)%2 == 0){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
  
  
  return 0;
}


Measured memory_bytes: 256
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] A_V = Console.ReadLine().Split(' ');
            String[] B_W = Console.ReadLine().Split(' ');
            long A = long.Parse(A_V[0]);
            long V = long.Parse(A_V[1]);
            long B = long.Parse(B_W[0]);
            long W = long.Parse(B_W[1]);
            long T = long.Parse(Console.ReadLine());
            String ans = "NO";

            if(V > W){
                long Kei = Math.Abs(V * T);
                long Doro = Math.Abs(W * T);
                if(Math.Abs(Kei - Doro) >= Math.Abs(A - B)) ans = "YES";
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27556
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
	ll l, r, minv = INF;
	cin >> l >> r;
	for (ll i = l;i < r;i++) {
		for (ll j = l+1;j <= r;j++) {
			ll mod = (i*j) % 2019;
			if (mod == 0) {
				cout << "0" << endl;
				return 0;
			}
			else {
				minv = min(minv, mod);
			}
		}
	}
	cout << minv << endl;
	return 0;
}

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


int main() {
int r,g,b;
cin >> r >> g >> b;

int A;
A = r*100 + g*10 + b;

if (A %4 == 0)  cout << "YES" << endl;
else  cout << "NO"  << endl;




return 0;
}
 

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

public class Main {
    private static long[] pos = new long[5];
    private static long member;

    private static long solver() {
        long min = Arrays.stream(pos).min().getAsLong();
        long rem = (member % min)>0 ? 1: 0;

        return 4 + member / min + rem;
    }


    public static void main(String[] args) {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(is);

        try {
            String[] inputArray = br.readLine().split(" ");
            member = Long.parseLong(inputArray[0]);
            for(int i=0; i<5; i++) {
                inputArray = br.readLine().split(" ");
                pos[i] = Long.parseLong(inputArray[0]);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        System.out.println(solver());

    }
}

Measured memory_bytes: 28628
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, const char * argv[]) {
    int n,m;
    cin >> n >> m;
    vector<int> a(n),b(n),c(m),d(m);
//    int a[n],b[n],c[m],d[m];
    for (int i=0; i<n; i++) {
        cin >> a[i] >> b[i];
    }
    for (int i=0; i<m; i++) {
        cin >> c[i] >> d[i];
    }
    for(int i=0;i<n;i++){
        long long int tempMin = 100000000*4;
        int ans = -1;
        for(int j=0;j<m;j++){
            long long int manhDist = abs(a[i]-c[j]) + abs(b[i]-d[j]);
            if(manhDist < tempMin) {
                ans = j;
                tempMin = manhDist;
            }
        }
        cout << ans+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define ll long long
#define P pair<int, int>

using namespace std;
int mod = 1000000007;

int N, x;
int main() {
  cin >> N >> x;
  ll now = 0;
  ll ans = 0;
  rep(i, N) {
    int a;
    cin >> a;
    if (now + a > x) {
      ll tmp = now + a - x;
      ans += tmp;
      a -= tmp;
    }
    now = a;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define ll long long
#define P pair<int, int>

using namespace std;
int mod = 1000000007;

int N, C, K;

int main() {
  cin >> N >> C >> K;
  vector<int> T(N);
  rep(i, N) {
    cin >> T.at(i);
  }

  sort(T.begin(), T.end());

  int mint = INT_MIN;
  int mini = INT_MIN;
  int ans = 0;
  rep(i, N) {
    int nowt = T.at(i);
    int nowi = i;
    if ((ll)nowt > (ll)mint+K || (ll)nowi >= (ll)mini+C) {
      ans++;
      mint = nowt;
      mini = i;
      // cout << "i: " << i << endl;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


typedef struct icetea{
  ll size;
  ll price;
  ld cosp;
} IceTea;

bool func(IceTea a, IceTea b){
  return a.cosp < b.cosp;
}

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

  vector<IceTea> IT;
  
  rep(i,4){
    ll p ; cin >> p;
    p *= 4;
    ll s = pow(2,i);
    ld c = (ld)p/(ld)s;
    IceTea a;
    a.size = s;
    a.price = p;
    a.cosp = c;
   
    IT.pb(a);
  }

  sort(all(IT), func);

  ll N; cin >> N;
  N*=4;
  ll money = 0;
  rep(i,4){
    money += (IT[i].price * (N / IT[i].size));
    N %= IT[i].size;
  }

  cout << money/4 << endl;
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	vl v(n);
	rep(i,n)cin>>v[i];
	vl next(n);
	vl ap(200002,-10);
	rrep(i,n){
		ap[v[i]]=i;
	}
	rrep(i,n){
		next[i]=ap[v[i]]+1;
		ap[v[i]]=i;
	}
	ll cir=0,it=0;
	vl z;
	while(1){
		if(next[it]<=it+1){
			cir++;
			z.push_back(it);
		}
		it=next[it];
		if(it==n){
			cir++;
			z.push_back(it);
			break;
		}
	}
	k%=cir;
	k=(k+(cir-1))%cir;
	vl ans;
	range(i,z[k],n){
		while(next[i]>i+1){
			i=next[i];
			if(i==n)break;
		}
		if(i!=n)ans.push_back(v[i]);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 10992
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 400010
#define ll long long
#define inf 2147483647
using namespace std;
struct aa{int x, y;}a[N];
int n, b[N], mnp, mxp, mn, mx, l, x1, x2, now;
ll ans;
inline bool cmp(aa a, aa b){return a.x<b.x;}
int main(){
	scanf("%d", &n);
	for(int i=1; i<=n; i++){scanf("%d%d", &a[i].x, &a[i].y); if(a[i].x>a[i].y)swap(a[i].x, a[i].y);}
	mnp=mxp=1;
	for(int i=2; i<=n; i++){
		if(a[i].x<a[mnp].x)mnp=i;
		if(a[i].y>a[mxp].y)mxp=i;
	}
	mx=a[mnp].x; mn=a[mxp].y;
	for(int i=1; i<=n; i++){mx=max(mx, a[i].x); mn=min(mn, a[i].y);}
	ans=(ll)(mx-a[mnp].x)*(a[mxp].y-mn);
	if(mnp==mxp){printf("%lld", ans); return 0;}
	x1=a[mxp].y-a[mnp].x; a[mnp].x=a[mnp].y; a[mxp].y=a[mxp].x;
	l=0; for(int i=1; i<=n; i++){b[++l]=a[i].x; b[++l]=a[i].y;}
	sort(b+1, b+1+l); sort(a+1, a+1+n, cmp);
	mn=a[1].y; for(int i=2; i<=n; i++)mn=min(mn, a[i].y);
	mx=a[1].x; for(int i=2; i<=n; i++)mx=max(mx, a[i].x);
	x2=inf; now=0;
	for(int i=1; i<=l&&b[i]<=mn; i++){
		while(now<n&&a[now+1].x<b[i]){now++; mx=max(mx, a[now].y);}
		x2=min(x2, mx-b[i]);
	}
	ans=min(ans, (ll)x1*x2); printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 4224
#include<iostream>
#include<string>
#include<cstdint>

int const MAXN = 4000;
int64_t R[MAXN], G[MAXN], B[MAXN];

int main() {
  int N; std::string S; std::cin >> N >> S;
  int64_t r = 0, g = 0, b = 0;
  for(int i = N-1; i >= 0; --i) {
    switch(S[i]) {
    case 'R': ++r; break;
    case 'G': ++g; break;
    case 'B': ++b; break;
    }
    R[i] = r; G[i] = g; B[i] = b;
  }
  int64_t ans = 0;
  for(int i = 0; i < N-2; ++i) for(int j = i+1; j < N-1; ++j) {
    if(S[i] == S[j]) continue;
    char c = 'R'+'G'+'B' - S[i] - S[j];
    int k = j+j-i;
    switch(c) {
    case 'R': ans += R[j+1]; break;
    case 'G': ans += G[j+1]; break;
    case 'B': ans += B[j+1]; break;
    }
    if(k < N && S[k] == c) --ans;
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#include <math.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++)

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int N;
    cin >> N;
    vector<int> V(N);
    vector<int> C(N);
    rep(i, N) cin >> V.at(i);
    rep(i, N) cin >> C.at(i);

    vector<int> profit(N);
    rep(i, N) profit.at(i) = V.at(i) - C.at(i);

    int sum = 0;
    rep(i, N)
    {
        sum += max(profit.at(i), 0);
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
n=int(input())
dict=[]
sum=0
for i in range(n):
    a,b=input().split()
    c=int(b)
    sum+=c
    dict.append((a,c))
s=input()
for x in dict:
    sum-=x[1]
    if(x[0]==s):
        break

print(sum)


Measured memory_bytes: 3060