akhauriyash/Code-Regression huggingface dataset:
import Foundation

let (x, n) = readInts().mapToTuple()
let ps = Set(readInts())
let r = Set(0...101)
    .symmetricDifference(ps)
    .sorted(by: <)
    .sorted { abs($0 - x) < abs($1 - x) }
print(r.first!)

// MARK: -----------------------------------------------------------------------


func readInt() -> Int {
    Int(readLine()!)!
}

func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}

extension Collection {
    func mapToTuple() -> (Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!, i.next()!)
    }
}

struct DP<Argument: Hashable, Element> {
    var dictionary = [Argument: Element]()
    
    var expression: (Argument, (Argument) -> Element) -> Element
    
    init(expression: @escaping (_ argument: Argument, _ note: (Argument) -> Element) -> Element) {
        self.expression = expression
    }
    
    subscript(_ argument: Argument) -> Element {
        mutating get {
            if let note = dictionary[argument] {
                return note
            } else {
                let result = expression(argument) { self[$0] }
                dictionary[argument] = result
                return result
            }
        }
    }
}


Measured memory_bytes: 13796
#include <stdio.h>
#include <stdlib.h>


#define	ll_int	long long int
#define	BUCKET_SIZE	10000000
#define	SUB_SIZE	100


int ELEMENT_N;

typedef struct data_t{
	ll_int num;
	int n;
	struct data_t *next;
} DATA_T;

DATA_T **S;


// ハッシュテーブルの初期化
void Init()
{
	int i;


	for(i = 0; i < BUCKET_SIZE; i++)
		S[i] = NULL;
}


// ハッシュ算出
ll_int Hash(ll_int num)
{
	return num / SUB_SIZE;
}


// 受け取った数値を探索
DATA_T *Find(ll_int num)
{
	ll_int h;
	DATA_T *p;


	h = Hash(num);

	for(p = S[h]; p != NULL; p = p->next){
		if(num == p->num)
			return p;
	}

	return NULL;
}


// 該当する添え字の箱へ昇順になるように数値を挿入
void Insert(ll_int num)
{
	ll_int h;
	DATA_T *p;
	DATA_T *i, *j;


	ELEMENT_N++;

	if(( p = Find(num) )){
		p->n++;
		return;
	}


	/* 挿入処理(比較していき、該当する場所へ突っ込む) */
	if( ( p = (DATA_T *)malloc(sizeof(DATA_T)) ) == NULL){
		printf("malloc error\n");
		exit(1);
	}

	p->num = num;
	p->n = 1;
	h = Hash(num);

	if(S[h] == NULL){
	// 該当する添え字の箱が空の場合
		S[h] = p;
		p->next = NULL;
	}else if(num < S[h]->num){
	// 該当する添え字の先頭に挿入
		p->next = S[h];
		S[h] = p;
	}else{
	// 先頭以降への挿入
		for(i = S[h], j = i->next; j != NULL; i = j, j = j->next){
			if(i->num < num && num < j->num){
				i->next = p;
				p->next = j;
				break;
			}
		}

		if(j == NULL){
		// 最後尾に突っ込む
			i->next = p;
			p->next = j;
		}
	}
}


// 受け取った数値の全削除
void Delete(ll_int num)
{
	DATA_T *p, *q;
	ll_int h;


	// 削除したい数値がないなら戻る
	if(Find(num) == NULL)
		return;


	h = Hash(num);
	p = S[h];

	// 先頭にある場合の処理
	if(num == p->num){
		S[h] = p->next;
		ELEMENT_N -= p->n;
		free(p);
		return;
	}

	// 先頭以降の処理
	for(q = p->next;; p = q, q = q->next){
		if(num == q->num){
			p->next = q->next;
			ELEMENT_N -= q->n;
			free(q);
			break;
		}
	}

}


// lとrを基準にハッシュテーブルの添え字を計算、条件にあった数値を出力
void Dump(ll_int l, ll_int r)
{
	DATA_T *p;
	ll_int start_h, end_h;
	ll_int i;
	int j;


	start_h = Hash(l);
	end_h = Hash(r);

	for(i = start_h; i <= end_h; i++){
		for(p = S[i]; p != NULL; p = p->next){
			if(r < p->num)
				return;

			if(l <= p->num && p->num <= r)
				for(j = 0; j < p->n; j++)
					printf("%lld\n", p->num);
		}
	}
}


int main()
{
	int q;
	int query;
	ll_int num, l, r;
	DATA_T *p;
	int i;


	ELEMENT_N = 0;
	S = (DATA_T **)malloc(sizeof(DATA_T *) * (BUCKET_SIZE + 1));

	scanf("%d", &q);

	for(i = 0; i < q; i++){
		scanf("%d", &query);

		if(query == 0){
		// insert
			scanf("%lld", &num);
			Insert(num);
			printf("%d\n", ELEMENT_N);
		}else if(query == 1){
		// find
			scanf("%lld", &num);
			if(( p = Find(num) ))
				printf("%d\n", p->n);
			else
				printf("0\n");
		}else if(query == 2){
		// Delete
			scanf("%lld", &num);
			Delete(num);
		}else if(query == 3){
		// Dump
			scanf("%lld %lld", &l, &r);
			Dump(l, r);
		}
	}

	return 0;
}


