akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::io::{self, Write};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, char) => {
        read_value!($next, String).chars().collect::<Vec<char>>()[0]
     };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
    ($next:expr, isize1) => {
        read_value!($next, isize) - 1
    };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}
macro_rules! printvec {
    ( $item:expr ) => {
        for &i in &$item {
            print!("{} ", i);
        }
        println!("");
    }
}
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);
impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}
impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}
#[derive(PartialEq, PartialOrd, Clone, Debug)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}
#[allow(dead_code)]
const MOD: usize = 1000000007;


fn main() {
    input!{
        N: usize, K: usize,
        h: [usize; N],
    }

    println!("{}", h.into_iter().fold(0, |acc, hi| acc + if hi >= K {1} else {0}));
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(q);
    for(int i = 0; i < q; i++) {
        cin >> a[i];
        a[i]--;
    }

    string ans;

    vector<int> score(n,0);

    REP(i, q)
    {
        score[a[i]]++;
    }

    REP(i, n)
    {
        ans = "No";
        if(score[i] > q - k) ans = "Yes";

        cout << ans << endl;
    }




}

Measured memory_bytes: 1408
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    H, N = LI()
    A = LI()
    if H - sum(A) > 0:
        print('No')
    else:
        print('Yes')

main()



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

namespace CSharpSample01
{
    
    class Program
    {

        
        static void Main(string[] args)
        {
            int[] ante = new int[5];
            for(int i = 0; i < 5; i++)
            {
                ante[i] = int.Parse(Console.ReadLine());
            }
            int k = int.Parse(Console.ReadLine());

            for(int i = 0; i < 4; i++)
            {
                int p = ante[i];
                for(int j = i + 1; j < 5; j++)
                {
                    int q = ante[j];
                    if(q - p > k)
                    {
                        Console.WriteLine(":(");
                        return;
                    }
                }
            }


            Console.WriteLine("Yay!");
        }
    }
}


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

int main(){
    int a,b;
    cin >> a >> b;
    int n;
    cin >> n;
    int frg=0;
    int s,f;
    for(int i=0;i<n;i++){
        cin >> s >> f;
        if((s<a&&a<f)||(s<b&&b<f)){
            frg=1;
            break;
        }else if(a<=s && f<=b){
            frg=1;
            break;
        }
    }
    cout << frg << endl;
    return 0;
}

Measured memory_bytes: 3112
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	          int i;

	          ll N,M;
	          cin >> N >> M;

	          if(N>=M/2) cout << M/2 << endl;
	          else cout << N+2*(M/2-N)/4 << endl;

	          return 0;
}


Measured memory_bytes: 256
package main

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

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

func scanString() string {
	if sc.Scan() {
		return sc.Text()
	}
	panic(sc.Err())
}

var sc = newScanner()

func main() {
	w := strings.ToLower(scanString())
	ans := 0
	for {
		t := scanString()
		if t == "END_OF_TEXT" {
			break
		}
		if w == strings.ToLower(t) {
			ans++
		}
	}
	fmt.Println(ans)
}



Measured memory_bytes: 1088
//#define _GLIBCXX_DEBUG
    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> pii;
    typedef map<int, int> mii;
    typedef map<char,int> mci;
    typedef vector<int> vi;
    typedef vector<vi> vvi;
    typedef vector<ll> vll;
    typedef vector<pair<int,int>> vii;
    typedef vector<char> vc;
    typedef vector<vc> vcc;
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()
    #define pb push_back
    #define mp make_pair
    #define F first
    #define S second
    #define in insert
    #define sz(v) v.size()
    #define mina(a,b) (a)=min((a),(b));
    #define maxa(a,b) (a)=max((a),(b));
    const int INF = 1e9 + 5;
    
    void solve(){
        string s; cin>>s;
        int a=s[0]-'0';
        int b=s[1]-'0';
        int c=s[2]-'0';
        int d=s[3]-'0';
        a=a*10+b;
        c=c*10+d;
        if(a>=1 && a<=12 && c>=1 && c<=12) cout<<"AMBIGUOUS";
        else if(a>=1 && a<=12) cout<<"MMYY";
        else if(c>=1 && c<=12) cout<<"YYMM";
        else cout<<"NA";
    }
    int main(){
        int T=1;
        //cin>>T;
        for(int i = 0; i < T; i++) solve(); 
    }

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>

using namespace std;

const double EPS = 1e-9;

double solve(double d, double px, double py, double vx, double vy) {
  if (px * vx + py * vy > (1 - EPS) * hypot(px, py) * hypot(vx, vy)) {
    double d2 = 2 - hypot(px, py);
    return d2 < d - EPS? d2: -1;
  } else if (px * vx + py * vy < (-1 + EPS) * hypot(px, py) * hypot(vx, vy)) {
    double d2 = hypot(px, py);
    return d2 < d - EPS? d2: -1;
  } else {
    return -1;
  }
}

int main() {
  double d, px, py, vx, vy, ans;
  cout.precision(20);
  while (true) {
    cin >> d;
    if (d == 0) {
      return 0;
    }
    cin >> px >> py >> vx >> vy;
    ans = solve(d, px, py, vx, vy);
    if (ans < 0) {
      cout << "impossible" << endl;
    } else {
      cout << fixed << ans << endl;
    }
  }
}

