akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmin(T &a, T b){ if (a > b){ a = b; return 1;} return 0;}
template<class T> inline bool chmax(T &a, T b){ if (a < b){ a = b; return 1;} return 0;}

const long long mod = 1e9+7;

int main(){
  int n, m; cin >> n >> m;
  vector<bool> oks(n+1, true);
  for(int i = 0; i < m; i++){
    int a; cin >> a;
    oks[a] = false;
  }
  vector<long long> dp(n + 1); //たどり着く移動方法
  dp[0] = 1;
  for(int i = 0; i < n; i++){
    for(int j = i + 1; j <= min(n, i + 2); j++){
      if(oks[i]){
        dp[j] += dp[i];
        dp[j] %= mod;
      }
    }
  }
  cout << dp[n] << endl;
}
    
                                               

Measured memory_bytes: 1024
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<limits>
using namespace std;
//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;

//grobal変数


int main() {
	int n, k;
	cin >> n >> k;
	VI a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans;
	if (n == k) {
		ans = 1;
	}
	else {
		for (int i = 0;; i++) {
			if (n <= k + (k - 1)*(i - 1)) {
				ans = i;
				break;
			}
		}

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



Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>

int isprime(int x){
	int i;
	if(x == 2){
		return 1;
	}
	if(x < 2 || x%2 == 0){
		return 0;
	}
	i = 3;
	while(i <= sqrt(x)){
		if(x%i == 0){
			return 0;
		}
		i = i + 2;
	}
	return 1;
}

int main(void){
	int a;
	int b=0, n, i;
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d", &a);
		if(isprime(a) == 1){
			b++;
		}
	}
	printf("%d\n", b);
	return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
#include<math.h>
#define N 10000
int main(){
  int n,i,j,k,array[N],scount,count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&array[i]);
  }


  for(i=0;i<n;i++){
    scount=0;
    k=sqrt(array[i]);
    for(j=2;j<=k;j++){
      if(array[i]%j==0) scount++;
    }
    if(scount==0) count++;
  }
  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 2072
#![allow(dead_code)]
use std::cmp;
use std::collections::*;

pub struct Scanner {
    bytes: Vec<u8>,
    begin: usize,
    end: usize,
}

impl Scanner {
    pub fn new() -> Self {
        let mut buffer: Vec<u8> = Vec::new();
        std::io::Read::read_to_end(&mut std::io::stdin(), &mut buffer).unwrap();
        let end = Scanner::skip_item(&buffer, 0);
        Scanner {
            bytes: buffer,
            begin: 0,
            end: end,
        }
    }
    pub fn next<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let s: &str = unsafe { std::str::from_utf8_unchecked(&self.bytes[self.begin..self.end]) };
        let ret: T = s.parse::<T>().unwrap();
        self.skip();
        ret
    }
    pub fn next_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut v: Vec<T> = Vec::with_capacity(n);
        for _i in 0..n {
            v.push(self.next());
        }
        v
    }
    pub fn next_chars(&mut self) -> Vec<u8> {
        let r = Vec::from(&self.bytes[self.begin..self.end]);
        self.skip();
        r
    }
    fn skip(&mut self) {
        self.begin = Scanner::skip_whitespace(&self.bytes, self.end);
        self.end = Scanner::skip_item(&self.bytes, self.begin);
    }
    fn skip_whitespace(s: &Vec<u8>, idx: usize) -> usize {
        let mut r = idx;
        while r < s.len() && s[r].is_ascii_whitespace() {
            r += 1;
        }
        r
    }
    fn skip_item(s: &Vec<u8>, idx: usize) -> usize {
        let mut r = idx;
        while r < s.len() && !s[r].is_ascii_whitespace() {
            r += 1;
        }
        r
    }
}

fn lower_bound<T: std::cmp::Ord>(v: &Vec<T>, val: &T) -> usize {
    let mut lb: isize = -1;
    let mut ub: isize = v.len() as isize;
    while ub - lb > 1 {
        let mid = (lb + ub) / 2;
        if *val <= v[mid as usize] {
            ub = mid;
        } else {
            lb = mid;
        }
    }
    return ub as usize;
}

fn dfs(
    u: usize,
    p: usize,
    dp: &mut Vec<i32>,
    ans: &mut Vec<usize>,
    a: &Vec<i32>,
    edge: &Vec<Vec<usize>>,
) {
    let idx = lower_bound(dp, &a[u]);
    let prev = dp[idx];
    dp[idx] = a[u];
    ans[u] = lower_bound(dp, &i32::max_value());

    for v in &edge[u] {
        if *v == p {
            continue;
        }
        dfs(*v, u, dp, ans, a, edge);
    }
    dp[idx] = prev;
}