/*
	Set_Range_Searchを改良
*/


Measured memory_bytes: 82384
#include <stdio.h>
#include <string.h>

int main(void){
  char c;
  int sn=0;
  int i,t,state=0;
  while(scanf("%c",&c)!=EOF){
    if(state==0){    //??°????????§????????????
      if(c>=48&&c<=57){
	state++;
	t=c-48;
      }
    }else{
      if(c>=48&&c<=57){
	t*=10;
	t+=c-48;
      }else{
	state=0;
	sn+=t;
	//printf("sn:%d\n",sn);
      }
      //printf("//%d\n",t);
    }
  }
  printf("%d\n",sn);
  return 0;
}

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

# define x first
# define y second
# define mp make_pair
// everything goes according to my plan
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right

# ifdef Local
# define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
# else
# define debug(...) (__VA_ARGS__)
# define cerr if(0)cout
# endif

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") {
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}


int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  int n;
  cin >> n;
  int a[3*n];
  for (int i = 0; i < 3*n; i++)
      cin >> a[i];
  sort (a, a + 3*n);
  ll sum = 0;
  for (int i = 3*n-2; i > n-1; i-=2)
      sum += a[i];
  cout << sum;

  return 0;
}






// Coded by Z..

Measured memory_bytes: 1408
#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;
  }
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define ins insert
#define rs (x<<1|1) 
#define mp make_pair
#define pb push_back
#define sqr(x) ((x)*(x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x)&(-x))
#define SZ(x) (int((x).size()))
#define All(x) (x).begin(),(x).end()
#define ms(x,y) memset(x,y,sizeof (x))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)]) 
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
template<class T>inline void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
inline int getgcd(int x,int y){if(!x)return y;return getgcd(y%x,x);}
inline int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=(ll)x*x%p)if(k&1)res=(ll)res*x%p;return res;}
const double pi=acos(-1);	
inline void judge(){
	freopen("input.txt","r",stdin);
} 
//********************************head*************************************
const int maxn=1e6+5;
int n;
int m,q[maxn];
int a[maxn];
ll s[maxn],f1l[maxn],f1r[maxn],g[maxn],f2[maxn],hhy[maxn];
db slope(int k,int j){
	return 1.*(g[k]-g[j])/(k-j);
}
void push(int i){
	while(m>1&&slope(i,q[m])>slope(q[m],q[m-1]))m--;
	q[++m]=i;
}
void pop(int i){
	while(m>1&&slope(q[m],q[m-1])<2*i)m--;
}
ll S(int x){
	return 1ll*x*(x+1)/2;
}
void work(ll *f){
	rep(i,1,n)s[i]=s[i-1]+a[i];
	q[m=1]=0;
	rep(i,1,n){
		pop(i);
		int j=q[m];
		f[i]=max(f[i-1],f[j]-(s[i]-s[j])+S(i-j));
		g[i]=2*f[i]+1ll*i*(i-1)+2*s[i];
		push(i);
	}
}
void solve(int l,int r,int tp){
	if(l==0&&r==n)rep(i,1,n)s[i]=s[i-1]+a[i];
	if(l==r){
		f2[l]=max(f2[l],f1l[l-1]+f1r[l+1]+1-a[l]);
		return;
	}
	int mid=(l+r-tp)>>1;
	solve(l,mid,tp);
	solve(mid+1,r,tp);
	q[m=1]=0;
	rep(i,l,mid){
		g[i]=2*f1l[i]+1ll*i*(i-1)+2*s[i];
		push(i);
	}
	rep(i,mid+1,r){
		pop(i);
		int j=q[m];
		hhy[i]=f1l[j]-(s[i]-s[j])+S(i-j)+f1r[i+1];
	}
	per(i,r-1,mid+1)hhy[i]=max(hhy[i],hhy[i+1]);
	rep(i,mid+1,r)f2[i]=max(f2[i],hhy[i]);
}
int main(){
	read(n);
	rep(i,1,n)read(a[i]),f2[i]=-1e18;
	work(f1l);
	reverse(a+1,a+n+1);
	work(f1r);
	reverse(a+1,a+n+1);
	reverse(f1r+1,f1r+n+1);
	solve(0,n,0);
	reverse(a+1,a+n+1);
	swap(f1l,f1r);
	reverse(f2+1,f2+n+1);
	reverse(f1l+1,f1l+n+1);
	reverse(f1r+1,f1r+n+1);
	solve(0,n,0);
	reverse(a+1,a+n+1);
	swap(f1l,f1r);
	reverse(f2+1,f2+n+1);
	reverse(f1l+1,f1l+n+1);
	reverse(f1r+1,f1r+n+1);
	int Q;read(Q);
	while(Q--){
		int x,y;read(x);read(y);
		printf("%lld\n",max(f1l[x-1]+f1r[x+1],f2[x]+a[x]-y));
	}
	return 0;
}

