akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
using Point = complex<double>;

#define X real()
#define Y imag()
double dot(Point a, Point b) {
    return (a.X * b.X + a.Y * b.Y);
}
using Line = pair<Point, Point>;
Point Projection(Line s, Point p) {
    Point vase = s.second - s.first;
    p -= s.first;
    return s.first + dot(p, vase) / norm(vase) * vase;
}
Point Reflection(Line s, Point p) {
    return p + (Projection(s, p) - p) * 2.0;
}
double cross(Point a, Point b) {
    return a.X * b.Y - a.Y * b.X;
}
int ccw(Point a, Point b, Point c) {
    if (cross(b - a, c - a) > EPS)return 1;
    if (cross(b - a, c - a) < -EPS)return -1;
    if (dot(b - a, c - a) < -EPS)return 2;
    if (abs(b - a) + EPS < abs(c - a))return -2;
    return 0;
}
bool isOrthogonal(Line a, Line b) {
    return dot(a.second - a.first, b.second - b.first) ? 0 : 1;
}
bool isParallel(Line a, Line b) {
    return cross(a.second - a.first, b.second - b.first) ? 0 : 1;
}
bool isCross(Line a, Line b) {
    if (ccw(a.first, a.second, b.first) * ccw(a.first, a.second, b.second)<=0 and
        ccw(b.first, b.second, a.first) * ccw(b.first, b.second, a.second)<=0) {
        return true;
    }
    return false;
}
Point CrossPoint(Line a, Line b) {
    double x, d;
    Point p1, p2, p3, p4;
    p1 = a.first;
    p2 = a.second;
    p3 = b.first;
    p4 = b.second;
    x = (p4.Y - p3.Y) * (p4.X - p1.X) - (p4.X - p3.X) * (p4.Y - p1.Y);
    d = (p4.Y - p3.Y) * (p2.X - p1.X) - (p4.X - p3.X) * (p2.Y - p1.Y);
    return p1 + x / d * (p2 - p1);

}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Point p1, p2, p3, p4;
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        double x1, x2, y1, y2, x3, x4, y3, y4;
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
        p1 = Point(x1, y1);
        p2 = Point(x2, y2);
        p3 = Point(x3, y3);
        p4 = Point(x4, y4);
        Line l1 = Line(p1, p2), l2 = Line(p3, p4);
        printf("%.9f %.9f\n",CrossPoint(l1, l2).X,CrossPoint(l1, l2).Y);
    }
    return 0;

}


Measured memory_bytes: 3228
//xahid f
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int val[3],k;
    cin>>val[0]>>val[1]>>val[2]>>k;
    sort(val,val+3);
    cout<<val[0]+val[1]+val[2]*pow(2,k)<<endl;
    
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second

int32_t main(){
	int n, k;
	cin >> n >> k;
	bool f[n + 1] = {};
	for (int i = 0; i < k; i++){
		int l;
		cin >> l;
		for (int i = 0; i < l; i++){
			int x;
			cin >> x;
			f[x] = true;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++){
		if (!f[i])
			ans ++;
	}
	cout << ans;
}


Measured memory_bytes: 3624
import heapq
N, M = map(int, input().split())
A = dict()

for _ in range(N):
  a, b = map(int, input().split())
  if a in A:
    A[a].append(b)
  else:
    A[a] = [b]

h = []
reward = 0

for day in range(1, M+1):
  bb = A.get(day)
  if bb:
    for x in bb:
      heapq.heappush(h, -x)
  if h:
    reward += heapq.heappop(h)
    
print(-reward)

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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);

LL func(LL n,LL bit)
{
    LL pw = 1LL << (bit + 1);
    n = n % pw;
    LL half = pw/2;
    if(n >= half){
        return (n - half + 1) % 2;
    }else{
        return 0;
    }
}
int main()
{
    LL a , b;
    cin >> a >> b;

    LL x = 0;
    for(LL i = 1;i <= 50;i++){
        if(func(b,i))x = x ^ (1LL << i);
    }
    if(a > 0){
        a = a - 1;
        for(LL i = 1;i <= 50;i++){
            if(func(a,i))x = x ^ (1LL << i);
        }
    }
    LL o = (b + 1)/2 - (a + 1)/2;
    if(o % 2 == 1)x = x ^ 1;

    cout << x << "\n";

}

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

