akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#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
 
using vd=vector<double>;
using vvd=vector<vd>;
 
 
int main(){
    int h,w;
    cin>>h>>w;
    vvi f(h+2,vi(w+2,1));
    vvi walk(h+2,vi(w+2,0));
    int gy,gx,y=0,x=0,v=0;
    range(i,1,h+1)range(j,1,w+1){
        char c;
        cin>>c;
        switch(c){
            case 'G': gy=i,gx=j,f[i][j]=0; break;
            case '.': f[i][j]=0;break;
            case '#': break;
            case '^': y=i,x=j,v=0,f[i][j]=0; break;
            case '>': y=i,x=j,v=1,f[i][j]=0; break;
            case 'v': y=i,x=j,v=2,f[i][j]=0; break;
            case '<': y=i,x=j,v=3,f[i][j]=0; break;
        }
    }
    walk[y][x]=1;
    rep(loop,2655){
        vvi vec={{-1,0},{0,1},{1,0},{0,-1}};
        if(f[y+vec[(v+1)%4][0]][x+vec[(v+1)%4][1]]==0){ //右手が道なら右に曲がって前に進む
            //cout<<"hoge";
            v=(v+1)%4;
            y+=vec[v][0], x+=vec[v][1];
            walk[y][x]=1;
        }else if(f[y+vec[v][0]][x+vec[v][1]]==1){ //（右が壁で、）正面が壁なら左に回る
            //cout<<"fuga";
            v=(v+3)%4;
        }else{ //そうでないならまえに進む
            //cout<<"zako";
            y+=vec[v][0],x+=vec[v][1];
            walk[y][x]=1;
        }
        if(y==gy&&x==gx){
            break;
        }
        // cout<<y<<","<<x<<","<<v<<endl;
        // rep(i,h+2){
        //     rep(j,w+2){
        //         if(i==y&&j==x){
        //             cout<<"^>v<"[v];
        //         }else{
        //             cout<<".#"[f[i][j]];
        //         }
        //     }
        //     cout<<endl;
        // }
    }
    if(y==gy&&x==gx){
        int ans=0;
        rep(i,h+2)rep(j,w+2)ans+=walk[i][j];
        cout<<ans<<endl;
    }else cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 3192
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

x = y = 0
for i in range(n):
    dif = b[i]-a[i]
    if dif>0:x += dif//2
    else:y += -dif

print('Yes' if x>=y else 'No')

Measured memory_bytes: 4596
from sys import stdin
N = int(stdin.readline().rstrip())
Hs = [ int(_) for _ in stdin.readline().rstrip().split()]
ans = 1
highest= Hs[0]
for i in range(1,N):
    if highest <= Hs[i]:
        ans+=1
        if highest < Hs[i]:
            highest = Hs[i]
print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;

class Program
{
    public class UnionFind
    {
        private int[] data;

        public UnionFind(int size)
        {
            data = new int[size];
            for (int i = 0; i < size; i++) data[i] = -1;
        }

        public bool Unite(int x, int y)
        {
            x = Root(x);
            y = Root(y);

            if (x != y)
            {
                if (data[y] < data[x])
                {
                    var tmp = y;
                    y = x;
                    x = tmp;
                }
                data[x] += data[y];
                data[y] = x;
            }
            return x != y;
        }

        public bool IsSameGroup(int x, int y)
        {
            return Root(x) == Root(y);
        }

        private int Root(int x)
        {
            return data[x] < 0 ? x : data[x] = Root(data[x]);
        }

        public int CountRoot()
        {
            int ctr = 0;
            for (int i = 0; i < data.Length; i++)
            {
                if (i == Root(i))
                    ctr++;
            }
            return ctr;
        }
    }

    public static void Main()
    {
        int N, M;
        string[] s = Console.ReadLine().Split(' ');
        N = int.Parse(s[0]);
        M = int.Parse(s[1]);
        bool[] IsBlack = new bool[N];

        UnionFind uf = new UnionFind(N);

        for (int i = 0; i < M; i++)
        {
            s = Console.ReadLine().Split(' ');
            uf.Unite(int.Parse(s[0]) - 1, int.Parse(s[1]) - 1);
        }

        Console.WriteLine(uf.CountRoot());
    }
}

Measured memory_bytes: 15456
char s[];main(){double*q,b;for(q=s+9;~scanf("%s",s);getchar()<14&&printf("%f\n",*q)){!sscanf(s,"%lf",q+1)?b=*q--,*q=*s-47?*s-42?*s-45?*q+b:*q-b:*q*b:*q/b:*++q;}}

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

using namespace std;

using ll = long long;
using dd = double;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<dd>;
using vb = vector<bool>;

template <class T, class V>
istream& operator>>(istream& in, pair<T, V>& pair) {
    return in >> pair.first >> pair.second;
}

template <class T>
istream& operator>>(istream& in, vector<T>& elements) {
    for (size_t i = 0; i < elements.size(); ++i) {
        in >> elements[i];
    }
    return in;
}

template <class Container, class Element>
bool Contains(const Container& container, const Element& element) {
    return container.find(element) != container.end();
}

template <class T>
ostream& operator<<(ostream& out, const vector<T>& elements) {
    for (const T& element : elements) {
        out << element << ' ';
    }
    return out;
}

template <class T, class V>
ostream& operator<<(ostream& out, const pair<T, V>& pair) {
    out << pair.first << ' ' << pair.second;
}

#define FOR(i,n) for(size_t i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(c) sort((c).begin(), (c).end())

static constexpr ll kMod = 1000000007;

int64_t InverseMod(int64_t number, int64_t mod);

int64_t Plus(int64_t a, int64_t b, int64_t mod = kMod) {
    return (a + b) % mod;
}

int64_t Minus(int64_t a, int64_t b, int64_t mod = kMod) {
    return (a + mod - b) % mod;
}

int64_t Mult(int64_t a, int64_t b, int64_t mod = kMod) {
    return (a * b) % mod;
}

int64_t Divide(int64_t a, int64_t b, int64_t mod = kMod) {
    return Mult(a, InverseMod(b, mod), mod);
}

int64_t Pow(int64_t number, int64_t degree, int64_t mod) {
    if (degree == 0) {
        return 1;
    }
    int64_t multiplier = Pow(number, degree / 2, mod);
    int64_t result = Mult(multiplier, multiplier, mod);
    if (degree % 2 != 0) {
        result = Mult(result, number, mod);
    }
    return result;
}

int64_t GcdExtended(int64_t a, int64_t b, int64_t& x, int64_t& y) {
    if (a == 0) {
        x = 0; y = 1;
        return b;
    }
    int64_t x1, y1;
    int64_t d = GcdExtended(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}

int64_t InverseMod(int64_t number, int64_t mod) {
    int64_t x, y;
    int64_t gcd = GcdExtended(number, mod, x, y);
    assert(gcd == 1);
    int64_t result = (x % mod + mod) % mod;
    assert(Mult(number, result, mod) == 1);
    return result;
}

ll Factorial(ll n) {
    ll result = 1;
    for (int i = 2; i <= n; ++i) {
        result = Mult(result, i);
    }
    return result;
}

ll Binomial(ll n, ll k) {
    if (n < k) {
        return 0;
    }
    return Divide(Factorial(n), Mult(Factorial(k), Factorial(n - k)));
}

ll BinWithRep(ll n, ll k) {
    return Binomial(n + k - 1, k);
}

int main() {
    ios_base::sync_with_stdio(false);
    
    ll n, k;
    cin >> n >> k;
    
    for (int i = 1; i <= k; ++i) {
        ll p = n - k + 1;
        cout << Mult(Binomial(p, i), BinWithRep(i, k - i)) << '\n';
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,ans,a[100005],prfx[100005];
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n>>m;
    for(ll i=1;i<=n;i++)cin>>a[i];
    for(ll i=1;i<=n;i++)prfx[i]=prfx[i-1]+a[i];
    map<ll,ll> mp;
    mp[0]++;
    for(ll i=1;i<=n;i++){
        ans+=mp[prfx[i]%m];
        mp[prfx[i]%m]++;
    }
    cout<<ans;
}

Measured memory_bytes: 5760
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
// #include <bits/stdc++.h> all

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  int h,n; cin >> h >> n;
  ll sum = 0;
  for(int i = 0; i < n; i++){
    int temp;
    cin >> temp;
    sum += temp;
  }

  if(sum >= h){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  

  return 0;
}

Measured memory_bytes: 384
Scanf.scanf "%d %d" (fun n p ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in

    let rec loop i p0 p1 =
        if i = n then (if p = 0 then p0 else p1) else
            if a.(i) mod 2 = 0 then loop (i + 1) (p0 * 2) (p1 * 2) else
                                    loop (i + 1) (p0 + p1) (p0 + p1)
    in
    loop 0 1 0 |> Printf.printf "%d\n"
)

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

const int NONE = -1;
const int NMAX = 18;
int n;
int memo[1<<NMAX];
int T[NMAX][NMAX];

int solve( int s ) {
    if ( memo[s] != NONE ) return memo[s];
    if ( s == ((1<<n)-1) ) return 0;
    int res = 1 << 24;
    for ( int i = 0; i < n; ++ i ) {
        if ( ( s & ( 1 << i ) ) == ( 1 << i ) ) continue;
        int minT = T[i][0];
        for ( int j = 1; j < n + 1; ++ j ) {
            if ( ( s & ( 1 << ( j - 1 ) ) ) == ( 1 << ( j - 1 ) ) )
                minT = min( minT, T[i][j] );
        }
        res = min( res, minT + solve( s | ( 1 << i ) ) );
    }
    return memo[s] = res;
}

int main() {
    while ( cin >> n && n ) {
        for ( int i = 0; i < 1<<NMAX; ++ i ) {
            memo[i] = NONE;
        }
        for ( int i = 0; i < n; ++ i ) {
            for ( int j = 0; j < n + 1; ++ j ) {
                cin >> T[i][j];
            }
        }
        cout << solve(0) << endl;
    }
}

Measured memory_bytes: 1892
#include <stdio.h>

int main(){
  int N;
  char S[110] = {};
  int x = 0;
  int max = 0;
  scanf("%d %s", &N, S);
  for(int i = 0; i < N; i++){
    if(S[i] == 'I'){
      x++;
      if(x > max){
        max = x;
      }
    }else{
      x--;
    }
  }
  printf("%d\n", max);
  return 0;
}


Measured memory_bytes: 128
N, K = map(int, input().split())
V = list(map(int, input().split()))
mx = 0

for i in range(K+1):
    j = K - i
    for k in range(i+1):
        value = []
        for l in range(N):
            if (l < k or l >= N-(i-k)):
                value.append(V[l])
        value = sorted(value)
        deleteList = []
        for l in range(min(j, len(value))):
            if (value[l] < 0):
                deleteList.append(l)
        sm = 0;
        for l in range(len(value)):
            if l not in deleteList:
                sm += value[l]
        if (sm > mx):
            mx = sm
print(mx)


Measured memory_bytes: 3064
/**
 * @Author:      G_bg
 * @DateTime:    2019-07-20 20:06:20
 * @Description: 
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const double PI = 3.1415926535898;
const double E = 2.718281828459;
const int INF = 0x7fffffff;
const int mod = 1e9+7;
const int maxn=1e5+10;
int main(int argc, char const *argv[]) {
	ios::sync_with_stdio(0);cin.tie(0);
	int n,d;cin >> n >> d;
	int x = n/(2*d+1);
	if(n%(2*d+1)) x++;
	cout << x << endl;
	//system("pause");
	return 0;
}

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

using namespace std;

typedef long long ll;

ll ans = 0;

ll f(ll n)
{
	if(n == 1)
		return 1;
	else
		return f(n / 2) * 2 + 1;
}

int main()
{
	ll n;
	cin >> n;
	cout << f(n) << endl;
	return 0;
} 

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

int main(void){
  int a, b, k;
  int f, num;

  cin >> a >> b >> k;

  num = 0;

  for (int i = a; i >= 1; i--) {
    if (a % i == 0 && b % i == 0) {
      f = i;
      num++;
    }

    if (num == k) break;
  }
  cout << f << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define owo(i,a, b) for(int i=(a);i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
 
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
gp_hash_table<int, int> mp;*/
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = acos(-1);
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
ll n;
ll ans;
int main()
{   
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    cin>>n;
    owo(i, 1, n+1) {
        ans+=1LL*i*(n-i+1);
    }
    ll a, b;
    owo(i, 0, n-1) {
        cin>>a>>b;
        if(a>b)swap(a, b);
        ans-=1LL*(a*(n-b+1));
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3616
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

#[allow(non_snake_case)]
fn main() {
    input! {
        S:usize,
        W:usize,
    }
    if S <= W {
        println!("unsafe");
    } else {
        println!("safe");
    }
}


Measured memory_bytes: 2136
#include<stdio.h>
int main(void)
{
	int w,n,a[100],b[100],i,j,z,s[100];
	scanf("%d",&w);
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d,%d",&a[i],&b[i]);
	}
	for(i=1;i<=w;i++){
		z=i;
		for(j=1;j<=n;j++){
			if(z==a[j]){
				z=b[j];
			}
			else if(z==b[j]){
				z=a[j];
			}
		}
		s[z]=i;
	}
	for(i=1;i<=w;i++){
		printf("%d\n",s[i]);
	}
	return 0;
}

Measured memory_bytes: 596
import sys

def common_divisor(x):
    List = []
    for data in x:
        if(data < 1):
            List.append(0)
    for i in range(1,min(x)+1):
        stat = 1
        for data in x:
            if(data % i != 0):
                stat = 0
                break
        if(stat == 1):
            List.append(i)
    return List

List = []

for i in sys.stdin:
    List.append(i.split())

for i in range(0,len(List[1])):
    List[1][i] = int(List[1][i])

res = common_divisor(List[1])

for data in res:
    print data


Measured memory_bytes: 44696
import sys
input = sys.stdin.buffer.readline

N = int(input())

if N % 10 == 7:
    print("Yes")
    exit()
N //= 10

if N % 10 == 7:
    print("Yes")
    exit()
N //= 10

if N % 10 == 7:
    print("Yes")
    exit()

print("No")

Measured memory_bytes: 9236
MOD = 10**9+7
N,M = map(int,input().split())
A = [int(input()) for _ in range(M)]
A.reverse()

if A and A[-1] == 1:
    dp = [1,0]
    while A and A[-1] == 1:
        A.pop()
else:
    dp = [1,1]


for i in range(2,N+1):
    if A and A[-1] == i:
        dp.append(0)
        while A and A[-1] == i:
            A.pop()
    else:
        dp.append((dp[-1]+dp[-2])%MOD)

print(dp[-1])

Measured memory_bytes: 7080
<?php
fscanf(STDIN, "%s", $s);
$i = 0;
$j = 0;
$swicth = -1;
while($s[$j]){
    $swicth++;
    while(strcmp($s[$i], $s[$j])==0){
        $i++;
    }
    $j = $i;
}
print $swicth;

Measured memory_bytes: 4604
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <array>
#include <cmath>
#include <queue>
#include <stack>
#include <numeric>

using namespace std;


int main() {
	int	n, x, t;
	cin >> n >> x >> t;
	cout << ((n + (x - 1)) / x)*t << endl;
}

Measured memory_bytes: 3632
#define  _CRT_SECURE_NO_WARNINGS

#pragma comment(linker, "/STACK:256000000")

#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <deque>
#include <queue>
#include <iomanip>
#include <fstream>
#include <string>

#define ll long long 
#define ld long double 
#define fi(n) for(int i = 0; i < (n); i++)
#define FOR(i, k, n) for(int i = (k); i < (n); i++)

//const int INF = 2147483647;
const int INF = 1e9;
const long long lINF = 9223372036854775807;

using namespace std;

//#define cin in
//#define cout out

ifstream in;
ofstream out;

ll cntOfNumb(ll a)
{
	ll cnt = 0;
	while (a > 0)
		a /= 10, cnt++;
	return cnt;
}

int main()
{
	in.open("input.txt");
	out.open("output.txt");
	ll n;
	cin >> n;
	ll answ = INF;
	FOR(i, 1, sqrt(n) + 2)
	{
		if (n % i == 0)
			answ = min(answ, max(cntOfNumb(i), cntOfNumb(n / i)));
	}
	cout << answ;
	return 0;
}

Measured memory_bytes: 256
/***
 ** "Nothing f***s you harder than time."
 **     -- Ser Davos
***/

/**
  *  Author: dhruv_gheewala
  *  Date:   14.03.2020
  *  Time:   11:17:28
**/

#define DEBUG
#if __has_include("debug.h")
    #include "debug.h"
#else
    #include<bits/stdc++.h>
    using namespace std;

    #define p(str) 42
    #define o(str) 108
    #define fundri 137
    #define d(...) 1729
#endif

typedef unsigned int ui;
typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

const bool testcases = 0;
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define test int __T__=1;if(testcases)cin>>__T__;while(__T__--)
#define nl cout<<'\n'
#define pb push_back
#define pop pop_back
#define all(s) s.begin(),s.end()
#define ff first
#define ss second
#define sort_by(cont,expr) sort(all(cont),[&](const auto &lhs,const auto &rhs){return expr;})

#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;~i;i--)
#define loop(i,l,r) for(int i=l;i<r;i++)
#define rloop(i,r,l) for(int i=r;i>l;i--)

ll seed;auto random_address=[]{char *p=new char;delete p;return (uint64_t)p;};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()*(random_address()|1));
inline int rnd(int l=0,int r=INT_MAX){return uniform_int_distribution<int>(l,r)(rng);}

template<typename T,typename U>inline bool exist(T cont,U val){return cont.find(val)!=cont.end();}
template<typename T>bool isPrime(T n){for(T i=2;i*i<=n;i++)if(n%i==0)return 0;return 1;}
template<typename TAIL>inline void inp(TAIL& T){cin>>T;}
template<typename HEAD,typename... TAIL>inline void inp(HEAD &H,TAIL&... T){cin>>H;inp(T...);}
template<typename T>inline bool in_range(T a,T l,T r){return (a>=l&&a<=r);}
template<typename T,typename U>inline istream& operator >>(istream& in,pair<T,U> &a){in>>a.ff>>a.ss;return in;}
template<typename T>inline istream& operator >>(istream& in,vector<T> &a){for(auto &x : a)in>>x;return in;}

int main()
{
    std::chrono::time_point<std::chrono::high_resolution_clock> start_time, end_time;
    start_time = std::chrono::high_resolution_clock::now();

    #ifdef DHRUV_GHEEWALA
        freopen("INPUT.txt","r",stdin);
        freopen("OUTPUT.txt","w",stdout);
        freopen("DEBUG.txt","w",stderr);
    #endif
    
    fast;
    int n,w;
    test{
    
    inp(n,w);
    vi a(n),b(n);
    rep(i,n)cin>>a[i]>>b[i];
    w++;
    vector<vector<ll>> dp(n,vector<ll>(w,0));
    loop(i,a[0],w)dp[0][i]=b[0];
    loop(i,1,n)
    {
        rep(j,w)
        {
            if(j-a[i]>=0)
                dp[i][j]=max(dp[i-1][j-a[i]]+b[i],dp[i-1][j]);
            else
                dp[i][j]=max(dp[i][j],dp[i-1][j]);
        }
    }
    d(dp);
    cout<<dp[n-1][w-1],nl;
    fundri;
    
    }

    end_time = std::chrono::high_resolution_clock::now();
    ll elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
    o("\n\n======\n");
    o("Elapsed Time: "<<elapsed_time<<" ms\n");

    return 0;
}

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

const int maxN = 2e5 + 10;

struct Node
{
	int to, next;
}edge[maxN * 2 + 1];

int n;
int head[maxN + 1], tot;
int sg[maxN + 1];

inline int read()
{
	int num = 0, f = 1;
	char ch = getchar();
	while( !isdigit( ch ) ) { if(ch == '-') f = -1; ch = getchar(); }
	while( isdigit( ch ) ) num = (num << 3) + (num << 1) + (ch ^ 48), ch = getchar();
	return num * f;
}

inline void add(int x, int y)
{
	tot ++;
	edge[tot].to = y;
	edge[tot].next = head[x];
	head[x] = tot;
}

inline void dfs(int u, int pa)
{
	sg[u] = 0;
	for(int i = head[u]; i; i = edge[i].next)
	{
		int v = edge[i].to;
		if(v == pa) continue;
		dfs(v, u);
		sg[u] ^= (sg[v] + 1);
	}
}

int main()
{
	n = read();
	for(int i = 1; i < n; i++)
	{
		int x = read(), y = read();
		add(x, y); add(y, x);
	}

	dfs(1, 0);

	if(sg[1]) puts("Alice");
	else puts("Bob");
	return 0;
}


Measured memory_bytes: 6016
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double ld;

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


int main() {
    ll N;
    cin >> N;

    map<string,ll> MapS;
    vector<string> S(N);

    rep(i,N){
        cin >> S[i];
        MapS[S[i]]++;
    }

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


    ll MaxCount=0;
    rep(i,S.size()){
        MaxCount = max(MaxCount,MapS[S[i]]);
    }

    vector<string> result;
    rep(i,S.size()){
        if(MapS[S[i]] == MaxCount){
            result.push_back(S[i]);
        }
    }

    sort(result.begin(),result.end());
    rep(i,result.size()){
        cout << result[i] << endl;
    }

}



Measured memory_bytes: 33456
program train;
var 
    i, temp : integer;
    a : array[1..3] of integer;

begin
    for i := 1 to 3 do 
        read(a[i]);

    temp := a[1];
    a[1] := a[2];
    a[2] := temp;

    temp := a[1];
    a[1] := a[3];
    a[3] := temp;

    for i := 1 to 3 do
        write(a[i],' ');

end.

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

int main()
{
int m,d,c=0;
cin>>m>>d;
for(int i=4;i<=m;i++)
{
for(int j=22;j<=d;j++)
{
int p=j;
int q=j%10;
p=p/10;
if(p*q==i&&p>=2&&q>=2)
c++;
}
}
cout<<c<<endl;
return 0;
}


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

int main() {
  ll Q, H, S, D, N;
  cin >> Q >> H >> S >> D >> N;

  ll q1=Q*4, h1=H*2, s1=S;
  ll q2=Q*8, h2=H*4, s2=S*2, d2=D;
  ll min1 = min({q1, h1, s1});
  ll min2 = min({q2, h2, s2, d2});
  ll ans = min2 * (N / 2); N %= 2;
  if (N == 1) ans += min1;

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


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define N 44

int fib(int);

int main(){
  int n;
  int x;

  scanf("%d",&n);

  x=fib(n);

  printf("%d\n",x);

  return 0;
}

int fib(int n){
  int i,F[N];

  F[0]=1;F[1]=1;

  for(i=2;i<=n;i++){
    F[i]=F[i-1]+F[i-2];
  }

  return F[n];

}



Measured memory_bytes: 2104
#include<stdio.h>
int main()
{
    int count=0,i,j;
    char s[200005];
    scanf("%s",s);
    for(i=0;s[i]!='\0';i++){
        count=count+(s[i]-48);
    }
    if(count%9==0)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 1812
/*
  テ、ツクツ嘉ィツァツ津・ツスツ「テ」ツ?ョテ」ツδ愿」ツδシテ」ツδ嘉」ツつ津」ツ?敕」ツ?ョテ」ツ?セテ」ツ?セテヲツ可アテ」ツ?甘」ツ??」ツ?ィテ」ツ?凖」ツつ凝」ツ?ィテ」ツつ?」ツつ禿」ツ?ゥテ」ツ??」ツ?ェテ」ツ?ョテ」ツ?ァ
  テ、ツコツ古ヲツャツ。テ・ツ?ε」ツつーテ」ツδェテ」ツδε」ツδ嘉」ツ?ォティツ青ステ」ツ?ィテ」ツ?療」ツ?ヲテ」ツ?凝」ツつ吋FSテ」ツ??
  テ、ツコツ古ヲツャツ。テ・ツ?ε」ツつーテ」ツδェテ」ツδε」ツδ嘉」ツ?ォティツ青ステ」ツ?ィテ」ツ?凖、ツスツ愿ヲツ・ツュテ」ツ?ョテゥツ堋崚」ツ?ォテ」ツ?ェテ」ツ?ォテ」ツ?凝」ツ?療」ツつ嘉」ツδ淌」ツつケテ」ツつ津」ツ?療」ツ?ヲテ」ツ?療」ツ?セテ」ツ??
  テ・ツ渉ッティツδステヲツ?ァテ」ツ?古ゥツォツ佚」ツ??」ツ?ョテ」ツ?ァテ、ツクツ?・ツコツヲテァツエツ凖」ツ?ァティツ?ε」ツ?暗」ツ?ヲテ」ツ?凝」ツつ嘉」ツつウテ」ツδシテ」ツδ嘉」ツつ津ヲツ崢クテ」ツ??」ツ?淌ヲツ鳴ケテ」ツ?古」ツ??」ツ??」ツ?凝」ツつづ」ツ??
 */

#include <iostream>
#include <algorithm>
using namespace std;

const int dx[6] = {1,1,0,-1,-1,0};
const int dy[6] = {0,1,1,0,-1,-1};
const int MAXN = 10;
const int NONE = -1;
const int INF = (1<<28);

int N, C;
int G[MAXN][MAXN];
bool vis[MAXN][MAXN];

// テヲツ按サテ」ツつ甘・ツ?、:(テ」ツつーテ」ツδォテ」ツδシテ」ツδ療」ツ??テ」ツ?ィテゥツ堋」テヲツ篠・テ」ツ?療」ツ?ヲテ」ツつ凝」ツ??テ」ツつーテ」ツδォテ」ツδシテ」ツδ療」ツ?ォテ」ツ??」ツ?湘」ツ?、テ・ツ青ォテ」ツ?セテ」ツつ古」ツ?ヲテ」ツ??」ツつ凝」ツ??
pair<int,int> dfs(int x, int y) {
  pair<int,int> res(0, 1);
  vis[y][x] = true;
  for(int i = 0; i < 6; ++i) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(nx < 0 || nx >= N) continue;
    if(ny < 0 || ny >= N) continue;
    if(G[ny][nx] == 0) {
      res.first = 1;
      continue;
    }
    if(G[ny][nx] != G[y][x]) continue;
    if(vis[ny][nx]) continue;

    pair<int,int> p = dfs(nx, ny);
    res.first |= p.first;
    res.second += p.second;
  }
  return res;
}

int putNum(int x, int y, int num) {
  int res = 0;
  G[y][x] = num;
  fill(vis[0], vis[MAXN], false);
  for(int i = 0; i < N; ++i) {
    for(int j = 0; j < N; ++j) {
      if(!vis[i][j] && G[i][j] != 0 && G[i][j] != NONE) {
        pair<int,int> p = dfs(j, i);
        if(!p.first) {
          if(G[i][j] == num) {
            res -= p.second;
          } else {
            res += p.second;
          }
        }
      }
    }
  }
  G[y][x] = 0;
  return res;
}

int main() {
  while(cin >> N >> C && (N|C)) {
    fill(G[0], G[MAXN], NONE);
    for(int i = 0; i < N; ++i) {
      for(int j = 0; j < i+1; ++j) {
        cin >> G[i][j];
      }
    }

    // テァツュツ氾」ツ?暗」ツ?ィテ」ツ?療」ツ?ヲティツイツ?」ツ?ョテ・ツ?、テ」ツつづ」ツ?づ」ツつ甘・ツセツ療」ツつ凝」ツ?ョテ」ツ?ァテ・ツ按敕ヲツ慊淌・ツ?、テ」ツ?ォテヲツウツィテヲツ??
    int res = -INF;

    for(int i = 0; i < N; ++i) {
      for(int j = 0; j < N; ++j) {
        if(G[i][j] == 0) {
          res = max(res, putNum(j, i, C));
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main()
{
    int a,b,c,d,e;
    scanf("%d %d", &a, &b);
    c=a+b;
    d=a-b;
    e=a*b;
    if(c>=d && d>=e || c>=e && e>=d)
    {
        printf("%d\n",c);
    }
    else if (d>=c && c>=e || d>=e && e>=c)
    {
        printf("%d\n",d);
    }
    else if(e>=d && d>=c || e>=c && c>=d)
    {
        printf("%d\n",e);
    }
    return 0;
}



Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var S string
	fmt.Scan(&S)
	var SRune = []rune(S)
	var size = len(SRune)
	var even = true // 偶数
	var odd = true  // 奇数

	for i := 0; i < size; i++ {
		var danceID = SRune[i]
		if (i+1)%2 == 0 {
			if even && !(danceID == rune('L') || danceID == rune('U') || danceID == rune('D')) {
				even = false
			}
		} else {
			if odd && !(danceID == rune('R') || danceID == rune('U') || danceID == rune('D')) {
				odd = false
			}
		}
	}
	if even && odd {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int ans=0,l,r,d;
  scanf("%d%d%d",&l,&r,&d);
  for(int i=l;i<=r;i++)
  {
    if(i%d==0)
      ans++;
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 3720
def smaller(m, n):
	if m < n: return m
	else: return n

A, B, C, X, Y = map(int, raw_input().split())

smallerpizza = smaller(X, Y)
morepizza = X + Y - 2*smallerpizza
neededpizza = ''
if smallerpizza == X: neededpizza = 'B'
else: neededpizza = 'A'

cost1 = A + B
if 2 * C < cost1: cost1 = 2 * C
cost2 = 0
if neededpizza == 'A': cost2 = A
if neededpizza == 'B': cost2 = B
if 2 * C < cost2: cost2 = 2 * C

print cost1 * smallerpizza + cost2 * morepizza

Measured memory_bytes: 2568
#include <algorithm>
#include <array>
#include <assert.h>
#include <bitset>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstring>
#include <functional>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <istream>

#include <map>
#include <math.h>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <stdint.h>

namespace asl
{
    class DisjointSet
    {
    public:
        std::vector<int> ds;

        DisjointSet(int n)
        {
            ds = std::vector<int>(n, -1);
        }

        int root(int a)
        {
            return ds[a] < 0 ? a : ds[a] = root(ds[a]);
        }

        bool join(int u, int v)
        {
            u = root(u), v = root(v);

            if (u == v)
                return false;

            if (ds[u] < ds[v])
                std::swap(u, v);

            ds[v] += ds[u];
            ds[u] = v;

            return true;
        }

        bool same(int u, int v)
        {
            return root(u) == root(v);
        }

    };
} 

#include <experimental/optional>

#include <tuple>

#include <random>

#include <utility>

#define endl '\n'

using namespace std;
using namespace asl;

void solve()
{
    int n, q;
    cin >> n >> q;

    DisjointSet ds(n);

    while (q--)
    {
        int t, u, v;
        cin >> t >> u >> v;

        if (t == 0)
        {
            ds.join(u, v);
        }
        else
        {
            cout << ds.same(u, v) << endl;
        }
    }
}

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

    int t = 1;

    for (int i = 1; i <= t; ++i)
    {
        solve();
    }

    return 0;
}




Measured memory_bytes: 4000
#include<stdio.h>
int main(void){
int H,W,i,j;
while(1){
scanf("%d%d",&H,&W);
if(H==0 && W==0) break;

for(i=0;i<H;i++){
 for(j=0;j<W;j++){
  printf("#");
}
 printf("\n");
}
 printf("\n");
}
}


Measured memory_bytes: 2084
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main ()
{
	int n, x;
	while (readf (" %s %s", &n, &x) > 0)
	{
		readln;
		auto a = readln.split.map !(to !(long)).array;
		a ~= a;
		auto b = a.dup;
		long res = long.max;
		foreach (i; 0..n)
		{
			res = min (res, x * 1L * i + sum (b[n..n * 2]));
			foreach (j; n..n * 2)
			{
				b[j] = min (b[j], a[j - i - 1]);
			}
		}
		writeln (res);
	}
}


Measured memory_bytes: 508
pub fn read_parameters<T>() -> Result<Vec<T>, String>
where
    T: std::str::FromStr,
{
    let mut line = String::new();

    match std::io::stdin().read_line(&mut line) {
        Ok(0) => return Err("eof".to_string()),
        Ok(_) => (),
        Err(err) => return Err(format!("{:?}", err)),
    }

    line.trim()
        .split_whitespace()
        .map(|x| x.parse::<T>())
        .collect::<Result<Vec<T>, _>>()
        .map_err(|_| format!("{}", "parse error"))
}

fn main() {
    let xv = read_parameters::<f64>().unwrap();
    let (x1, y1, x2, y2) = (xv[0], xv[1], xv[2], xv[3]);

    let r2 = (x2 - x1).powi(2) + (y2 - y1).powi(2);
    println!("{:.8}", r2.sqrt());
}



Measured memory_bytes: 5072
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			B();
		}

		public static void B()
		{
			Scanner cin = new Scanner();
			int count = cin.NextInt();
			double sum = 0;
			for (int n = 0; n < count; ++n) {
				double value = cin.NextDouble();
				string unit = cin.Next();
				if (unit == "JPY") {
					sum += value;
				} else {
					sum += value * 380000.0;
				}
			}

			Console.WriteLine(sum);
			Console.Read();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}


		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 13140
#include <iostream>
#define REP(i, a, b) for (auto i = (a); i < (b); ++i)

using namespace std;

signed main() {
   int n; cin >> n;
   string s; cin >> s;
   int lcs[n + 1][n + 1];
   REP(i, 0, n + 1) REP(j, 0, n + 1) lcs[i][j] = 0;
   REP(i, 1, n + 1)
       REP(j, i + 1, n + 1)
           if (s[i - 1] == s[j - 1] && lcs[i - 1][j - 1] < j - i)
               lcs[i][j] = lcs[i - 1][j - 1] + 1;
   int ans = 0;
   REP(i, 0, n + 1) REP(j, 0, n + 1) ans = max(ans, lcs[i][j]);
   cout << ans;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    string x;
    cin >> x;
    int n = 0, w = 0, s = 0, e = 0;
    bool cnt = false;

    rep(i, 0, x.size())
    {
        if (x[i] == 'N')
            ++n;
        if (x[i] == 'W')
            ++w;
        if (x[i] == 'S')
            ++s;
        if (x[i] == 'E')
            ++e;
    }

    if (s > 0 && n == 0)
    {
        cout << "No\n";
        return 0;
    }
    else if (n > 0 && s == 0)
    {
        cout << "No\n";
        return 0;
    }
    else if (w > 0 && e == 0)
    {
        cout << "No\n";
        return 0;
    }
    else if (e > 0 && w == 0)
    {
        cout << "No\n";
        return 0;
    }

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

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = {}
result = 0
a_sum = 0
for i in range(n):
    a_sum += a[i]
    if a_sum in b:
        result += b[a_sum]
        b[a_sum] += 1
    else:
        b[a_sum] = 1
    result += a_sum==0
print(result)

Measured memory_bytes: 111056
"use strict";
function main(input) {
  const n = parseInt(input[0]);
  const a = input[1].trim().split(" ").map(i => parseInt(i));

  let buka = [];

  for(let i=0;i<n;i++){
    buka.push(0);
  }

  for(let i=0;i<n;i++){
    buka[a[i]-1]++;
  }

  for(let i=0;i<n;i++){
    console.log(buka[i]);
  }
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Measured memory_bytes: 63284
<?php
fscanf(STDIN, '%s', $str);
$arr = str_split($str);
$ans = 0;
$list = [];
for ($i=0; $i < 3; $i++) { 
    if ($arr[$i] == 'R') {
        $ans++;
        if ($i == 2) {
            $list[] = $ans;
        }
    } else {
        $list[] = $ans;
        $ans = 0;
    }
}
echo max($list);

Measured memory_bytes: 16244
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<vector<int>> E;
vector<int> D;

void BT(int c, int p, int d)
{
    int n = 0;
    for (int e: E[c])
    if (e != p)
        BT(e, c, d+1),
        n++;
    D[d] = max(D[d], n);
}

int main()
{
    int N;
    cin>>N;
    E = vector<vector<int>>(N);
    for (int i=0; i<N-1; i++)
    {
        int a, b;
        cin>>a>>b;
        E[a-1].push_back(b-1);
        E[b-1].push_back(a-1);
    }
    int ansd = N;
    long long ansl = 0;
    for (int i=0; i<N; i++)
    {
        D = vector<int>(N+1);
        BT(i, -1, 0);
        int d;
        long long l = 1;
        for (d=0; D[d]>0; d++)
            l *= D[d];
        d++;
        if (d<ansd || d==ansd && l<ansl)
            ansd = d,
            ansl = l;
    }
    for (int i=0; i<N; i++)
    for (int e: E[i])
    if (i<e)
    {
        D = vector<int>(N+1);
        BT(i, e, 0);
        BT(e, i, 0);
        int d;
        long long l = 2;
        for (d=0; D[d]>0; d++)
            l *= D[d];
        d++;
        if (d<ansd || d==ansd && l<ansl)
            ansd = d,
            ansl = l;
    }
    cout<<ansd<<" "<<ansl<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define ld long double
#define int long long
#define double long double
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pi 3.141592653589793238
const int MOD = 1e9+7;
const int INF = 1LL<<60;


const int N = 2e5+5;

// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


void solve(){
    int n, m, k; cin>>n>>m>>k;
    vector<int> a(n), b(m);
    int ans = 0;
    For(i, 0, n){
        cin>>a[i];
    }
    For(i, 0, m){
        cin>>b[i];
    }
    For(i, 1, m){
        b[i]+=b[i-1];            
    }
    For(i, 1, n){
        a[i]+=a[i-1];
    }
    int cur = 0;
    int pos;
    For(i, 0, n){
        pos = upper_bound(all(b), k-cur)-b.begin();
        ans = max(ans, i+pos);
        cur = a[i];
        if(cur > k){
            cout<<ans;
            return;
        }
    }
    pos = upper_bound(all(b), k-cur)-b.begin();
    ans = max(ans, n+pos);
    cout<<ans;
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 6372
var input = function(){
  return input= require('fs').readFileSync('/dev/stdin', 'utf8').split("\n");
  };

var out = function(x)
{
  if (x == "0 0")
  {
    return x;
  }
  var array = x.split(" ").map(Number);

  if (array[0] < array[1])
  {
    console.log(array[0] + " " + array[1]);
  }
  else
  {
    console.log(array[1] + " " + array[0]);
  }


  return x;
}

var Arr=input()
.forEach(function(element)
{
  if (element != 0)
  {
    out(element);
  }
}
);

Measured memory_bytes: 11060
def harmony(A: int, B: int)->int:
    C = A+B
    if C % 2 == 1:
        return -1
    return C//2


if __name__ == "__main__":
    A, B = map(int, input().split())
    ans = harmony(A, B)
    if ans < 0:
        print('IMPOSSIBLE')
    else:
        print(ans)


Measured memory_bytes: 38384
//file_name:ABC97_C.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


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

    int count = 0;
    string slist[26000];
    rep(i,s.size()){
        int y = s.size();
        int z = i+5;
        int x = min(y,z);
        srep(j,i,x){
            string ss;
            srep(k,i,j+1){
                ss += s[k];
            }
            slist[count] = ss;
            count ++;
        }
    }

    sort(slist,slist+count);

    int kk = 1;
    int ii = 0;
    string ans = slist[0];
    ii++;
    while(kk<k){
        if(slist[ii] == ans){
            ii++;
        }else{
            ans = slist[ii];
            kk++;
            ii++;
        }
    }

    cout << ans << endl;

    return 0;
}



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

int main() {
	int n;
	cin>>n;
	long long d;
	cin>>d;
	long long x[n],y[n];
	int count=0;
	for(int i=0;i<n;i++){
	    cin>>x[i]>>y[i];
	    if((x[i]*x[i]+y[i]*y[i])<=(d*d))
	    count++;
	}
	cout<<count<<endl;
	return 0;
}


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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int x;
    cin >> x;
    vector<int> dp(100,100);
    dp[0] = 0;
    for (int i = 0;i < 95;++i) for (int j = 1;j <= 5;++j) dp[i+j] = min(dp[i+j],dp[i]+1);
    int y = x/100,z = x%100;
    cout << (y >= dp[z]) << endl;
    // p_ary(dp,0,100);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <complex>
#include <cstdio>

using namespace std;

const double EPS = 1e-10;
typedef complex<double> P;
typedef vector<P> G;

struct L { P p, q; L(P p, P q) : p(p), q(q) {} };

double dot(P a, P b) { return real(conj(a)*b); }
double cross(P a, P b) { return imag(conj(a)*b); }

P ssCrosspoint(L a, L b){
	double A = cross(a.q-a.p, b.q-b.p);
	double B = cross(a.q-a.p, a.q-b.p);
	return b.p + B/A * (b.q-b.p);
}

bool check(const vector<P>& vp, const P& c, double r){
    for(auto& p : vp){
        if(abs(p - c) > r + EPS) return false;
    }
    return true;
}

int main(){
    int N;
    while(cin >> N){
        vector<P> vp;
        for(int i=0;i<N;i++){
            int x, y; cin >> x >> y;
            vp.emplace_back(x, y);
        }
        double res = 1e10;
        for(int i=0;i<N;i++){
            for(int j=i+1;j<N;j++){
                P c1 = 0.5*(vp[i] + vp[j]);
                double r = abs(vp[i] - c1);
                if(check(vp, c1, r)){
                    res = min(res, r);
                }               
                for(int k=j+1;k<N;k++){
                    P c2 = 0.5*(vp[i]+vp[k]);
                    P q1 = c1 + (vp[j]-vp[i]) * P(0, 1);
                    P q2 = c2 + (vp[k]-vp[i]) * P(0, 1);
                    P d1 = (q1-c1)/abs(q1-c1);
                    P d2 = (q2-c2)/abs(q2-c2);
                    if(abs(cross(d1, d2)) < EPS) continue;
                    L l1 = L(c1, q1);
                    L l2 = L(c2, q2);
                    P test = ssCrosspoint(l1, l2);
                    r = abs(test - vp[i]);
                    if(check(vp, test, r)){
                        res = min(res, r);
                    }               
                }
            }
        }
        printf("%.8lf\n", res);
    }
}

Measured memory_bytes: 256