Measured memory_bytes: 41472
from sys import stdin
input = stdin.readline

H, W, M = map(int, input().split())

h = [0] * H
w = [0] * W
bomb = set([])

for _ in range(M):
    i, j = map(int, input().split())
    h[i - 1] += 1
    w[j - 1] += 1
    bomb.add((i - 1, j - 1))

max_h = max(h)
max_w = max(w)

h_ind = []
w_ind = []


# print(h)
# print(w)


for i, mh in enumerate(h):
    if mh == max_h:
        h_ind.append(i)

for i, mw in enumerate(w):
    if mw == max_w:
        w_ind.append(i)

# print(h_ind)
# print(w_ind)

for ih in h_ind:
    for iw in w_ind:
        if (ih, iw) not in bomb:
            print(max_h + max_w)
            exit()

print(max_h + max_w - 1)


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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> l(n);
  rep(i,n) cin >> l[i];

  vector<int> j(n);
  int sum = 0;
  rep(i,n) {
    j[i] = sum + l[i];
    sum = j[i];
  }
  j.insert(j.begin(), 0);
  int ans = 0;
  rep(i,n+1){
    if(j[i] <= x) ans++;
  }

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

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    Section[] sections = new Section[M];
    for (int i = 0; i < M; i++) {
      int a = scanner.nextInt();
      int b = scanner.nextInt();
      sections[i] = new Section(a, b);
    }
    Arrays.sort(sections, Comparator.comparingInt(section -> section.end));

    int cnt = 0;
    int right = 0;
    for (Section sec : sections) {
      if (sec.start >= right) {
        cnt++;
        right = sec.end;
      }
    }
    System.out.println(cnt);
  }

  private static class Section {
    private final int start;
    private final int end;

    private Section(int start, int end) {
      this.start = start;
      this.end = end;
    }
  }
}


Measured memory_bytes: 90212
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <complex>
#include <tuple>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repri(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define repr(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define reprs(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define LF "\n"

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;
typedef vector<int> VI;
typedef vector<ll> VL;

/*
 * @
 * @brief	pair用の比較演算子（第二要素での比較）
 * 	std::sort(v.begin(), v.end(), sort_pair_second<T1, T2>());
 *  std::sort(v.begin(), v.end(), sort_pair_second<T1, T2, std::greater<int> >());
 */
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

void Main() {
	ll n;
	vector<PLL> job;
	cin >> n;
	rep(i,n) {
		ll a, b;
		cin >> a >> b;
		job.push_back({a,b});
	}

	sort(job.begin(), job.end(), sort_pair_second<ll, ll>());
	// rep(i,n) {
	// 	cout << job[i].first << " " << job[i].second << LF;
	// }

	ll cur=0;
	rep(i,n) {
		cur+=job[i].first;
		if (cur > job[i].second) {
			cout << "No\n";
			return;
		}
	}

	cout << "Yes\n";
	return;
}

int main(){
	FAST;
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 6256
using System;
using System.Collections.Generic;
using System.Linq;
 
class Hello
{
    
    static void Main()
    {
        int a=int.Parse(Console.ReadLine());
        string [] str=Console.ReadLine().Split(' ');
        Array.Reverse(str);
        Console.Write(str[0]);
        for(int i=1;i<str.Length;i++)Console.Write(" {0}", str[i]);
        Console.WriteLine();
    }
}


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

int main(){
  long long a,b,c;
  cin >> a >> b >> c;
  
  if(a%2==0 || b%2==0 || c%2==0){
    cout << 0 << endl;
    return 0;
  }
  
  if(b<c)
    swap(b,c);
  if(a<b)
    swap(a,b);
  
  cout << b*c << endl;
  
  return 0;
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 1050000;

/* ...o(^-^)o... */

lint arr[MAX];

struct rmq{
    int n;
    rmq(int n_){
        n = 2;
        while(n < n_) n *= 2;
        rep(i, n*2) arr[i] = 0;
    }
    void update(int k, lint a){
        k += n - 1;
        arr[k] = a;
        while(k > 0){
            k = (k - 1) / 2;
            arr[k] = arr[k * 2 + 1] | arr[k * 2 + 2];
        }
    }
    lint query_(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return arr[k];
        else{
            lint vl = query_(a, b, k * 2 + 1, l, (l + r) / 2);
            lint vr = query_(a, b, k * 2 + 2, (l + r) / 2, r);
            return vl | vr;
        }
    }
    lint query(int a, int b){
        return query_(a, b, 0, 0, n);
    }
};


int main(){
    int n; string s; int q; cin >> n >> s >> q;
    rmq Q = rmq(n);

    rep(i, n){
        lint l = (1LL << (s[i] - 'a'));
        Q.update(i, l);
    }

    rep(p, q){
        int a; cin >> a;
        if(a == 1){
            int i; char c; cin >> i >> c; i--;
            lint l = (1LL << (c - 'a'));
            Q.update(i, l); 
        }else{
            int l, r; cin >> l >> r; l--;
            lint res = Q.query(l, r);
            out(bit_c(res));
        }
    }
}

Measured memory_bytes: 9092
a, b, c = map(int, input().split())
n = max(a, b, c)
if (n*3 - sum([a, b, c])) % 2 == 0:
    ans = (n*3 - sum([a, b, c])) / 2
else:
    ans = (n*3 - sum([a, b, c])) / 2 + 2

print(int(ans))


Measured memory_bytes: 38256
import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int N=sc.nextInt();
        int K=sc.nextInt();
        int p[]=new int[N];
	int ans=0;
	for(int i=0; i<N; i++){
	    p[i]=sc.nextInt();
	}

	Arrays.sort(p);
	for(int i=0; i<K; i++){
	    ans+=p[i];
	}
	System.out.println(ans);
    }
}