Measured memory_bytes: 1292
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repA(i,a,b) for(int i=a;i<=b;i++)
#define repD(i,b,a) for(int i=b;i>=a;i--)
#define fill(a) memset(a,0,sizeof(a))
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <set>
#include <map>
#include <math.h>
#include <bitset>
#include <vector>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

typedef long long ll;

const ll INF = 1e18, MOD = 1e9 + 7;
const int INT_MAX = 1e9;

ll n, k;

ll d[100][100002], a[100], p[100][100002];

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

	for (int i = 0; i < n; i++)
		scanf ("%lld", &a[i]);

	for (int i = 0; i <= a[0]; i++)
		d[0][i] = 1;

	for (int i = k; i >= 0; i--)
		p[0][i] = (d[0][i] + p[0][i + 1]) % MOD;

	for (int i = 1; i < n; i++)
	{
		for (int j = k; j >= 0; j--)
		{
			d[i][j] = (p[i - 1][max (0LL, j - a[i])] + MOD - p[i-1][j + 1]) % MOD;
			p[i][j] = (p[i][j + 1] + d[i][j]) % MOD;
		}
	}

	cout << d[n-1][k];

}


Measured memory_bytes: 156544
import heapq
n, m = [int(item) for item in input().split()]
a = [-int(item) for item in input().split()]

heapq.heapify(a)

for i in range(m):
    highest = heapq.heappop(a)
    highest /= 2.0
    heapq.heappush(a, highest)

ans = 0
for item in a:
    ans += int(item)
print(-ans)

Measured memory_bytes: 14180
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int n;
vector<int> h;

ll dp[100100];

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

int main(){
    cin >> n;
    h.resize(n);

    rep(i,n){
        cin >> h[i];
    }

    rep(i,100100){
        dp[i] = 1e9;
    }
    dp[0] = 0;

    for(int i=0; i<n; i++){
        chmin(dp[i+1], dp[i] + abs(h[i+1] - h[i]));
        chmin(dp[i+2], dp[i] + abs(h[i+2] - h[i]));
    }
    

    dunk(dp[n-1]);
}

Measured memory_bytes: 1408
#include <stdio.h>

int main(){
  int N, H[100000], i, max = 0, cnt=0;

  scanf("%d", &N);
  for(i=0;i<N;i++){
  	scanf("%d", &H[i]);
  }
  
  for(i=0;i<N-1;i++){
  	if(H[i]>=H[i+1]){
    	cnt++;
    }else{
    	if(cnt>max){
        	max = cnt;
        }
      	cnt = 0;
    }
  }
 	if(cnt>max){
        max = cnt;
    }
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    string s;
    int n,k;
    cin>>n>>s>>k;
    for(int i=0;i<n;i++){
        if(s[i]!=s[k-1])s[i]='*';
    }
    cout<<s<<endl;
}


Measured memory_bytes: 256
const MOD = 10**9+7
// factors[f].e+n-1、において max(n)=10**5, max(factors[f].e)=log(M)=log(10**9)=29.89..=30
const N = 10**5+30

let fac = [...new Array(N)].fill(0)
let ifac = [...new Array(N)].fill(0)
const mul = (a,b) => ((a>>16)*b%MOD*65536+(a&65535)*b)%MOD;

const factorization = (n) => {
    let primes= []
    for(let i=2; i*i<=n; i++) {
        let exponent = 0
        while(n%i===0) {
            n /= i
            exponent++
        }
        if(exponent) {
            primes.push({p:i, e:exponent})
        }
    }
    
    if(n!==1) {
        primes.push({p:n, e:1})
    }
    return primes
}

const mpow = (x, n) => {
    ans = 1;
    let _x = x
    while(n != 0){
        if(n & 1) ans = mul(ans,_x);
        _x = mul(_x,_x);
        n = n >> 1;
    }
    return ans;
}

const comb = (n, r) => {
    if(n == 0 && r == 0) return 1;
    if(n < r || n < 0) return 0;
    // const tmp = mul(ifac[n-r],ifac[r])
    // return mul(tmp,fac[n])
    return mul(mul(fac[n],ifac[r]), ifac[n-r])
}

const init = () => {
    fac[0] = 1;
    ifac[0] = 1;
    for(let i=0; i<N; i++){
        fac[i+1] = mul(fac[i],(i+1));
        ifac[i+1] = mpow(fac[i+1], MOD - 2)
    }
}