int main() {
  int N;
  cin >> N;
  double p;
  if (N % 2 == 0) {
    p = 1.0 / 2.0;
  }
  else {
    p = (N + 1.0) / (2.0 * N);
  }
  
  cout << p << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v){
  const char* dlm = "";
  for(const auto& x:v) os << exchange(dlm, " ") << x;
  return os;
}
int32_t main(){
  vector<int32_t> a,s;
  size_t n,k; cin>>n>>k;
  while(n!=0||k!=0){
    a.resize(n);
    for(auto&& x:a) cin>>x;
    s.resize(n+1); s[0]=0;
    for(size_t i=1; i<n+1; ++i) s[i]=s[i-1]+a[i-1];
    int32_t ret=s[k]-s[0];
    for(size_t i=1; i<n-k; ++i) ret=max(ret,s[i+k]-s[i]);
    cout<<ret<<'\n';
    cin>>n>>k;
  }
}


Measured memory_bytes: 3592
use proconio::{input, marker::Usize1};

const M: usize = 300000;

fn main() {
    input! {
        n: usize,
        k: usize,
    }

    let mut st = SegTree::new(M, std::cmp::max);
    for _ in 0..n {
        input! {a: usize}
        let l = if a > k {a - k} else {0};
        let r = (a + k).min(M);
        let m = st.get(l, r + 1, None) + 1;
        st.set(a, m);
    }

    println!("{}", st.get(0, M + 1, None));
}


struct SegTree {
    tree: Vec<u64>,
    leaf_size: usize,
    op: fn(u64, u64) -> u64,
}

impl SegTree {
    fn new(n: usize, op: fn(u64, u64) -> u64) -> Self {
        let mut ls = 1;
        while ls < n {
            ls <<= 1;
        }
        Self {
            tree: vec![0; 2 * ls - 1],
            leaf_size: ls,
            op,
        }
    }

    fn set(&mut self, mut i: usize, v: u64) {
        i += self.leaf_size - 1;
        self.tree[i] = v;
        while i > 0 {
            i = (i - 1) / 2;
            self.tree[i] = (self.op)(self.tree[2 * i + 1], self.tree[2 * i + 2]);
        }
    }

    fn get(&self, s: usize, e: usize, rng: Option<(usize, usize, usize)>) -> u64 {
        let (i, l, r) = if let Some(rng) = rng { rng } else { (0, 0, self.leaf_size) };
        if l >= e || r <= s {
            0
        } else if l >= s && r <= e {
            self.tree[i]
        } else {
            let m = (l + r) / 2;
            let vl = self.get(s, e, Some((2 * i + 1, l, m)));
            let vr = self.get(s, e, Some((2 * i + 2, m, r)));
            (self.op)(vl, vr)
        }
    }
}


Measured memory_bytes: 8824
a;f(H,W){for(long long i=H,x,y,z,t;i--;)x=(H-i)*W,y=W/2*i,z=(W+1)/2*i,t=(x>z?x-y:x<y?z-x:i),t<a?a=t:0;}main(H,W){scanf("%d%d",&H,&W);a=H<W?H:W;H%3&&W%3?f(H,W),f(W,H):(a=0);printf("%d\n",a);}

Measured memory_bytes: 128
#import<cstdio>
#define r(a) for(int i=0;i<a;i++)
#define s (scanf("%d",&w),w)
#define c(a,b) a=a<b?a:b
int w,n,m,d[999],p[999];main(){n=s;m=s;r(n)d[i]=s;r(n)p[i]=1e9;r(m){s;r(n)c(p[i],p[i+1]+w*d[n-i-1]);}printf("%d\n",*p);}

Measured memory_bytes: 1036
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <iterator>
#include <cmath>

using namespace std;

char arr[100010];
vector<int> lis[100010];

int cnt[100010];