Measured memory_bytes: 38476
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int n;
    scanf("%d", &n);

    vector<int> cnt(n+1);
    int i, j, k;
    for (i = 1; i <= 100; i++) {
        for (j = 1; j <= 100; j++) {
            for (k = 1; k <= 100; k++) {
                int tmp = i * i + j * j + k * k + i*j + j*k + k*i;
                if (tmp <= n) cnt[tmp]++;
            }
        }
    }
    for (i = 1; i <= n; i++) {
        printf("%d\n", cnt[i]);
    }

    return;
}

int main()
{
    solve();
    return 0;
}


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

int main(){
  int n, r;
  cin >> n >> r;
  
  if(n<10)
    cout << r + 100 * (10-n) << endl;
  else cout << r << endl;
  
}

Measured memory_bytes: 256
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <stack>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
#include <iterator>
#include <cstring>
#include <cstdlib>

using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll> point;
typedef pair<int, int> pointI;
 
#define PI 3.1415926535897932384626433832795
 
const ll mod=1000000007LL;
const ll top=10000000047;
vector<ll> primes;
 
ll stupid_pow(ll base, int e) {
	ll ans=1;
	while (e>0) ans*=base, e--;
	return ans;
}
 
ll compute_norm(ll n) {
	ll i=1, ans=n;
	while (stupid_pow(i, 3)<=n) {
		ll tmp=stupid_pow(i, 3);
		if (n%tmp==0) ans=n/tmp;
		i++;
	}
	return ans;
}
 
bool is_square(ll n, int left, int right) {
	if (left+1==right) return primes[left]*primes[left]==n;

	int mid=(left+right)/2;
	if (primes[mid]*primes[mid]<=n) return is_square(n, mid, right);
	else return is_square(n, left, mid);
}
 
ll compute_pair(ll n) {
	ll ans=1;
	for (int i=0; primes[i]<2500; i++) {
		if (n%primes[i]!=0) continue;
		int e=0;
		while (n%primes[i]==0) e=(3+e-1)%3, n/=primes[i];
		ans*=stupid_pow(primes[i], e);
	}
	if (is_square(n, 0, primes.size())) ans*=sqrt(n);
	else ans*=n*n;
	return ans;
}
 
short tmp[100047];

