akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define PI acos(-1.0);

int main() {
  int a, b;
  cin >> a >> b;
  if (a == 1 && b == 1) {
    cout << "Draw" << endl;
  } else if (a == 1) {
    cout << "Alice" << endl;
  } else if (b == 1) {
    cout << "Bob" << endl;
  } else {
    if (a == b)
      cout << "Draw" << endl;
    else if (a > b)
      cout << "Alice" << endl;
    else
      cout << "Bob" << endl;
  }
}

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

int main() {
    int r; cin >> r;
    cout << int(pow(r, 2)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N; cin >> N;
    ll A[N]; REP(i, N) cin >> A[i];

    ll ans = 0;
    REP(i, 62) {
        ll cnt[2] = {};
        REP(j, N) {
            cnt[A[j]>>i & 1]++;
        }
        ll num = (cnt[0] * cnt[1]) % MOD;
        (ans += (1LL<<i) % MOD * num % MOD) %= MOD;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 2560
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned()
}

fn main() {
    let v = read_line().split_whitespace().map(|x| x.parse::<i32>().unwrap()).collect::<Vec<_>>();
    let (a, b, c) = (v[0], v[1], v[2]);
    
    let remain = a - b;
    println!("{}", if remain > c { 0 } else { c - remain });
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main()
{
    string s, t;
    cin >> s >> t;
    string ans;
    int n = s.size(), m = t.size();
    for (int i = 0; i <= n - m; i++)
    {
        bool f = false;
        string tmp = s;
        for (int j = 0; j < m; j++)
        {
            if (tmp[i + j] == '?')
                continue;
            if (tmp[i + j] != t[j])
                f = true;
        }
        if (f)
            continue;
        for (int j = 0; j < m; j++)
            tmp[i + j] = t[j];
        for (int j = 0; j < n; j++)
            if (tmp[j] == '?')
                tmp[j] = 'a';
        if (ans.empty())
            ans = tmp;
        else
            ans = min(ans, tmp);
    }

    if (ans.empty())
        cout << "UNRESTORABLE" << endl;
    else
        cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  vvl c(3, vl(3));
  rep(i, 3){
    rep(j, 3){
      cin >> c[i][j];
    }
  }

  if(!((c[0][0] - c[0][1] == c[1][0] - c[1][1]) && (c[1][0] - c[1][1] == c[2][0] - c[2][1]))){
    cout << "No" << endl;
    return 0;
  }
  if(!((c[0][1] - c[0][2] == c[1][1] - c[1][2]) && (c[1][1] - c[1][2]== c[2][1] - c[2][2]))){
    cout << "No" << endl;
    return 0;
  }
  if(!((c[0][2] - c[0][0] == c[1][2] - c[1][0]) && (c[1][2] - c[1][0]== c[2][2] - c[2][0]))){
    cout << "No" << endl;
    return 0;
  }
  if(!((c[0][0] - c[1][0] == c[0][1] - c[1][1]) && (c[0][1] - c[1][1]== c[0][2] - c[1][2]))){
    cout << "No" << endl;
    return 0;
  }
  if(!((c[1][0] - c[2][0] == c[1][1] - c[2][1]) && (c[1][1] - c[2][1] == c[1][2] - c[2][2]))){
    cout << "No" << endl;
    return 0;
  }
  if(!((c[2][0] - c[0][0] == c[2][1] - c[0][1]) && (c[2][1] - c[0][1] == c[2][2] - c[0][2]))){
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;
  
  return 0;
}


Measured memory_bytes: 256
import sys, re
from math import ceil, floor, sqrt, pi, factorial#, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    s = s_input()

    correct = 753

    min_ans = INF

    for i in range(len(s)-2):
        tmp_i = int(s[i:i+3])
        min_ans = min(min_ans, abs(tmp_i-correct))

    print(min_ans)
            
if __name__ == '__main__':
    main()


Measured memory_bytes: 40496
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K;
  string S;

  cin>>K>>S;

  if(K>=S.size()){
    cout<<S<<endl;
  }

  else{
    for(int i=0; i<K; i++){
      cout<<S.at(i);
    }
    cout<<"..."<<endl;
  }
}

Measured memory_bytes: 3600
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll mod = 1000000007;
const int N = 200010;
ll fact[N], invf[N];

ll add(ll x, ll y){
    return (x+y)%mod;
}

ll mul(ll x, ll y){
    return (x%mod)*(y%mod)%mod;
}

ll powll(ll x, ll y){
    x %= mod;
    ll res = 1LL;
    while(y){
        if (y & 1LL)
            res *= x;
        res %= mod;
        x = (x*x) % mod;
        y >>= 1LL;
    }
    return res;
}

ll divll(ll x, ll y){
    x %= mod;
    return (x * powll(y,mod-2)) % mod;
}

ll nPr(ll n, ll r){
    if (n < r || r < 0) return 0;
    return mul(fact[n], invf[n-r]);
}

ll nCr(ll n, ll r){
    if (n < r || r < 0) return 0;
    return mul(mul(fact[n], invf[r]), invf[n-r]);
}

void init_f(){
    fact[0] = 1;
    FOR(i,1,N-1){
        fact[i] = (fact[i-1] * i) % mod;
    }
    invf[N-1] = divll(1, fact[N-1]);
    FORR(i,N-1,1){
        invf[i-1] = (invf[i] * i) % mod;
    }
}

ll calc(ll n, ll r){
    ll ret = 1;
    REP(i,r) ret = (ret * (n - i)) % mod;
    ret = (ret * invf[r]) % mod;
    return ret;
}

int main(void){
    ll n, a, b;
    cin >> n >> a >> b;
    init_f();
    ll ans = powll(2, n) - 1;
    ans -= calc(n, a) + calc(n, b);
    ans = (ans + 4 * mod) % mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
import itertools
n,m=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(m)]

path=[[] for _ in range(n)]
for a,b in AB:
  path[a-1].append(b-1)
  path[b-1].append(a-1)

ans=0
for ptn in itertools.permutations(range(1,n)):
  start=0
  for nex in ptn:
    if start not in path[nex]: break
    start=nex
  else:
    ans+=1
print(ans)

Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	fmt.Print(lcm(a, b))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}

func gcd(a, b int) int {
	if a < b {
		return gcd(b, a)
	} else if b == 0 {
		return a
	} else {
		return gcd(b, a%b)
	}
}

Measured memory_bytes: 512
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
 
using namespace std; 

int main(){


	long long w,h;
	cin>>w>>h;

	vector<pair<long long,bool> > e(w+h);
	for(int i=0;i<w;i++){
		cin>>e[i].first;
		e[i].second=false;
	}
	for(int i=0;i<h;i++){
		cin>>e[w+i].first;
		e[w+i].second=true;
	}

	sort(e.begin(),e.end());
	
	long long H=h+1,W=w+1;
	long long res=0;
	for(int i=0;i<w+h;i++){

		if(e[i].second){
			res+=e[i].first*W;
			H--;
		}else{
			res+=e[i].first*H;
			W--;
		}
	}

	cout<<res<<endl;

}

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

int main() {
    int b,ans=0,co=2;
    float a,c;
    cin>>a>>b>>c;
    c+=0.5;
    float x=a;
	while(x<c)
	{
	    ans+=b;
	    x=a*co;
	    co++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
use std::io::{self, BufReader, Read};
use std::str::FromStr;
use std::string::String;

fn main() {
	let mut sc = ::Scanner::new(io::stdin());
	let a = sc.next_i32().unwrap();
	let b = sc.next_i32().unwrap();
	println!("{}", a * b - a - b + 1);
}

#[derive(Debug)]
pub struct Scanner<R> {
	reader: BufReader<R>
}

impl<R: io::Read> Scanner<R> {
	
	pub fn new(read: R) -> Scanner<R> {
		Scanner { reader: BufReader::new(read) }
	}

	pub fn next_str(&mut self) -> Option<String> {
		let mut buf = [0; 1];
		let size = self.reader.read(&mut buf).unwrap();
		if size == 0 {
			None{}
		} else {
			let first = self.skip_whitespace(&mut buf);
			if first.is_none() {
				return None{}
			}
			let mut v = vec![buf[0]];
			loop {
				let size = self.reader.read(&mut buf).unwrap();
				if size == 0 || char::from(buf[0]).is_whitespace() {
					break;
				}
				v.push(buf[0]);
			}
			Some(String::from_utf8(v).unwrap())
		}
	}

	pub fn next_line(&mut self) -> Option<String> {
		let mut buf = [0; 1];
		let mut v :Vec<u8> = vec![];
		let mut size = self.reader.read(&mut buf).unwrap();
		if size == 0 {
			return None{}
		}
		loop {
			if size == 0 || char::from(buf[0]) == '\n' {
				return Some(String::from_utf8(v).unwrap())
			}
			v.push(buf[0]);
			size = self.reader.read(&mut buf).unwrap();
		}
	}

	pub fn next_vec<S: FromStr>(&mut self, size: u32) -> Vec<S> {
		let mut v: Vec<S> = vec![];
		for _ in 0..size {
			let token = self.next_str().unwrap();
			v.push(S::from_str(&token).ok().unwrap());
		}
		v
	}

	pub fn next_as<S: FromStr>(&mut self) -> Option<S> {
		if let Some(s) = self.next_str() {
			if let Ok(v) = S::from_str(&s) {
				return Some(v)
			}
		}
		None{}
	}

	pub fn next_i32(&mut self) -> Option<i32> {
		self.next_as::<i32>()
	}

	pub fn next_i64(&mut self) -> Option<i64> {
		self.next_as::<i64>()
	}

	pub fn next_f32(&mut self) -> Option<f32> {
		self.next_as::<f32>()
	}

	pub fn next_f64(&mut self) -> Option<f64> {
		self.next_as::<f64>()
	}

	fn skip_whitespace(&mut self, mut buf: &mut [u8]) -> Option<u8> {
		loop {
			if !char::from(buf[0]).is_whitespace() {
				return Some(buf[0])
			}
			let size = self.reader.read(&mut buf).unwrap();
			if size == 0 {
				return None{}
			}
		}
	}
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; cin>>n;
	vector<ll> a(n);
	for(auto &x : a){
		cin>>x;
	}
	ll sum = accumulate(a.begin(), a.end(), 0LL);
	ll cur = 0, ans = 1e18;
	for(int i = 0; i + 1 < n; i++){
		cur += a[i]; sum -= a[i];
		ans = min(ans, abs(sum - cur));
	}
	cout<<ans<<endl;


	return 0;
}

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

int main(){
    string s, t; cin >> s >> t;
    int n = s.size();
    for(int i = 0; i < n; i++){
        if(s[i] != t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N; cin >> N;
    vector<ll> a(N), b(N), c(N);
    rep(i, N) cin >> a[i];
    rep(i, N) cin >> b[i];
    rep(i, N) cin >> c[i];
    sort(all(a));
    sort(all(b));
    sort(all(c));

    ll ans = 0;
    rep(i, N){
        auto itr_up = lower_bound(all(a), b[i]);
        ll num_a;
        num_a = distance(a.begin(), itr_up);
        // cout << num_a << endl;
        auto itr_down = upper_bound(all(c), b[i]);
        ll num_c = distance(c.begin(), itr_down);
        num_c = N - num_c;
        // cout << num_c << endl << endl;
        ans += num_a * num_c;
    }   

    cout << ans << endl;
}

Measured memory_bytes: 5648
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer a = Integer.parseInt(scanner.next());
        Integer b = Integer.parseInt(scanner.next());
        Integer c = Integer.parseInt(scanner.next());
        Integer d = Integer.parseInt(scanner.next());

        int count_a = 0;
        for(int i =0; i < 101; i++) {
            a -= d;
            if(a <= 0) break;
            count_a++;
        }

        int count_b = 0;
        for(int j =0; j < 101; j++) {
            c -= b;
            if(c <= 0) break;
            count_b++;
        }

        if(count_a >= count_b) {
            System.out.println("Yes");
        } else {
            System.out.println("No");

        }
    }
}


Measured memory_bytes: 35512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int a,b;
  cin >> a >> b;
  if(a%3==0||b%3==0||(a+b)%3==0){
    cout << "Possible" << endl;
  }else{
    cout << "Impossible" << endl;
  }
}


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

int toInt(string a){
	int ret = 0;
	for(int i=0;a[i];i++){
		int num = 1;
		if(isdigit(a[i])){
			num = a[i++]-'0';
		}
		if(a[i]=='m') ret += num * 1000;
		else if(a[i]=='c') ret += num * 100;
		else if(a[i]=='x') ret += num * 10;
		else if(a[i]=='i') ret += num * 1;
	}
	return ret;
}

string toString(int a){
	string ret;
	char l[5]="ixcm";
	for(int i=0;i<4;i++){
		if(a%10) ret += l[i];
		if(a%10>1) ret += a%10+'0';
		a/=10;
	}
	reverse(ret.begin(), ret.end());
	return ret;
}

int n;
main(){
	int i,j;
	cin >> n;
	while(n--){
		string a,b;
		cin >> a >> b;
		cout << toString(toInt(a) + toInt(b)) << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = nextInt()
    val a = nextInt()
    println(if ((n % 500) <= a) "Yes" else "No")
}

fun next() = readLine()!!
fun nextInt() = next().toInt()

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 31804
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main{

	private static int H;
	private static int W;

	private static String[][] F ;
	private static boolean[][] State;

	public static void main(String args[]) throws IOException {
		Scanner scan = new Scanner(System.in);
		int Ans = 0;

		while(true) {
			String[] s = scan.nextLine().split(" +");
			Ans = 0;

			H = Integer.parseInt(s[0]);
			W = Integer.parseInt(s[1]);

			if(H == 0 && W == 0) {
				break;
			}

			F = new String[H][W];
			State = new boolean[H][W];

			for(int i = 0;i < H; i++) {
				String[] str = scan.nextLine().split("");
				F[i] = str;
				Arrays.fill(State[i], false);
			}

			for(int i = 0;i < H; i++) {
				for(int j = 0; j < W;j++) {
					if(!State[i][j]){
						State[i][j] = true;
						Fdiv(i,j);
						Ans++;
					}
				}
			}
			System.out.println(Ans);
		}
		scan.close();
	}

	private static int[][] st = {{-1,0},{0,1},{1,0},{0,-1}};

	private static void Fdiv(int y,int x) {
		for(int k = 0;k < 4;k++) {
			int xx = x + st[k][1];
			int yy = y + st[k][0];

			if(!(0 <= xx && xx < W && 0 <= yy && yy < H)) {
				continue;
			}

			if(!State[yy][xx] && F[y][x].equals(F[yy][xx])) {
				State[yy][xx] = true;
				Fdiv(yy,xx);
			}
		}
	}
}



Measured memory_bytes: 31400
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) ((x).begin()),((x).end())
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimization ("unroll-loops")
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using pii = pair<int, int>;
using ppp = pair<int , pii>;

int32_t main()
{
	int m1, m2, d1, d2;
	cin >> m1 >> d1 >> m2 >> d2;
	printf("%d\n",m1==m2?0:1);
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pp pair<int, int>
#define ppp pair<pp, int>
#define fi first
#define se second
#define esp 1e-15
#define inf 1000000001
#define mod 1000000007
#define N 1000010
#define base 311097
typedef long long ll;
typedef long double ld;
const long long oo = (ll)1e18;
using namespace std;
int a, b;

int main() {
   //  freopen("in.in", "r", stdin);

  //  freopen("in2.in", "r", stdin);
   // freopen("ou.ou", "w", stdout);



    ios::sync_with_stdio(false);
    cin >> a >> b;
    if (a == 1) a = 14;
    if (b == 1) b = 14;
    if (a > b) cout << "Alice";
    else
        if (a < b) cout << "Bob";
    else
        cout << "Draw";

    /**/ return 0;
}



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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

    int A, B, C, D;
    cin >> A >> B >> C >> D;

    cout << min(A, B) + min(C, D) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int A,B;
  cin>>A>>B;
  if((A+B)%2){
    cout<<"IMPOSSIBLE"<<endl;
  }else{
    cout<<(A+B)/2<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    int a[100];
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    int rate[9];
    for (int i = 0; i < 9; ++i) {
        rate[i] = 0;
    }
    for (int i = 0; i < N; ++i) {
        if (a[i] >= 3200) {
            rate[8] += 1;
        } else {
            for (int j = 0; j < 8; ++j) {
                if (a[i] < 400 * (j + 1)) {
                    rate[j] += 1;
                    break;
                }
            }
        }
    }
    int num = 0;
    for (int i = 0; i < 8; ++i) {
        if (rate[i] > 0) {
            num += 1;
        }
    }
    int num2 = num + rate[8];
    if (num < 1) {
        num = 1;
    }
    cout << num << " " << num2 << endl;
    return 0;
}

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

using namespace std;
using ll = long long;


int main()
{
	int n; cin >> n;
	vector<int> a(n), b;
	for(int i = 0; i < n; i++)cin >> a[i];


	for(int i = 0; i < n; i++) {
		if(a[i] - 1 > (int)b.size()) {
			cout << -1 << endl;
			return 0;
		}
		b.insert(b.begin() + a[i] - 1, a[i]);
	}
	for(auto i : b)cout << i << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <algorithm>

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

using namespace std;

int n;
int x[200000];
int y[200000 - 1];

int main(){
	scanf("%d", &n);
	rep(i, n){
		scanf("%d", x + i);
	}
	for(int i = n - 2; i >= 0; --i){
		y[i] = x[i + 1] - x[i];
		x[i] = max(x[i], x[i + 1]);
	}
	printf("%d\n", *max_element(y, y + n - 1));
	return 0;
}

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

int GCD(int a, int b){
  if(b == 0)
    return a;
  return GCD(b, a % b);
}

void solve(int a, int b){
  if(a < b)
    swap(a, b);
  int gcd = GCD(a, b);
  cout << gcd << " " << a / gcd * b << endl;
}

int main(){
  int a, b;
  while(cin >> a >> b){
    solve(a, b);
  }
}

Measured memory_bytes: 1160
// 学籍番号: 17D8101029G 石塚 博之 ID: mcatpolo 言語: c //
#include <stdio.h>
#include <string.h>

#define N 1000
#define Q 150

int dp[N][N];

int match(char m, char n){
	if(m==n) return 0;
	else return 1;
}

int min(int a, int b, int c){
	int min = a;
	if(min>b) min = b;
	if(min>c) min = c;

	return min;
}

int main(void)
{
	int i, j, m, n, cnt;
	char X[N], Y[N];

	scanf("%s", X); m = strlen(X);
	scanf("%s", Y); n = strlen(Y);

	// 初期化

	cnt = 0;

	for(i=0; i<m; i++){
		for(j=0; j<n; j++){
			dp[i][j] = 0;
		}
	}

	for(i=0; i<m; i++){
		if(cnt == 0 && !match(X[i], Y[0])){
			cnt = 1;
		}
		dp[i][0] = i + 1 - cnt;
	}
	
	cnt = 0;

	for(j=0; j<n; j++){
		if(cnt == 0 && !match(X[0], Y[j])){
			cnt = 1;
		}
		dp[0][j] = j + 1 - cnt;
	}

	//初期化終わり

	for(i=1; i<m; i++){
		for(j=1; j<n; j++){
			if (i>j){
				dp[i][j] = min(dp[i-1][j-1] + match(X[i], Y[j]), dp[i][j-1] + 1, dp[i-1][j] + 1);
			}
			else {
				dp[i][j] = min(dp[i-1][j-1] + match(X[i], Y[j]), dp[i][j-1] + 1, dp[i-1][j] + 1);
			}
		}
	}
	/*
	for(int i=0; i<m; i++){
		for(int j=0; j<n; j++){
			printf("%d ", dp[i][j]);
		}
		printf("\n");
	}
	*/

	printf("%d\n", dp[m-1][n-1]);

	return 0;
}


Measured memory_bytes: 5684
#include "bits/stdc++.h"
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> values(N, 0);
	for(int i = 0; i < N ; i++)
	{
		cin >> values[i];
	}

	int sum = 0;
	for(int i = 0; i < N ; i++)
	{
		for(int j = i + 1 ; j < N ; j++)
		{
			sum += values[i]*values[j];
		}
	}

	cout << sum << endl;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int n;
	cin >> n;
    ll a[n];
    fr(i,n){
      cin >> a[i];
    }
    ll l[n];
    ll r[n];
    fr(i,n){
      l[i]=0;
      r[i]=0;
    }
    fr(i,n){
      if(i+a[i]<n){
        l[i+a[i]]++;
      }
      if(i-a[i]>0){
        r[i-a[i]]++;
      }
    }
    ll ans=0;
    fr(i,n){
      ans+=l[i]*r[i];
    }
      cout << ans << endl;
}


Measured memory_bytes: 8276
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define int long long
typedef complex<double>P;
int n,l,k,r,r1,t,l1,c,f,a[1000001],b[100001],dp[1<<9],dp2[1<<9];
main(){
  cin>>n;
  if(((n%1000)%111)==0||(n/10)%111==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

a, b = map(int, input().split())

ans = 0

for i in range(2):
    if (a > b):
        ans += a
        a -= 1
    else:
        ans += b
        b -= 1
print(ans)



Measured memory_bytes: 9092
n = int(input())
l0 = 2
l1 = 1
if n == 1:
  print(l1)
else:
  for i in range(2, n+1):
    if i == 2:
      li = l0
      lj = l1
    l = li + lj
    li = lj
    lj = l
  print(l)

Measured memory_bytes: 3060
<?php
fscanf(STDIN, "%d %d", $N, $K);
$s = trim(fgets(STDIN));
$arr = explode(" ", $s);

for ($i = $N; $i <= 99999; $i++) {
    $istr = (string)$i;
    $posall = false;
    for ($m = 0; $m < $K; $m++) {
        $pos = strpos($istr, $arr[$m]);
        if ($pos !== false) {
            $posall = true;
        }
    }
    if ($posall === false) {
        echo $istr."\n";
        break;
    }
}


Measured memory_bytes: 4604
import java.util.Scanner;


public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i;
        while(true) {
            double avg = 0, sum = 0, a = 0;
            int n = sc.nextInt();
            if(n == 0) break;
            int s[] = new int[n];

            for(i = 0; i < n; i++) {
                s[i] = sc.nextInt();
                sum += s[i];
            }
            avg = sum / n;
            sum = 0;
            for(i = 0; i < n; i++) {
                sum += Math.pow(s[i] - avg, 2);
            }

            a = (double)sum / n;
            a = Math.sqrt(a);
            System.out.println(String.format("%.8f", a));
        }
        sc.close();
    }
}


Measured memory_bytes: 31928
#include<bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int x, y ,z;
    cin >> x >> y >> z;

    cout << z << " " << x << " " << y << "\n";
    return 0;
}

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

int main(int argc, char **argv)
{
	ll n; cin >> n;
	vector<ll> a(3*n); for (ll i = 0; i < 3*n; ++i) cin >> a[i];

	sort(a.begin(), a.end(), greater<ll>());

	ll res{0};
	for (ll i = 0; i < n; ++i)
		res += a[i*2+1];
	std::cout << res << std::endl;
}

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

class Solve {
private:
	using Point = std::complex<long double>;
	long double epsilon{1e-6};

	int N;
	std::vector<Point> points;

	int countPoints(int pi_1, int pi_2)
	{
		Point &p1{points[pi_1]}, &p2{points[pi_2]};
		if (std::abs(p1 - p2) > 2 + epsilon) return 0;
		Point center{p1 + std::polar((long double)1.0, std::acos(std::abs(p2 - p1) / 2) + std::arg(p2 - p1))};
		int count{};
		for (auto& e: points)
			if (std::abs(e - center) <= 1 + epsilon)
				count++;
		return count;
	}
public:
	bool is_last_query_{};
	Solve()
	{
		scanf("%d", &N);
		if (N == 0)
		{
			is_last_query_ = true;
			return;
		}
		points.resize(N);
		for (auto& e: points)
		{
			long double r, i;
			std::cin >> r >> i;
			e.real(r);
			e.imag(i);
		}
		int max{1};
		for (int i{}; i < N; i++)
			for (int j{}; j < N; j++)
				if (i != j)
					max = std::max(max, countPoints(i, j));
		printf("%d\n", max);
		return;
	}
};

int main()
{
	while (!Solve().is_last_query_);
	return 0;
}


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

int main(){
    int n,m; cin >> n >> m;
    int CBcnt = 0;
    int Acnt = 0;
    
    ll ans = 0;
    vector<ll> a(n),b(m),c(m);
    vector<pair<ll,ll>> CB(m);
    rep(i,n) cin >> a[i];
    rep(i,m){
        cin >> b[i] >> c[i];
        CB[i] = make_pair(c[i],b[i]);
    }
    sort(a.begin(),a.end(),greater<ll>());
    sort(CB.begin(),CB.end(),greater<pair<ll,ll>>());
    ll CBsum = 0;
    for(ll i = 0; i < m; i++) CBsum += CB[i].second;

    int CBtmp = 0;
    while(CBcnt + Acnt < n){
        if(CBtmp >= m) break;
        while(CB[CBtmp].second && CBcnt + Acnt < n){
            if(CB[CBtmp].first > a[Acnt]){
                ans += CB[CBtmp].first;
                CB[CBtmp].second--;
                CBcnt++;
            }else{
                ans += a[Acnt];
                Acnt++;
            }
        }
        CBtmp++;
    }
    while(CBcnt + Acnt < n){
        ans += a[Acnt];
        Acnt++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4224
import scala.io.StdIn.readInt

object Main {
  def fib(a:Int, b:Int, n:Int):Int = {
    if (n ==  0)
      a
    else
      fib(a+b, a, n-1)
  }

  def main(args: Array[String]) = {
    val n = readInt()
    println(fib(1, 0, n))
  }
}

Measured memory_bytes: 43608
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N, K; cin >> N >> K;
    vec A(N); cin >> A;

    int S = 0;
    REP(i, N) S += A[i];

    vec y;
    for(int i = 1; i * i <= S; i++) if(S % i == 0){
        y.pb(i);
        y.pb(S / i);
    }
    int ans = 1;
    vec B(N);
    for(int x: y){
        int p = 0, m = 0;
        REP(i, N) B[i] = A[i] % x;
        Sort(B);
        int i0 = 0, i1 = N - 1;
        int cnt = 0;
        while(i0 < i1){
            int M = min(B[i0], x - B[i1]);
            B[i0] -= M;
            B[i1] += M;
            cnt += M;
            if(B[i0] == 0) i0++;
            if(B[i1] == x) i1--;
        }
        bool f = true;
        REP(i, N) if(B[i] % x != 0) f = false;
        if(f && cnt <= K) Max(ans, x);
    }
    Out(ans);

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <map>

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
// constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

template <intmax_t X = 943681729, intmax_t MOD = 1000000007>
class rolling_hash {
  std::vector<intmax_t> hash, offset;

public:
  rolling_hash(const std::string& s): hash(s.length()+1), offset(s.length()+1) {
    for (size_t i = 0; i < s.length(); ++i)
      hash[i+1] = (hash[i]*X+s[i]) % MOD;

    offset[0] = 1;
    for (size_t i = 1; i <= s.length(); ++i)
      offset[i] = offset[i-1] * X % MOD;
  }

  intmax_t get_base() const { return X; }
  intmax_t get_mod() const { return MOD; }

  intmax_t prefix(size_t i) const {
    // hash of prefix s[0..i-1] (inclusive)
    assert(0 < i);
    return hash[i];
  }

  intmax_t substr(size_t i, size_t j) const {
    // hash of substring s[i..j-1] (inclusive)
    assert(i < j);
    intmax_t res = hash[j];
    res = (res - offset[j-i]*hash[i]) % MOD;
    if (res < 0) res += MOD;
    return res;
  }

  intmax_t inserted(size_t i, int ch) const {
    intmax_t res = 0;
    if (i > 0) res += prefix(i);
    res = (res*X + ch) % MOD;
    size_t n = hash.size()-1;
    if (i < n) res = (res*offset[n-i] + substr(i, n)) % MOD;
    return res;
  }

  void inspect() const {
    for (size_t i = 0; i < hash.size(); ++i)
      fprintf(stderr, "%jd%c", hash[i], i+1<hash.size()? ' ':'\n');
  }
};

intmax_t pomae(std::string const& s, std::string const& t) {
  using rh0 = rolling_hash<>;
  using rh1 = rolling_hash<943681729, 1000000009>;
  rh0 rs0(s), rt0(t);
  rh1 rs1(s), rt1(t);
  // fprintf(stderr, "%s\n", s.c_str());
  // fprintf(stderr, "%s\n", t.c_str());

  size_t n = s.length();
  size_t m = t.length();

  std::vector<bool> vb(n);
  for (size_t i = 0; i+m <= n; ++i) {
    vb[i] = ((rs0.substr(i, i+m) == rt0.substr(0, m)) && (rs1.substr(i, i+m) == rt1.substr(0, m)));
  }

  std::vector<intmax_t> dp(n+1);
  for (size_t i = m; i <= n; ++i)
    if (vb[i-1]) dp[i] = dp[i-m] + 1;

  // for (size_t i = 0; i < n; ++i)
  //   fprintf(stderr, "%d%c", !!vb[i], i+1<n? ' ': '\n');
  // for (size_t i = 0; i <= n; ++i)
  //   fprintf(stderr, "%jd%c", dp[i], i<n? ' ': '\n');

  return *std::max_element(dp.begin(), dp.end());
}

int main() {
  char buf[500001];
  scanf("%s", buf);
  std::string s1 = buf;
  scanf("%s", buf);
  std::string t = buf;

  std::string s = s1;
  while (s.length() < t.length()) s += s1;

  intmax_t r0 = pomae(s+s+s+s, t);
  intmax_t r1 = pomae(s+s+s+s+s+s+s+s, t);
  if (r0 < r1) {
    puts("-1");
  } else {
    printf("%jd\n", r0);
  }
}


Measured memory_bytes: 340644
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 1000005

struct Info{
	Info(ll arg_num,ll arg_count){
		num = arg_num;
		count = arg_count;
	}
	ll num,count;
};


ll fact[SIZE],inv_fact[SIZE];

ll mod_pow(ll x,ll count, ll mod){

	if(count == 0)return 1;
	ll ret = mod_pow((x*x)%mod,count/2,mod);
	if(count%2 == 1){

		ret = (ret*x)%mod;
	}
	return ret;
}

ll extgcd(ll a,ll b,ll &x,ll &y){
	ll d = a;
	if(b != 0){
		d = extgcd(b,a%b,y,x);
		y -= (a/b)*x;
	}else{
		x = 1;
		y = 0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}

ll nCk(ll n,ll k){

	if(k > n)return 0;

	ll ret = fact[n]*inv_fact[k];
	ret %= MOD;
	ret *= inv_fact[n-k];

	return ret%MOD;
}



int main(){

	fact[0] = 1;
	for(ll i = 1; i < SIZE; i++){
		fact[i] = i*fact[i-1];
		fact[i] %= MOD;
	}
	inv_fact[SIZE-1] = mod_inverse(fact[SIZE-1],MOD);
	for(ll i = SIZE-1; i >= 1; i--){

		inv_fact[i-1] = inv_fact[i]*i;
		inv_fact[i-1] %= MOD;
	}

	ll N,M;
	scanf("%lld %lld",&N,&M);

	vector<Info> info;

	ll tmp = M;
	for(int i = 2; i*i <= M; i++){

		if(tmp%i != 0)continue;

		int count = 0;

		while(tmp%i == 0){

			count++;
			tmp /= i;
		}
		info.push_back(Info(i,count));
	}

	if(tmp > 1){

		info.push_back(Info(tmp,1));
	}

	ll ans = 1;

	for(int i = 0; i < info.size(); i++){

		ll tmp = nCk(N-1+info[i].count,info[i].count);
		ans *= tmp;
		ans %= MOD;
	}

	printf("%lld\n",ans);

	return 0;
}



Measured memory_bytes: 19392
import java.util.Scanner;

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (Math.min(a, b) < c && c < Math.max(a, b))
			System.out.println("Yes");
		else
			System.out.println("No");

		sc.close();
	}

}


Measured memory_bytes: 23508
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner cin = new Scanner(System.in);
        BigDecimal a = cin.nextBigDecimal();
        BigDecimal b = cin.nextBigDecimal();
        BigDecimal c = cin.nextBigDecimal();

        BigDecimal ab = sqrt(a, 50).add(sqrt(b, 50));
        if(ab.compareTo(sqrt(c,50)) < 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }

    public static BigDecimal sqrt(BigDecimal a, int scale){
        //とりあえずdoubleのsqrtを求める
        BigDecimal x = new BigDecimal(
                Math.sqrt(a.doubleValue()), MathContext.DECIMAL64);
        if(scale < 17) return x;

        BigDecimal b2 = new BigDecimal(2);
        for(int tempScale = 16; tempScale < scale; tempScale *= 2){
            //x = x - (x * x - a) / (2 * x);
            x = x.subtract(
                    x.multiply(x).subtract(a).divide(
                            x.multiply(b2), scale, BigDecimal.ROUND_HALF_EVEN));
        }
        return x;
    }
}


Measured memory_bytes: 25300
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 1000005
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  char s[MAX];
  scanf("%s", s);
  int last = strlen(s) - 1;
  int cnt = 0;
  int add = 0;
  for ( int i = last; i >= 0; i-- ) {
    int n = (int)(s[i] - '0') + add;
    if ( (n <= 4) || (n == 5 && s[i - 1] < '5') ) {
      add = 0;
      cnt += n; 
      continue;
    }
    cnt += 10 - n;
    add = 1;
  }
  printf("%d\n", cnt + add);
  return 0;
}


Measured memory_bytes: 1152
# LongestCommonSubsequences
import numpy as np
S = np.array([ord(i)-97 for i in input()], dtype=int)
T = np.array([ord(i)-97 for i in input()], dtype=int)
Ns = len(S)
Nt = len(T)
equal = np.equal.outer(S, T).astype(int)

dp = [np.zeros(Nt + 1, dtype=int)]
for i in range(Ns):
    x = dp[-1].copy()
    newDP = x.copy()
    newDP[1:] = np.maximum(x[:-1] + equal[i], newDP[1:])
    np.maximum.accumulate(newDP, out=newDP)
    dp.append(newDP)


ans = ""
i, j = Ns, Nt
while i > 0 and j > 0:
    if S[i-1] == T[j-1]:
        ans += chr(S[i-1]+97)
        i -= 1
        j -= 1
        continue
    if dp[i][j] == dp[i - 1][j]:
        i -= 1
    else:
        j -= 1

print(ans[::-1])


Measured memory_bytes: 155644
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    H, W, K = map(int, input().split())
    K -= 1
    dp = [[0] * W for _ in range(H + 1)]
    dp[0][0] = 1
    for i in range(H):
        for j in range(W):
            for bit in range(1 << (W - 1)):
                flg = True
                for mask in range(W - 2):
                    if (bit & (1 << mask)) and (bit & (1 << (mask + 1))):
                        flg = False
                if flg:
                    next_j = j
                    if bit & (1 << j):
                        next_j = j + 1
                    elif j > 0 and (bit & (1 << (j - 1))):
                        next_j = j - 1
                    dp[i + 1][next_j] = (dp[i + 1][next_j] + dp[i][j]) % mod
    print(dp[H][K])


if __name__ == '__main__':
    resolve()


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

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

  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    a--; // 0-indexed
    v.at(i) = a;
  }

  int now = 0;
  int count = 0;
  while(1) {
    if (now == 1) {
      cout << count << endl;
      return 0;
    }
    if (count >= n) {
      cout << -1 << endl;
      return 0;
    }
    now = v.at(now);
    count++;
  }

  return 0;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long fac(long long n){
	long long ret = 1;
	for(long long i = 1; i<=n; i++){
		ret*=i;
		ret%=mod;
	}
	return ret;
}
long long ferma(long long n,long long r){
	if(r==0) return (long long)1;
	if(r==1) return n;
	long long ret = ferma(n,r/2);
	if(r%2) return (((ret*ret)%mod)*n)%mod;
	else return (ret*ret)%mod;
}
int main(){
	long long x,y;
	cin>>x>>y;
	if(x<y) swap(x,y);
	if(x>2*y) cout<<0;
	else if(x==2*y) cout<<1;
	else{
		long long one = 0;
		while(x!=y){
			one++;
			x-=2;
			y--;
		}
		if(x%3) cout<<0;
		else{
			one+=x/3;
			long long two = x/3;
			long long a = fac(one)*fac(two);
			a = ferma(a%mod,mod-2);
			cout<<(fac(one+two)*a)%mod;
		}
	}
}

Measured memory_bytes: 3620
//#include <cmath>
//#include <ctime>
#include <cstdio>
//#include <cstdlib>
//#include <cstring>

//#include <map>
//#include <set>
//#include <queue>
//#include <string>
//#include <vector>
//#include <sstream>
//#include <iostream>
#include <algorithm>
//#include <functional>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

const int MAXN = 3005;
const int P = 1000000007;
const int INF = 1000000007;
const double eps = 1e-6;

inline int getint() {
    int r = 0; bool b = true; char c = getchar();
    while (c < '0' || c > '9') { if (c == '-') b = false; c = getchar(); }
    while (c >= '0' && c <= '9') { r = (r<<1)+(r<<3) + c - '0'; c = getchar(); }
    return b ? r : -r;
}

int n;
LL a[MAXN], dp[MAXN][MAXN];
bool vis[MAXN][MAXN];

LL dfs(int l, int r) {
    if (l > r) return 0;
    if (l == r) return a[l];
    if (vis[l][r]) return dp[l][r];
    vis[l][r] = true;
    return dp[l][r] = max(a[l] - dfs(l + 1, r), a[r] - dfs(l, r - 1));
}

int main() {
    n = getint();
    for (int i = 1; i <= n; ++i)
        a[i] = getint();
    printf("%lld", dfs(1, n));
}

Measured memory_bytes: 78464
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef pair<ll,ll> pll;
typedef vector<string> vs;
typedef vector<pll> vpl;
typedef vector<int> vi;
template<class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P){
    in >> P.first >> P.second;
    return in;
}
template<class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &P){
    out << "(" << P.first << ", " << P.second << ")";
    return out;
}
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
    for(auto &x: arr) in >> x;
    return in;
}
template<class T>
ostream &operator<<(ostream &out, const vector<T> &arr){
    for(auto &x: arr) out << x << ' '; cout << "\n";
    return out;
}
template<class T>
istream &operator>>(istream &in, deque<T> &arr){
    for(auto &x: arr) in >> x;
    return in;
}
template<class T>
ostream &operator<<(ostream &out, const deque<T> &arr){
    for(auto &x: arr) out << x << ' '; cout << "\n";
    return out;
}
int d[21][21][21][21];
string s[21];
int n , m;
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
int32_t main(){
	cin >> n >> m;
	rep(i,0,21){
		rep(j,0,21){
			rep(k,0,21){
				rep(w,0,21){
					d[i][j][k][w] = (int) 1e7;
				}
			}
		}
	}
	rep(i,0,n) cin>> s[i];
	rep(stx , 0 , n){
		rep(sty, 0 , m){
			if(s[stx][sty] == '#') continue;
			queue<pii> q;
			d[stx][sty][stx][sty] = 0;
			q.push(pii(stx,sty));
			while(!q.empty()){
				pii u = q.front();
				q.pop();
				for(int j = 0 ; j < 4; j ++){
					int x = u.first + dx[j] , y = u.second + dy[j];
					if(x >= 0 && y >= 0 && x < n && y < m && (d[stx][sty][u.first][u.second] +1 ) < d[stx][sty][x][y] && s[x][y] != '#'){
						d[stx][sty][x][y] = d[stx][sty][u.first][u.second] +1 ;
						q.push(pii(x,y)) ; 
					}
				}
			}
		}
	}
	ll ans = 0;
	rep(i,0,n){
		rep(j,0,m){
			rep(k,0,n){
				rep(w,0,m){
					if(d[i][j][k][w] < (int) 1e7){
						ans = max(ans , (ll)d[i][j][k][w]) ;
					}
				}
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	string S;
	while(cin>>S){
		vector<int> A(10),B(10);
		REP(i,10){
			A[i] = S[i]-'0';
		}
		REP(i,9){
			REP(j,9-i){
				B[j]=(A[j]+A[j+1])%10;
			}
			swap(A,B);
		}
		out(A[0]);
	}
	return 0;
}


Measured memory_bytes: 3220
package main

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

func search(t string, S []string) bool{
	for _, s := range(S){
		if t == s{
			return true
		}
	}
	return false
}
func main(){
	var ans int
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	sc.Scan()
	S := strings.Split(sc.Text(), " ")
	sc.Scan()
	sc.Scan()
	T := strings.Split(sc.Text(), " ")
	for _, t := range(T){
		if search(t, S){
			ans++
		}
	}
	fmt.Println(ans)

}


Measured memory_bytes: 1428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    ll n, m, d[105][105], ans = 0;
    vector<P3> es;
    cin >> n >> m;
    REP(i,n)fill(d[i],d[i]+n,IINF/2);
    REP(i,m){
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        d[a][b] = c;
        d[b][a] = c;
        es.push_back({c,{a,b}});
    }
    REP(k,n)REP(i,n)REP(j,n){
        d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
    }
    REP(i,m){
        ll a, b, c;
        a = es[i].second.first;
        b = es[i].second.second;
        c = es[i].first;
        if(d[a][b] < c) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384