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

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char& c){
	string res;
	return "'" + res + c + "'";
}
 
string to_string(bool b) {
	return (b ? "True" : "False");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
	if (!first) {
    	res += ", ";
  	}
  	first = false;
	res += to_string(v[i]);
	}
	res += "}";
	return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}
 
template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto &x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}";
	return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr<<endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "\t[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else		
#define debug(...)
#endif	

// THINK: INT vs LONG LONG?

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);	
    int h, w, m;
    cin >> h >> w >> m;
    vector<int> r_cnt(h), c_cnt(w);
    // r_target.reserve(w), c_target.reserve(h);
    vector<pair<int, int>> targets(m);
    for (int i = 0; i < m; ++i){
    	int r, c;
    	cin >> r >> c;
    	--r, --c;
    	r_cnt[r]++;
    	c_cnt[c]++;
    	targets[i] = {r, c};
    }

   	// pick best row, then best col
   	int b_row = (int) (max_element(r_cnt.begin(), r_cnt.end()) - r_cnt.begin());
   	ll cnt = r_cnt[b_row];
   	vector<int> nc_cnt = c_cnt;
   	for (auto t: targets){
   		if (t.first == b_row) nc_cnt[t.second]--;
   	}
   	cnt += *max_element(nc_cnt.begin(), nc_cnt.end());
   	ll ans = cnt;

   	// pick best col, then row
   	int b_col = (int) (max_element(c_cnt.begin(), c_cnt.end()) - c_cnt.begin());
   	cnt = c_cnt[b_col];
   	vector<int> nr_cnt = r_cnt;
   	for (auto t: targets){
   		if (t.second == b_col) nr_cnt[t.first]--;
   	}
   	cnt += *max_element(nr_cnt.begin(), nr_cnt.end());
   	ans = max(ans, cnt);

   	cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 10340
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <fstream>
#include <cassert>
#include <unordered_map>
#include <cstring>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;

int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;
	if (u == s) {
		cout << a - 1 << " " << b;
	}
	else {
		cout << a << " " << b - 1;
	}
}



Measured memory_bytes: 256
sPrime = input()
t = input()

indices = []
for i in range(len(sPrime) - len(t) + 1):
	if sPrime[i] != t[0] and sPrime[i] != "?":
		continue
	possible = True
	for j in range(i+1, i+len(t)):
		diff = j - i
		tLetter = t[diff]
		if sPrime[j] != "?" and sPrime[j] != tLetter:
			possible = False
			break
	if possible:
		indices.append(i)
possibilities = []
for i in indices:
	new = ""
	for l in range(len(sPrime)):
		letter = sPrime[l]
		if l < i or l >= i + len(t):
			new = new + letter
		else:
			new = new + t[l - i]
	possibilities.append(new)

for i in range(len(possibilities)):
	possibilities[i] = possibilities[i].replace("?", "a")
possibilities.sort()
if len(possibilities) == 0:
	print("UNRESTORABLE")