int main() {
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vector<ll> input(n); for (int i=0; i<n; i++) cin>>input[i];
    primes.reserve(10000);
 
    for (int i=2; i<100047; i++) {
    	if (tmp[i]==0) {
    		primes.emplace_back(i);
    		for (int j=1; i*j<100047; j++) tmp[i*j]=1;
    	}
    }
 
    bool inserted_one=false;
    map<point, int> mmap;
    int ans=0;
 
    for (int i=0; i<n; i++) {
    	ll pr=compute_pair(input[i]), nm=compute_norm(input[i]);
    	if (pr==1) {
    		if (inserted_one==false) ans++, inserted_one=true;
    	}
    	else mmap[point(pr, nm)]++;
    }

    for (map<point, int>::iterator i1=mmap.begin(); i1!=mmap.end(); i1++) {
    	map<point, int>::iterator i2=mmap.find(point(i1->first.second, i1->first.first));
    	if (i2==mmap.end()) ans+=i1->second;
    	else if (i1->second==i2->second) {
    		if (i1->first.first>i2->first.first) ans+=i1->second;
    	}
    	else if (i1->second>i2->second) ans+=i1->second;
    }
 
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 7680
#include <stdio.h>

int main(void)
{
	int a,b,c,d,max,min,center;
	
	max=0;
	min=101;
	center=0;
	
	scanf("%d %d %d %d",&a,&b,&c,&d);
	
	
	int array[3]={a,b,c};
	
	if((a>c&&a-c<=d)||(a<c&&c-a<=d)){
		printf("Yes\n");
	}else{
		for(int i=0;i<3;i++){
		if(array[i]>max){
			max=array[i];
		}
		if(array[i]<min){
			min=array[i];
			}
		}
	
		for(int i=0;i<3;i++){
			if((array[i]!=max&&array[i]!=min)||(a==b&&a==c)){
				center=array[i];
			}
		}
		if(max-center<=d&&center-min<=d){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}
	return 0;
}
	

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
const int N = 1e5 + 5;
int main()
{
    int n,k;
    long long sum = 0;
    cin>>n>>k;
    int a[n];
    for(int i = 0; i < n; ++i)
        cin>>a[i];
    sort(a,a+n);
    for(int i = 0; i < (n - k); ++i)
        sum += a[i];
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1024
import math

N = int(input())
ans = int(0)
s = math.ceil(math.log10(N+1))


if s == 1:
    ans = N
elif s==2:
    ans = 9
elif s==3:
    ans = (N//100-1)*100+N%100+10
elif s==4:
    ans = 909
elif s==5:
    ans = (N//10000-1)*10000+N%10000+910
elif s==6:
    ans = 90909


print(ans)

Measured memory_bytes: 3060
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
 
#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl
 
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 100005;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	char c;
	cin>>c;
	c++;
	cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
n = input()
t, a = map(int, raw_input().strip().split())
arr = map(int, raw_input().strip().split())

ans = int(1e20)
pans = 0
for i in xrange(n):
    x = arr[i]
    add = t - x * 0.006
    diff = abs(add - a)
    if diff < ans:
        ans = diff
        pans = i

print pans + 1


Measured memory_bytes: 2692
// -*- coding:utf-8-unix -*-

use proconio::input;

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

    let mut is_white = vec![vec![true; w]; h];
    for _ in 0..n {
        input! {
            x: usize,
            y: usize,
            a: u8,
        }

        match a {
            1 => {
                for i in 0..h {
                    for j in 0..x {
                        is_white[i][j] = false;
                    }
                }
            },
            2 => {
                for i in 0..h {
                    for j in x..w {
                        is_white[i][j] = false;
                    }
                }
            },
            3 => {
                for i in 0..y {
                    for j in 0..w {
                        is_white[i][j] = false;
                    }
                }
            },
            4 => {
                for i in y..h {
                    for j in 0..w {
                        is_white[i][j] = false;
                    }
                }
            },
            _ => unreachable!(),
        }
    }

    let ans = is_white.iter().fold(0, |acc, row| {
        acc + row.iter().filter(|&p| *p == true).count()
    });
    println!("{}", ans);
}


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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int64_t a,int64_t b){return a/gcd(a, b)*b;}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
// }

int main()
{
	int n, m, a, b;
	vector<int> one_to;
	vector<int> to_last;

	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> a >> b;
		if (a == 1)
			one_to.push_back(b);
		if (b == n)
			to_last.push_back(a);
	}
	if (one_to.size() == 0 || to_last.size() == 0)
	{
		cout << "IMPOSSIBLE" << endl;
		return (0);
	}
	sort(one_to.begin(), one_to.end());
	sort(to_last.begin(), to_last.end());
	int j = 0;
	for (int i = 0; i < to_last.size(); i++)
	{
		while (j < one_to.size() && one_to[j] < to_last[i])
			j++;
		if (one_to[j] == to_last[i])
		{
			cout << "POSSIBLE" << endl;
			return (0);
		}
	}
	cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 4268
import java.util.*;

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


        int n = sc.nextInt();
        int k = sc.nextInt();
        int r = sc.nextInt();
        int s = sc.nextInt();
        int p = sc.nextInt();
        char[] t = new char[n];
        char[] output = new char[n];
        t = sc.next().toCharArray();
        output = t.clone();

        int ans = 0;

        for (int i=0; i<k; i++){
            if (t[i]=='r'){
                ans += p;
                output[i] = 'p';
            }else if (t[i]=='s'){
                ans += r;
                output[i] = 'r';
            }else {
                ans += s;
                output[i] = 's';
            }
        }
//        System.out.println(ans);

        for (int i=k; i<n; i++){
            if (t[i]=='r'){
                if (output[i-k]=='p'){
                    output[i] = '*';
                }else {
                    output[i] = 'p';
                    ans += p;
                }
            }else if (t[i]=='s'){
                if (output[i-k]=='r'){
                    output[i] = '*';
                }else {
                    output[i] = 'r';
                    ans += r;
                }
            }else {
                if (output[i-k]=='s'){
                    output[i] = '*';
                }else {
                    output[i] = 's';
                    ans += s;
                }
            }
        }
//        System.out.println(t[1]);
//        System.out.println(output[1]);
        System.out.println(ans);

    }
}

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

using namespace std;



int main() {

    string s;
    cin >> s;
    string result = "";
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '0' || s[i] == '1') {
            result += s[i];
        }
        else {
            result = result.substr(0, result.length()-1);
        }
    }
    cout << result;

    return 0;
}



Measured memory_bytes: 3580
using System;    
     
class sample13{    
    static void Main(string[] args){
        int result = 0 ;
        int remainder = 0;
        decimal fresult = 0;
        int[] int_number = new int[2];
        string[] str_number = Console.ReadLine().Split(' '); 
        
        //入力された数字をintへ変換
        for(int i = 0 ; i < 2; i++){
                    int_number[i] = int.Parse(str_number[i]);
        }
        
        //バリデーション
        if(int_number[0] < 1 || int_number[1] < 1 || int_number[0] > 1000000000 || int_number[1] > 1000000000 ){
            
                    Console.WriteLine("入力した値は範囲外です。");
                    Environment.Exit(0);
        } 
                
        //計算
        result = int_number[0] /int_number[1];
        remainder = int_number[0] %int_number[1];
        fresult = (decimal)int_number[0] /int_number[1];
        
        Console.WriteLine("{0} {1} {2}",result,remainder,fresult);
    }    
}  