const main = (arg) => {
    let [n, m] = arg.split(" ").map(Number)
    let factors = factorization(m)
    let ans = 1
    init()
    Object.keys(factors).forEach(f=>{
        let a = factors[f].e+n-1
        let b = factors[f].e
        ans = mul(ans,comb(a, b))
    })
    console.log(ans)
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 40828
#include <bits/stdc++.h>
using namespace std;
#define ll	    long long
#define vi      vector <ll>
#define vii     vector <pair<int,int>>
#define ii      pair<int,int>
#define loop(n)	for(ll i=0;i<n;i++)
#define pb      push_back
const ll mod=1e9+7;
void fast();
int main()
{
    int n;
    cin>>n;
    int a[n],mn=1e9+5,cnt=0,neg=0;
    ll sum=0;
    loop(n){
        cin>>a[i];
        if(a[i]<0)
            cnt++;
        else
            neg+=cnt%2,cnt=0;
        sum+=abs(a[i]);
        mn=min(mn,abs(a[i]));
    }
    neg+=cnt%2;
    if(neg&1)
        sum-=2*mn;
    cout<<sum;
}
void fast(){
std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
/// 20
/// 15 7 13 15 15 15 15 13 19
/*

*/


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
#define lint long long
#define ll long long
static const int INF = 1 << 22;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007

/*******source code below********/
int N;
int e[101];
int numcnt(int n) {
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (e[i] >= n - 1) ans++;
	}
	return ans;
}
int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		int cur = i;
		for (int j = 2; j <= N; j++) {
			while (cur %j == 0) {
				e[j]++;
				cur /= j;
			}
		}
	}

	cout << numcnt(75) + numcnt(25)*(numcnt(3) - 1) + numcnt(15)*(numcnt(5) - 1)
		+ numcnt(5)*(numcnt(5) - 1)*(numcnt(3) - 2) / 2 << endl;
	return 0;

}

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

int main() {
    int n; cin >> n;
    string s; cin >> s;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') a[i] = 0;
        if (s[i] == 'G') a[i] = 1;
        if (s[i] == 'B') a[i] = 2;
    }
    vector<long long> cnt(3);
    for (int i = 0; i < n; i++) {
        cnt[a[i]]++;
    }
    long long ans = 1;
    for (int i = 0; i < 3; i++) {
        ans *= cnt[i];
    }

    for (int j = 0; j < n; j++) {
        for (int i = 0; i < j; i++) {
            int k = j + (j - i);
            if (k < n) {
                if (a[i] == a[j]) continue;
                if (a[j] == a[k]) continue;
                if (a[k] == a[i]) continue;
                ans--;
            }
        }
    }

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

Measured memory_bytes: 3652
#pragma comment(linker, "/STACK:512000000")
#define _CRT_SECURE_NO_WARNINGS
//#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve();
void precalc();
clock_t start;
//int timer = 1;

int testNumber = 1;

bool todo = true;

int main() {
#ifdef AIM
    freopen("/home/alexandero/ClionProjects/ACM/input.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    start = clock();
    int t = 1;
    cout.sync_with_stdio(0);
    cin.tie(0);
    precalc();
    cout.precision(10);
    cout << fixed;
    //cin >> t;
    int testNum = 1;
    while (t--) {
        //cerr << testNum << endl;
        //cout << "Case #" << testNum++ << ": ";
        solve();
        ++testNumber;
        //++timer;
    }

#ifdef AIM
    cerr << "\n\n time: " << (clock() - start) / 1.0 / CLOCKS_PER_SEC << "\n\n";
#endif

    return 0;
}

//BE CAREFUL: IS INT REALLY INT?

template<typename T>
T binpow(T q, T w, T mod) {
    if (!w)
        return 1 % mod;
    if (w & 1)
        return q * 1LL * binpow(q, w - 1, mod) % mod;
    return binpow(q * 1LL * q % mod, w / 2, mod);
}

template<typename T>
T gcd(T q, T w) {
    while (w) {
        q %= w;
        swap(q, w);
    }
    return q;
}
template<typename T>
T lcm(T q, T w) {
    return q / gcd(q, w) * w;
}

void precalc() {

}

//#define int li

//const int mod = 1000000007;


void solve() {
    int n;
    cin >> n;
    int sum = 0;
    for (int i = 1; i <= n; ++i) {
        sum += i;
        if (sum >= n) {
            int val = i;
            vector<int> ans;
            while (n) {
                int cur = min(n, val);
                --val;
                ans.push_back(cur);
                n -= cur;
            }
            sort(all(ans));
            for (int x : ans) {
                cout << x << "\n";
            }
            return;
        }
    }
}


















































Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;int main(){char s[10000];int len;scanf("%s",s+1);int flag=0;for(int i=1;i<=strlen(s+1);++i){if(flag==0&&s[i]=='C')flag=1;if(flag==1&&s[i]=='F')flag=2;}if(flag==2)puts("Yes");else puts("No");}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
H,W = map(int,input().split())
meiro = []
for h in range(H):
    meiro.append(input())
from collections import deque
Q = deque([[0,0]])
ansmap = [[-1 for _ in range(W)] for __ in range(H)]
ansmap[0][0] = 0
step = 0
while Q:
    cue = Q.popleft()
    step = ansmap[cue[0]][cue[1]]
    for i in range(4):
        # 上
        if cue[0]-1 >= 0:
            if meiro[cue[0]-1][cue[1]] == "." and (ansmap[cue[0]-1][cue[1]] > step+1 or ansmap[cue[0]-1][cue[1]] == -1):
                ansmap[cue[0]-1][cue[1]] = step+1
                Q.append([cue[0]-1,cue[1]])
        # 右
        if cue[1]+1 < W:
            if meiro[cue[0]][cue[1]+1] == "." and (ansmap[cue[0]][cue[1]+1] > step+1 or ansmap[cue[0]][cue[1]+1] == -1):
                ansmap[cue[0]][cue[1]+1] = step+1
                Q.append([cue[0],cue[1]+1])
        # 下
        if cue[0]+1 < H:
            if meiro[cue[0]+1][cue[1]] == "." and (ansmap[cue[0]+1][cue[1]] > step+1 or ansmap[cue[0]+1][cue[1]] == -1):
                ansmap[cue[0]+1][cue[1]] = step+1
                Q.append([cue[0]+1,cue[1]])
        # 左
        if cue[1]-1 >= 0:
            if meiro[cue[0]][cue[1]-1] == "." and (ansmap[cue[0]][cue[1]-1] > step+1 or ansmap[cue[0]][cue[1]-1] == -1):
                ansmap[cue[0]][cue[1]-1] = step+1
                Q.append([cue[0],cue[1]-1])
cnt=0
for m in meiro:
    cnt += m.count('#')
if ansmap[H-1][W-1] == -1:
    print(-1)
else:
    print(H*W - ansmap[H-1][W-1]-1 - cnt)


Measured memory_bytes: 44400
#include<stdio.h>
int main(void){
    int N,a[100],i,j,max=0,sum=0,n;
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&a[i]);
    }
    i=0;
    while(i<N){
        for(j=0;j<N;j++){
            if(max<a[j]){
                max=a[j];
                n=j;
            }
        }
        if(i%2==0){
            sum+=max;
        }
        else{
            sum-=max;
        }
        a[n]=max=0;
        i++;
    }
    printf("%d\n",sum);
	return 0;		
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
ll INF = LLONG_MAX;
 