int main()
{
    //freopen("in", "r", stdin);
    //freopen("out", "w", stdout);

    int n, m, i, j;
    scanf("%s%d", arr + 1, &m);

    n = strlen(arr + 1);

    for(i = 0; i < m; i++)
    {
        int l, r;
        scanf("%d%d", &l, &r);

        if(l <= n / 2 && r > (n + 1) / 2)
        {
            int ln = n / 2 - l;
            int rn = r - ((n + 1) / 2 + 1);
            if(ln >= rn)
                r = n / 2 - rn - 1;
            else
                l = ((n + 1) / 2 + 1) + ln + 1;
        }

        if(n % 2 == 1)
        {
            if(r == (n + 1) / 2)
                r--;
            if(l == (n + 1) / 2)
                l++;
        }

        if(r < l)
            continue;

        if(r > n / 2)
        {
            r = n - r + 1;
            l = n - l + 1;
            swap(l, r);
        }

        lis[l].push_back(r);
    }

    int c = 0;
    for(i = 1; i <= n / 2; i++)
    {
        c += cnt[i];

        int t = (arr[n - i + 1] - arr[i] - c) % 26;

        if(lis[i].empty())
        {
            if(!t)
                continue;

            printf("NO\n");
            return 0;
        }

        sort(lis[i].begin(), lis[i].end());
        lis[i].erase(unique(lis[i].begin(), lis[i].end()), lis[i].end());

        for(j = 1; j < lis[i].size(); j++)
            lis[lis[i][j - 1] + 1].push_back(lis[i][j]);
        
        c += t;
        cnt[lis[i][0] + 1] -= t;
    }

    printf("YES\n");
    return 0;
}

Measured memory_bytes: 6400
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
	int k, t; cin >> k >> t;
	vector<int>A(t);
	for (int i = 0; i < t; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end(),greater<int>());

	while(A.size()>1){
		if (A.front() > A.back()) {
			A.front() -= A.back();
			A.erase(--A.end());
		}
		else if (A.front()!=1 && A.front() == A.back()) {
			A.front()=1;
			A.back() = 1;
		}else break;

		sort(A.begin(), A.end(), greater<int>());
	}

	cout<<A.front() - 1 << endl;

    return 0;
}

Measured memory_bytes: 256
/*
* Note: This template uses some c++11 functions , so you have to compile it with c++11 flag.
*       Example:-   $ g++ -std=c++11 c++Template.cpp
*
* Author : Akshay Pratap Singh
* Handle: code_crack_01
*
*/
 
/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

int main(){
    int n;
    SCD(n);
    int arr[n];
    int a;
    REP(i,n){
        arr[i]=0;
    }
    FOR(i,0,n-1,1){
        SCD(a);
        arr[a-1]++;
    }
    REP(i,n){
        printf("%d\n", arr[i]);
    }
}

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

using namespace std;

char s[20];