fn main() {
    let mut scan = Scanner::new();
    let n: usize = scan.next();
    let a: Vec<i32> = scan.next_vec(n);
    let mut edge: Vec<Vec<usize>> = vec![Vec::new(); n];
    for _ in 0..n - 1 {
        let u: usize = scan.next();
        let v: usize = scan.next();
        let (u, v) = (u - 1, v - 1);
        edge[u].push(v);
        edge[v].push(u);
    }
    let mut dp: Vec<i32> = vec![i32::max_value(); n];
    let mut ans: Vec<usize> = vec![0; n];
    dfs(0, 0, &mut dp, &mut ans, &a, &edge);
    for x in ans {
        println!("{}", x);
    }
}


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

#define MAX_N 100
#define MAX_W 100000

ll dp[MAX_N][MAX_W + 1];
vector<ll> wei(MAX_N), val(MAX_N);
void knapsack(int n, int w){
    if (n >= 1){
      if (w -  wei.at(n)>= 0){
          dp[n][w] = max(dp[n-1][w-wei.at(n)] + val.at(n), dp[n-1][w]);
      }
      else dp[n][w] = dp[n-1][w];
    }
    else{
        if (w >= wei.at(n))dp[n][w] = val.at(n);
        else dp[n][w] = 0;
    }
}

int main(){
    int N, W;cin >> N >> W;
    for (int i = 0; i < N; i++)
    {
        cin >>wei.at(i) >> val.at(i);
    }
    for (int i = 0; i < N; i++){
        for (int j = 1; j <= W; j++)
        {
           knapsack(i, j);
        }
    }
    cout << dp[N-1][W] << endl;
    
}


Measured memory_bytes: 78336
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main {
  double a, b, c;
  cin >> a >> b >> c;
  c *= PI / 180.0;
  double h = b * sin(c);
  cout << prec(32);
  cout << a * h / 2.0 << endl;
  cout << a + b + sqrt(a * a + b * b - 2.0 * a * b * cos(c)) << endl;
  cout << h << endl;
}



Measured memory_bytes: 3548
#include <stdio.h>

int main(){
	long long int N=0;
	scanf("%lld", &N);
	long long int sum=0;
	for(int i=1;i<=N;i++){
		if(i%3!=0&&i%5!=0){
			sum+=i;
		}
	}
	printf("%lld", sum);
	return 0;
}

Measured memory_bytes: 1692
import Data.Bits
import Data.Maybe
import qualified Data.ByteString.Char8 as B
main=print.solve.map(fst.fromJust.B.readInt).B.words=<<B.getContents
solve(n:a1:a2:as)=if e then -1 else a1-r where
  s=a1+a2
  x=foldr xor 0 as
  d=(s-x)`div`2
  e=s-x<0 || (s-x)`mod`2/=0 || d.&.x/=0 || r==0 || r>a1
  r=d`xor`foldr f 0[0..63]
  f i y
    |testBit x i && setBit y i`xor`d<=a1=setBit y i
    |otherwise=y

Measured memory_bytes: 3824
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define iFOR(i, a, b) for(int i=(a); i>=(b); --i)
#define make_unique(a) sort(all((a))), (a).resize(unique(all((a)))-(a).begin())

using namespace std;

typedef pair<int,int> PII;
typedef long long LL;
typedef double DD;
typedef long double LD;
typedef pair<LL,LL> PLL;
typedef pair<DD,DD> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;