using vc = vector<char>;
using vi = vector<int>;
using vll = vector<ll>;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int N, K; cin >> N >> K;
    vll xs (N);
    vll ys (N);
    F0R(i, N) cin >> xs[i] >> ys[i];

    ll area = INF; 
    FOR(i, 0, N) {
        FOR(j, i+1, N) {
            ll l = min(xs[i], xs[j]);
            ll r = max(xs[i], xs[j]);

            FOR(k, 0, N) {
                if (!(l <= xs[k] && xs[k] <= r)) continue;    
                FOR(m, k+1, N) {
                    if (!(l <= xs[m] && xs[m] <= r)) continue;
                    ll u = min(ys[k], ys[m]);
                    ll d = max(ys[k], ys[m]);

                    int inside = 0;
                    F0R(p, N) {
                        if (l <= xs[p] && xs[p] <= r && u <= ys[p] && ys[p] <= d) ++inside;
                    }
                    if (inside >= K) {
                        area = min(area, (r-l) * (d-u));
                    }
                }
            }
        }
    }
    cout << area << endl;
}


Measured memory_bytes: 256
N = int(input())
S = input()
memo_1 = set()
memo_2 = set()
memo_3 = set()

for i in range(N):
    for ii in memo_2:
        memo_3.add(ii + S[i])
    for j in memo_1:
        memo_2.add(j + S[i])
    memo_1.add(S[i])


#print(memo_1)
#print(memo_2)
#print(memo_3)
print(len(memo_3))




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

class Program {
    static void Main() {
        int[] arr = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        Console.WriteLine("{0} {1} {2:f7}", arr[0] / arr[1], arr[0] % arr[1], 1.0 * arr[0] / arr[1]);
    }
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int n, m; cin >> n >> m;
  using Taplis = tuple<int64_t, int64_t, int64_t>;
  vector<Taplis> data;
  rep(i, n) {
    int64_t x, y, z; cin >> x >> y >> z;
    data.emplace_back(x, y, z);
  }

  int64_t max_sum = 0;  

  for (int xf = -1; xf < 2; xf += 2)
  for (int yf = -1; yf < 2; yf += 2)
  for (int zf = -1; zf < 2; zf += 2) {
    auto const xyzsummer = [&](Taplis const& t) {
      return get<0>(t) * xf + get<1>(t) * yf + get<2>(t) * zf;
    };
    sort(data.begin(), data.end(), [&](auto const& lhs, auto const& rhs) {
      return xyzsummer(lhs) > xyzsummer(rhs);
    });
    int64_t sum = 0;
    rep(i, m) {
      sum += xyzsummer(data[i]);
    }
    maximize(max_sum, sum);
  }
  cout << max_sum << endl;
}


Measured memory_bytes: 256
/*huzaifa242 copyright*/
#include <bits/stdc++.h>
using namespace std;
#define PI 3.1415926535897932384626
#define mod 1000000007
#define MAX 100005
int dp[MAX];
vector<int> nn(105);
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);  
    #endif
    int i,j,n,k;
    cin>>n>>k;
    memset(dp,0,sizeof(dp));
    for(i=0;i<n;i++)
    cin>>nn[i];
    for(i=1;i<=k;i++)
    {
        for(j=0;j<n;j++)
        if(i-nn[j]>=0)
        dp[i]|=(!dp[i-nn[j]]);
    }
    cout<<(dp[k]==0?"Second":"First")<<"\n";
    return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rept(i,k,n) for(ll i = (k); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<long long,long long> Pll;
typedef tuple<int,int,int> Tii;

template <typename T>
ostream& operator<<(ostream& s, const vector<T> &vec){
    for(int i=0;i<vec.size();i++){
        if(i) s << ',';
        else s << '{';
        s <<setw(2)<< vec[i];
    }
    s << '}' << endl;
    return s;
}
ll mod = 998244353;

int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    vector<vector<ll>> dp(c+1,vector<ll>(d+1,0));
    dp[a][b]=1;
    rept(i,a,c+1){
        rept(j,b,d+1){
            if(i==a&&j==b) continue;
        //    dp[i][j]=(dp[i-1][j]+dp[i][j-1]+(dp[i-1][j]-dp[i-1][j-1]*(i-1))*(j-1)+(dp[i][j-1]-dp[i-1][j-1]*(j-1))*(i-1)+dp[i-1][j-1]*(i-1)*(j-1))%mod;
            dp[i][j]=(dp[i-1][j]*j+dp[i][j-1]*i-(dp[i-1][j-1])*(i-1)*(j-1)+mod*(i-1)*(j-1))%mod;
        }
    }
    cout<<dp[c][d]<<endl;
    return 0;
}