Measured memory_bytes: 18056
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;


int N;
vector<ll> dat;

void init(int n){
  N = 1;
  while(N < n)  N *= 2;
  dat.resize(2 * N, 0);
}

ll query(int a, int b, int l, int r, int k){
  if(r <= a || b <= l) return 0;
  if(a <= l && r <= b) return dat[k];

  int m = (l + r) / 2;
  ll vl = query(a, b, l, m, k * 2 + 1);
  ll vr = query(a, b, m, r, k * 2 + 2);
  return max(vl, vr);
}

void update(int p, ll x, int l, int r, int k){
  if(p < l || r <= p) return;
  if(r - l == 1){
    dat[k] = x;
    return;
  }
  
  int m = (l + r) / 2;
  if(l <= p && p < m) update(p, x, l, m, k * 2 + 1);
  if(m <= p && p < r) update(p, x, m, r, k * 2 + 2);
  dat[k] = max(dat[k * 2 + 1], dat[k * 2 + 2]);
}


ll calc(const vector<int> &x){
  int n = x.size();  
  vector<int> y = x;
  vector<int> ind;
  
  sort(ALL(y));
  REP(i, x.size()) ind.push_back(lower_bound(ALL(y), x[i]) - y.begin());
  init(n);

  
  REP(i, n){
    ll M = query(0, ind[i], 0, N, 0);
    update(ind[i], M + x[i], 0, N, 0);
  }

  return query(0, N, 0, N, 0);
}


int main(){
  
  int n;
  cin >> n;
  
  vector<int> x(n);
  
  ll S = 0;

  REP(i, n){
    cin >> x[i];
    S += x[i];
  }

  cout << S - calc(x) << endl;
  return 0;
}

Measured memory_bytes: 4440
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
using namespace std;
const int N=200010;
int a[N],b[N],n;
int main()
{
    IO;
    int T=1;
    //cin>>T;
    while(T--)
    {
        cin>>n;
        for(int i=1;i<=n;i++) cin>>a[i];
        for(int i=1;i<=n;i++) cin>>b[i];
        reverse(b+1,b+1+n);
        vector<int> p,q;
        int val=0,cnt=0;
        for(int i=1;i<=n;i++)
        {
            if(a[i]!=b[i]) continue;
            cnt++;
            p.push_back(i);
            val=b[i];
        }
        for(int i=1;i<=n;i++)
        {
            if(!cnt) break;
            if(a[i]==b[i]) continue;
            if(a[i]!=val&&b[i]!=val)
            {
                cnt--;
                q.push_back(i);
            }
        }
        if(cnt) return cout<<"No\n",0;
        for(int i=0;i<q.size();i++) swap(b[p[i]],b[q[i]]);
        cout<<"Yes\n";
        for(int i=1;i<=n;i++) cout<<b[i]<<' ';
        cout<<'\n';
    }
    return 0;
}


Measured memory_bytes: 5912
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int GCD(int m,int n){
	int remain;
	if((remain = m % n) == 0)return n;
	else return GCD(n,remain);
}

int main(){
	int n;
	cin >> n;
	ll k,a[n];
	cin >> k;
	REP(i,n) cin >> a[i];
	if(n == 1){
		if(k == a[0]) cout << "POSSIBLE" << endl;
		else cout << "IMPOSSIBLE" << endl;
		return 0;
	}
	ll ans = a[0],mx = a[0];
	for(int i = 1; i < n; i++){
		ans = GCD(ans, a[i]);
		mx = max(mx, a[i]);
	}
	if(k % ans == 0 && k <= mx) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VL = vector<LL>;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define f first
#define s second
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define FILL(a, b) memset(a, b, sizeof(a))

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

const int MOD = 998244353;

vector<vector<pair<int, __float128>>> g; 

__float128 dist(PII a, PII b)
{
	return sqrt((LL)(a.f - b.f) * (a.f - b.f) + (LL)(a.s - b.s) * (a.s - b.s));
}

int main()
{
    ios::sync_with_stdio(false);
    PII s, t;
    cin >> s.f >> s.s >> t.f >> t.s;
    int n;
    cin >> n;
    g.resize(n + 2);
    VI x(n + 2), y(n + 2), r(n + 2);
    for (int i = 0; i < n; ++i)
    {
    	cin >> x[i] >> y[i] >> r[i];
    }
    x[n] = s.f,    y[n] = s.s;
    x[n + 1] = t.f, y[n + 1] = t.s;

    for (int i = 0; i < n + 2; ++i)
    {
    	for (int j = i + 1; j < n + 2; ++j)
    	{
    		__float128 d = dist({x[i], y[i]}, {x[j], y[j]});
    		d = max((__float128)0.0, d - r[i] - r[j]);
    		g[i].EB(j, d);
    		g[j].EB(i, d);
    	}
    }

    vector<__float128> dist(n + 2, 1e18);
    dist[n] = 0;
    set<pair<__float128, int>> que;
    que.emplace(dist[n], n);
    while(!que.empty())
    {
    	auto kek = *que.begin();
    	__float128 cur_d = kek.f;
    	int v = kek.s;
    	que.erase(que.begin());
    	for (auto el : g[v])
    	{
    		int to = el.f;
    		__float128 w = el.s;
    		if (dist[to] > dist[v] + w)
    		{
    			que.erase({dist[to], to});
    			dist[to] = dist[v] + w;
    			que.emplace(dist[to], to);
    		}
    	}
    }

    cout << fixed << setprecision(12) << (long double)dist[n + 1] << "\n";

    return 0;
}

Measured memory_bytes: 32768
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}