int gcd(int a, int b){
    if(!b) return a;
    return gcd(b, a%b);
}
int main(){
    int X;
    scanf("%d",&X);
    printf("%d",360/gcd(X,360));
	return 0;
}
/*
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }

void _main() {
  ll X, Y;
  cin >> X >> Y;

  int ans = 0;

  while (X <= Y) {
    ans++;
    X *= 2;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,ans=0;
long long a[100003],b[100003]={};
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		{
		cin>>a[i];
		if(a[i]>100000)
			a[i]=0;
		}
	if(n==1&&a[1]!=1)
		{cout<<"1";return 0;}
		
	for(int i=1;i<=n;i++)
		{
		if(a[i]!=0)
			{
			b[a[i]]++;
			if(b[a[i]]==a[i])
				ans+=a[i];
			}
		}
	cout<<n-ans;
	return 0;			
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int n;
ll a[100000], l;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> l;
  FOR(i, 0, n) cin >> a[i];
  FOR(i, 0, n-1){
    if(a[i] + a[i+1] >= l){
      cout << "Possible\n";
      FOR(j, 0, i) cout << j+1 << "\n";
      FORR(j, n-2, i+1) cout << j+1 << "\n";
      cout << i+1 << "\n";
    return 0;
    }
  }
  cout << "Impossible\n";
  return 0;
}

Measured memory_bytes: 1664
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc.Split(bufio.ScanWords)
	var S, W int
	nextInt(&S, &W)
	if W >= S {
		fmt.Printf("unsafe")
	} else {
		fmt.Printf("safe")
	}
}

const MAX_INT int = 1_000_000_000

var sc = bufio.NewScanner(os.Stdin)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)

func nextLine() string {
	buffer := make([]byte, 0)
	for true {
		line, isPrefix, err := reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func nextInt(A ...*int) {
	L := strings.Split(nextLine(), " ")
	for i, a := range A {
		*a, _ = strconv.Atoi(L[i])
	}
}
func nextInts(A *[]int) {
	L := strings.Split(nextLine(), " ")
	(*A) = make([]int, len(L))
	for i, l := range L {
		(*A)[i], _ = strconv.Atoi(l)
	}
}

func nextInt64(A ...*int64) {
	L := strings.Split(nextLine(), " ")
	for i, a := range A {
		*a, _ = strconv.ParseInt(L[i], 0, 64)
	}
}

func max(a int, b int) int {
	if a >= b {
		return a
	}
	return b
}



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


int main()
{
    int n, x, y;
    cin >> n >> x >> y;
    int cnt[n];
    memset(cnt, 0, sizeof cnt);

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (i != j)
                cnt[min((int)abs(j - i), min((int) abs(x - i) + 1 + abs(j - y), (int)abs(y - i) + 1 + abs(j - x)))]++;
        }
    }
    for (int i = 1; i < n; i++) {
        cout << cnt[i]/2 << "\n";
    }
}


Measured memory_bytes: 256
use self::union_find::UnionFind;
use proconio::input;
use proconio::marker::Usize1;

fn main() {
    input! {
        n: usize,
        m: usize,
        ab: [(Usize1, Usize1); m],
    };
    let mut uf = UnionFind::new(n);
    for &(a_i, b_i) in ab.iter() {
        uf.unite(a_i, b_i);
    }
    let mut max_size = 0;
    for i in 0..n {
        max_size = std::cmp::max(max_size, uf.size(i));
    }
    let ans = max_size;
    println!("{}", ans);
}

mod union_find {
    pub struct UnionFind {
        p: Vec<usize>,
        s: Vec<usize>,
    }

    impl UnionFind {
        pub fn new(n: usize) -> Self {
            let mut p = vec![0; n];
            for i in 0..n {
                p[i] = i;
            }
            let s = vec![1; n];
            Self { p, s }
        }

        pub fn root(&mut self, x: usize) -> usize {
            if self.p[x] == x {
                return x;
            } else {
                self.p[x] = self.root(self.p[x]);
                self.p[x]
            }
        }

        pub fn size(&mut self, x: usize) -> usize {
            let rx = self.root(x);
            self.s[rx]
        }

        pub fn unite(&mut self, x: usize, y: usize) {
            let rx = self.root(x);
            let ry = self.root(y);
            if rx == ry {
                return;
            };
            if self.s[rx] >= self.s[ry] {
                self.s[rx] += self.s[ry];
                self.p[ry] = rx;
            } else {
                self.s[ry] += self.s[rx];
                self.p[rx] = ry;
            }
        }
    }
}


Measured memory_bytes: 10848
n = gets.to_i
ans = 0

def keta(m)
  ret = 0
  for i in 1..(m-1) do
    if i.even?
      ret += 10 ** i - 10 ** (i-1)
    end
  end
  ret
end

def keta2(m)
  ret = 0
  for i in 1..(m-1) do
    if i.odd?
      ret += 10 ** i - 10 ** (i-1)
    end
  end
  ret
end

for m in 1..6 do
  if n / 10 ** m == 0
    if m.odd?
      if m == 1
        ans = n
      else
        ans = n % 10 ** m - keta(m)
      end
    else
      ans = keta2(m)
    end
    break
  end
end

puts ans

Measured memory_bytes: 1788
package main

import (
	"bytes"
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"os"
	"runtime/debug"
	"strings"
)

func main() {
	b, _ := ioutil.ReadAll(os.Stdin)
	if len(b) == 0 {
		test()
	} else {
		solve(bytes.NewReader(b), os.Stdout)
	}
}

func solve(r io.Reader, w io.Writer) {
	var n, m int
	fmt.Fscanln(r, &n, &m)
	cntByX := make(map[int]int)
	cntByMod := make(map[int]int)
	for i := 0; i < n; i++ {
		var x int
		fmt.Fscan(r, &x)
		cntByX[x]++
		cntByMod[x%m]++
	}
	pairN := 0

	for mod := 0; mod <= m/2; mod++ {
		cnt := cntByMod[mod]
		if mod == 0 || (m%2 == 0 && mod == m/2) {
			pairN += cnt / 2
			cntByMod[mod] %= 2
			continue
		}
		that := m - mod
		assert(mod < that)
		if cnt > cntByMod[that] {
			cnt = cntByMod[that]
		}
		pairN += cnt
		cntByMod[mod] -= cnt
		cntByMod[that] -= cnt
	}

	for x, cnt := range cntByX {
		if cnt > 1 && cntByMod[x%m] > 1 {
			if cnt > cntByMod[x%m] {
				cnt = cntByMod[x%m]
			}
			c := cnt / 2
			pairN += c
			cntByMod[x%m] -= c * 2
		}
	}

	fmt.Fprintln(w, pairN)
}

func test() {
	tests := []struct {
		in   string
		want string
	}{
		{
			in: `
7 5
3 1 4 1 5 9 2
`,
			want: `3`,
		},
		{
			in: `
15 10
1 5 6 10 11 11 11 20 21 25 25 26 99 99 99
`,
			want: `6`,
		},
		{
			in: `
3 10
8 8 8
`,
			want: `1`,
		},
		{
			in: `
20 10
1 5 6 10 11 11 11 11 11 11 31 31 20 21 25 25 26 99 99 99
`,
			want: `8`,
		},
	}
	for i, tt := range tests {
		fmt.Printf("=== TEST %d\n", i)
		buf := new(bytes.Buffer)
		solve(strings.NewReader(chomp(tt.in)), buf)
		if got, want := chomp(buf.String()), chomp(tt.want); got != want {
			fmt.Printf("%d: got %v, want %v\n", i, got, want)
		}
	}
}

func chomp(s string) string {
	return strings.Trim(s, "\n")
}

func assert(b bool) {
	if !b {
		debug.PrintStack()
		log.Fatal("err!")
	}
}


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

int main() {
  int n, a, m = INT_MAX;
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> a;
    int t = 0;
    while(a % 2 == 0) {
      a /= 2;
      t++;
    }
    m = min(m, t);
  }
  cout << m << endl;
}

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


class Program
{
    static void Main(string[] args)
    {
        string num = Console.ReadLine();
        char[] mul = num.ToCharArray();
        foreach (char m in mul)
        {
            if (m == '1')
            {
                Console.Write("9");
            }
            else
            {
                Console.Write("1");
            }
        }

    }

}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=1e9;

int main(){
	int N;
	cin>>N;
	int a[100];
	rep(i,N)cin>>a[i];
	int ans=MAX;
	for(int i=-100;i<=100;i++){
		int sum=0;
		rep(j,N)sum+=(i-a[j])*(i-a[j]);
		ans=min(ans,sum);
	}
	cout<<ans;
}

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

using namespace std;

int main(void)

{
    int a,b;
    string s1, s2, s3;
    cin>>s1>>s2>>a>>b>>s3;
    if(!s3.compare(s1)){
        a--;
    }
    else{
        b--;
    }
    cout<<a<<" "<<b<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	long long n,k,ans=0;
	string s;
	cin>>n;
	for(int i=1;i<=n;i++){
	    if(i%3&&i%5)ans+=i;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, s, e) for(int i=s; i>=e; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int n, tmpa;
    vector<int> a;
    cin >> n;

    rep(i, n){
        cin >> tmpa;
        a.push_back(tmpa);
    }

    sort(a.begin(), a.end());
    ll mod = 1e9+7;
    ll res = 1;
    if(n%2 == 0){
        ll marker = 1;
        for(int i=0; i<n-1; i+=2){
            if(a[i]==marker && a[i+1]==marker) marker+=2;
            else{
                cout << 0 << endl;
                return 0;
            }
        }
        rep(i, n/2){
            res *= 2;
            res %= mod;
        }
    }else{
        ll marker = 2;
        if(a[0] != 0){
            cout << 0 << endl;
            return 0;
        }
        for(int i=1; i<n-1; i+=2){
            if(a[i]==marker && a[i+1]==marker) marker+=2;
            else{
                cout << 0 << endl;
                return 0;
            }
        }
        rep(i, (n-1)/2){
            res *= 2;
            res %= mod;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long
#define ld long double

#define mod 1000000007
#define EULER 2.7182818284
#define INF 1000000000

#define pb push_back
#define ins insert
#define IT iterator
#define PQ priority_queue
#define    nl           "\n"
#define fi first
#define se second
#define maxe max_element
#define mine min_element
#define er erase
#define lb lower_bound
#define ub upper_bound

#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define mpi map<int,int>
#define mpl map<ll,ll>
#define umpi unordered_map<int,int>
#define umpl unordered_map<ll,ll>
#define si set<int>
#define sl set<ll>
#define msi multi_set<int>
#define msl multi_set<ll>

#define mem(v,i) memset(v,i,sizeof(v)) // v is array. To set all elements to 0 or -1 only. mem(arr,0);


#define repab(i,a,b) for(int i=(a);i<=(b);i++)
#define reprab(i,a,b) for(int i=(a);i>=(b);i--)
#define repll(i,a,b) for(ll i=(a);i<=(b);i++)
#define rep(i,n) for(int i=(0);i<(n);i++)
#define repr(i,n) for(int i=(n);i>=0;i--)
#define bs bitset
#define bpc(a) __builtin_popcount(a)
#define tc int t;cin>>t;while(t--)
template<typename T> void TIME(T start, T end)
{
#ifndef ONLINE_JUDGE
    double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count();
    time_taken *= 1e-9;
    cout << "\nExecuted in: " << fixed
         << time_taken << setprecision(9);
    cout << " sec";
#endif
}

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

ll max(ll a,ll b)
{
    if(a>b)return a;return b;
}
ll min(ll a,ll b)
{
    if(a<b)return a;return b;
}

ll mypow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}
//..............................!!!!!!Get ready to fight!!!!!!............................


int main()
{   
     auto start = chrono::high_resolution_clock::now();
    fast
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    for(ll i=k;i<=n+1;i++){
        ll first=i*(i-1)/2;
        ll last=n*(n+1)/2-(n-i+1)*(n-i)/2;
        ans=(ans+last-first+1)%mod;
    }
    cout<<ans;
    auto end = chrono::high_resolution_clock::now();
    TIME(start, end);
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <set>
#include <string>
#define MAX 1000000000


using namespace std;
#define ll long long
#define dbg if(0)

bool check(int p,int k,int *rui,int n){
    int ok,ng,low=0;
    for(int i=0;i<k;i++){
        ng=n+1;
        ok=low;
        int mid;
        while(abs(ok-ng)>1){
            mid= (ok+ng)/2;
            if(rui[mid]-rui[low]<=p)ok = mid;
            else ng=mid;
        }
        low=ok;
        dbg cout<< p << " " << low << " "<< ok << " "<< ng <<endl;
        if (low==n)break;
    }
    return low>=n;
}


int binary_search(int ok,int ng,int k,int *rui,int n){
    while(abs(ok-ng)>1){
        int mid= (ok+ng)/2;
        if(check(mid,k,rui,n))ok=mid;
        else ng=mid;
    }
    return ok;

}
int main(){
    int n,k;
    cin >>n>>k;
    int w[n];
    int rui[n+1];
    int ans=0;
    rui[0]=0;
    for(int i=0; i<n;i++){
        cin>>w[i];
        rui[i+1]=w[i]+rui[i];
    }
    ans=binary_search(MAX,-1,k,&rui[0],n);
    
    cout <<ans<<endl;
    return 0;
}



Measured memory_bytes: 3872
S = input()[::-1]
W = [s[::-1] for s in ('dream', 'dreamer', 'erase', 'eraser')]

def isOk():
    now = 0
    while now < len(S):
        for w in W:
            if S[now: now + len(w)] == w:
                now += len(w)
                break
        else:
            return False
    return True

print('YES' if isOk() else 'NO')


Measured memory_bytes: 3188
#include <iostream>
#define ll long long
using namespace std;

int main() {
        ll x;
        cin>>x;
        ll ans=x/500;
        ll rem=x%500;
        ll ans2=ans*1000;
        // cout<<"ans2--"<<ans2<<endl;
        ll ans3=rem/5;
        // cout<<ans3<<"--ans3"<<endl;
        ll ans4=ans2+ans3*5;
        cout<<ans4;
	return 0;
}

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

#define F first
#define S second
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;

typedef long long ll;

void solve(){
	ll ans=1000;
	int n;
	cin>>n;
	vector<int>a(n);
	for(int i=0;i<n;++i){
		cin>>a[i];
	}
	int mn=1e9+7;
	for(int i=0;i<n;i++){
		if(mn>=a[i]){
			mn=a[i];
		}
		else{
			ans=ans%mn+(ans/mn*a[i]);
			mn=a[i];
		}
	}
	cout<<ans;
}

int main(){
	Red;
	int T=1;
	//cin>>T;
	while(T--)solve();
}

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 200021
#define int ll
int N,K;
int A[maxn];
int fw[maxn];

void upd(int p,int v){ //update position p by +=v
	for (int i=p; i<=N + 10; i+= (i&(-i))){
		fw[i] += v;
	}
}

int qry(int p){ //query from 1 to p
	int ans = 0;
	for (int i = p; i>0; i -= (i&(-i))){
		ans += fw[i];
	}
	return ans;
}


int32_t main(){
	fast;
	
	cin>>N>>K;
	
	FOR(i,1,N) cin>>A[i];
	
	vpi vect;
	int cursm = A[1];
	
	FOR(i,1,N + 1){
		vect.pb(pi(cursm - K * i,i));
		cursm += A[i];
	}
	
	sort(all(vect),greater<pi>());
	
	
	int ans = 0;
	aFOR(i,vect){
		ans += qry(N + 1) - qry(i.s);
		upd(i.s,1);
	}
	
	cout<<ans;
	
}



Measured memory_bytes: 7920
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;


int main() {
    int a,b; cin >> a >> b;
    int c = max((a+b), (a-b));
    cout << max(c, (a*b));
}

Measured memory_bytes: 256
#![allow(unused)]

use std::cmp::{min, max};
use std::io::Write;

macro_rules! dbg {
    ($($a:expr),*) => {
        writeln!(
            std::io::stderr(),
            concat!($(stringify!($a), " = {:?}, "),*),
            $($a),*);
    }
}

//
// Based on EbTech's Scanner https://stackoverflow.com/q/56449027
//
struct Scanner<'a, R: std::io::BufRead> {
    reader: R,
    buf: String,
    iter: std::str::SplitWhitespace<'a>,
}

impl<'a, R: std::io::BufRead> Scanner<'a, R> {
    fn new(reader: R) -> Scanner<'a, R> {
        Scanner { reader: reader, buf: String::new(), iter: "".split_whitespace() }
    }

    fn get_str(&mut self) -> &str {
        if let Some(t) = self.iter.next() {
            return t;
        }
        self.buf.clear();
        self.reader.read_line(&mut self.buf).expect("I/O error");
        self.iter = unsafe { std::mem::transmute(self.buf.split_whitespace()) };
        self.get_str()
    }

    fn get<T: std::str::FromStr>(&mut self) -> T {
        self.get_str().parse().ok().expect("Parse error")
    }
}

fn main() {
    let stdin = std::io::stdin();
    solve(Scanner::new(stdin.lock()));
}

fn solve<R: std::io::BufRead>(mut sc: Scanner<R>) {
    let n: usize = sc.get();
    let xs: Vec<i64> = (0..n).map(|_| sc.get()).collect();

    //
    // dp[i][j] = 数列 (a_k) (i + 1 <= k <= j + 1) における X - Y
    //
    let mut dp = vec![vec![0; n]; n];

    for i in (0..n).rev() {
        dp[i][i] = xs[i];
        for j in (i + 1)..n {
            dp[i][j] = max(xs[i] - dp[i + 1][j], xs[j] - dp[i][j - 1]);
        }
    }

    println!("{}", dp[0][n - 1]);
}

Measured memory_bytes: 90364
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n, t;
ll dp[100100];

int main() {
	cin >> n >> t;
	vector<ll> d(n);
	rep(i, n)cin >> d[i];
	sort(ALL(d));
	auto ub = d.begin();
	auto lb = d.begin();
	dp[0] = 1;
	FOR(i, 1, n) {
		ub++;
		lb = lower_bound(ALL(d), d[i] - t);
		dp[i] = mod_mul(dp[i - 1], (ub - lb + 1));
	}
	cout << dp[n - 1] << endl;
}


Measured memory_bytes: 4396
#include <bits/stdc++.h>
#define MOD (ll)(998244353)
#define MAX (ll)(1e5 + 4)
#define INF (ll)(1e17)
using namespace std;
using ll =  long long;
using ld = long double;

bool fun (pair<int, int> p1, pair<int, int> p2) {
	return p1.first > p2.first ? 1 : p1.second < p2.second;
}

int main () {
	int n;
	cin >> n;
	int ar[n][2];
	for (int j = 0; j < 2; j++) {
		for (int i = 0; i < n; i++) {
			cin >> ar[i][j];
		}
	}
	int ma = n * n * n;
	for (int i = 0; i < (1 << n); i++) {
		vector<int> ve;
		vector<pair<int, int>> vv[2];
		for (int j = 0; j < n; j++) {
			bool x = (i >> j) & 1;
			ve.push_back (ar[j][x]);
			vv[x ^ (j & 1)].push_back (make_pair (ar[j][x], j));
		}
		if (vv[0].size () - (n & 1) != vv[1].size ()) {
			continue;
		}
		sort (ve.begin (), ve.end ());
		sort (vv[0].begin (), vv[0].end ());
		sort (vv[1].begin (), vv[1].end ());
		bool fl = 1;
		int cc = 0;
		for (int i = 0; i < n; i++) {
			if (ve[i] != vv[i & 1][i / 2].first) {
				fl = 0;
				break;
			}
		}
		if (!fl) {		
			continue;
		}
		for (int i = 0; i < n; i++) {
			bool fl = i & 1;
			int d = n + 1, ind = 0, ii = 0;
			for (int j = 0; j < vv[fl].size (); j++) {
				if (ve[i] == vv[fl][j].first) {
					if (abs (i - vv[fl][j].second) < d) {
						ind = vv[fl][j].second;
						ii = j;
						d = abs (i - vv[fl][j].second);
					}
				}
			}	
			vv[fl][ii].first = -20;
			cc += abs (i - ind);
			int ch = 1;
			if (ind < i) {
				ch - 1;
			}
			for (int j = 0; j < vv[0].size (); j++) {
				if (vv[0][j].second >= min (ind, i) && vv[0][j].second <= max (ind, i)) {
					vv[0][j].second += ch;
				}
			}
			for (int j = 0; j < vv[1].size (); j++) {
				if (vv[1][j].second >= min (ind, i) && vv[1][j].second <= max (ind, i)) {
					vv[1][j].second += ch;
				}
			}
		}
		ma = min (cc, ma);
	}
	if (ma == n * n * n) {
		cout << "-1\n";
	}
	else {
		cout << ma << "\n";
	}
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int n, o = 0, t = 0;
	bool flag = true;
	cin >> n;
	vector<int>a(n);
	for (auto& i : a)
	{
		cin >> i;
	}
	sort(a.rbegin(), a.rend());
	for (auto& i : a)
	{
		if (flag)
		{
			o += i;
		}
		else {
			t += i;
		}
		flag = !flag;
	}
	cout << o - t << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <numeric>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
ll MOD = 1000000007;
const int mod = 1000000007;
ll INF = 1LL << 60;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
   for (auto &v : vec)
      is >> v;
   return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec)
{
   os << "[";
   for (auto v : vec)
      os << v << ",";
   os << "]";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const deque<T> &vec)
{
   os << "deq[";
   for (auto v : vec)
      os << v << ",";
   os << "]";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &vec)
{
   os << "{";
   for (auto v : vec)
      os << v << ",";
   os << "}";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_set<T> &vec)
{
   os << "{";
   for (auto v : vec)
      os << v << ",";
   os << "}";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const multiset<T> &vec)
{
   os << "{";
   for (auto v : vec)
      os << v << ",";
   os << "}";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_multiset<T> &vec)
{
   os << "{";
   for (auto v : vec)
      os << v << ",";
   os << "}";
   return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{
   os << "(" << pa.first << "," << pa.second << ")";
   return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const map<TK, TV> &mp)
{
   os << "{";
   for (auto v : mp)
      os << v.first << "=>" << v.second << ",";
   os << "}";
   return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp)
{
   os << "{";
   for (auto v : mp)
      os << v.first << "=>" << v.second << ",";
   os << "}";
   return os;
};
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
   fill((T *)array, (T *)(array + N), val);
}

bool is_prime(int64_t x)
{
   for (int64_t i = 2; i * i <= x; i++)
   {
      if (x % i == 0)
         return false;
   }
   return true;
}

ll a[202020];
int solve()
{
   ll n;
   cin >> n;
   multiset<ll> se;
   for (int i = 0; i < n; i++){
      cin >> a[i];
      se.insert(a[i]);
   }
   ll ans = 0;
   while(se.size()){
      ll t1 = *se.rbegin();
      se.erase(se.find(t1));

      for(int i=50; i > -1; i--){
         ll t2 = (1LL << i);
         if(se.count(t2 - t1)){
            ans++;
            se.erase(se.find(t2 - t1));
            break;
         }
      }
   }
   

   cout << ans << endl;


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

   solve();
}

Measured memory_bytes: 11264
/*
ID: seekho
PROG: friday
LANG: C++14                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(998244353)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

// #define N 50005


int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);

    int n,k;
    cin >> n >> k;

    vector<pii> vec(n);

    rep(i,n) {
    	cin >> vec[i].Y >> vec[i].X;
    }

    sort(all(vec));
    reverse(all(vec));

    map<int,int> M;
    int ans = 0, td = 0, dis = 0;

    rep(i,k) {
    	td += vec[i].X;
    	if(M[vec[i].Y] == 0) dis++;
    	M[vec[i].Y]++;
    }
    ans = td + dis*dis;
    int p1 = k-1, p2 = k;

    while(p1 >= 0 and p2 < n) {
    	if(M[vec[p1].Y] == 1) {
    		p1--;
    		continue;
    	}

    	if(M[vec[p2].Y] >= 1) {
    		p2++;
    		continue;
    	}

    	td -= vec[p1].X;
    	M[vec[p1].Y]--;
    	dis++;

    	td += vec[p2].X;
    	M[vec[p2].Y] = 1;

    	ans = max(ans, td + dis*dis);

    	p1--;
    	p2++;
    }

    cout << ans << "\n";
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll div_ceil(ll, ll);

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

int main() {
  ll N;
  std::cin >> N;
  pair<ll, ll> v[N];
  REP(i, N) { cin >> v[i].second >> v[i].first; }
  sort(v, v + N);
  ll time = 0;
  // REP(i, N) { cout << v[i].first << v[i].second << '\n'; }
  ll ans = true;
  REP(i, N) {
    time += v[i].second;
    if (time > v[i].first) {
      ans = false;
      break;
    }
  }
  if (ans) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
}

ll div_ceil(ll a, ll b) {
  ll quotient = a / b;
  ll remainder = a % b;
  if (remainder == 0) {
    return quotient;
  } else {
    return quotient + 1;
  }
}


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

int main(){
  int te[5];
  int wi[3];
  bool ju[3];
  while(cin>>te[0] && te[0]){
    for(int i=0;i<3;i++) ju[i]=0;
    ju[te[0]-1]=1;
    for(int i=1;i<5;i++){
      cin >>te[i];
      ju[te[i]-1]=1;
    }
    int co=0;
    for(int i=0;i<3;i++)
      if(ju[i]==1) 
	co++;
    if(co==1 || co==3)
      for(int i=0;i<3;i++) 
	wi[i]=3;
    else{
      if(ju[0]==1 && ju[1]==1) wi[0]=1,wi[1]=2;
      else if(ju[1]==1&&ju[2]==1) wi[1]=1,wi[2]=2;
      else wi[2]=1,wi[0]=2;
    }
    for(int i=0;i<5;i++)
      cout<<wi[te[i]-1]<<endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

// 桁/以下確定/3/5/7/頭0
long long dp[20][2][2][2][2][2];
int main(){
    int n; cin>>n;
    string s=to_string(n);
    int nn=s.size();
    dp[0][0][0][0][0][0]=1;
    for(int i=1;i<=nn;i++){
        int num=s[i-1]-'0';
        for(int j=0;j<2;j++){
            for(int d=0;d<=(j?9:num);d++){
                if(d!=0&&d!=3&&d!=5&&d!=7) continue;
                for(int k=0;k<2;k++){
                    for(int l=0;l<2;l++){
                        for(int m=0;m<2;m++){
                            for(int x=0;x<2;x++){
                                if(x==1&&d==0) continue;
                                dp[i][j||d<num][k||d==3][l||d==5][m||d==7][x||(d!=0)]+=dp[i-1][j][k][l][m][x];
                            }
                        }
                    }
                }
            }
        }
    }
    // cout<<dp[nn][1][0][1][1]<<endl;
    long long ans=dp[nn][0][1][1][1][1]+dp[nn][1][1][1][1][1];
    cout<<ans<<endl;
    return 0;
}


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

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

    int longest = 0;
    int cnt = 0;
    for (int i = 0; i < s.size(); ++i)
    {
        if(s[i] == 'A' or s[i] =='C' or s[i]=='G' or s[i] =='T'){
            ++cnt;
        }else{
            longest = max(cnt, longest);
            cnt = 0;
        }
    }
    longest = max(cnt, longest);

    cout << longest << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
class aoj
{
    static void Main()
    {
        string a = Console.ReadLine();
        char[] b = new char[a.Length];
        for(int i = 0; i < a.Length; i++)
        {
            int c = (int)a[i];
            c-= 3;
            if (c < 'A') c += 26;
            b[i] = (char)c;
        }
        string d = new string(b);
        Console.WriteLine(d);
    }
}

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

int main(){
  int i,j,cnt;
  int n;
  cin>>n;
  if(9>=n)cout<<n;
  else if(99>=n)cout<<9;
  else if(999>=n)cout<<n-90;
  else if(9999>=n)cout<<909;
  else if(99999>=n)cout<<n-9090;
  else cout<<90909;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

#include <deque>

using T = tuple<ll, int, int>;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w;
    cin, h, w;
    int sx, sy, gx, gy;
    cin, sy, sx, gy, gx;
    sx--;
    sy--;
    gx--;
    gy--;
    auto mp = make_v(h, w, '#');
    REP(i, 0, h) {
        REP(j, 0, w) {
            cin, mp[i][j];
        }
    }

    deque<T> q;
    q.emplace_front(0LL, sx, sy);
    const int inf = 1 << 29;
    auto cost = make_v(h, w, inf);
    int ans = -1;
    while (q.size()) {
        auto [c, x, y] = q.front();
        q.pop_front();
        if (x == gx && y == gy) {
            ans = c;
            break;
        }
        if (cost[y][x] < c) continue;
        cost[y][x] = c;
        REP(dx, -2, 3) {
            REP(dy, -2, 3) {
                if (dx == 0 && dy == 0) continue;
                int nc = 1;
                if (dx * dy == 0 && abs(dx + dy) == 1) {
                    nc = 0;
                }
                int nx = x + dx;
                int ny = y + dy;
                if (0 <= nx && nx < w && 0 <= ny && ny < h && mp[ny][nx] == '.' && cost[ny][nx] > c + nc) {
                    if (nc == 0) {
                        q.emplace_front(c, nx, ny);
                    } else {
                        q.emplace_back(c + nc, nx, ny);
                    }
                }
            }
        }
    }
    print(ans);

    return 0;
}


Measured memory_bytes: 9368
import sys
from bisect import *
from collections import *
from copy import deepcopy
from datetime import *
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    S = input().rstrip()
    N = len(S)
    idx = 0
    ans = 0
    tmp = 0
    while idx < N:
        if S[idx] in ['A','C','G','T']:
            tmp += 1
        else:
            ans = max(ans,tmp)
            tmp = 0
        idx += 1
    print(max(ans,tmp))

if __name__ == '__main__':
    main()

Measured memory_bytes: 4080
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N,K; cin>>N>>K;
  vector<pii> A(N);
  rep(i,0,N) cin>>A[i].first>>A[i].second;
  sort(ALL(A));
  int sum=0;
  rep(i,0,N){
    sum+=A[i].second;
    if(sum>=K){
      cout<<A[i].first;
      break;
    }
  }
  }


Measured memory_bytes: 1792