Measured memory_bytes: 73680
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define m0(x) memset(x,0,sizeof(x))
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

map<ll, ll> primeFactors(ll n)
{
    map<ll, ll> ret;
    while (n % 2 == 0)
    {
        if( ret.find(2) != ret.end() ) {
            ret[2]++;
        }
        else
        {
            ret[2] = 1;
        }
        n = n / 2;
    }
    for (ll i = 3; i <= sqrt(n); i = i+2)
    {
        while (n%i == 0)
        {
            if( ret.find(i) != ret.end() ) {
            ret[i]++;
        }
        else
        {
            ret[i] = 1;
        }
            n = n / i;
        }
    }
    if (n > 2)
        {
            if( ret.find(n) != ret.end() ) {
            ret[n]++;
        }
        else
        {
            ret[n] = 1;
        }
        }
    return ret;
}

void print_map(map<ll, ll> mp){
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        std::cout << "key = " << itr->first           // キーを表示
                        << ", val = " << itr->second << "\n";    // 値を表示
    }
}

// Returns nCr % p
ll nCrModp(ll n, ll r, ll p)
{
    ll C[r+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j-1])%p;
    }
    return C[r];
}

ll hantokei(ll a, ll b, ll L) {
    ll count = 0;
    while (a % L != b)
    {
        a++;
        count++;
    }
    return count;
}