int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c==17)
        cout<<"YES"<<endl;
    else
        cout <<"NO"<<endl;

    return 0;
}


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

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

int main()
{
    int r, D, x;
    cin >> r >> D >> x;
    for (int i = 0; i < 10; i++)
    {
        x = r * x - D;
        cout << x << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int md;
inline int mul(int a, int b) {
  return (int)((long long)a * b % md);
}
vector<vector<int>> grh;
vector<int> dp;
vector<int> ep;
void dfs (int crr, int prt) {
  int tmp = 1;
  for (int nxt : grh[crr]) {
    if (nxt == prt) continue;
    dfs(nxt, crr);
    tmp = mul(tmp, dp[nxt] + 1);
  }
  dp[crr] = tmp;
}
void efs (int crr, int prt) {
  vector<int> cld = grh[crr];
  int ind = find(cld.begin(), cld.end(), prt) - cld.begin();
  if (cld.begin() + ind != cld.end()) cld.erase(cld.begin() + ind);
  int n = cld.size();
  vector<int> acm(n + 1, 1), bcm(n + 1, 1);
  for (int i = 1; i <= n; i++) {
    acm[i] = mul(acm[i - 1], dp[cld[i - 1]] + 1);
    bcm[i] = mul(bcm[i - 1], dp[cld[n - i]] + 1);
  }
  for (int i = 0; i < n; i++) {
    int tmp = ep[crr] + 1;
    if (i) tmp = mul(tmp, acm[i]);
    if (n - i) tmp = mul(tmp, bcm[n - 1 - i]);
    ep[cld[i]] = tmp;
  }
  for (int nxt : cld) {
      efs(nxt, crr);
    }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n >> md;
  grh.resize(n);
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    grh[--x].push_back(--y);
    grh[y].push_back(x);
  }
  dp.resize(n, 1);
  ep.resize(n, 0);
  dfs(0, 0);
  efs(0, 0);
  for (int i = 0; i < n; i++) {
    int ret = mul(dp[i], ep[i] + 1);
    cout << ret << '\n';
  }
  return 0;
}

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

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

int main(){
  string s,t;
  cin >> s >> t;

  int ans = 0;
  rep(i, s.size()){
    if(s.at(i)!=t.at(i))ans++;
  }

  cout << ans;
}

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

#define MAX_N 200000
#define MAX_M 200000

int N, M;
vector<int> ab[MAX_N + 1];

int main()
{
	cin >> N >> M;
	for( int i = 0; i < M; i++ ) {
		int a, b;
		cin >> a >> b;
		ab[a].push_back( b );
	}

	int ans = 0;
	for( int i = 0; i < ab[1].size(); i++ ) {
		int idx = ab[1][i];
		for( int j = 0; j < ab[idx].size(); j++ ) {
			if( ab[idx][j] == N ) {
				ans = 1;
				break;
			}
		}
	}

	if( ans == 1 ) {
		cout << "POSSIBLE" << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}

	return 0;
}


Measured memory_bytes: 8576
import java.util.*;

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

        int N = sc.nextInt();
        int button [] = new int [N]; 

        for (int i = 0; i < N; i++) {
            button[i] = sc.nextInt();
        } 

        int now = 1;
        int count = 0;

        for (;;) {
            if ( now == 2) {
                System.out.println( count );
                break;
            } else if ( count >= N ) {
                System.out.println( -1 );
                break;
            } else {
                count++;
                now = button[now - 1];
            }
        }
    }
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n,m,k,a[400001],b[400001],sa[400001],sb[400001];
bool ok(ll val)
{
    for(ll i=0;i<=n;i++)
        if(i<=val&&val-i<=m)
        {
            ll suma=sa[i]+sb[val-i];
            if(suma<=k)
                return 1;
        }
    return 0;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        sa[i]=sa[i-1]+a[i];
    }
    for(int i=1;i<=m;i++)
    {
        cin>>b[i];
        sb[i]=sb[i-1]+b[i];
    }
    ll st=0;
    ll dr=n+m;
    ll maxim=0;
    while(st<=dr)
    {
        ll mij=(st+dr)/2;
        if(ok(mij))
        {
            if(mij>maxim)
                maxim=mij;
            st=mij+1;
        }
        else
            dr=mij-1;
    }
    cout<<maxim;
    return 0;
}