int main()
{
    scanf("%s",s);
    int len = strlen(s);
    int cou = 15 - len;
    for(int i = 0;i < len;i++)
        if(s[i] == 'o')
            cou++;
    if(cou >= 8)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>

using namespace std;

int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;

    cout << (char) (s1[0] - 32) << (char) (s2[0] - 32) << (char) (s3[0] - 32) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,tot=0;
	scanf("%d",&n);
	for(int i=1,x;i<=n;i++) {
		scanf("%d",&x);
		if(x==tot+1) tot++;
	}
	printf("%d\n",tot==0?-1:n-tot);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;
using P = pair<int,int>;

int main(){

  int N, a;
  cin >> N;
  int ans = 0;
  vector<int> vec(N);

  for (int i = 0; i < N; i++){
    cin >> a;
    vec.at(i) = a-1;
  }
  ans = accumulate(vec.begin(), vec.end(), 0);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <string>
#define int long long

using namespace std;

int N, M, K;
int A[202020], B[202020];
int Asum[202020], Bsum[202020];

int calcB(int rest)
{
    // cout << rest << endl;
    if (rest < 0LL)
        return 0;
    int ret = 0;
    for (int i = 20; i >= 0; i--)
    {
        if (ret + (1LL << i) >= M)
            continue;
        if (Bsum[ret + (1LL << i)] <= rest)
        {
            ret += 1 << i;
        }
    }
    if (ret == 0 && Bsum[0] > rest)
    {
        return 0;
    }
    return ret + 1;
}

signed main()
{
    cin >> N >> M >> K;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        if (i == 0)
            Asum[i] = A[i];
        else
            Asum[i] = Asum[i - 1] + A[i];
    }
    for (int i = 0; i < M; i++)
    {
        cin >> B[i];
        if (i == 0)
            Bsum[i] = B[i];
        else
            Bsum[i] = Bsum[i - 1] + B[i];
    }

    int ans = 0LL;
    for (int a = 0; a <= N; a++)
    {
        if (a == 0LL)
        {
            ans = max(ans, calcB(K));
        }
        else
        {
            if (K - Asum[a - 1] < 0LL)
                continue;
            ans = max(ans, a + calcB(K - Asum[a - 1]));
        }
    }

    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000
#define LLINF 1e18

// nCr
// combination
ull calc_combination(ull N, ull K) {
	if (K < 0 || N < K) return 0;
	ull ret = 1;
	for (ull i = 1; i <= K; ++i) {
		ret *= N--;
		ret /= i;
	}
	return ret;
}

void solve_abc_a() {
	ll n, m;
	ll x, y;
	//ll a, b, d;
	ll c;
	//char c;
	ll h, w;
	ll k;
	string s, t;
	ll l_ans = 0;
	string s_ans = "NG";
	ll l, r;

	cin >> n >> x >> y;

	l_ans = ceil((float)n / x) * y;


	cout << l_ans << "\n";

	return;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(7);

	solve_abc_a();

	return 0;
}


Measured memory_bytes: 3640
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')

S = input()

def kaibun(s):
    for i in range(len(s) // 2 + 1):
        if s[i] != s[-i - 1]:
            return False
    return True

N = len(S)
l = S[:(N - 1) // 2]
r = S[(N + 3) // 2 - 1:]
print('Yes' if kaibun(S) and kaibun(l) and kaibun(r) else 'No')

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

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

fn main() {
    input!{
        n: u64,
        d: u64,
        x: u64,
        a: [u64; n],
    }
    let mut ans = x;
    for a_ in a.iter() {
        ans += (d - 1) / a_ + 1;
    }

    println!("{}", ans)
}


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

int main(){
	// sengen
	int a,b,c,k;
	// nyuryoku
	cin >> a >> b >> c >> k;
	// keisan
	while(k > 0){
		if(a >= b){
			b *= 2;
			k--;
		}else if(b >= c){
			c *= 2;
			k--;
		}
		if(b > a && c > b){
			cout << "Yes" << endl;
			return 0;
		}
	}
	// syutsuryoku
	cout << "No" << endl;
}

Measured memory_bytes: 3592
using System;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            int maxi = 0;
            int sum = 0;

            for (int i = 0; i < n; i++)
            {
                var l = cin.ReadInt;
                sum += l;
                maxi = Max(maxi, l);
            }
            sum -= maxi;
            if (sum > maxi)
            {
                Console.WriteLine("Yes");
            }
            else
                Console.WriteLine("No");

            return;
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for (long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }
}



Measured memory_bytes: 11220
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = null;
		PrintStream out = null;
		try {
			sc = new Scanner(System.in);
			out = System.out;
			exec(sc, out);
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			if(out != null) {
				out.close();
			}
			if(sc != null) {
				sc.close();
			}
		}
		System.exit(0);
	}
	public static void exec(final Scanner sc, final PrintStream out) throws Exception{
		final int N = sc.nextInt();
		final long K = sc.nextLong();
		final int A[] = new int[N];
		final int cnt[][] = new int[N][2];

		final long mod = 1000*1000*1000+7;

		final int prev = 0;
		final int next = 1;
		for(int i=0;i<N;i++) {
			A[i] = sc.nextInt();
		}

		for(int i=0;i<N;i++) {
			for(int j=0;j<N;j++) {
				if(A[i] > A[j]) {
					if(i<j) {
						cnt[i][next]++;
					}else {
						cnt[i][prev]++;
					}
				}
			}
		}
		final long Sn = K*(K+1)/2;
		final long Sp = Sn - K;
		final long Snm = Sn % mod;
		final long Spm = Sp % mod;

		long sum = 0;
		for(int i=0;i<N;i++) {
			sum += cnt[i][next]*Snm;
			sum = sum % mod;
			sum += cnt[i][prev]*Spm;
			sum = sum % mod;
		}

		out.println(sum);

	}
}


Measured memory_bytes: 27076
#include<iostream>
#include<cmath>
using namespace std;
int n, s;
int main() {
	while (cin >> n) {
		s = 0;
		for (int i = 0; i < 31; i++) {
			if (n % 2 == 1) {
				if (s) { cout << ' '; }
				cout << pow(2, i); s++;
				n -= 1;
			}
			n /= 2;
		}
		cout << endl;
	}
}

Measured memory_bytes: 1272
#include <iostream>
#include <cctype>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <complex>
#include <cstring>
#include <set>
#include <map>
using namespace std;
#define loop(i,a,b) for(int i=a; i<int(b); i++)
#define rep(i,a) loop(i,0,a)

set<char> ok[256];
bool chk(string &s){
    rep(i,s.size()-1){
        if(ok[s[i]].count(s[i+1])==0){
            return false;
        }
    }
    return true;
}

int main(){
    string ks[3]={"ABC","DEF","GHI"};
    rep(i,3)rep(j,3){
        if(j-1>=0) ok[ks[i][j]].insert(ks[i][j-1]);
        if(j+1< 3) ok[ks[i][j]].insert(ks[i][j+1]);
        if(i-1>=0) ok[ks[i][j]].insert(ks[i-1][j]);
        if(i+1< 3) ok[ks[i][j]].insert(ks[i+1][j]);
    }

    string s;
    while(cin>>s){
        if(chk(s)) cout<<s<<endl;
    }
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

const ll MOD = 998244353;
const ll MAX = 200200;

long long fac[MAX], finv[MAX], inv[MAX];
// 前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1; // mod.MODにおける1,2,…,nの逆元
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD; // iの逆元をMOD/iの逆元を利用して求める
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数の計算
long long COM(int n, int k){
    if (n < 0 || k < 0 || n < k) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modpow(long long a, long long n, long long p) {
    long long res = 1;
    while (n) {
        if (n & 1) res = res * a % p;
        a = a * a % p;
        n >>= 1;
    }
    return res;
}

int main(){
    ll n, m, k; cin >> n >> m >> k;

    COMinit();
    ll ans = 0;
    rep(i,k+1){
        ll count = (COM(n-1,i)*modpow(m-1,n-1-i,MOD)%MOD)*m;
        ans += count;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8300
#include "bits/stdc++.h"
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
int main() {fio ;// remove during scanf
	int a, b;
	cin >> a >> b;
	bool h1 = a + b == 15;
	bool h2 = a * b == 15;

	if(h1 && !h2) {
		cout << '+';
	} else if(h2 && !h1) {
		cout << '*';
	} else {
		cout << 'x';
	}
    return 0;
}

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

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


int main() {
  int n;
  string s;
  cin >> n >> s;
  if (n % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  rep (i, n / 2) {
    if (s.at(i) != s.at(n / 2 + i)) {
      cout << "No" << endl;
      return 0; 
    }
  }
  cout << "Yes" << endl;

}



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

const int N_MAX = 100000;
typedef pair<string, int> P;

int main() {
  int n, q;
  queue<P> a;

  cin >> n >> q;
  for (int i = 0; i < n; ++i) {
    string s;
    int t;
    cin >> s >> t;
    a.push(P(s, t));
  }

  int b = 0;
  while (!a.empty()) {
    P p = a.front(); a.pop();
    if (p.second > q) {
      b += q;
      a.push(P(p.first, p.second - q));
    } else {
      b += p.second;
      cout << p.first << " " << b << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 6344
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

x, a, b = MAP()

if abs(x-a) < abs(x-b):
	print("A")
else:
	print("B")


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

int main(){
  int N,sumAlice=0,sumBob=0;
  cin >> N;
  vector<int>vec(N);
  
  for(int i=0; i<N ; i++){
    cin >> vec.at(i);}
  
  sort( vec.begin(), vec.end() );
  reverse( vec.begin(), vec.end() );
  
  for(int i=0; i<N ; i+=2){
      sumAlice += vec.at(i);
  }
  
  for(int i=1; i<N ; i+=2){
      sumBob += vec.at(i);
  }
  
  cout << sumAlice-sumBob << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int res = Math.max(a + b, Math.max(a - b, a * b));
        System.out.println(res);
    }
}


Measured memory_bytes: 23124
fun main(args: Array<String>) = yorukatsu15d()

fun yorukatsu15d() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map { it.toLong() }.toLongArray()

    var answer = 0L

    for (i in 0..62) {
        var zero = 0L
        var one = 0L
        for (a in aList) if ((a and 1) == 0L) zero++ else one++

        answer += (((1L shl i) % MOD * one) % MOD * zero) % MOD
        answer %= MOD

        for (j in aList.indices) aList[j] = aList[j] shr 1
    }

    println(answer)
}

private const val MOD = (1e9 + 7).toLong()


Measured memory_bytes: 112452
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;

  if(s.at(2)==s.at(3) && s.at(4)==s.at(5)) cout << "Yes" <<endl;
  else cout << "No" <<endl;
  
  
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <numeric>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>

///////////////////////////////////////////////////////////////
// namespace
///////////////////////////////////////////////////////////////
using namespace std;
// namespace mp = boost::multiprecision;

///////////////////////////////////////////////////////////////
// types
///////////////////////////////////////////////////////////////
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
// using mpi = mp::cpp_int;
// using mpf = mp::number<mp::cpp_dec_float<1024>>;

///////////////////////////////////////////////////////////////
// mod https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
///////////////////////////////////////////////////////////////
// ll MOD = 1000000007;
//
// ll mod(long long val) {
//     long long res = val % MOD;
//     if (res < 0) res += MOD;
//     return res;
// }
//
// ll modinv(ll a) {
//     ll b = MOD, u = 1, v = 0;
//     while (b) {
//         ll t = a / b;
//         a -= t * b; swap(a, b);
//         u -= t * v; swap(u, v);
//     }
//     u %= MOD;
//     if (u < 0) u += MOD;
//     return u;
// }
//
// const int MAX = -1;
// ll fac[MAX], finv[MAX], inv[MAX];
// void com_init() {  // initialize nCk table with O(N)
//     fac[0] = fac[1] = 1;
//     finv[0] = finv[1] = 1;
//     inv[1] = 1;
//     for (int i = 2; i < MAX; i++){
//         fac[i] = fac[i - 1] * i % MOD;
//         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
//         finv[i] = finv[i - 1] * inv[i] % MOD;
//     }
// }
// ll com(int n, int k){  // nCk
//     if (n < k) return 0;
//     if (n < 0 || k < 0) return 0;
//     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
// }

void sieve(vector<bool> &is_prime) {  // O(n log log n)
    int n = is_prime.size();
    for (int i = 0; i < n; ++i) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for (int i = 0; i < n; ++i) {
        if (!is_prime[i]) continue;
        for (int j = 2 * i; j < n; j += i) is_prime[j] = false;
    }
}

int main() {
    int N = 100005;
    vector<bool> is_prime(N + 5, false);
    sieve(is_prime);
    vector<int> v(N + 5, 0);
    for (int i = 1; i <= N; ++i) {
        v[i] += v[i-1];
        if (i % 2 == 1 && is_prime[i] && is_prime[(i + 1) / 2]) ++v[i];
    }
    int q; cin >> q;
    for (int i = 0; i < q; ++i) {
        int l, r; cin >> l >> r;
        cout << v[r] - v[l-1] << endl;
    }
    return 0;
}


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

class Test
{
    class Exam
    {
        public int m { get; set; }
        public int f { get; set; }
        public int r { get; set; }
    }

    static void Main()
    {
        int[] point = new int[3];
        List<Exam> seiseki = new List<Exam>();

        string ss;
        while ((ss = Console.ReadLine()) != "-1 -1 -1")
        {
            point = ss.Split().Select(int.Parse).ToArray();
            seiseki.Add(new Exam { m = point[0], f = point[1], r = point[2] });
        }

        foreach (Exam e in seiseki)
        {
            if (e.m == -1 || e.f == -1) Console.WriteLine("F");
            else if (e.m + e.f >= 80) Console.WriteLine("A");
            else if (e.m + e.f >= 65 && e.m + e.f < 80) Console.WriteLine("B");
            else if (e.m + e.f >= 50 && e.m + e.f < 65) Console.WriteLine("C");
            else if (e.m + e.f >= 30 && e.m + e.f < 50) { 
                if (e.r >= 50) Console.WriteLine("C");
                else Console.WriteLine("D");
            }
            else if (e.m + e.f <= 30) Console.WriteLine("F");
        }
     }
}


Measured memory_bytes: 18216
#include <iostream>
#include <vector>
using namespace std;
using Graph = vector<vector<int>>;
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true;
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v); // 再帰的に探索
    }
}

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    // 全頂点が訪問済みになるまで探索
    int count = 0;
    seen.assign(N, false);
    for (int v = 0; v < N; ++v) {
        if (seen[v]) continue; // v が探索済みだったらスルー
        dfs(G, v); // v が未探索なら v を始点とした DFS を行う
        ++count;
    }
    cout << count-1 << endl;
}

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

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

    int ans = 0;

    if (a < 0) {
        ans += (0 - a) * c;
        a = 0;
    }
    if (a == 0) {
        ans += d;
    }

    ans += (b-a) * e;
    cout << ans << endl;
}


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

int main(){

int N;
cin >> N;

long long mi =1000000000;

vector<long long> A(N);
      for(int i = 0; i < N; i++){ 
             
             cin >> A.at(i);
             
             mi = min(mi, A.at(i));
      }
long long ans = mi;
      for(int i = 0; i < N; i++){ 
            if (A.at(i) % ans != 0){
                  ans = A.at(i) % ans;
                  i = -1;
                  continue;
            }

      }

cout << ans << endl; 

}
          

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

int main(){
    int N; cin >> N;
    long long int ans = 0;
    map<string, long> m;
    for(int i=0; i < N; i++){
        string s; cin >> s;
        sort(s.begin(), s.end());
        if(m[s] == 0){
            m[s] = 1;
        } else {
            ans += m[s];
            m[s] += 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 11136
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define mkp make_pair
#define no {cout << "-1\n"; return;}

void solve() {
    int n, x, m, ans = 0;
    cin >> n >> x >> m;
    if (n <= m) {
        loop(i, n) {
            ans += x;
            x = x * x % m;
        }
    }
    else {
        map <int, int> was;
        int cnt = 0, fst = x;
        while (was.find(x) == was.end()) {
            was[x] = cnt++;
            x = x * x % m;
        }
        int len = cnt - was[x];
        int pos = was[x];
        n -= pos;
        loop(i, pos) {
            ans += fst;
            fst = fst * fst % m;
        }
        int cycle = 0;
        do {
            cycle += fst;
            fst = fst * fst % m;
        } while (fst != x);
        ans += n / len * cycle;
        n %= len;
        loop(i, n) {
            ans += x;
            x = x * x % m;
        }
    }
    cout << ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 6724
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  int N;
  cin>>N;
  vector<string> S(N);
  rep(i,N) cin>>S[i];

  sort(S.begin(),S.end());
  S.erase(unique(S.begin(),S.end()),S.end());

  cout<<S.size()<<endl;

  return 0;
}


Measured memory_bytes: 9520
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper


r = inp()
print('ABC' if r < 1200 else 'ARC' if r < 2800 else 'AGC')


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define bit(k) (1LL<<(k))
#define SUM(v) accumulate(all(v), 0LL)

typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
struct fast_ios{ fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }fast_ios_;

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

#define TOSTRING(x) string(#x)
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os  << "["; for(auto _: v) os << _ << ", "; os << "]"; return os; };
template <typename T> ostream &operator<<(ostream &os, set<T> &st) { os << "("; for(auto _: st) { os << _ << ", "; } os << ")";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair< T, U >& p){os << "{" <<p.first << ", " << p.second << "}";return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &mp){ os << "["; for(auto _: mp){ os << _ << ", "; } os << "]" << endl; return os; }

#define DUMPOUT cerr
void dump_func(){ DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) { DUMPOUT << head; if (sizeof...(Tail) > 0) { DUMPOUT << ", "; } dump_func(std::move(tail)...); }

#ifdef DEBUG
#define dbg(...) dump_func(__VA_ARGS__)
#define dump(...) DUMPOUT << string(#__VA_ARGS__) << ": "; dump_func(__VA_ARGS__)
#else
#define dbg(...)
#define dump(...)
#endif

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const long double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/


int main() {
    int N;
    cin >> N;
    vector<ll> v, w;
    rep(i,N){
        int x, y;
        cin >> x >> y;
        v.emplace_back(x-y);
        w.emplace_back(x+y);
    }
    sort(all(v));
    sort(all(w));
    dump(v);
    dump(w);
    ll maxx = 0;
    chmax(maxx, v.back() - v[0]);
    chmax(maxx, w.back() - w[0]);
    cout << maxx << endl;
}


Measured memory_bytes: 6688
#include <bits/stdc++.h>
#define pb              push_back
#define ll              long long int
#define scd(a)          scanf("%d",&a)
#define mp(a,b)         make_pair(a,b)
#define scl(w)          scanf("%I64d",&w)
#define scdd(a,b)       scanf("%d %d",&a,&b)
#define srt(a)          sort(a.begin(),a.end())
#define rsrt(a)         sort(a.rbegin(),a.rend())
#define scll(a,b)       scanf("%I64d %I64d",&a,&b)
///4direction ->        int del_x[]={-1,0,1,0},del_y[]={0,1,0,-1};
#define input(v,n)      for (int i=0;i<n;i++){int a;cin >> a;v.push_back(a);}
#define inputll(v,n)    for (ll i=0;i<n;i++){ll a;cin >> a;v.push_back(a);}
#define vii             vector < int >
#define vll             vector < ll >
#define pii             pair < int , int >
#define pll             pair < ll , ll >
#define show(x)         cout << #x << " : " << x << endl
#define mk              make_pair
#define inf             10000000000000016

#define maxn            1000006

using namespace std;

ll A[maxn] , B[maxn];

int main()
{
      ll n,m,k;
      cin >> n >> m >> k;

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

      for (int i=1 ; i<=m;i++){
            cin >> B[i];
            B[i]+=B[i-1];
      }

      ll ans = 0;

      for (int i=0 ; i<=n;i++){
            ll temp = k - A[i];
            if (temp<0)break;

            ll b = 0 , e = m , cnt = 0;
            while(b<=e){

                  ll mid = (b+e)/2;
                  if (B[mid]<=temp){
                        cnt = max(cnt,mid);
                        b = mid+1;
                  }
                  else e = mid-1;
            }
            ans = max(ans,i+cnt);
      }

      cout << ans << endl;


      return 0;
}


Measured memory_bytes: 6740
//#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cstring>
#include <cassert>

using namespace std;

#ifdef LOCAL_DEBUG
#include <local_debug.h>
#define DEBUG(x...) cerr << #x << " = "; DBG::_print(x)
#else
#define DEBUG(x...)
#endif

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

int gcd(int a, int b) {
   if (a < 0) a = -a;
   if (b < 0) b = -b;
   if (a < b) swap(a, b);
   while (b > 0) {
      int t = b;
      b = a % b;
      a = t;
   }
   return a > 0 ? a : 1;
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   int K;
   cin >> K;

   llong res = 0;
   FOR(a, 1, K) FOR(b, 1, K) FOR(c, 1, K)
      res += gcd(a, gcd(b, c));

   cout << res << '\n';

   return 0;
}


Measured memory_bytes: 3592
def LI(): return list(map(int,input().split()))
N,M = LI()
ks = [LI() for _ in range(M)]
p = LI()
ans = 0
for i in range(2**N):
    bit = [i>>j & 1 for j in range(N)]
    for j,x in enumerate(ks):
        k,*s = x
        if p[j]!=sum([bit[y-1] for y in s])%2:
            break
    else:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef std::pair<long long, long long> PAIR;
int main(int argc, char* argv[])
{
	//ABC166 D
	long long x;
	vector<pair<long long,long long>> s;
	long long a = 0, b = 0;
	// X
	// A5乗 - B5乗 = X
	// になる A と B を返す

	cin >> x;

	s.push_back(PAIR(0, 0));
	long long i = 1;
	while (/*2147483647 >= i * i * i * i * i*/2000 > i) {
		s.push_back(PAIR(i, i * i * i * i * i));
		s.push_back(PAIR((-i), (-i) * (-i) * (-i) * (-i) * (-i)));
		i++;
	}

	for (vector<pair<long long, long long>>::iterator ita = s.begin(); ita != s.end(); ita++) {
		for (vector<pair<long long, long long>>::iterator itb = s.begin(); itb != s.end(); itb++) {
			if (ita->second - itb->second == x) {
				a = ita->first;
				b = itb->first;
				goto AAA;
			}
		}
	}

AAA:
	cout << a << " " << b;

	return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
namespace mp = boost::multiprecision;
using i64 = int64_t;
using f80 = __float80;
using u64 = uint_fast64_t;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr u64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N;
  cin >> N;
  vector<vector<pair<int,int>>> G(N);
  i64 a, b, c;
  rep(i, N-1){
    cin >> a >> b >> c;
    a--;
    b--;
    G.at(a).emplace_back(make_pair(b,c));
    G.at(b).emplace_back(make_pair(a,c));
  }
  
  i64 Q, K;
  cin >> Q >> K;
  K--;

  vi x(Q);
  vi y(Q);
  rep(i,Q){
    cin >> x[i] >> y[i];
    x[i]--;
    y[i]--;
  }

  vi d(N,INF);
  d.at(K) = 0;

  queue<i64> que;
  que.push(K);
  while(!que.empty()){
    i64 cur = que.front();
    que.pop();
    for(auto &p:G.at(cur)){
      if(d.at(p.first)<INF) continue;
      d.at(p.first) = d.at(cur) + p.second;
      que.push(p.first);
    }
  }

  rep(i,Q){
    cout << d.at(x[i]) + d.at(y[i]) << "\n";
  }
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 10740