ll  tokei(ll a, ll b, ll L) {
    ll count = 0;
    while (a != b) {
        if (a == 0) {
            a = L;
        }
        a--;
        count++;
    }
    return count;
}
int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
int main()
{
    vector<int> v(4);
    cin >>
        v.at(0) >> v.at(1) >> v.at(2) >> v.at(3);

    if(vector_finder(v, 1) * vector_finder(v, 7) * vector_finder(v, 9) * vector_finder(v, 4)){
        cout << "YES" << endl;
    }else {
        cout << "NO" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


def main():
    l = list(map(int, input().split()))
    l = sorted(l)
    small = l[2] // 2
    large = l[2] - small
    print((large - small) * l[0] * l[1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <set>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

const int N = 26;
int D;
int c[26];
int s[365][26];
int t[365];
int M;
int d[100000], q[100000];
set<int> lasts[26];

void update_score(int &score, int d, int b) {
	int a = t[d];
	
	//aを消す
	set<int>::iterator itL = prev(lasts[a].lower_bound(d));
	set<int>::iterator itR = lasts[a].upper_bound(d);
	score -= c[a] * (d - *itL) * (*itR - d);
	score -= s[d][a];
	
	//bを追加する
	itL = prev(lasts[b].lower_bound(d));
	itR = lasts[b].upper_bound(d);
	score += c[b] * (d - *itL) * (*itR - d);
	score += s[d][b];
	
	lasts[a].erase(d);
	lasts[b].insert(d);
	t[d] = b;
}

int main() {
	int i, j;
	
	cin >> D;
	rep(i, N) cin >> c[i];
	rep(i, D) rep(j, N) cin >> s[i][j];
	rep(i, D) { cin >> t[i]; t[i]--; }
	cin >> M;
	rep(i, M) { cin >> d[i] >> q[i]; d[i]--; q[i]--; }
	
	int score = 0;
	rep(i, D) score += s[i][t[i]];
	
	rep(i, N) {
		int last = -1;
		int damage = 0;
		
		lasts[i].insert(-1);
		lasts[i].insert(D);
		rep(j, D) {
			if (t[j] == i) {
				last = j;
				lasts[i].insert(j);
			}
			damage += j - last;
		}
		score -= c[i] * damage;
	}
	
	rep(i, M) {
		update_score(score, d[i], q[i]);
		cout << score << endl;
	}
	return 0;
}

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

using namespace std;

int main(void) {
    string s, t;
    cin >> s >> t;
    long n = s.size(), m = t.size();
    
    for(long i=n-m; i>=0; i--) {
        bool ok = true;
        for(long j=0; j<m; j++)
            ok &= (s[i+j] == '?' || s[i+j] == t[j]);
        if(ok) {
            for(long j=0; j<m; j++)
                s[i+j] = t[j];
            for(long i=0; i<n; i++)
                if(s[i] == '?') s[i] = 'a';

            cout << s << endl;
            return 0;
        }
    }

    cout << "UNRESTORABLE" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1<<30
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define RREP(i,a,b) for(ll i=(a); i>=(b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> p;
typedef vector<pair<ll, ll>> vpl;


ll dp[2005][2005] = {};
ll comb(ll n, ll k){
    if(dp[n][k] != 0) return dp[n][k];
    rep(i,n+1){
        dp[i][0] = 1;
        dp[i][i] = 1;
    }
    REP(i, 2, n+1){
        REP(j, 1, i){
            dp[i][j] = (dp[i-1][j-1] % MOD + dp[i-1][j] % MOD) % MOD;
            //printf("%d \n",dp[i][j]);
        }
        //cout << "\n";
    }

    return dp[n][k];
}

int main(){
    ll n,k; cin >> n >> k;
    REP(i,1,k+1){
        cout << comb(n-k+1,i) * comb(k-1,i-1) % MOD << "\n";
    }
}

Measured memory_bytes: 30080
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){ 
    string op; cin >> op;
    int res = 0;
    rep(i,4) op[i] == '+' ? res++ : res-- ;
    cout << res << ln;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fs first
#define se second
#define pb push_back
using namespace std;

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

const int maxn=5e5+5;
const ll inf=0x3f3f3f3f;
const ll mod=1e9+7;

char s[maxn];

ll n;
int check(ll num){
	ll tmp=n;
	while(tmp%num==0) tmp/=num;
	if(tmp%num==1){
		return 1;
	}
	else return 0;
}

int main(){	
	scanf("%lld",&n);
	ll ans=2;	
	if(n==2){
		printf("1");return 0;
	}
	for(ll i=2;i*i<=n;i++){
		ans+=check(i);
		if(i*i!=n&&n/i!=i) ans+=check(n/i);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
import copy
import sys
from _operator import itemgetter
from collections import Counter
from math import log2, pi, ceil

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()

s = input()
c = Counter(s)
print('Yes' if len(c.keys()) == 2 and max(c.values()) == 2 else 'No')

Measured memory_bytes: 3444
//BISMILLAHHIR RAHMANIR RAHIM
#include<bits/stdc++.h>
using namespace std;
typedef long long int            ll;
typedef unsigned long long int   ull;
#define min3(a,b,c)              min(a,min(b,c))
#define F                        first
#define S                        second
#define PB                       push_back
#define MP                       make_pair
#define PI                       2*acos(0.0)
#define MOD                      998244353
int main()
{
   int n;
   ll sum=0;
   cin>>n;
   for(int i=1; i<=n; i++){
    if(i%3==0){
        continue;
    }
    else if(i%5==0){
        continue;
    }
    sum+=i;
   }
   cout<<sum<<endl;
}


Measured memory_bytes: 3600
package main
     
import "fmt"
 
func main() {
    a := make([][]int, 3)
    for i := range a {
        a[i] = make([]int, 3)
    }
    for i := range a  {
        for j := range a[i]  {
            fmt.Scan(&a[i][j])
        }
    }
    var n int
    var b []int
    fmt.Scan(&n)
    b = scanNums(n)

    for i := range b {
        a = strSearch(a, b[i])
    }

    ans := "No"
    for i := range a {
        if a[i][0] == a[i][1] && a[i][1] == a[i][2] { ans = "Yes"}
        if a[0][i] == a[1][i] && a[1][i] == a[2][i] { ans = "Yes"}
    }
    if a[0][0] == a[1][1] && a[1][1] == a[2][2] { ans = "Yes"}
    if a[2][0] == a[1][1] && a[1][1] == a[0][2] { ans = "Yes"}

    fmt.Println(ans)
}

func scanNums(len int) (nums []int) {
    var num int
    for i := 0; i < len; i++ {
        fmt.Scan(&num)
        nums = append(nums, num)
    }
    return
}

func strSearch(a [][]int, b int) [][]int {
    for i := 0; i < len(a); i++ {
        for j := 0; j < len(a[i]); j++ {
            if a[i][j] == b {
                a[i][j] = -1
            }
        }
    }
    return a
}

Measured memory_bytes: 512
#include <cstdio>
#include <vector>
#define N 100005
using namespace std;
int n, a, b, c, x[N], y[N];
vector<int> v[N];

void f(int p, int q, int z[]) {
	if(z[p]!=0) return;
	z[p] = q;
	for(int i=0; i<v[p].size(); i++) f(v[p][i], q+1, z);
}

int main() {
	int i;
	scanf("%d", &n);
	for(i=0; i<n-1; i++) {
		scanf("%d%d", &a, &b);
		v[a].push_back(b);
		v[b].push_back(a);
	}
	f(1, 1, x);
	f(n, 1, y);
	for(i=1; i<=n; i++) x[i]<=y[i] ? c++ : c--;
	puts(c>0 ? "Fennec":"Snuke");
	return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
struct State{
    int h, w;
 
    State(){}
    State(int h, int w) : h(h), w(w) {}
   
    int area(){
	return h*w;
    }
    int perimeter(){
	return 2*(h+w);
    }
};
 
int main(){
    int N, W, D;
 
    while(cin >> N >> W >> D, (N | W | D)){
	int p, s;
	vector<State> cakes;
	cakes.push_back(State(W,D));
	for(int i = 0 ; i < N ; i++){
	    cin >> p >> s; p--;
	    State cake = cakes[p], a, b;
	    cakes.erase(cakes.begin()+p);
	    int pos = s % (cake.perimeter()/2);
 
	    if(pos < cake.h){
		a = State(pos,cake.w);
		b = State(cake.h-pos,cake.w);
	    }else{
		pos -= cake.h;
		a = State(cake.h,pos);
		b = State(cake.h,cake.w-pos);
	    }     
	    if(a.area() < b.area()){
		cakes.push_back(a);
		cakes.push_back(b);
	    }else{
		cakes.push_back(b);
		cakes.push_back(a);
	    }
	}
	vector<int> area;
	int len = cakes.size();
	for(int i = 0 ; i < len ; i++){
	    area.push_back(cakes[i].area());
	}
	sort(area.begin(), area.end());
	for(int i = 0 ; i < len ; i++){
	    if(i != len-1) cout << area[i] << " ";
	    else cout << area[i] << endl;
	}
    }
    return 0;
}

Measured memory_bytes: 3088
{-# LANGUAGE BangPatterns #-}

module Main
  ( main
  )
where

import           Control.Applicative
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import           Control.Monad.ST
import           Data.Ord
import qualified Data.Vector.Unboxed           as UV

parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine

main = do
  [n, k] <- readIntList
  putStrLn $ if n == k then "Yes" else "No"


Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m,h[2001][2001],w[2001][2001];
char b[2001][2001];
int main(void){
    cin >> n >> m;
    for(int i=0;i<n;i++){
        cin >> b[i];
    }
    for(int i=0;i<n;i++){
        vector<int> o;
        o.clear();
        o.push_back(-1);
        for(int j=0;j<m;j++){
            if(b[i][j]=='#') {
                o.push_back(j);
                h[i][j]=-1;
            }
        }
        o.push_back(m);
        for(int x=0;x<o.size()-1;x++){
            for(int j=o[x]+1;j<o[x+1];j++){
                assert(h[i][j]==0);
                h[i][j]=o[x+1]-o[x]-1;
            }
        }
    }
    for(int j=0;j<m;j++){
        vector<int> o;
        o.clear();
        o.push_back(-1);
        for(int i=0;i<n;i++){
            if(b[i][j]=='#') {
                o.push_back(i);
                w[i][j]=-1;
            }
        }
        o.push_back(n);
        for(int x=0;x<o.size()-1;x++){
            for(int i=o[x]+1;i<o[x+1];i++){
                assert(w[i][j]==0);
                w[i][j]=o[x+1]-o[x]-1;
            }
        }
    }
    int ans=-1;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(h[i][j]==-1||w[i][j]==-1) continue;
            ans=max(ans,h[i][j]+w[i][j]);
        }
    }
    cout << ans-1 << endl;
}

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

struct union_find {
    vector<int> rank, par;
    union_find(int n) {
      rank.resize(n+1);
      par.resize(n+1);
      for(int i = 1; i <= n; i++) rank[i] = 1, par[i] = i;
    }
    int find(int x) {
        if(x == par[x]) return x;
        else return par[x] = find(par[x]);
    }
    void unite(int x, int y) {
        x = find(x); y = find(y);
        if(x == y) return;
        if(rank[x] > rank[y]) par[y] = x;
        else{
            par[x] = y;
            if(rank[x] == rank[y]) rank[y]++;
        }
    }
    bool same(int x, int y) {
        x = find(x); y = find(y);
        return x == y;
    }
};

int main(){
  int n, m; cin >> n >> m;
  union_find u = union_find(n);
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int c; cin >> c;
    v.push_back(c);
  }
  for (int i = 0; i < m; i++) {
    int a, b; cin >> a >> b;
    u.unite(a, b);
  }
  int count = 0;
  for (int i = 0; i < n; i++) {
    count += u.same(i+1, v[i]);
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 1660
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		long ans = (long) N * ((long) N - 1) / 2;
		System.out.println(ans);
	}

	int[] H;

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 21200
#include <stdio.h>
int main(void){
    // Your code here!
    int n,m;
    long int k;
    scanf("%d %d %ld",&n,&m,&k);
    
    long int a[200000]={};
    long int as[200001]={};
    for(int i=0;i<n;i++)
    {
        scanf("%ld",&a[i]);
        if(i==0){
            as[i]=0;
        }
        as[i+1]=as[i]+a[i];
        
        //printf("%d %d\n",a[i],as[i]);
    }//printf("\n");
    
    long int b[200000]={};
    long int bs[200001]={};
    for(int i=0;i<m;i++)
    {
        scanf("%ld",&b[i]);
        if(i==0){
            bs[i]=0;
        }
        bs[i+1]=bs[i]+b[i];
        
        //printf("%d ",bs[i]);
    }//printf("\n");
    
    int num=0;
    int mo=m;
    for(int i=0;i<=n;i++)
    {
        if(as[i]>k)
        {
            break;
        }
        for(int j=mo;j>=0;j--)
        {
            if(as[i]+bs[j]<=k)
            {
                if(i+j>num)
                {
                    num=i+j;
                }
                mo=j;
                break;
            }
        }
        
    }
    
    
    printf("%d\n",num);
}

Measured memory_bytes: 7940
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int H, W, K;
	cin >> H >> W >> K;
	vector<string> s(H);
	for (int i = 0; i < H; ++i) { cin >> s[i]; }

	vector<vector<int>> wc(H + 10, vector<int>(W + 10, 0));
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			wc[i + 1][j + 1] = (s[i][j] == '1');
		}
	}
	for (int i = 0; i <= H; ++i) {
		for (int j = 0; j < W; ++j) { wc[i][j + 1] += wc[i][j]; }
	}
	for (int j = 0; j <= W; ++j) {
		for (int i = 0; i < H; ++i) { wc[i + 1][j] += wc[i][j]; }
	}

	int ans = 1e8;
	for (int b = 0; b < (1<<(H - 1)); ++b) {
		vector<int> x;
		x.push_back(0);
		int tmp = 0;
		for (int i = 0; i < H - 1; ++i) {
			if ((b>>i) & 1) {
				x.push_back(i + 1);
				++tmp;
			}
		}
		x.push_back(H);

		// 左から貪欲
		int l = 0;
		bool ok = true;
		int add = 0;
		for (int j = 1; j <= W; ++j) {
			for (int i = 1; i < x.size(); ++i) {
				int x1 = x[i - 1], x2 = x[i];
				int k = wc[x2][j] - wc[x2][l] - wc[x1][j] + wc[x1][j];
				if (k > K) { ok = false; }
			}
			if (!ok) {
				if (l + 1 < j) {
					l = j - 1;
					++add;
					ok = true;
				} else {
					add = 1e8;
					j = 1e8;
				}
			}
		}
		ans = min(ans, tmp + add);
		
		// 右から貪欲
		int r = W + 1;
		add = 0;
		ok = true;
		for (int j = W; j > 0; --j) {
			for (int i = 1; i < x.size(); ++i) {
				int x1 = x[i - 1], x2 = x[i];
				int k = wc[x2][r - 1] - wc[x2][j - 1] - wc[x1][r - 1] + wc[x1][j - 1];
				if (k > K) { ok = false; }
			}
			if (!ok) {
				if (r - 1 > j) {
					r = j + 1;
					++add;
					ok = true;
				} else {
					add = 1e8;
					j = -1;
				}
			}
		}
		ans = min(ans, tmp + add);
	}
	cout << ans << endl;

	return 0;
}


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

int main()
{
    int n, d, x;
    int a[105];
    cin >> n >> d >> x;
    for(int i = 1; i <= n ; i++){
        cin >> a[i];
    }
    int answer = x;
    for(int i = 1; i <= d; i++){
        for(int j = 1; j <= n; j++){
            if((((i - 1) / a[j]) * a[j]) == (i - 1)){
                answer++;
            }
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int n, x, in, moto=0;
	vi v;
	cin >> n >> x;
	rep(i, n) {
		cin >> in;
		v.push_back(in);
	}
	sort(all(v));
	rep(i, n) {
		moto += v[i];
		if (moto > x) {
			cout << i << endl;
			return 0;
		}
	}
	int j = 0;
	while(moto <= x){
		moto += v[0];
		if (moto > x) {
			cout << j+n << endl;
			return 0;
		}
		j++;
	}
}

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

int main() {

	long res;
	string N; cin >> N;
	long mylen = N.length();

	res = (int)(N[0]) + 9 * (mylen - 1) - 49;

	if (mylen == 1) res = stoi(N);
	if (count(next(N.begin()), N.end(), '9') == mylen - 1) res = 9 * (mylen - 1) + (int)(N[0]) - 48;

	cout << res << endl;
}

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

int main() {
  string S;
  cin >> S;
  int p = 0;//最大値
  int q = 0;//現在値
  
  for(int i = 0; i < S.size(); i++){
    if(S.at(i) == 'A' || S.at(i) == 'T' || S.at(i) == 'G' || S.at(i) == 'C'){
      q++;
      if(i == S.size() - 1 && q > p){
        p = q;
      }
    }
    else if(q > p){
      p = q;
      q = 0;
    }
    else{
      q = 0;
    }
  }
  cout << p << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define ss second
#define ff first
#define INF 300000000000001
#define ll_max 9000000000000000001
#define mod 998244353
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define db(args...) {string _ss = #args; replace(_ss.begin(), _ss.end(), ',' , ' '); stringstream ___s(_ss) ; debug(___s, args);}
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;
const ll N = 300001;
const ll M = 1;
struct point {
    ll x, y;
    ll i;
};

void debug(stringstream &s){}
template <typename T, typename... Args>
void debug(stringstream &s, T a, Args... args)
{
    string word;
    s >> word;
    cout << word << " = " << a << endl;
    debug(s, args...);
}

ll fast_exp(ll x, ll n)
{
    if(n == 0) return 1;
    else if(n & 1)
        return fast_exp(x, n - 1) * x % mod;
    else
    {
        ll tmp = fast_exp(x, n >> 1);
        return tmp * tmp % mod;
    }
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    int test = 0;
    while(_--)
    {
        ll n, x = 0, y = 0, ans = 0, k;
        string s;
        cin >> s;
        if(s == "ABC")
            cout << "ARC";
        else cout << "ABC";
        //cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3636