Measured memory_bytes: 9920
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;

unsigned int randxor() {
  static unsigned int x=123456789,y=362436069,z=521288629,w=88675123;
  unsigned int t;
  t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) );
}




int main() {
  int D;
  cin >> D;
  vector<int> c(26);
  rep(i,26) cin >> c[i];
  vector<vector<int>> s(D + 1, vector<int>(26, 0));
  vector<vector<int>> last_day(D + 1, vector<int>(26, 0));
  vector<int> t(D);
  rep(i,D) rep(j,26) cin >> s[i + 1][j];


  int score = 0;
  auto Scoring = [&](int d, int id, int oid) {
    score += s[d][id];
  
    if (oid != -1) {
      t[d - 1] = id;
      score -= s[d][oid];
      for (int i = d; i <= D; i++) {
        if (last_day[i][oid] != d) break;
        last_day[i][oid] = last_day[i - 1][oid];
        score += c[oid] * (i - d);
        score -= c[oid] * (i - last_day[i][oid]);
      }

      for (int i = d; i <= D; i++) {
        if (last_day[i][id] == i) break;
        score += c[id] * (i - last_day[i][id]);
        last_day[i][id] = d;
        score -= c[id] * (i - last_day[i][id]);
      }
    } else {
      last_day[d][id] = d;
      for (int i = 0; i < 26; i++) {
        if (i != id) last_day[d][i] = last_day[d - 1][i];
        score -= c[i] * (d - last_day[d][i]); 
      }
    }
  };

  auto init = [&](){
    for (int i = 0; i < D; i++) {
      t[i] = i % 26;
    }

  };
  
  //初期解生成 
  init();
  
  rep(p, 1000000) {

    int d = randxor() % D;
    int change_q = randxor() % 26;    
    int old_q = t[d];
    int old_score = score;
    Scoring(d + 1, change_q, old_q);
    if (score < old_score) {
      Scoring(d + 1, old_q, change_q);
    }
  }
  
  rep(i,D) cout << t[i] + 1 << endl;
  return 0;
} 

Measured memory_bytes: 3740
fn main() {

    let (a, b) = {
        let mut s =  String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let mut ws = s.split_whitespace();
        let a: i32 = ws.next().unwrap().parse().unwrap();
        let b: i32 = ws.next().unwrap().parse().unwrap();
        (a,b)
    };
    let x = a * b;
    let mut ans = String::new(); 
    ans = if x % 2 == 0 {"Even".to_string()}
      else {"Odd".to_string()};

    println!("{}", ans)
}

Measured memory_bytes: 4352
# -*- coding: utf-8 -*-
N, K, Q = map(int, input().split())
P = [0 for i in range(N)]
for i in range(Q):
    P[int(input())-1] += 1
for p in P:
    if K - Q + p <= 0:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 4684
#[allow(unused_imports)]
use std::cmp;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let a = sc.read_vec::<usize>(n);

    if a.iter().any(|&e| e == 0) {
        println!("0");
        return;
    }

    let mut ans = 1;
    for a in a.into_iter() {
        if ans as f64 > 1e18 as f64 / a as f64 {
            println!("-1");
            return;
        }
        ans *= a;
    }
    if ans > 1e18 as usize {
        println!("-1");
        return;
    }
    println!("{}", ans);
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


Measured memory_bytes: 2356
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	for (int i = 0; i + 1 < s.size(); i++)if (s[i] == s[i + 1]) {
		cout << i + 1 << " " << i + 1 + 1 << endl;
		return 0;
	}
	for (int i = 0; i + 2 < s.size(); i++)if (s[i] == s[i + 1] || s[i] == s[i + 2] || s[i + 1] == s[i + 2]) {
		cout << i + 1 << " " << i + 1 + 2 << endl;
		return 0;
	}
	cout << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using int64 = int64_t;

constexpr int64 MOD = 1000000007;

int N;
int A[101010];

int main() {
    cin >> N;
    for (int j = 0; j < N; ++j) {
        cin >> A[j];
    }
    sort(A, A+N);
    int kind = 1;
    int64 acc = A[0];
    for (int j = 1; j < N; ++j) {
        if (2 * acc >= A[j]) {
            ++kind;
        } else {
            kind = 1;
        }
        acc += A[j];
    }
    cout << kind << endl;
    return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;++i)
#define repi(i,n) for(ll i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define slf(n) scanf("%lf", &n);
typedef long long ll;
typedef double lf;
static const ll max_n = 100010;
static const ll mod = 1000000007;
static const ll max_value = 100000000000100;

ll N, M;


void Main(){
    // bool is_ok = true;
    // printf("------------- V=%lld---------\n", V);
    ll A, B;
    sll(A);
    sll(B);
    cout<< A * B <<endl;
}

int main(){
    Main();

    return 0;

}

Measured memory_bytes: 3256