akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long N, K, Q;
    cin >> N >> K >> Q;
    vector<long long> scores;
    scores.resize(N);
    fill(scores.begin(), scores.end(), K - Q);
    for (long long i = 0; i < Q; ++i) {
        long long a;
        cin >> a;
        ++scores[a - 1];
    }
    for (long long i = 0; i < N; ++i) {
        if (scores[i] > 0) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1408
# include <stdio.h>
int a[200000+3], n;
bool small(int i, int j, int k) {return a[i]<=k && a[j]<=k;}
bool big(int i, int j, int k) {return a[i]>k && a[j]>k;}
bool judge(int k)
{
    for(int i=0; i<n-1; ++i)
    {
        if(big(n+i, n+i+1, k) || big(n-i, n-i-1, k)) return false;
        if(small(n+i, n+i+1, k) || small(n-i, n-i-1, k)) return true;
    }
    return small(1,1,k);
}
int main()
{
    scanf("%d",&n);
    for(int i=1; i<n<<1; ++i)
        scanf("%d",&a[i]);
    int l=1, r=(n<<1)-1, mid;
    while(l < r)
    {
        mid = l+r>>1;
        if(judge(mid))
            r = mid;
        else
            l = mid + 1;
    }
    printf("%d\n",r);
    return 0;
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	if(s.size()==2){
		if(s.at(0)==s.at(1)) cout << 1 << " " << 2 << endl;
		else cout << -1 << " " << -1 << endl;
	}
	else{
		rep(i,s.size()-2){
			if(s.at(i)==s.at(i+1) || s.at(i)==s.at(i+2) || s.at(i+1)==s.at(i+2)){
				cout << i+1 << " " << i+3 << endl;
				return 0;
			}
		}
		cout << -1 << " " << -1 << endl;
	}
}

Measured memory_bytes: 512
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int modNum = 1000000007;

		BigInteger ten = BigInteger.valueOf(10);
		BigInteger nine = BigInteger.valueOf(9);
		BigInteger eight = BigInteger.valueOf(8);

		BigInteger tenN = ten.pow(n);
		BigInteger nineN = nine.pow(n);
		BigInteger eightN = eight.pow(n);

		long ans = tenN.add(nineN.negate()).add(nineN.negate()).add(eightN).mod(BigInteger.valueOf(modNum)).longValue();

		System.out.println(ans);

	}
}

Measured memory_bytes: 89376
#define _USE_MATH_DEFINES
#include <sstream> //string stream its useful!
#include<string>
#include<iostream>
#include<utility> //pair
#include <vector> // vector
#include <algorithm>    // swap,sort,binary_search
#include <functional>   // std::greater
#include <map> //map
#include<set> //set
#include<queue> //queue
#include<list> //list
#include<cmath>
#include<numeric>
#include<cassert>
#include <iomanip> //cout<<setprecision
#include <regex>
#include <ctype.h> //toupper case

typedef long long ll;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
ll W = 1000000007;


using namespace std;
void omajinai() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(15);
}

class Main{
public:
    int N;
    ll K;
    vector<ll> A;
    Main(){
        cin>>N>>K;
        A = vector<ll>(N);
        REP(i,N) cin>>A[i];
    }
    
    ll gcd(ll i , ll j){
        if(i<j) swap(i,j);
        if(i%j==0) return j;
        return gcd(j,i%j);
    }
    
    bool hantei(){
        if(find(A.begin(),A.end(),K)!= A.end()) return true;
        if(K>*(A.end() -1)) return false;
        ll allgcd = *A.begin();
        {
            for(ll j:A) allgcd = gcd(allgcd,j);
        }
        return K%allgcd == 0;
    }
    
    void run(){
        sort(A.begin(),A.end());
        cout<<(hantei()?"POSSIBLE":"IMPOSSIBLE")<<endl;
    }
};

#ifndef gtest
int main(){
    omajinai();
    Main().run();
    return 0;
}
#endif

Measured memory_bytes: 1024
use std::fmt;
use std::cmp;
use std::io::stdin;
use std::io::BufRead;
use std::str;
use std::str::FromStr;
use std::char;

fn main() {
	let stdin = stdin();
	let mut scan = InputScanner::new(stdin.lock(),256);

	let h:usize = scan.next();
	let w:usize = scan.next();

	let s = (0..h).map(|_| scan.next::<String>().chars().collect::<Vec<char>>()).collect::<Vec<Vec<char>>>();

	let mut m = s.clone();

	for y in 0..h {
		for x in 0..w {
			if s[y][x] != '#' {
				continue;
			}

			let mut c = 0;

			for cy in (cmp::max(0,y as i32 - 1) as usize)..cmp::min(y+2,h) {
				if s[cy][x] == '#' {
					c += 1;
				}
			}

			for cx in (cmp::max(0,x as i32 - 1) as usize)..cmp::min(x+2,w) {
				if s[y][cx] == '#' {
					c += 1;
				}
			}

			if c > 2 {
				for cy in (cmp::max(0,y as i32 - 1) as usize)..cmp::min(y+2,h) {
					if s[cy][x] == '#' {
						m[cy][x] = '.';
					}
				}

				for cx in (cmp::max(0,x as i32 - 1) as usize)..cmp::min(x+2,w) {
					if s[y][cx] == '#' {
						m[y][cx] = '.';
					}
				}
			}
		}
	}

	let count:i64 = m.iter().fold(0,|mut acc,l| {
		acc += l.iter().filter(|&&c| c == '#').count() as i64;
		acc
	});

	if count == 0 {
		println!("Yes");
	} else {
		println!("No");
	}
}
struct InputScanner<R: BufRead> {
	reader: R,
	buf: Vec<u8>, // Should never be empty
	pos: usize,   // Should never be out of bounds as long as the input ends with '\n'
}
impl<R: BufRead> InputScanner<R> {
	fn new(reader: R, capacity: usize) -> Self {
		InputScanner {
			reader: reader,
			buf: Vec::with_capacity(capacity),
			pos: 0,
		}
	}