else:
	print(possibilities[0])

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

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

	for (int i = 0; i < 3; i++)
	{
		if (n % 10 == 7)
		{
			cout << "Yes" << endl;
			return 0;
		}
		n /= 10;
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  string s;
  cin >> s;
  string ans;
  REP(i, s.size()) {
    if (!ans.empty() && s[i] == 'B') {
      ans.erase(ans.size() - 1);
    }
    if (s[i] != 'B') {
      ans += s[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
  string s, t;
  cin >> s >> t;
  int n = s.length(), m = t.length();
  int dp[3010][3010];
  for (int i = 1; i <= n; ++i)
  {
    for (int j = 1; j <= m; ++j)
    {
      if (s[i - 1] == t[j - 1])
        dp[i][j] = dp[i - 1][j - 1] + 1;
      else
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
    }
  }

  int i = n, j = m;
  string ans;
  while (i > 0 && j > 0)
  {
    if (dp[i][j] == dp[i - 1][j])
      i--;
    else if (dp[i][j] == dp[i][j - 1])
      j--;
    else
    {
      ans.push_back(s[i - 1]);
      i--, j--;
    }
  }
  reverse(all(ans));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 35584
import java.util.*;
public class Main{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        while (true) {
           int H = sc.nextInt(); 
           int W = sc.nextInt();
           if(H == 0 &&  W==0)
           {
               break;
           }
           for (int i = 0; i < H; i++) {
               int cnt = i%2;
              for (int j = 0; j < W; j++) {
                if(cnt %2 ==0)
                {
                    System.out.print("#");
                }
                else{
                    System.out.print(".");
                }
                cnt ++;
              } 
              System.out.println();

           }
           System.out.println();
        }
        sc.close();
    }
}


Measured memory_bytes: 35088
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
const int N = 18;

int n;
vector<pair<int, int> > a[N];

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
    {
        int q;
        scanf("%d", &q);
        while (q--)
        {
            int x, y;
            scanf("%d%d", &x, &y);
            --x;
            a[i].push_back(m_p(x, y));
        }
    }
    int ans = 0;
    for (int x = 0; x < (1 << n); ++x)
    {
        int yans = 0;
        for (int i = 0; i < n; ++i)
        {
            if ((x & (1 << i)))
            {
                ++yans;
            }
        }
        bool z = true;
        for (int i = 0; i < n; ++i)
        {
            if ((x & (1 << i)))
            {
                for (int j = 0; j < a[i].size(); ++j)
                {
                    pair<int, int> u = a[i][j];
                    if ((x & (1 << u.first)) && !u.second)
                    {
                        z = false;
                        break;
                    }
                    if (!(x & (1 << u.first)) && u.second)
                    {
                        z = false;
                        break;
                    }
                }
            }
            if (!z)
                break;
        }
        if (z)
        {
            ans = max(ans, yans);
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

def main():
    from math import sqrt
    input = sys.stdin.readline
    n = int(input())
    m = int(sqrt(n)) + 1

    ans = 0
    for i in range(1, n + 1):
        j = n // i
        if n % i == 0:
            j -= 1
        ans += j
    
    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 63228
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x1 = sc.nextInt();
        int y1 = sc.nextInt();
        int x2 = sc.nextInt();
        int y2 = sc.nextInt();

        System.out.print((x2 - (y2 - y1))+" "+(y2 + (x2 - x1))+" "+(x1 - (y2 - y1))+" "+(y1 + (x2 - x1)));
        
    }
}





Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
#define data_type int
#define endl "\n"

int main()
{
    data_type a,b,c,k;
    cin>>a>>b>>c>>k;
    while(b<=a && k>0)
      b*=2,k--;
   while(b>=c && k>0)
      c*=2,k--;

   cout<<((a<b && b<c)?"Yes":"No")<<endl;


    return 0;
}



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

int main(){
	string s;
	cin >> s;
	int l = s.size();
	string s1 = "",s2 = "";
	int cnt = 0;
	for(int i = 0;i < l;i++){
		s1 += s[i];
		if(s1 != s2){
			cnt++;
			s2 = s1;
			s1 = "";
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < int(n); ++ (i))
using namespace std;

template <typename T, class Compare = less<T> >
struct sliding_window {
    deque<pair<int, T> > data;
    function<bool (T const &, T const &)> compare;
    sliding_window(Compare const & a_compare = Compare()) : compare(a_compare) {}
    T front() { return data.front().second; }  // O(1), minimum
    void push_back(int i, T a) { while (not data.empty() and compare(a, data.back().second)) data.pop_back(); data.emplace_back(i, a); }  // O(1) amortized.
    void pop_front(int i) { if (data.front().first == i) data.pop_front(); }
    void push_front(int i, T a) { if (data.empty() or not compare(data.front().second, a)) data.emplace_front(i, a); }
};

constexpr int inf = 1e9 + 7;
int main() {
    // input
    int n, k; cin >> n >> k;
    string s, t; cin >> s >> t;
    // solve
    vector<int> delta(n + 1);
    REP (i, n) {
        delta[i + 1] = delta[i] + (i == 0 or t[i - 1] != t[i]);
    }
    vector<int> dp(n + 1, inf);
    sliding_window<int> sw_b, sw_w;
    dp[0] = 0;
    sw_b.push_back(0, 2 * dp[0] - delta[0] + (t[0] == 'B'));
    sw_w.push_back(0, 2 * dp[0] - delta[0] + (t[0] == 'W'));
    REP3 (r, 1, n + 1) {
        if (r - k - 1 >= 0) {
            sw_b.pop_front(r - k - 1);
            sw_w.pop_front(r - k - 1);
        }
        dp[r] = (s[r - 1] == t[r - 1]) ?
            dp[r - 1] :
            ((t[r - 1] == 'W' ? sw_b : sw_w).front() + delta[r]) / 2 + 1;
        if (r < n) {
            sw_b.push_back(r, 2 * dp[r] - delta[r] + (t[r] == 'B'));
            sw_w.push_back(r, 2 * dp[r] - delta[r] + (t[r] == 'W'));
        }
    }
    // output
    cout << dp[n] << endl;
    return 0;
}

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

int main() {
  float r, ans;
  cin >> r;
  ans = 2 * r * M_PI;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3744
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int[] A = new int[str.length()];

        for (int i = 0; i < str.length(); i++) {
            A[i] = str.charAt(i);
        }
        if (A[0] == A[1] || A[1] == A[2] || A[2] == A[3]) {
            System.out.println("Bad");
        } else {
            System.out.println("Good");
        }
    }
}

Measured memory_bytes: 21972
n=int(input())
i=0
j=n-1
print(i)
a=input()
print(j)
b=input()
while 1:
    if j-i<2:
        print(i)
        _=input()
        print(j)
        if input()!='Vacant':
            print('助けてくれ～～～')
    k=(j-i)//2+i
    print(k)
    c=input()
    if(k-i)%2and a==c or not(k-i)%2and a!=c:
        j=k
    else:
        a=c
        i=k

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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

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

int sumTable[501][501];

signed main() {
  int N, M, Q;
  cin >> N >> M >> Q;
  vector<P> LR;
  rep(i, M) {
    P p;
    cin >> p.first >> p.second;
    LR.pb(p);
  }

  vector<P> Query;
  rep(i, Q) {
    P p;
    cin >> p.first >> p.second;
    Query.pb(p);
  }

  vector<vector<int>> sumTable(N+1, vector<int>(N+1,0));
  rep(i, M) {
    sumTable[LR[i].first][LR[i].second] ++;
  }
  rep(i,N){
    rep(j, N) {
      sumTable[i+1][j+1] += sumTable[i][j+1];
      sumTable[i+1][j+1] += sumTable[i+1][j];
      sumTable[i+1][j+1] -= sumTable[i][j];
    }
  }
  rep(i, Q) {
    int l = --Query[i].first;
    int r = Query[i].second;
    cout << sumTable[r][r] - sumTable[l][r] - sumTable[r][l] +
                sumTable[l][l]
         << endl;
  }
}

Measured memory_bytes: 4336
#https://atcoder.jp/contests/agc013/tasks/agc013_a

n = int(input())
l = list(map(int, input().split()))
flag = None
ans = 1
for i in range(1, n):
    if l[i-1] == l[i]:
        pass
    elif flag == None:
        flag = l[i-1] < l[i]
    elif flag == (l[i-1] < l[i]):
        pass
    else:
        ans += 1
        flag = None
print(ans)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
typedef long long ll;
const ll INF = 100000000000;
// グラフ
using Edge = pair<int, ll>;         // {重み, 行き先}
using Graph = vector<vector<int>>; // グラフ

int main() {
  int n, m;
  cin >> n >> m;
  vector<ll> dist(n, INF);
  vector<int> pre(n, -1);
  Graph G(n);
  dist[0] = 0;
  queue<int> que;
  rep(i,m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  que.push(0);
  while (!que.empty()){
    int v = que.front();
    que.pop();
    for(int u: G[v]){
      if(dist[u] != INF) continue;
      dist[u] = dist[v] + 1;
      pre[u] = v;
      que.push(u);
    }
  }
  cout << "Yes" << endl;
  for (int i = 1; i < n; i++){
    cout << pre[i] + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 10956
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;

const ll INF = LONG_LONG_MAX;

template<typename T>
struct compress{
    vector<T> dat;
    compress(const vector<T> &x) {
        dat = x;
        
        dat.push_back(-INF);
        dat.push_back(INF);
        
        sort(dat.begin(), dat.end());
        dat.erase(unique(dat.begin(), dat.end()), dat.end());
    }
    inline int size(){
        return (int)dat.size();
    }
    inline int idx(T a) {
        return (int)(lower_bound(dat.begin(), dat.end(), a) - dat.begin());
    }
};

int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    int N,K;
    cin >> N >>K;
    vector<ll> x(N),y(N);
    repeat(i, N){
        cin >> x[i] >> y[i];
    }
    compress<ll> zipx(x),zipy(y);
    int w = zipx.size();
    int h = zipy.size();
    
    vector<vint> fld(w,vint(h,0));
    repeat(i, N){
        fld[zipx.idx(x[i])][zipy.idx(y[i])] = 1;
    }
    repeat(i, w-1){
        repeat(j, h-1){
            fld[i+1][j+1] += fld[i+1][j];
        }
    }
    repeat(j, h-1){
        repeat(i,w-1){
            fld[i+1][j+1] += fld[i][j+1];
        }
    }
    ll ans = INF;
    repeat(rx, w-2){
        repeat(lx, rx){
            repeat(by, h-2){
                repeat(ty, by){
                    int num = fld[rx+1][by+1]-fld[rx+1][ty]-fld[lx][by+1]+fld[lx][ty];
                    //cout << num << endl;
                    if(num < K) continue;
                    ll area = (zipx.dat[rx+1]-zipx.dat[lx+1])*(zipy.dat[by+1]-zipy.dat[ty+1]);
                    ans = min(ans,area);
                }
            }
        }
    }
    cout << ans <<endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int N = S.length();

        boolean first = palindrome(S);
        boolean second = palindrome(S.substring(0,(N - 1) / 2));
        boolean third = palindrome(S.substring(((N + 3) / 2) - 1, N));

        if(first == true && second == true && third == true)
            System.out.println("Yes");
        else System.out.println("No");
	}
	public static boolean palindrome(String S){
        boolean flag = true;
        for(int i=0; i<S.length(); i++) {
            if(S.charAt(i) != S.charAt(S.length()-i-1))
                flag = false;
        }
		return flag;
	}
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int dp[3][110000];
int main()
{
	int N;
	cin >> N;
	vec(A);
	vec(B);
	vec(C);
	fx(N) {
		vecp(A);
		vecp2(B);
		vecp2(C);
	}

	//dp[0][0] = A[0];
	//dp[1][0] = B[0];
	//dp[2][0] = C[0];

	for (int x = 0; x < N;x++) {
		fy(3) {
			fz(3) {
				if (y == z) { continue; }
				if (y==0) {
					dp[z][x + 1] = max(dp[z][x + 1], dp[y][x] + A[x]);
				}
				else if (y==1) {
					dp[z][x + 1] = max(dp[z][x + 1], dp[y][x] + B[x]);
				}
				else {
					dp[z][x + 1] = max(dp[z][x + 1], dp[y][x] + C[x]);
				}

			}
		}
	}
	ce(max({dp[0][N],dp[1][N],dp[2][N]}))
    return 0;
}



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

int main() {
  string s;
  int N, K;
  cin >> s >> K;
  N = s.size();
  int ct = 0;
  for (int i = 0; i < N; i++) {
    if (s[i] == 'a') continue;
    int p = 'z'-s[i]+1;
    if (p + ct <= K) {
      s[i] = 'a';
      ct += p;
    }
  }
  int q = (K-ct)%26;
  for (int i = 0; i < q; i++) {
    if (s[N-1] == 'z') s[N-1] = 'a';
    else s[N-1] = s[N-1] + 1;
  }
  cout << s << endl;
}

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

int main(){
  int n,k;
  int sum = 1;
  cin>>n>>k;
  for (int i=0; i < n; i++){
    if(sum*2 < sum + k){
      sum *= 2;
    } else {
      sum += k;
    }
  }
  cout << sum <<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class A
{
    static long[] Read() => Console.ReadLine().Split().Select(long.Parse).ToArray();
    static void Main()
    {
        var a = Read();
        Console.WriteLine(Math.Max(Math.Max(a[0] * a[2], a[0] * a[3]), Math.Max(a[1] * a[2], a[1] * a[3])));
    }
}

Measured memory_bytes: 28172
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
count =0
for i in range(N):
    if B[i]>A[i] + A[i+1]:
        count +=A[i] + A[i+1]
        A[i+1]=0
    elif B[i]>A[i]:
        count +=B[i]
        A[i+1] -= B[i]-A[i]
    else:
        count +=B[i]

print(count)


Measured memory_bytes: 18624
#include <iostream>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int arr[100000];
  int ans = 0;
  for(int i = 0; i<n; i++) {
    int input;
    cin >> input;
    arr[i] = input;
    if(input >= k) {
      ans ++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;
double PI = acos(-1);

int main() {
    double a, b, c, S, L, h;
    cin >> a >> b >> c;
    
    double rad = c * PI / 180;
    S = a * b * sin(rad) / 2;
    L = a + b + sqrt(a * a + b * b - a * b * cos(rad) * 2);
    h = S * 2 / a;
    
    printf("%.10f\n", S);
    printf("%.10f\n", L);
    printf("%.10f\n", h);
    return 0;
}



Measured memory_bytes: 3460
# ABC074C - Sugar Water
# input
a, b, c, d, e, f = list(map(int, input().rstrip().split()))
A = a * 100
B = b * 100

# default values
x, y = min(a, b) * 100, 0
dens = y / x


# exhaustive search
for i in range(f // A + 1):
    for j in range(((f - A * i) // B) + 1):
        if i == 0 and j == 0:
            continue
        water = i * A + j * B
        rest = f - water
        for k in range(rest // c + 1):
            for l in range((rest - c * k) // d + 1):
                sugar = c * k + d * l
                total = water + sugar

                if sugar / total > e / (e + 100):  # compare to e (the max density)
                    break
                else:
                    if sugar / total > dens:
                        dens = sugar / total
                        x, y = total, sugar
print(x, y)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std; typedef long long ll; const int INF=1e9+7;
typedef pair<int,int> P;
const int mx=2000; vector<vector<int>> v(mx);
vector<vector<int>> d(mx, vector<int>(mx)); int n,k; vector<int> era(mx);

void dfs(int id, int from, int to, int len) {
  d[id][to]=len;
  if (len > k) era[id]++, era[to]++;
  for(int x:v[to]) {
    if (x == from) continue;
    dfs(id,to,x,len+1);
  }
}
int main() {
  if (mx != 2000) cerr<<"MXMXMXMXMXMx"<<endl;
  cin>>n>>k;
  for(int i=0;i<n-1;i++) {
    int a,b; cin>>a>>b; a--; b--; v[a].push_back(b); v[b].push_back(a);
  }
  for(int i=0;i<n;i++) dfs(i,-1,i,0);
  set<P, greater<P>> s;
  for(int i=0;i<n;i++) {
    if (era[i]) s.insert({era[i],i});
  }
  //for(int i=0;i<n;i++) cout<<era[i]<<" "; cout<<endl;
  int an=0;
  while(!s.empty()) {
    auto it=s.begin();
    int w=(*it).first;
    int t=(*it).second;
    //cout<<w<<" "<<t<<endl;
    s.erase({w,t});
    if (w<=0) continue;
    //cout<<t<<endl;
    an++;
    set<P, greater<P>> s2;
    for(P x:s) {
      if (d[t][x.second] > k) s2.insert({x.first-2,x.second});
      else s2.insert(x);
    }
    s=s2;
  }
  cout<<an<<endl;
}

Measured memory_bytes: 16384
using System;
using System.Linq;

namespace _20190315_05 {
    class Program {
        static void Main(string[] args) {
            var line0 = Console.ReadLine().Split(' ').Select(d => long.Parse(d)).ToArray();
            var n = line0[0];
            var k = line0[1];
            var line1 = Console.ReadLine().Split(' ').Select(d => long.Parse(d)).ToArray();
            long x = 0;
            for (int j = 40; j >= 0; j--) {
                if (line1.Where(d => ((d >> j) & 1) == 1).Count() <= n / 2) {
                    x += (long)1 << j;
                    //Console.WriteLine(j);
                }
                if (x > k) {
                    x -= (long)1 << j;
                    //Console.WriteLine(j + ":ok");
                    //continue;
                }
            }
            //Console.WriteLine(x);
            long ans = line1.Select(d => d ^ x).Sum();
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 31324
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <typeinfo>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;

int main(){

    long n, min, max, sum;
    sum=0;
    cin >> n;
    vector<long> ints(n);
    for(int i=0; i<n; i++){
        cin >> ints[i];
    }

    min = ints[0];
    max = ints[0];
    for(int i=0; i<n; i++){
        sum+=ints[i];
        if(max < ints[i]){
            max = ints[i];
        }
        if(min > ints[i]){
            min = ints[i];
        }
    }

    cout << min << " " << max << " " << sum << endl;

    return 0;
}



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

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

    long long a, b;
    cin >> a >> b;

    // 素因数分解
    long long aa = a, bb = b;
    map<long long, long long> mp;
    for(int i = 2; i <= sqrt(a); i++){
        while(aa % i == 0){
            aa /= i;
            mp[i]++;
        }
    }
    if(aa != 1){
        mp[aa] = 1;
    }

    map<long long, long long> mp2;
    for(int i = 2; i <= sqrt(b); i++){
        if(bb % i == 0){
            long long cnt = 0;
            while(bb % i == 0){
                bb /= i;
                cnt++;
            }
            if(mp2.count(i)) mp2[i] = max(mp2[i], cnt);
            else mp2[i] = cnt;
        }
    }
    if(bb != 1){
        if(mp2.count(bb)) mp2[bb] = max(mp2[bb], 1LL);
        else mp2[bb] = 1;
    }

    set<int> st;
    for(auto x: mp){
        if(mp2.count(x.first)){
            st.insert(x.first);
        }
    }

    cout << st.size() + 1 << endl;

    return 0;
}

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

int gcd(int a, int b){
    return (b==0)? a :gcd(b, a%b);
}
        
int main(){
    int n, k;
    cin >> n >> k;
    int a, amax;
    cin >> a;
    amax = a;
    for(int i=1; i<n; i++){
        int b;
        cin >> b;
        a = gcd(a,b);
        amax = max(amax,b);
    }
    if(k%a==0 && amax>=k){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/* ファイル名：ITP1_6_B.c	*/
/* 内容：52枚あるトランプのカードの中の足りないカードを探す	*/

/* include	*/
#include <stdio.h>

/* 外部変数宣言	*/

/* プロトタイプ宣言	*/

/* 関数名:main	*/
/* 処理内容:52枚あるトランプのカードの中の足りないカードを探す	*/
int main( void )
{
	/* 内部変数定義	*/
	/* 入力	*/
	int n;		/* 今あるカードの枚数	*/
	char mark;	/* カードの絵柄			*/
	int num;	/* カードのランク(数字)	*/
	
	/* 処理	*/
	int card[4][13];	/* 該当するカードがあるかを調べるための配列	*/
	int i;	/* ループ用変数1										*/
	int j;	/* ループ用変数2										*/
	
	/* 処理用配列の初期化	*/
	for(i = 0; i < 4; i++){
		for(j = 0; j < 13; j++){
			card[i][j] = 0;	/* 該当するカードがないことにする	*/
		}
	}
	
	scanf("%d",&n);	/* 今あるカードの枚数を取得	*/
	
	/* 今あるカードを取得	*/
	/* 今あるカードの枚数だけループ	*/
	for(i = 0; i < n; i++){
		scanf(" %c%d",&mark,&num);	/* カードの絵柄とランクを取得	*/
		
		/* カードの絵柄がスペードだった場合	*/
		if(mark == 'S'){
			card[0][num - 1] = 1;	/* 該当するカードがあることにする	*/
		}
		/* カードの絵柄がハートだった場合	*/
		else if(mark == 'H'){
			card[1][num - 1] = 1;	/* 該当するカードがあることにする	*/
		}
		/* カードの絵柄がクラブだった場合	*/
		else if(mark == 'C'){
			card[2][num - 1] = 1;	/* 該当するカードがあることにする	*/
		}
		/* カードの絵柄がダイヤだった場合	*/
		else if(mark == 'D'){
			card[3][num - 1] = 1;	/* 該当するカードがあることにする	*/
		}
		/* 上記4つ以外の絵柄はないため処理なし	*/
		else{
			/* 処理なし	*/
		}
	}
	
	/* ないカードを出力	*/
	for(i = 0; i < 4; i++){
		for(j = 0; j < 13; j++){
			/* 該当するカードがなかった場合	*/
			if(card[i][j] == 0){
				/* カードの絵柄がスペードだった場合	*/
				if(i == 0){
					printf("S %d\n",j + 1);	/*改行付きで出力する	*/
				}
				/* カードの絵柄がハートだった場合	*/
				else if(i == 1){
					printf("H %d\n",j + 1);	/*改行付きで出力する	*/
				}
				/* カードの絵柄がクラブだった場合	*/
				else if(i == 2){
					printf("C %d\n",j + 1);	/*改行付きで出力する	*/
				}
				/* カードの絵柄がダイヤだった場合	*/
				else if(i == 3){
					printf("D %d\n",j + 1);	/*改行付きで出力する	*/
				}
				/* 上記4つ以外の絵柄はないため処理なし	*/
				else{
					/* 処理なし	*/
				}
			}
			/* 該当するカードがある場合	*/
			else{
				/* 処理なし	*/
			}
		}
	}
	return 0;
}



Measured memory_bytes: 2056
#include<stdio.h>

int main()
{
  int N,s = 1,ans = 0,t;
  int i;
  int a[200000];

  scanf("%d",&N);

  for(i = 0;i < N;i++){
    scanf("%d",&t);
    a[i] = t;
  }

  i = 0;
  while(i < N){
    if(a[i] == s){
      ans++;
      s++;
    }
    i++;
  }

  if(ans == 0){
    printf("-1\n");
  }
  else{
    ans = N - ans;
    printf("%d\n",ans);
  }

  return 0;
}
    
    


Measured memory_bytes: 896
#include <stdio.h>
int main(void) {

int i,j,a,b;
int ari[1000][1000]={};
int s[1000]={},t[1000]={};

scanf("%d %d",&a,&b);

for(i=0;i<a;i++)
 for(j=0;j<b;j++)
 scanf("%d",&ari[i][j]);
 
for(i=0;i<b;i++)
 scanf("%d",&s[i]);
 
for(i=0;i<a;i++)
 for(j=0;j<b;j++)
 t[i] += s[j] * ari[i][j];
 
for(i=0;i<a;i++)
 printf("%d\n",t[i]);

    return 0;
}

Measured memory_bytes: 4520
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};

int D;
LL C[26];
VVL S;

void input(){
    cin >> D;
    REP(i,26) cin >> C[i];
    S.assign(D,VL(26));
    REP(i,D) REP(j,26) cin >> S[i][j];
}

void solve(){
    // last days
    LL L[26] = {};

    LL score = 0;
    REP(day,D){

        LL best = -LINF;
        LL choice = -1;

        REP(cand, 26){
            LL tmp = L[cand];
            L[cand] = day+1;

            LL gain = S[day][cand];
            REP(i,26){
                gain -= C[i] * (day+1 - L[i]);
            }

            if(best < gain){
                best = gain;
                choice = cand;
            }


            L[cand] = tmp;
        }

        L[choice] = day+1;
        cout << choice+1 << "\n";

    }

}


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    input();
    solve();

}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n, m;
string s, t;
bool f;
int main(){
	cin >> s >> t;
	for(int i=0;i<s.size();i++){
		bool ff = 1;
		for(int j=0;j<s.size();j++){
			if(s[(i+j)%s.size()]!=t[j]) ff = 0;
		}
		if(ff) f = 1;
	}
	if(f) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void eq(int ind, int l, int r, int index, int val, vector<int>& st){
    if(l>r || index<l || r<index) return;
    if(l==r && l==index){
        st[ind]=val;
        return;
    }
    eq(2*ind+1,l,(l+r)/2,index,val,st);
    eq(2*ind+2,(l+r)/2+1,r,index,val,st);
    st[ind]=max(st[2*ind+1],st[2*ind+2]);
}

int sq(int ind, int l, int r, int s,int e, vector<int>& st){
    if(l>r || r<s || e<l) return 0;
    if(s<=l && r<=e) return st[ind];
    return max(sq(2*ind+1,l,(l+r)/2,s,e,st),sq(2*ind+2,(l+r)/2+1,r,s,e,st));
}

void solve(){
    int n,k,mx=0,lim=1;
    cin>>n>>k;
    vector<int> a(n,0);
    for(int i=0;i<n;i++) {
        cin>>a[i];
        mx=max(mx,a[i]+1);
    }

    while(lim<=4*mx) lim*=2;
    vector<int> st(lim+100,0);
    int ans=0;
    for(int i=n-1,l,r;i>=0;i--){
        l=max(0,a[i]-k);
        r=min(mx,a[i]+k);
        l=sq(0,0,mx-1,l,r,st)+1;
        ans=max(ans,l);
        eq(0,0,mx-1,a[i],l,st);
    }
    cout<<ans<<"\n";
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    return 0;
}

Measured memory_bytes: 12704
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define vec vector
#define pb push_back
#define s(x) scanf("%d",&x)
#define all(x)	x.begin(),x.end()
#define pii pair<int,int>
#define fi first
#define se second
#define mod 1000000007
#define SZ 200005
#define endl "\n"
#define trc(x) cerr << #x << ": " << x << endl
#define trcc(x,y) cerr << #x << ": " << x << endl << #y << ": " << y << endl << endl
#define boost ios::sync_with_stdio(0);cin.tie(0)

int n, m, k, x;



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

	int ans = 0;

	for(int i = 0; i < n; i++) {
		for(int j = i+1; j < n ; j++) {
			for(int k = j+1; k < n; k++) {
				if(a[i]+a[j]>a[k] and a[i]+a[k]>a[j] and a[k]+a[j]>a[i] and a[i]!=a[j] and a[j]!=a[k] and a[i]!=a[k]) {
					ans++;
					// cout << i+1 << j+1 << k+1<<endl;
				}
				
			}
		}
	}
	cout << ans;


}




signed main() {
	boost;
	int t=1;
	// cin>>t;
	while(t--) purple18();
}

Measured memory_bytes: 3540
n,h =map(int,input().split())
a,b = [0]*n,[0]*n
for i in range(n):
    a[i],b[i] = map(int,input().split())
A = max(a)
s = list()
for i in range(n):
    if b[i] > A:
        s.append(b[i])
s.sort()
s.reverse()
c = sum(s)
if c < h:
    print(len(s) + (h-c)//A + [1,0][(h-c)%A==0])
else:
    S = 0
    for i in range(len(s)):
        S += s[i]
        if S >= h:
            print(i+1)
            break

Measured memory_bytes: 12140
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)
using namespace std;
typedef long long ll;
const int MAXK = 5 + 100000;
const int MAXN = 5 + 100;
int N,K,arr[MAXN],memo[MAXK];


int dp(int k) {
    if(k <= 0) {
        return 0;
    }
    int& ans = memo[k];
    if(ans == -1) {
        ans = 0;
        foi(i,0,N) {
            if(k - arr[i] >= 0 && !dp(k - arr[i])) {
                ans = 1;
                break;
            }
        }
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> N >> K;
    foi(i,0,N) {
        cin >> arr[i];
    }
    memset(memo, -1, sizeof memo);
    cout << (dp(K) ? "First" : "Second") << '\n';
    return 0;
}


Measured memory_bytes: 5376
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, M, K = read_ints()
    A = read_ints()
    B = read_ints()
    A_read = 0
    B_read = M
    B_sum = sum(B)
    A_sum = 0
    max_read = 0
    for A_read in range(N+1):
        if A_read > 0:
            A_sum += A[A_read-1]
        while B_read > 0 and A_sum+B_sum > K:
            B_read -= 1
            B_sum -= B[B_read]
        if A_sum+B_sum <= K:
            max_read = max(max_read, A_read+B_read)
    return max_read


if __name__ == '__main__':
    print(solve())


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

int main() {
	ios_base::sync_with_stdio( false );

	string s;
	cin >> s;
	for( int i = 1; i <= s.size(); ++i ) {
		if( (i&1) == 1 ) {
			cout << s[i-1];
		}
	}

	cout << endl;
	return 0;
}


Measured memory_bytes: 592
import numpy as np

N, M, C = [int(x) for x in input().split()]
B = np.array([int(x) for x in input().split()])
A = np.empty((N,M))

count = 0
for n in range(N):
    A[n] = [int(m) for m in input().split()]
    #count = count + 1 if sum(A[n] * B)+C > 0 else count 
    count += (sum(A[n] * B)+C > 0)
print(count)


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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define LEN(s)      (string(s)).length()
#define NPOS        string::npos
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<class T>string join(const vector<T>& v,string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(LEN(d));}

template<class T>ostream& operator<<(ostream& o,const vector<T>& v)
{o<<"{";if(SZ(v))o<<join(v,", ");o<<"}";return o;}

template<class T,class U>ostream& operator<<(ostream& o,const pair<T,U>& p)
{o<<"(";o<<p.first<<", "<<p.second;o<<")";return o;}

template<class T>bool contain(const string& s,const T& v)
{return s.find(v)!=NPOS;}

template<class T,class U>string& replace(string& s,const T& f,const U& t)
{for(auto p=s.find(f);p!=NPOS;p=s.find(f,p+LEN(t)))s.replace(p,LEN(f),t);}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

int main() {
    string S; cin >> S;
    ll N = LEN(S);
    
    if (N == 1) {
        cout << "YES" << endl;
        return 0;
    }
    
    vector<ll> abc(3, 0);
    REP(i, N) abc[S[i] - 'a']++;
    
    vector<P> ps(3);
    REP(i, 3) ps[i] = {abc[i], i};
    SORT(ps);
    
    vector<ll> c(3);
    REP(i, 3) c[i] = ps[i].second;
    
    ll prev2 = c[2]; abc[c[2]]--;
    ll prev1 = c[1]; abc[c[1]]--;
    FOR(i, 2, N) {
        bool ng = true;
        RREP(j, 2) if (c[j] != prev2 && c[j] != prev1 && abc[c[j]] > 0) {
            prev2 = prev1;
            prev1 = c[j];
            abc[c[j]]--;
            
            ng = false;
            break;
        }
        if (ng) break;
    }
    
    REP(i, 3) if (abc[i] != 0) {
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    
    return 0;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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

const int INF = 1e9;

int main(void){

	int N; cin >> N;
	vector<int> X(N);

	REP(i,N) cin >> X[i];

	SORT(X);
	int mid;
	if(N%2 == 0) mid = N/2-1;
	else mid = N/2;

	int ans = INF;
	// FOR(i,X[mid],X[mid+1]+1){
	REP(i, 100){
		int sum = 0;
		REP(j,N) sum += pow(i - X[j], 2);
		ans = min(ans, sum);
	}

	cout << ans << endl;


	return 0;

}


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

#define sq(x) ((x)*(x))
const long long M = 1e9+7;

long long dp[800005];
long long *cmb;

long long fact(long long x){
    if(dp[x])
        return dp[x];
    return dp[x]=(fact(x-1)*x)%M;
}

long long gcdExtended(long long a, long long b, long long *x, long long *y) 
{ 
    if (a == 0) { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    long long x1, y1;
    long long gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
} 

long long modInverse(long long b, long long m) 
{ 
    long long x, y;
    long long g = gcdExtended(b, m, &x, &y); 
  
    // Return -1 if b and m are not co-prime 
    if (g != 1) 
        return -1; 
    return (x%m + m) % m; 
} 
  
// Function to compute a/b under modlo m 
long long modDivide(long long a, long long b) 
{ 
    long long inv = modInverse(b, M); 
    assert(inv !=-1);
    return (inv * a) % M; 
} 


long long perma(long long x, long long y){
    if(cmb[x]) return cmb[x];
    if(y==0){
        return 1;
    }
    return cmb[x] = (x* perma(x+1, y-1))%M;
}
long long perm(long long x, long long y){
    return perma(x-y+1, y);
}

long long pow2(long long x, long long y){
    if(y==0)
        return 1;
    if(y==1)
        return x;
    return y&1 ? (x*pow2(sq(x)%M, y>>1))%M : (pow2(sq(x)%M, y>>1))%M;
}

long long comb(long long x, long long y){
    return y<x-y ? modDivide(perm(x, y),fact(y)) : modDivide(perm(x, x-y),fact(x-y));
}
    
int main(){
    int n, k;
    memset(dp, 0, sizeof(dp));
    dp[1]=dp[0]=1;
    scanf("%d%d", &n, &k);
    cmb = new long long[n+2];
    memset(cmb, 0, sizeof(long long)*n);
    cmb[n+1]=1;
    long long res=0;
    if(k>=n) k=n-1;
    for(int i=0; i<=k; i++){
        res+=(modDivide(fact(n-1), (fact(n-i-1)*fact(i))%M)*(comb(n,i)))%M;
        res%=M;

        //cerr << i << endl;
    }
    printf("%lld", res);
    delete[] cmb;
    return 0;
}

Measured memory_bytes: 13184
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
#define dbg(x) cout<<#x<<" = "<<x<<endl
typedef long long ll;
const int maxn = 105;
char str[maxn];
int main()
{
   scanf("%s",str);
   int len=strlen(str);
   int tmp=len-1;
   ll sum=0;
   for(int i=0;i<(1<<tmp);i++)
   {
       ll ans=0;
       ll tt=str[0]-'0';
       for(int j=0;j<tmp;j++)
       {
           if(i&(1<<j))
           {
              ans+=tt;
              tt=str[j+1]-'0';
           }
           else
           {
               tt=tt*10+str[j+1]-'0';
           }
       }
       ans+=tt;
       sum+=ans;
   }
   printf("%lld\n",sum);
    return 0;
}


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

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

    for(int i=0; i<S.size(); i++){
        S[i] += N;
        if(S[i]>90)
            S[i] -= 26;
    }

    for(int i=0; i<S.size(); i++){
        cout << S[i];
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  long long n;
  cin>>n;
  long long a;
  for(long long i=1;i*i<=n;i++){
    if(n%i==0)a=i;
  }
  long long ans=a+n/a-2;
  printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int total =0;
  int i = 0; 
  int b = 100000000;
  int n = N;
	while(i<=8){
      if(n / b != 0){
        total += n/b;
        n = n - (n/b*b);
      }
      b /= 10;
      i++;
    }
  cout << (N % total == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        string[] readerstr = ReadLine().Split(' ');
        int[] num = new int[readerstr.Length];
        for(int i=0;i<readerstr.Length;i++){
            num[i] = int.Parse(readerstr[i]);
        }
        long ans = 0;
        //全部AB
        int ab_maxmai = Max(num[3],num[4]);
        int ab = num[2]*2*ab_maxmai;
        ans = Max(ans,ab);
        //ABと残りAかB
        int abandab_kyoutu = Min(num[3],num[4]);
        int abandab = num[2]*2*abandab_kyoutu;
        int abandab_a = (num[3]-abandab_kyoutu)*num[0];
        int abandab_b = (num[4]-abandab_kyoutu)*num[1];
        abandab += abandab_a + abandab_b;
        ans = Min(ans,abandab);
        //全部AかB
        int aorb = num[0]*num[3] + num[1]*num[4];
        ans = Min(ans,aorb);
        
        WriteLine(ans);
    }
}

Measured memory_bytes: 11092
n = int(input())
a = [int(i) for i in input().split()]
mod = 10 ** 9 + 7
point1 = (sum(a) ** 2)
point2 = 0
for i in a:
    point2 += i ** 2
    point2 = point2
ans = (point1 - point2) // 2
print(ans % mod)

Measured memory_bytes: 31432