	#[inline]
	fn next<T: FromStr>(&mut self) -> T
	where
		T::Err: fmt::Debug,
	{
		if self.buf.is_empty() {
			self._read_next_line();
		}
		let mut start = None;
		loop {
			match (self.buf[self.pos], start.is_some()) {
				(b' ', true) | (b'\n', true) | (b'\r', true) => break,
				(_, true) | (b' ', false) => self.pos += 1,
				(b'\n', false) | (b'\r', false) => self._read_next_line(),
				(_, false) => start = Some(self.pos),
			}
		}
		let target = &self.buf[start.unwrap()..self.pos];
		unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
	}

	#[inline]
	fn _read_next_line(&mut self) {
		self.pos = 0;
		self.buf.clear();
		if self.reader.read_until(b'\n', &mut self.buf).unwrap() == 0 {
			panic!("Reached EOF");
		}
	}
}


Measured memory_bytes: 4352
n, x, y = map(int, input().split())

ans = [0] * (n+1)
for i in range(1, n+1):
        for j in range(i+1, n+1):
                ans[min(j-i, abs(i-x)+1+abs(j-y))] += 1
for i in range(1, n): print(ans[i])

Measured memory_bytes: 3444
#include <cstdio>
#define rep(i,n)for(i=0;i<n;i++)
#define max(a,b)(a>=b?a:b)
bool osenbei[10][10000];
int r,c,s,cnt,res,ans,i,j,k;
int main() {
	while(scanf("%d %d",&r,&c),r) {
		rep(i,r)rep(j,c)scanf("%d",&s),osenbei[i][j]=s;
		ans=0;rep(i,1<<r) {
			rep(j,r)if(i&(1<<j))rep(k,c)osenbei[j][k]=!osenbei[j][k];
			res=0;rep(j,c) {cnt=0;rep(k,r)cnt+=osenbei[k][j];res+=max(cnt,r-cnt);}
			ans=max(ans,res);
			rep(j,r)if(i&(1<<j))rep(k,c)osenbei[j][k]=!osenbei[j][k];
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1124
let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let n, m = Scanf.sscanf (read_line ()) "%d %d" @@ fun n m -> (n, m)
let a = read_line () |> split_string ~pattern:" " |> List.map int_of_string

let sum = List.fold_left (+) 0 a

let () = Printf.printf "%d\n" @@ if sum <= n then n - sum else -1

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

int main() {
    ll a,b;
    cin >> a >> b;
    
    ll result=0;
    if(b/100 > 0){
        a *= 1000;
    }else if(b/10 > 0){
        a *= 100;
    }else{
        a *= 10;
    }

    if(floor(sqrt(a+b)) == sqrt(a+b)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


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

using namespace std;

int main(){

  int N; cin >> N;

  double sum = 0;

  for (int i = 0; i < N; i++){
    double A; cin >> A;
    sum += 1 / A;
  }

  cout << setprecision(16) << 1 / sum << endl;
  
  return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn main() {
  input! {
    a: isize,
    b: isize,
    c: isize,
    k: isize
  };

  let res: isize = if k <= a {
    k
  } else if k <= a + b {
    a
  } else {
    let rest = k - (a + b);
    a - std::cmp::min(rest, c)
  };
  println!("{}", res);
}


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

using namespace std;



int main(){
    int arr[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++) cin >> arr[i][j];
    }
    int mark[3][3] = {0};
    int n; cin >> n;
    while(n--){
        int t;
        cin >> t;
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++) if(t == arr[i][j]) mark[i][j] = 1;
        }
    }
    int check = 0;
    for(int i = 0; i < 3; i++){
        if(mark[i][0] + mark[i][1] + mark[i][2] == 3){
            check = 1;
            break;
        }
        if(mark[0][i] + mark[1][i] + mark[2][i] == 3){
            check = 1;
            break;
        }
    }
    if(mark[1][1] + mark[2][2] + mark[0][0] == 3) check = 1;
    if(mark[0][2] + mark[1][1] + mark[2][0] == 3) check = 1;
    if(check) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define SZ(x) ((int)(x).size())
#define MEM(x,a) memset(x,a,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1000000007,N=1e5,M=1e5+5,INF=0x3f3f3f3f;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//head

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin>>k;
    vector<ll> a;
    rep(i,1,10)a.pb(i);
    int cur=0;
    while(a.size()<=k){
        int la=a[cur]%10;
        if(la==0){
            a.pb(a[cur]*10);
            a.pb(a[cur]*10+1);
        }
        else if(la==9){
            a.pb(a[cur]*10+8);
            a.pb(a[cur]*10+9);
        }
        else{
            a.pb(a[cur]*10+la-1);
            a.pb(a[cur]*10+la);
            a.pb(a[cur]*10+la+1);
        }
        ++cur;
    }
    cout<<a[k-1];
    return 0;
}

Measured memory_bytes: 1400
from collections import defaultdict
from itertools import combinations

N = int(input())
S = [input() for _ in range(N)]

dic = defaultdict(int)
for s in S:
    dic[s[0]] += 1

comb = combinations("MARCH", 3)

ans = 0
for x1,x2,x3 in comb:
    ans += dic[x1]*dic[x2]*dic[x3]

print(ans)


Measured memory_bytes: 10112
import java.util.*;
import java.util.Arrays;
public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int result = 0;
       
        for(int i=1;i<=n;i=i+2){
            int count =0;
            for(int j=1;j<=i;j++){
                if(i%j==0){
                    count++;
                }
                if(count==8){
                    
                    result++;
                }
            }
            
        }


        System.out.println(result);
    


    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string.h>
using namespace std;

#define MAX 100000

int main(void) {
	int answer, N, b[MAX];
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		cin >> b[i];
	}
	answer = b[0] + b[N - 2];
	for (int i = 0; i < N - 2; i++) {
		if (b[i] >= b[i + 1]) {
			answer += b[i + 1];
		}
		else {
			answer += b[i];
		}
	}
	cout << answer << endl;
	return 0;
}

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

int a[maxn];
int main()
{
    int H,W;
    int h,w;
    scanf("%d%d",&H,&W);
    scanf("%d%d",&h,&w);
    int ans=(H-h)*(W-w);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int k = sc.nextInt();
		sc.close();

		if (e - a <= k) {
			System.out.println("Yay!");
		} else {
			System.out.println(":(");
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>

using namespace std;

using ll = long long;
using ui = unsigned int;
const ll MOD = 1000000007;
const ll INF = 9223372036854775807;


//C
int main() {
	ll N;
	scanf("%lld", &N);
	char S[100010];
	scanf("%s", &S); 

	ll result = 0;

	char prev = ' ';
	for (ll i = 0; i < N; i++) {
		if (prev != S[i]) {
			result++;
		}

		prev = S[i];
	}

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

}


//B
/*
int main() {
	ll N;
	scanf("%lld", &N);
	vector<ll> d(N, 0);

	for (ll i = 0; i < N; i++) {
		scanf("%lld", &d[i]);
	}

	ll result = 0;

	for (ll i = 0; i < N; i++) {
		for (ll j = i + 1; j < N; j++) {
			result += d[i] * d[j];
		}
	}

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

}
*/


//A
/*
int main() {
	ll A;
	scanf("%lld", &A);
	ll B;
	scanf("%lld", &B);

	ll result = 0;

	result = max(0LL, A - B * 2);

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

	return 0;
}
*/


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdlib>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

int main() {
    int N;
    cin >> N;
    bool ok = true;
    int xs = 0, ys = 0, ts = 0;
    REP (i, 0, N) {
        int x, y, t;
        cin >> t >> x >> y;

        int d = abs(xs - x) + abs(ys - y);
        int dt = t - ts;

        if (d > dt) {
            ok = false;
        }
        d -= dt;
        if (d % 2) {
            ok = false;
        }
        xs = x;
        ys = y;
        ts = t;
    }
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
a=Counter()
while True:
    try:
        a[int(input())]+=1
    except EOFError:
        break
b=a.most_common()
c=b[0][1]
d=[i[0] for i in b if i[1] == c]
d.sort()
for j in d:
    print(j)


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll H, W;
string S[30];
bool U[25][25];

ll x[4] = {1, 0, -1, 0};
ll y[4] = {0, 1, 0, -1};

struct Data {
    pll g;
    ll c;
};

ll solve(pll s, pll g) {
    memset(U, 0, sizeof(U));
    queue<Data> q;
    q.push(Data{s, 0});
    U[s.first][s.second] = true;
    while (!q.empty()) {
        auto t = q.front();
        q.pop();

        if (t.g.first == g.first && t.g.second == g.second) {
            return t.c;
        }
        REP(i, 4) {
            ll nx = t.g.first + x[i];
            ll ny = t.g.second + y[i];
            if (nx < 0 || nx >= H || ny < 0 || ny >= W)
                continue;
            if (S[nx][ny] == '#' || U[nx][ny])
                continue;
            U[nx][ny] = true;
            q.push(Data{pll(nx, ny), t.c + 1});
        }
    }

    return 0;
}

int main() {
    cin >> H >> W;
    REP(i, H) {
        cin >> S[i];
    }

    ll ans = 0;
    REP(i, H) {
        REP(j, W) {
            if (S[i][j] == '#')
                continue;
            REP(k, H) {
                REP(l, W) {
                    if (S[i][j] == '#')
                        continue;
                    ans = std::max(ans, solve(pll(i, j), pll(k, l)));
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <bitset>
#include <string>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    const int len = S.size()-1;
    long ans = 0;
    string tmp;
    // int ans = S[0] - '0';
    for (int i=0;i<pow(2, len);i++)
    {
        // cout << "hoge" << i << endl;
        tmp = S[0];
        // cout << atoi("5") + atoi("3") << endl;
        // cout << bitset<9>(i).to_string().substr(9-len) << endl;
        string bit = bitset<9>(i).to_string().substr(9-len);
        for(int j=0;j<len;j++)
        {
            if(bit[j] == '0'){
                tmp += S[j+1];
            } 
            else
            {
                ans += stol(tmp);
                tmp = S[j+1];
            }
            // cout << "fuga" << j << ":" << tmp << endl;
        }
        ans += stol(tmp);
    }


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

Measured memory_bytes: 512
#include <iostream>
int main()
{

	while (1) {
		int card;
		std::cin >> card;
		if (card == 0) {
			break;
		}
		int a[10000], b[10000];
		int ascore = 0, bscore = 0;
		for (int i = 0; i < card; i++) {
			std::cin >> a[i] >> b[i];
			if (a[i] > b[i]) {
				ascore = ascore + (a[i] + b[i]);
			}
			else if (b[i] > a[i]) {
				bscore = bscore + (a[i] + b[i]);
			}
			else {
				ascore = ascore + a[i];
				bscore = bscore + b[i];
			}
		}
		std::cout << ascore << " " << bscore << std::endl;
	}
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    set<int> st;
    int x;
    for (int i = 0; i < n; ++i) {
        cin >> x;
        if (st.count(x)) {
            st.erase(x);
        } else {
            st.insert(x);
        }
    }
    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
#define MAX 100007
#define MOD 1000000007
int b[1005][1005];
long long output[1005][1005];


int main(){
  int n, m;
  cin>>n>>m;
  
  for(int i=0 ; i<n ; i++){
      for(int j=0;j<m;j++){
      char x; cin>>x;
      if(x =='.')
        b[i][j] = 0 ; 
      else
        b[i][j] = 1 ;
      }
  }
  
  for(int i=m-2;i>=0;i--){
    if(b[n-1][i] == 1){
      for(int j = i;j>=0;j--)
        output[n-1][j] = 0;
      break;
    }
    output[n-1][i] = 1;
  }
  
   for(int i=n-2;i>=0;i--){
    if(b[i][m-1] == 1){
      for(int j = i;j>=0;j--)
        output[i][m-1] = 0;
      break;
    }
    output[i][m-1] = 1;
  }
  
  for(int i = n-2;i>=0;i--){
    for(int j = m-2;j>=0;j--){
      if(b[i][j] == 1)
        continue;
      output[i][j] = output[i+1][j] + output[i][j+1];
      output[i][j] =  output[i][j]%MOD;
    }
  }
  
  cout<<output[0][0]<<endl;
  
  return 0;
}

Measured memory_bytes: 12032
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n,m,l;
		n = sc.nextInt();
		m = sc.nextInt();
		l = sc.nextInt();
		long matrix_a[][] = new long[n][m];
		long matrix_b[][] = new long[m][l];
		long matrix_c[][] = new long[n][l];

		for(int i = 0; i < n; i++){
			for(int j = 0; j < l; j++){
				matrix_c[i][j] = 0;
			}
		}

		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				matrix_a[i][j] = sc.nextInt();
			}
		}
		for(int i = 0; i < m; i++){
			for(int j = 0; j < l; j++){
				matrix_b[i][j] = sc.nextInt();
			}
		}

		for(int i = 0; i < n; i++){
			for(int j = 0; j < l; j++){
				for(int k = 0; k < m; k++){
					matrix_c[i][j] += matrix_a[i][k] * matrix_b[k][j];
				}
			}
		}

		for(int i = 0; i < n; i++){
			for(int j = 0; j < l; j++){
				System.out.print(matrix_c[i][j]);
				if(j + 1 != l){
					System.out.print(" ");
				}
			}
			System.out.println();
		}


	}

}

Measured memory_bytes: 53828
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
                         **/
#include<bits/stdc++.h>
using namespace std;
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz size
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 3*1e5+5;
const int mod = 1000000009;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 10000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b;
    int pwur = qpow(b,e>>1);
    return pwur * pwur;
}
int modinv(int x){
    return qpow(x,mod-2);
}

/// My Code -------------------------------------------------

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    ///freopen("a.in","r",stdin);
    ///freopen("a.out","w",stdout);
    int n;
    cin>>n;
    vi dp(100010);
    rep(i,100010){
        dp[i]=inf;
    }
    dp[0]=0;
    rep(i,100010){
        dp[i+1]=min(dp[i+1],dp[i]+1);
        for(int j=1;j<100;j++){
            if(i+qpow(6,j)>100000)break;
            int x=qpow(6,j);
            dp[i+x]=min(dp[i+x],dp[i]+1);
        }
        for(int j=1;j<100;j++){
            if(i+qpow(9,j)>100000)break;
            int x=qpow(9,j);
            dp[i+x]=min(dp[i+x],dp[i]+1);
        }
    }
    cout<<dp[n]<<enl;


    return 0;
}


Measured memory_bytes: 3992
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

int top , S[1000];

void push (int a){
  S[++top] = a;
}
int pop(){
  top--;
  return S[top+1];
}

int main(){
    int a,b;
    top = 0;
    char s[100];
    while(scanf("%s",s)!=EOF){
      if(s[0] == '+'){
        a = pop();
        b = pop();
        push(a+b);
      }else if(s[0] == '-'){
        b = pop();
        a = pop();
        push(a-b);
      }else if(s[0] == '*'){
        a = pop();
        b = pop();
        push(a*b);
      }else push(atoi(s));
    }
    printf("%d\n",pop());
    return 0;
}



Measured memory_bytes: 2684
"use strict";

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }

function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

function main(input) {
  var _splitNum = splitNum(input),
      _splitNum2 = _slicedToArray(_splitNum, 3),
      N = _splitNum2[0],
      H = _splitNum2[1],
      W = _splitNum2[2];

  var result = (N - H + 1) * (N - W + 1);
  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function splitNum(line) {
  return line.split(/\s+/).map(function (n) {
    return parseInt(n);
  });
}


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

int main(){
  int N; cin>>N;
  vector<int> h(N),dp(100010);
  for(int i=0;i<N;i++)
    cin>>h[i];
  for(int i=0;i<N;i++)
    dp[i] = INT_MAX;
  dp[0] = 0;
  for(int i=0;i<N;i++){
    if(dp[i+1] > dp[i] + abs(h[i] - h[i+1]))
      dp[i+1] = dp[i] + abs(h[i] - h[i+1]);
    if(dp[i+2] > dp[i] + abs(h[i] - h[i+2]))
      dp[i+2] = dp[i] + abs(h[i] - h[i+2]);
  }
  cout<<dp[N-1]<<endl;
  return 0;
}


Measured memory_bytes: 1024
package main

import "fmt"

type Combination struct {
	n int
	f *Factorial
}

func NewCombination(n int, m int64) *Combination {
	f := NewFactorial(n, m)
	return &Combination{n, f}
}

func (c *Combination) Combination(n, k int) int64 {
	return c.f.F[n] * c.f.Inv[k] % c.f.Mod * c.f.Inv[n-k] % c.f.Mod
}

func (c *Combination) Permutation(n, k int) int64 {
	return c.Combination(n+k-1, n-1)
}

func (c *Combination) Factorial(n int) int64 {
	return c.f.F[n]
}

type Factorial struct {
	n      int
	Mod    int64
	F, Inv []int64
}

func NewFactorial(n int, m int64) *Factorial {
	f := Factorial{n, m, nil, nil}
	f.F = make([]int64, n+1)
	f.Inv = make([]int64, n+1)
	f.F[0] = 1
	for i := 1; i <= n; i++ {
		f.F[i] = f.F[i-1] * int64(i) % f.Mod
	}
	f.Inv[n] = pow(f.F[n], f.Mod-2, f.Mod)
	for i := n; i > 0; i-- {
		f.Inv[i-1] = f.Inv[i] * int64(i) % f.Mod
	}
	return &f
}

func pow(x, n, m int64) int64 {
	if n == 0 {
		return 1
	}
	if n&1 == 0 {
		r := pow(x, n/2, m)
		return r * r % m
	}
	return x * pow(x, n-1, m) % m
}

func div(x, n, m int64) int64 {
	return x * pow(n, m-2, m) % m
}

func main() {
	var n, m, k int
	const M int64 = 998244353
	fmt.Scan(&n, &m, &k)
	c := NewCombination(n, M)
	var ans int64
	for i := 0; i <= k; i++ {
		m64, p := int64(m), int64(n-i-1)
		x := c.Combination(n-1, i)
		x *= m64 * pow(m64-1, p, M) % M
		x %= M
		ans += x
		ans %= M
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5056
#include<iostream>
#include<cctype>
#include<cstring>
#include<cstdio>
using namespace std;
int main(){
	string s,s1,s2;
	cin>>s>>s1>>s2;
	s=toupper(s[0]);
	s1=toupper(s1[0]);
	s2=toupper(s2[0]);

	cout<<s<<s1<<s2;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int data[101];
	int i;
	int n;
	
	for (i = 0; i <= 100; i++){
		data[i] = 0;
	}
	
	while (scanf("%d", &n) != EOF){
		data[n]++;
		
		if (data[0] < data[n]){
			data[0] = data[n];
		}
	}
	
	for (i = 1; i <= 100; i++){
		if (data[i] == data[0]){
			printf("%d\n", i);
		}
	}
	
	return (0);
}

Measured memory_bytes: 596
import sys

n = int(sys.stdin.readline().rstrip())

def main():
    ans = 0
    for i in range(1, n + 1):
        if (i % 3 == 0) or (i % 5 == 0):
            continue
        ans += i
    print(ans)

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 9180
/**************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

***************************/

#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define MAXI 1000000007
#define mp make_pair
using namespace std;
/*long long int fib(long long int n) 
{ 
  
  long long int f[n+2];   // 1 extra to handle case, n = 0 
  long long int i; 
  f[0] = 0; 
  f[1] = 1; 
  
  for (i = 2; i <= n; i++) 
  { 
      f[i] = f[i-1] + f[i-2]; 
  } 
  
  return f[n]; 
}*/ 
int main()
{   ll v=0,h=0,d,m,n,cnt=0,j=0,l=0,y=0,t,k=0,sum=1,x=0,i,mask,min,r=1,adv,g=0,low,high,yeah=0;
    string s1,s2,s3;
    map<char,long long int>mp;
    vector<long long int> v1;
    vector<long long int> v2;
    set<char> sy;
    char c;
    long long pos=0,pred=0;
    long long MAX=1e9+7;
    cin>>n;
    for(i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0){cnt+=i;}
    }
    cout<<cnt;
    
     return 0;   
    
}

Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void) {
	int n, i;
	ll a[200003] = {}, m1, m2, ans = 1e20;
	ll* p1, * p2;

	cin >> n;
	for (i = 1; i <= n; i++) {
		cin >> a[i];
		a[i] += a[i - 1];
	}

	for (i = 2; i < n - 1; i++) {
		p1 = lower_bound(a + 1, a + i, a[i] / 2 + 1);
		p2 = lower_bound(a + i + 1, a + n + 1, (a[n] + a[i]) / 2 + 1);
		for (int t1 = 0; t1 < 2; t1++) {
			for (int t2 = 0; t2 < 2; t2++) {
				m1 = max({ *p1,a[i] - *p1,*p2 - a[i],a[n] - *p2 });
				m2 = min({ *p1,a[i] - *p1,*p2 - a[i],a[n] - *p2 });
				ans = min(ans, m1 - m2);
				p2--;
			}
			p1--;
			p2 += 2;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>

#define rep(i, n) for (int i = 0; i < n; i++) 
#define rrep(i, n) for(int i = n-1; i>=0; i--)
#define range(i, n, m) for (int i = n; i < m; i++) 
#define rrange(i, n, m) for (int i = n - 1; i => m; i--) 
#define MOD 1000000007

typedef long long int ll;
typedef unsigned long long int ull;


using namespace std;

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


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

	ll A, B, C;

	cin >> A >> B >> C;

	if (A == B && B == C) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}


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

int main()
{
  ll N;
  ll a[5];
  ll res=0;
  cin >> N;
  rep(i,5) cin >> a[i];
  sort(a,a+5);
  res = N/a[0]+4;
  if(N%a[0]) res++;

  cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[35];
int main(){
    int n,m,k;
    string s;cin>>s;
    for(int i=0;i<s.size();i++) a[s[i]-'a']=1;
    for(k=0;k<26;k++)if(!a[k])break;
    if(k==26)cout<<"None";
    else printf("%c",k+'a');
    return 0;
}

Measured memory_bytes: 512
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  ll n;
  vector<ll>  a(5);
  cin >> n;

  rep(i,5) cin >> a[i];

  vsort(a);

  cout << kiriage(n,a[0]) + 4 << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
 
public class Main {
	private static FastScanner sc = new FastScanner();
	
	public static void main(String[] args) {
		int N = sc.nextInt();
		long K = sc.nextLong();
		
		long[] A = new long[N];
		long[] B = new long[N];
		for(int i=0; i<N; i++) {
			A[i] = sc.nextLong();
			B[i] = sc.nextLong();
		}
		
		boolean[] digit = new boolean[31];
		for(int i=0; i<31; i++) {
			digit[i] = ((K >> i) & 1) == 1 ? true : false;
		}
		long max = 0;
		a:
		for(int i=0; i<N; i++) {
			for(int j=0; j<31; j++) {
				if(!digit[j] && ((A[i] >> j) & 1) == 1) {
					continue a;
				}
			}
			max += B[i];
		}

		for(int i=1; i<31; i++) {
			if(!digit[i]) continue;
			boolean[] digit2 = new boolean[31];
			for(int j=0; j<31; j++) {
				if(j == i) {
					digit2[j] = false;
				} else if(j < i) {
					digit2[j] = true;
				} else {
					digit2[j] = digit[j];
				}
			}
			long ans = 0;
			b:
			for(int k=0; k<N; k++) {
				for(int j=0; j<31; j++) {
					if(!digit2[j] && ((A[k] >> j) & 1) == 1) {
						continue b;
					}
				}
				ans += B[k];
			}
			
			if(ans > max) max = ans;
		}
		
		System.out.println(max);
	}
	
	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}


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

int main(){
    int n;
    vector <int> p;
    int same_cnt = 0;
    cin >> n;
    for (int i = 0; i < n; i ++){
        int _p;
        cin >> _p;
        p.push_back(_p);
    }
    for (int i = 0; i < n; i ++){
        if (i + 1 == p[i]) {
            same_cnt += 1;
            i += 1;
        }
    }
    int ans = same_cnt;
    cout << ans << endl;
}

Measured memory_bytes: 3924
N, K = map(int, input().split())

if K > (N-1)*(N-2)//2:
    print(-1)
    exit()

left = (N-1)*(N-2)//2 - K
ans = []

for i in range(N-1):
    ans.append((1, i+2))

now = N - 1
tmp = N
while left > 0:
    left -= 1
    ans.append((now, tmp))
    if tmp == N:
        now = now - 1
        tmp = now
    tmp += 1
print(len(ans))

for a, b in ans:
    print(a, b)


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main() {
  int n;
  string s;
  cin >> n >> s;
  rep(i, s.length()) {
    s[i] = (s[i] + n);
    if (s[i] > 90) s[i] = 64 + s[i] - 90;
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll n;
vector<pair<ll, ll> > ba;
int main(void) {
    cin >> n;
    ll cnta=0;
    rep(i,n){
        ll tmpb,tmpa;
        cin >> tmpa >> tmpb;
        ba.push_back(make_pair(tmpb,tmpa));
    }
    sort(ba.begin(),ba.end());
    rep(i,n){
        cnta+=ba[i].second;
        DEBUG{
            printf("b : %lld, a : %lld\n",ba[i].first,cnta);
        }
        if(cnta>ba[i].first){
            cout << "No" << endl;
            return 0;    
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 6384
/* ex3_2
   moka223711 */

#include <stdio.h>

int main(void){
	int num;
	// 入力numを受け取る
	scanf("%d", &num);

	// num % 10で1の位を取得する
	// switch文で1の位の値に応じてnum本の本の読み方を出力する
	switch(num % 10){
		case 2: case 4: case 5: case 7: case 9:
			printf("hon");
			break;
		case 0: case 1: case 6: case 8:
			printf("pon");
			break;
		default: // case 3:
			printf("bon");
	}

	return 0;
}


Measured memory_bytes: 1736
s = list(input())
K = int(input())
ans = []
for c in s:
    cnt = ord('z') - ord(c) + 1
    if c == 'a':
        ans.append('a')
    elif K >= cnt:
        K -= cnt
        ans.append('a')
    else:
        ans.append(c)
K %= 26
if 122 < ord(ans[-1]) + K:
    ans[-1] = chr(ord(ans[-1]) + K - 26)
else:
    ans[-1] = chr(ord(ans[-1]) + K)
print(*ans,sep='')


Measured memory_bytes: 12428
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define nl '\n'
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define dcit cin.sync_with_stdio(0);cin.tie(0);
#define frp(x, y) freopen(x, "r", stdin);freopen(y, "w", stdout);
typedef pair<int, int> pii;
typedef long long ll;

#ifdef LOCAL_PROJECT

#define gc getchar()
#define pc(x) putchar(x)

#endif
#ifndef LOCAL_PROJECT

#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)

#endif

template<typename T> void scani(T &x) {x = 0;register bool _=0;register T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printi(T n) {register bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);pc(10);}
string nextstring() { string r; register char c=gc;while(c==32||c==10) c = gc;while(!(c==32||c==10)) { r += c;c = gc; }return r; }
char nextgetchar(){ register char c = gc; while(c==32 || c==10) c = gc; return c;}
void prints(string k){ for (int i = 0; i < k.length(); i++)pc(k[i]); }

void scani() {}

template<typename First, typename ... Ints>
void scani(First &arg, Ints&... rest) { scani(arg);scani(rest...); }

int N, M, dp[3002][3002], maxi; string a, b, ans;


int main(){
    a = nextstring();
    b = nextstring();
    for (int i = 1; i <= a.size(); i++) {
        for (int j = 1; j <= b.size(); j++) {
            if(a[i-1]==b[j-1]) dp[i][j] = dp[i-1][j-1]+1;
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    int i = a.size(), j = b.size();
    int index = dp[i][j];
    char lcs[index+1];
    lcs[index]='\0';
    while (i > 0 && j > 0) {
        if (a[i-1] == b[j-1]) {
            lcs[index-1] = a[i-1];
            i--; j--; index--;
        }
        else if (dp[i-1][j] > dp[i][j-1])i--;
        else j--;
    }

    printf("%s", lcs);
    return 0;
}

Measured memory_bytes: 35456
import math
import fractions
mod = 10 ** 9 + 7

nmax = 2 * 10 ** 5 + 1  # change here
fac = [0] * (nmax + 1)
finv = [0] * (nmax + 1)
inv = [0] * (nmax + 1)
fac[0] = 1
fac[1] = 1
finv[0] = 1
finv[1] = 1
inv[1] = 1
for i in range(2, nmax):
    fac[i] = fac[i - 1] * i % mod
    inv[i] = mod - inv[mod % i] * (mod // i) % mod
    finv[i] = finv[i - 1] * inv[i] % mod


def comb(n, r):
    if n < r:
        return 0
    else:
        return (fac[n] * ((finv[r] * finv[n - r]) % mod)) % mod


N, A, B, C = map(int, input().split())


G = fractions.gcd(A, B)
A = int(A / G)
B = int(B / G)

P = 0
A_N = pow(A, N, mod)
B_N = pow(B, N, mod)
for i in range(N):
    P = (P + ((N + i) * ((((A_N * pow(B, i, mod)) % mod) * ((pow(A+B, N-1-i, mod) * comb(N + i - 1, i)) % mod)) % mod
                        + (((B_N * pow(A, i, mod)) % mod) * ((pow(A+B, N-1-i, mod) * comb(N + i - 1, i)) % mod)) % mod)) % mod) % mod
P = (P * 100) % mod
Q = (pow(A+B, 2*N-1, mod) * (100 - C)) % mod
print((P * pow(Q, mod-2, mod)) % mod)


Measured memory_bytes: 71276
#include<iostream>
using namespace std;
int N;
void dfs(string s,char mx){
    if(s.size()==N)cout<<s<<endl;
    else for(char c='a';c<=mx;c++)dfs(s+c,c==mx?char(mx+1):mx);
}
int main(){
    cin>>N;
    dfs("",'a');
    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){

  int a[3];
  for (int i = 0; i < 3; i++){
    cin >> a[i];
  }
  sort(a, a+3);
  cout << a[2] * 10 + a[1] + a[0] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
bool ch[10];
int main() {
	ll n,k;
	cin>>n>>k;
	for(ll i=0;i<k;i++){
		ll now;
		cin>>now;
		ch[now]=true;
	}
	for(ll i=n;;i++){
		ll now=i;
		bool ans=true;
		while(now!=0){
			ll next=now%10;
			if(ch[next]){
				ans=false;
			}
			now/=10;
		}
		if(ans){
			cout <<i;
			return 0;
		}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n, m;
vector<int> a, b;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    b.resize(n-1);
    rep(i, n-1) cin >> b[i];
    int ans=b[0]+b[n-2];
    for(int i=1;i<n-1;i++){
        ans+=min(b[i-1],b[i]);
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main
{
    static HashMap<Integer,Integer> h;
    static int v=0;
    public static void main(String args[])throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        int n=Integer.parseInt(st.nextToken());
        int q=Integer.parseInt(st.nextToken());
        h=new HashMap<>(q);
        StringBuilder sb=new StringBuilder("");
        int c=0;
        while(q-->0)
        {
            String s=br.readLine();
            int a=Integer.parseInt(s.substring(0,s.indexOf(' ')));
            int b=Integer.parseInt(s.substring(s.indexOf(' ')+1));
            int v1=0;
            int v2=0;
            int p1=0;
            int p2=0;
            if(!h.containsKey(a))
            {
                h.put(a,-1);
                v1=1;
                p1=a;
            }
            else
            {
                v=0;
                p1=find(a);
                v1=v;
            }
            if(!h.containsKey(b))
            {
                h.put(b,-1);
                v2=1;
                p2=b;
            }
            else
            {
                v=0;
                p2=find(b);
                v2=v;
            }
            if(p1==p2)
            {
                sb.append(c+"\n");
                continue;
            }
          //  System.out.println(v1+" "+v2+" "+h);
            if(v1>v2)
            {
                h.put(p1,-1*(v1+v2));
                h.put(p2,p1);
                c=Math.max(-1*h.get(p1),c);
            }
            else
            {
                h.put(p2,-1*(v1+v2));
                h.put(p1,p2);
                c=Math.max(-1*h.get(p2),c);
            }
            sb.append(c+"\n");
        }
       // System.out.println(h);
        int cc=1;
        for(int a:h.keySet())
        {
        	if(h.get(a)<0)cc=Math.max(-1*h.get(a),cc);
        }
        System.out.println(cc);
    }
    static int find(int a)
    {
        if(h.get(a)<=-1)
        {
            v=h.get(a)*-1;
            return a;
        }
        int val=find(h.get(a));
        h.put(a,val);
        return val;
    }
}


Measured memory_bytes: 76784
import java.util.Scanner;
import java.util.HashSet;

class Main{
	public static void main(String arg[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.nextLine();
		HashSet<Integer> d = new HashSet<Integer>();
		
		for(int i = 0; i < N; i++) {
			d.add(sc.nextInt());
		}
		sc.close();
		
		System.out.println(d.size());
	}
}

Measured memory_bytes: 22100
#include <iostream>
#include <vector>

using namespace std;

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


int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int max_num = max(a, max(b, c));
  int ans = 3 * max_num - a - b - c;
  if(ans % 2 == 1){
    ans += 3;
  }
  cout << ans / 2 << endl;
}



Measured memory_bytes: 888
#include<stdio.h>
int main()
{
  int n,c,s,o;
  char dam;
  while(1){
    c=s=o=0;
    while(1){
    scanf("%d%c",&n,&dam);
    if(n==0)break;
    if(n>10)s+=10;
    else if(n==1){s+=1;o++;}
    else s+=n;
    if(dam=='\n'){
      c++;
      if(s>21)s=0;
      else{
	if(o>0&&(s+10)<=21)s+=10;
      }
    }
    if(c!=0)break;
  }
    if(n==0)break;
    printf("%d\n",s);
  }
  return 0;
}

Measured memory_bytes: 600