akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
  int p[100],m[100][100],n,i,j,k,l,o;
  scanf("%d",&n);
  for(i = 1;i <= n;i++){
    scanf("%d%d",&p[i-1],&p[i]);
  }
  for(i = 1;i <= n;i++){
    m[i][i] = 0;
  }
  for(l =2;l <= n;l++){
    for(i = 1;i <= n-l+1;i++){
      j = i+l-1;
      m[i][j] = 1000000;
      for(k = i;k <= j -1;k++){
	o = m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	if(o < m[i][j]){
	  m[i][j] = o;
	}
      }
    }
  }
  printf("%d\n",m[1][n]);
}



Measured memory_bytes: 2112
let nil = -1

type node = {
  mutable parent : int;
  mutable left : int;
  mutable right : int;
  mutable depth : int;
  mutable height : int;
}

let make () = { parent = nil; left = nil; right = nil; depth = nil; height = nil }

let search_root t n =
  let rec doit i =
    if i = n then nil
    else if t.(i).parent = nil then i
    else doit (i + 1) in
  doit 0

let set_depth t n =
  let rec doit i d =
    t.(i).depth <- d;
    if t.(i).left <> nil then doit t.(i).left (d + 1);
    if t.(i).right <> nil then doit t.(i).right (d + 1) in
  doit (search_root t n) 0

let set_height t n =
  let rec doit i =
    let hl = ref 0 in
    let hr = ref 0 in
    if t.(i).left <> nil then begin
      doit t.(i).left;
      hl := t.(t.(i).left).height + 1
    end;
    if t.(i).right <> nil then begin
      doit t.(i).right;
      hr := t.(t.(i).right).height + 1
    end;
    t.(i).height <- (max !hl !hr) in
  doit (search_root t n)

let print t =
  let sibling i =
    if t.(i).parent = nil then nil
    else if t.(t.(i).parent).left <> i && t.(t.(i).parent).left <> nil then t.(t.(i).parent).left
    else if t.(t.(i).parent).right <> i && t.(t.(i).parent).right <> nil then t.(t.(i).parent).right
    else nil in
  let degree i = 0 + (if t.(i).left <> nil then 1 else 0) + (if t.(i).right <> nil then 1 else 0) in
  t |> Array.iteri (fun i _ ->
    "node " ^ string_of_int i
    ^ ": parent = " ^ string_of_int t.(i).parent
    ^ ", sibling = " ^ string_of_int (sibling i)
    ^ ", degree = " ^ string_of_int (degree i)
    ^ ", depth = " ^ string_of_int t.(i).depth
    ^ ", height = " ^ string_of_int t.(i).height
    ^ (if t.(i).parent = nil then ", root"
       else if t.(i).left = nil && t.(i).right = nil then ", leaf"
       else ", internal node")
    |> Printf.printf "%s\n")

let () =
  let n = read_int () in
  let t = Array.init n (fun _ -> make ()) in
  for _ = 0 to n - 1 do
    let (id, l, r) = Scanf.scanf "%d %d %d\n" (fun id l r -> (id, l, r)) in
    t.(id).left <- l;
    t.(id).right <- r;
    if l <> nil then t.(l).parent <- id;
    if r <> nil then t.(r).parent <- id;
  done;
  set_depth t n;
  set_height t n;
  print t

Measured memory_bytes: 2312
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
int main(){
  ll H,W,ans=0,c[10][10];
  cin>>H>>W;
  rep(i,10) rep(j,10) cin>>c[i][j];
  rep(k,10) rep(j,10) rep(i,10) c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
  rep(i,H) rep(j,W){
    ll a;cin>>a;
    if(a>=0) ans+=c[a][1];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
    ll A, B;
    cin >> A >> B;
    write(A * B / gcd(A, B));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main(void){
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  REP(i, h) cin >> s[i];
  
  vector<vector<int>> L(h,vector<int>(w, 0)), R(h,vector<int>(w, 0));
  vector<vector<int>> U(h,vector<int>(w, 0)), D(h,vector<int>(w, 0));

  REP(i, h){
    REP(j, w){
      if(s[i][j] == '#'){
        D[i][j] = 0;
        L[i][j] = 0;
        continue;
      }
      D[i][j] = i ? D[i-1][j] + 1 : 1;
      L[i][j] = j ? L[i][j-1] + 1 : 1;
    }
  }

  REPr(i, h){
    REPr(j, w){
      if(s[i][j] == '#'){
        U[i][j] = 0;
        R[i][j] = 0;
        continue;
      }
      U[i][j] = i != h-1 ? U[i+1][j] + 1 : 1;
      R[i][j] = j != w-1 ? R[i][j+1] + 1 : 1;
    }
  }
  int ans = 0;
  REP(i, h) REP(j, w){
    int b = U[i][j] + D[i][j] + L[i][j] + R[i][j] - 3;
    chmax(ans, b);
  } 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 67200
#include <iostream>
#include <algorithm>
#include <string>

constexpr int INF = 1 << 30;

void solve() {
    std::string s;
    std::cin >> s;
    std::reverse(s.begin(), s.end());

    int stay = 0, up = INF;
    for (char c : s) {
        int d = c - '0';

        int nstay = stay + d,
            nup = stay + (10 - d);

        int ud = d + 1;

        if (ud == 10) {
            nup = std::min(nup, up);
        } else {
            nstay = std::min(nstay, up + ud);
            nup = std::min(nup, up + (10 - ud));
        }

        stay = nstay;
        up = nup;
    }

    std::cout << std::min(stay, up + 1) << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}


Measured memory_bytes: 1948
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input!{
        w: usize,
        h: usize,
        n: usize,
        xya: [(usize, usize, usize); n],
    };
    let mut ans = vec![vec![1u32; w]; h];

    for (x, y, a) in xya{
        match a {
            1 => {
                for i in 0..h{
                    for j in 0..x{
                        ans[i][j] = 0;
                    }
                }
            },
            2 => {
                for i in 0..h{
                    for j in x..w{
                        ans[i][j] = 0;
                    }
                }
            },
            3 => {
                for i in 0..y{
                    for j in 0..w{
                        ans[i][j] = 0;
                    }
                }
            },
            4 => {
                for i in y..h{
                    for j in 0..w{
                        ans[i][j] = 0;
                    }
                }
            },
            _ => {},
        }
    }

    println!(
        "{}",
        ans.iter().map(|v| v.iter().sum::<u32>()).sum::<u32>()
    );
}


Measured memory_bytes: 4352
N = int(input())
A = [int(input()) for _ in range(N)]

ans = 0

if A[0] > 0:
    ans = -1
else:
    for i in range(N-1):
        if A[i] == A[i+1]-1:
            continue
        elif A[i] >= A[i+1]:
            ans += A[i]
        else:
            ans = -1
            break
    else:
        ans += A[N-1]

print(ans)

Measured memory_bytes: 11048
//Daniel Grzegorzewski
#include <bits/stdc++.h>

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios()
{
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int N = 2*(int)1e5 + 10;

int n, res[N];
PII a[N];

int main()
{
	init_ios();
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i].ST;
		a[i].ND = i;
	}
	sort(a+1, a+n+1);
	int ile = (n-1)/2;
	for (int i = 1; i <= n; ++i) {
		int x1 = 1, x2 = n, x3;
		if (i <= n/2)
			x1 = i+1;
		else
			x2 = i-1;
		while (x2-x1 > 1) {
			x3 = (x1+x2)/2;
			int lew = x3-1;
			if (i < x3)
				--lew;
			if (lew < ile)
				x1 = x3;
			else
				x2 = x3;
		}
		int wyn = a[x1].ST;
		int lew = x2-1;
		if (i < x2)
			--lew;
		if (lew == ile)
			wyn = a[x2].ST;
		res[a[i].ND] = wyn;
	}
	for (int i = 1; i <= n; ++i)
		cout<<res[i]<<"\n";
}

Measured memory_bytes: 4608
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

// author:Swastik Banerjee

using namespace std;

typedef long long ll;
#define MOD 1000000007

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



  int x;
  cin >> x;

  long double ok1 = (long double)(x) / (long double)(3);

  long double ok2 = (long double)(x) / (long double)(3);

  long double ok3 = x - (ok1 + ok2);

  long double prod = ok1 * ok2 * ok3;

  cout << fixed << setprecision(12) << prod;
}

Measured memory_bytes: 888
#include <cstdio>

int main()
{
	int a;
	while ( scanf("%d", &a) != EOF )
	{
		int ans = 0;
		while ( a )
		{
			if ( a%10 == 2 ) ans++ ;
			a /= 10;
		}
		printf("%d\n", ans);
	}
	return 0;
}








Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long
const int N = 1e5 + 10;
const int MOD = 1e9 + 7;
 
int32_t main(){
    boost;
    string s;
 
    cin >> s;
 
    for(int i = 0 ; i < s.length()-1 ; ++i){
    	if(s[i] == s[i+1]){
    		cout << i+1 << " " << i+2;
    		return 0;
    	}
    }
 
 
    for(int i = 0 ; i < s.length()-2; ++i){
    	if(s[i] == s[i+2]){
    		cout << i+1 << " " << i+3;
    		return 0;
    	}
    }
 
    cout << -1 << " " << -1;
    return 0;
}

Measured memory_bytes: 512
N = int(input())

# N!を素因数分解をしたときの可能な最大値はNであることに注意
# eは0~Nまでの指数をカウントするもの
e = [0]*(N+1)

# 2からNまでそれぞれ順に素因数分解していく
for i in range(2, N+1):
    cur = i
    # 2~iまでそれぞれで割っていく
    for j in range(2, i+1):
        while cur % j == 0:
            e[j] += 1
            # curはjで割った結果になる
            cur //= j

def num(m):
        return len(list(filter(lambda x: x >= m-1, e)))

print(num(75) + 
      num(25) * (num(3) - 1) + 
      num(15) * (num(5) - 1) + 
      num(5) * (num(5) - 1) * (num(3) - 2) // 2)


Measured memory_bytes: 3060
#!python3

def factor(n):
    ans = []
    i = 0
    while n & 1 == 0:
        n >>= 1
        i += 1

    if i > 0:
        ans.append((2, i))

    for i in range(3, int(n**.5) +1, 2):
        x, y = divmod(n, i)

        if y == 0:
            j = 1
            x1 = x
            while True:
                x1, y = divmod(x, i)
                if y == 0:
                    x = x1
                    j += 1
                else:
                    ans.append((i, j))
                    break
            n = x

    if n > 1:
        ans.append((n, 1))

    return ans

def resolve():
    A, B = map(int, input().rstrip().split(" "))

    fa = dict(factor(A))
    fb = dict(factor(B))


    a = A
    for k, v in fa.items():
        if k in fb:
            v2 = fb[k]
            if v < v2:
                a *= k ** (v2 - v)
            del fb[k]
    for k, v in fb.items():
        a *= k ** v

    print(a)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
#define ll long long
int main()
{
	int ans1=0;
	int ans2=0;
	int ans3=0;
    ll n,x = 1;
 ans1=ans2=ans3=0;
        cin >> n;
        x = 1;ans1=ans2=ans3=0;
        vector<char>ans;
        int k = 10;ans1=ans2=ans3=0;
        while(x <= n)
        {ans1=ans2=ans3=0;
            if(n % (x*26)==0)
            {ans1=ans2=ans3=0;
                n -= x*26;ans1=ans2=ans3=0;
                ans.push_back('z');ans1=ans2=ans3=0;
            }
            else
            {ans1=ans2=ans3=0;
                char c = ((n/x)%(26))-1+'a';ans1=ans2=ans3=0;
                ans.push_back(c);ans1=ans2=ans3=0;
                n -= x * (c-'a'+1);ans1=ans2=ans3=0;
            }
            x = x * 26;ans1=ans2=ans3=0;
        }
        for(int i=ans.size()-1;i>=0;i--)
        {
            cout << ans[i];
        }
        cout << '\n';
    


    return 0;
}


Measured memory_bytes: 3628
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

x,k,d=map(int,input().split())
if x>0:
    tmp=x//d
    if tmp>k:
        print(x-k*d)
    elif tmp%2 == k%2:
        print(x-tmp*d)
    else:
        print(abs(x-(tmp+1)*d))

else:
    tmp=(-x)//d
    if tmp>k:
        print(-x-k*d)
    elif tmp%2 == k%2:
        print(-x-tmp*d)
    else:
        print(abs(-x-(tmp+1)*d))

Measured memory_bytes: 68140
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6+10;
#define int long long
int n,m;
map<int,pair<int,int>>map1;
typedef long long ll;
int num[N];
signed main()
{
	for(int i=0;i<=1000;i++)
	{
		int y=pow(i,5);
		num[i]=y;
	}
	for(int i=0;i<=1000;i++)
		for(int j=0;j<=1000;j++)
		{
			map1[num[i]-num[j]]={i,j};
			map1[num[i]+num[j]]={i,-j};
		}
	int x;
	cin>>x;
	cout<<map1[x].first<<" "<<map1[x].second<<endl;
	return 0;
}


Measured memory_bytes: 97960
#071 b-not found
#A~ 65 65+26 a~97 97+26
s=input()
a=[chr(i) for i in range(97,97+26)]
flag=False
for i in range(26):
    if a[i] not in s:
        ans=i
        flag=True
    if flag:
        break
if flag:
    print(chr(97+i))
else:
    print("None")

Measured memory_bytes: 3188
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

#include <bits/stdc++.h>
 
using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair

typedef long long ll;
typedef long double ld;

void solve(){
    ll a;
    cin >> a;
    string s;
    cin >> s;
    ll c = 0;
    c += (s[0] - '0') * 100LL;
    c += (s[2] - '0') * 10LL;
    c += (s[3] - '0') * 1LL;
    ll res = a * c;
    res = res / 100LL;
    cout << fixed << setprecision(0) << res << "\n";
    return;
}

int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}

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

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long long llong;
typedef long double ld;

using namespace std;

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
        cerr << (*i) << " ";
    }
    cerr << "\n";
}

int n;
ll a, b;
ll h[120000];

int main() {
    cin >> n >> a >> b;
    a -= b;
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    ll l = 0;
    ll r = 1e9;
    while (r - l > 1) {
        ll mid = (l + r) >> 1;
        ll cnt = 0;
        for (int i = 0; i < n; ++i) {
            if (h[i] > mid * b) {
                cnt += (h[i] - mid * b + a - 1) / a;
            }
        }
        if (cnt <= mid)
            r = mid;
        else
            l = mid;
    }
    cout << r << "\n";
    return 0;
}




Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

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

    li h, w, a, b;
    cin >> h >> w >> a >> b;

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cout << ((i < b) != (j < a) ? 1 : 0);
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
const int INF = 100000000;
int dx[] = {0,1,-1,0,1,-1,1,-1};
int dy[] = {1,0,0,-1,1,-1,-1,1};

int main(){
    int n, m;
    cin >> n >> m;
    vector<tuple<int, int, int, int>> v;
    for(int i = 1; i <= m; i++){
        int p, y, x = 0;
        cin >> p >> y;
        v.emplace_back(p, y, x, i);
    }
    sort(v.begin(), v.end());
    int tmp = 0;
    int num = 1;
    for(auto &t: v){
        if(get<0>(t) != tmp){
            tmp = get<0>(t);
            num = 1;
            get<2>(t) = num;
            num++;
        }else{
            get<2>(t) = num;
            num++;
        }
    }
    vector<tuple<int, int, int, int>> ans(m+1);
    for(auto t: v){
        ans[get<3>(t)] = t;
    }
    for(auto t: ans){
        if(get<0>(t) == 0) continue;
        printf("%06d", get<0>(t));
        printf("%06d\n", get<2>(t));
    }
}


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

using namespace std;

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

  int maxa = 0, minb = 1e9 + 1;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    maxa = max(maxa, a);
    minb = min(minb, b);
  }

  cout << maxa + minb << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

long total = 0;

void FizzBuzz(const int m){
	if(m % 3 != 0){
		if(m % 5 != 0)
			total += m;
	}
}

int main(void){
	int i, m;
	
	scanf("%d",  &m);
	
	for(i = 1;i <= m;i++){
		FizzBuzz(i);
	}
	
	printf("%ld\n", total);
	
	return 0;
}

Measured memory_bytes: 1732
c = list(map(int,input().split()))
a = list(map(int,input().split()))

a.sort(reverse=True)
#print(a)
flag = 0
damage = 0
for i in range(c[1]):
  damage += a[i]
  if damage >= c[0]:
    flag = 1
    break

if flag == 1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 13960
def solve(n, s):
    dict_1 = dict()
    dict_2 = dict()
    dict_3 = dict()
    for i in range(n):
        a = s[i]
        for k2 in dict_2.keys():
            dict_3[k2 + a] = 1
        for k1 in dict_1.keys():
            dict_2[k1 + a] = 1
        dict_1[a] = 1
    return len(dict_3.keys())


def main():
    n = int(input())
    s = input()
    res = solve(n, s)
    print(res)


def test():
    assert solve(4, "0224") == 3
    assert solve(6, "123123") == 17
    assert solve(19, "3141592653589793238") == 329


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    readonly Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        int N = cin.nextint;
        var A = cin.next;
        var B = cin.next;
        var C = cin.next;

        int cnt = 0;
        for (int i = 0; i < N; i++)
        {
            if (A[i] == B[i] && B[i] == C[i])
            {

            }
            else if (A[i] == B[i])
            {
                cnt++;
            }
            else if (B[i] == C[i])
            {
                cnt++;
            }
            else if (C[i] == A[i])
            {
                cnt++;
            }
            else
            {
                cnt += 2;
            }
        }
        WriteLine(cnt);
    }

}

class Scanner
{
    string[] s; int i;
    readonly char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
    public void join<T>(IEnumerable<T> values) { WriteLine(string.Join(" ", values)); }
}

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

const int MAXN = 55;
const int dx[4] = { 0, 0, 1, -1 };
const int dy[4] = { 1, -1, 0, 0 };
char mp[MAXN][MAXN];
int n, m;

bool isval(int x, int y) {
	return x >= 0 && y >= 0 && x < n && y < m && mp[x][y] == '#';
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			cin >> mp[i][j];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++) {
			if (mp[i][j] == '.')
				continue;
			bool bd = 1;
			for (int k = 0; k < 4; k++) {
				int x = i + dx[k], y = j + dy[k];
				if (isval(x, y))
					bd = 0;
			}
			if (bd)
				return cout << "No", 0;
		}
	cout << "Yes";
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "YES"; }
  string_type do_falsename() const { return "NO"; }
};

ll tens[32];

ll dp(const int digit, const ll D, bool zero) {
  if (digit == 1) return (D == 0 ? 10 : 0);
  if (digit == 0) return (D == 0 ? 1 : 0);
  if (abs(D) > tens[digit]) return 0;
  ll res = 0;
  for (int diff = -9; diff <= 9; ++diff) {
    int count = 10 - abs(diff) - (zero ? 1 : 0);
    ll nD = D - diff * (tens[digit - 1] - 1);
    if (nD % 10 == 0) res += dp(digit - 2, nD / 10, false) * count;
  }
  return res;
}

void solve(const ll D) {
  tens[0] = 1;
  REP(i,18) tens[i + 1] = tens[i] * 10;
  ll res = 0;
  for (int digit = 1; digit <= 18; ++digit) {
    res += dp(digit, D, true);
  }
  cout << res << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll D;
	scanf("%lld", &D);
	solve(D);
	return 0;
}


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

int main()
{
  int n;
  cin>>n;
  vector<int>s1,s2,s;
  for(int i=0;i<n;i++)
  {
      int x;
      cin>>x;
      s1.push_back(x);
      s.push_back(i+1);
  }
  for(int i=0;i<n;i++)
  {
      int x;
      cin>>x;
      s2.push_back(x);
  }
  if(s1==s2)
  {
      cout<<"0";
      return 0;
  }
  int x=0,i=1;
  do
  {
      if(s==s1)
      {
          x+=i;
      }
      if(s==s2)
      {
          x-=i;
      }
      i++;
  }
  while(next_permutation(s.begin(),s.end()));
  cout<<abs(x);
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll unsigned long long
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
int a=m/n;
if(n==1)
{cout<<m;return 0;}
if(m%n==0)
{cout<<(m/n);return 0;}
for(int i=a;i>=1;i--)
{if(m%i==0&&(m/i)>=n)
{cout<<i;return 0;}}
cout<<1;return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p;
    cin >> n;
    for(i = 0; i < n; i++){
        cin >> x;
        if(x % 2 == 0 && (x%3 != 0 && x % 5 != 0)){
            cout << "DENIED";
            return 0;
        }
    }
    cout << "APPROVED";

    return 0;
}


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

public class Test
{
	public static void Main()
	{
		var s = Console.ReadLine();
		if(s.Any(x=>x=='a')
		&&s.Any(x=>x=='b')
		&&s.Any(x=>x=='c'))
		{
			Console.WriteLine("Yes");
		}
		else{
			Console.WriteLine("No");
		}
	}
}

Measured memory_bytes: 13268
import java.io.*;
import java.util.*;


// 2011/10/22

//0092 ÅåÌ³û`ðT·
public class Main {

	
	// C return falseÅ¨µÜ¢
	boolean main() throws IOException {

		int[] ir = readIntArray();
		int size = ir[0];
		if (size == 0)
			return false;

		int[][] map = new int[size][size];
		
		for(int y = 0; y < size; y++) {
			String s = reader.readLine();
			for(int x = 0; x < size; x++) {
				map[x][y] = s.charAt(x) == '*' ? 1 : 0;
			}
		}
		
		int sq;
		for(sq = 1; sq <= size; sq++) {
			boolean isOK = false;
			loop2:
			for(int x = 0; x < size - sq + 1; x++) {
				for(int y = 0; y < size - sq + 1; y++) {
					
					boolean dame = false;
					loop:
					for(int xx = 0; xx < sq; xx++) {
						for(int yy = 0; yy < sq; yy++) {
							if (map[x + xx][y + yy] != 0) {
								dame = true;
								break loop;
							}
						}
					}
					if (!dame) {
						isOK = true;
						break loop2;
					}
				}
			}
			if (!isOK) {
				break;
			}
		}
		int max = sq-1;
		
		
		// ðÌ\¦
		System.out.printf("%d\n", max);
		
		return true; // ³íI¹ Ö
	}
	

//	private final static boolean DEBUG = true;  // debug
	private final static boolean DEBUG = false; // release

	public static void main(String[] args) throws IOException {

		if (DEBUG) {
			log = System.out;
			
			String inputStr = "10,...*....**,..........,**....**..,........*.,..*.......,..........,.*........,..........,....*..***,.*....*...,0,";

			inputStr = inputStr.replace(",", "\n");

			reader = new BufferedReader(new StringReader(inputStr)); 

		}
		else {
			log = new PrintStream(new OutputStream() { public void write(int b) {} } ); // «ÌÄ
			reader = new BufferedReader(new InputStreamReader(System.in)); // R\[©ç
		}
		
		//int N = readIntArray()[0];

		for(int i = 0; /*i < N*/; i++) {
			boolean b = new Main().main();
			if (!b)
				break;
		}		
		
		reader.close();
	}

	
	static PrintStream log;
	static BufferedReader reader;
	

	// WüÍæè1sªÌXy[XæØèÌ®lðÇÞ
	// EOFÌêÍnullðÔ·
	private static int[] readIntArray() throws IOException {
		
		String s = reader.readLine();
		if (s == null)
			return null;
		String[] sp = s.split(" ");
		int[] a = new int[sp.length];
		for(int i = 0; i < sp.length; i++) {
			a[i] = Integer.parseInt(sp[i]);
		}
		return a;
	}
		
}

Measured memory_bytes: 15000
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int main()
{
    int k;
    vector<int> n = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin >> k;
    cout << n[k-1] << endl;
    return 0;
}

Measured memory_bytes: 3592
N=int(input())

def cal(s):
    if int(s)>N:
        return 0
    if all(s.count(c) > 0 for c in '753'): ret=1
    else: ret=0
    
    for c in "753":
        ret+=cal(s+c)
    return ret

print(cal("3")+cal("5")+cal("7"))

Measured memory_bytes: 3060
//#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << x << "\n"
using namespace std;
using point = pair< int,int >;
using ll = long long;

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

    int A[n];

    REP (i, n) {
        scanf("%d", &A[i]);
    }

    int cnt = 0;

    for (int i = 1; i < n; ++i) {
        if (A[i - 1] == A[i]) {
            cnt++;
            i++;
        }
    }

    OUT(cnt);
    return 0;
}



Measured memory_bytes: 256
n = int(input())
t,a = map(int,input().split())
df = [int(x) for x in input().split()]

sa = []

for i in df:
    b = t - i * 0.006  
    c = abs(b - a)
    sa.append(c)
  
x = sa.index(min(sa)) + 1
print(x)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#define fs first
#define sc second
using namespace std;
const int maxn = 1e5+10;
using pii = pair<int,int>;

int N;
int arr[4][4];
bool vis[4][4];
int main(){
    for(int i = 1;i<=3;i++){
        for(int j = 1;j<=3;j++){
            scanf("%d",&arr[i][j]);
        }
    }
    cin>>N;
    while(N--){
        int tmp;cin>>tmp;
        for(int i = 1;i<=3;i++){
            for(int j = 1;j<=3;j++){
                if(arr[i][j] == tmp)
                    vis[i][j] = 1;
            }
        }
    }
    for(int i = 1;i<=3;i++){
        int ok1 = 1,ok2 = 1;
        for(int j = 1;j<=3;j++){
            if(vis[i][j] == 0) ok1 = 0;
            if(vis[j][i] == 0) ok2 = 0;
        }
        if(ok1 || ok2){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    if(vis[1][1] && vis[2][2] && vis[3][3]){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(vis[1][3] && vis[2][2] && vis[3][1]){
        cout<<"Yes"<<endl;
        return 0;
    }

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

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

using namespace std;

int f1(int&, bool&);

int f2(int&, bool&);

int f3(int&, bool&);

vector< int > undefined;
string S;

bool isout(int val)
{
  return(val < 0 || val >= 1024);
}
int f1(int& idx, bool& f)
{
  int val = f2(idx, f);

  while(S[idx] == '+' || S[idx] == '-') {
    if(S[idx] == '+') {
      ++idx;
      val += f2(idx, f);
    } else {
      ++idx;
      val -= f2(idx, f);
    }
    if(isout(val)) throw(1);
    f = true;
  }
  return (val);
}

int f2(int& idx, bool& f)
{
  int val = f3(idx, f);

  while(S[idx] == '*') {
    idx++;
    val *= f3(idx, f);
    if(isout(val)) throw(1);
    f = true;
  }
  return (val);
}

int f3(int& idx, bool& f)
{
  int val = 0;
  if(S[idx] == '(') {
    ++idx;
    int now = idx;
    bool flag = false;
    val = f1(idx, flag);
    if(!flag) throw(1);
    ++idx;
    return (val);
  } else if(isdigit(S[idx])) {
    while(isdigit(S[idx])) {
      val = val * 2 + S[idx] - '0';
      ++idx;
      if(isout(val)) throw(1);
    }
  } else {
    throw (1);
  }
  return (val);
}

int make(int idx)
{
  int ret = -1;
  if(idx == undefined.size()) {
    try {
      int pos = 0;
      bool f = false;
      int val = f1(pos, f);
      if(pos + 1 != S.size()) throw (1);

      //cout << S << " " << val << endl;

      ret = max(ret, val);
    } catch(int e) {}
  } else {
    string s = "01+-*()";
    for(char c : s) {
      S[undefined[idx]] = c;
      ret = max(ret, make(idx + 1));
    }
  }
  return (ret);
}

int main()
{
  cin >> S;
  S += "~";
  for(int i = 0; i < S.size(); i++) {
    if(S[i] == '.') undefined.push_back(i);
  }
  cout << make(0) << endl;
}

Measured memory_bytes: 3292
#include <stdio.h>
#include <string.h>

int main(){
    char str[100];
    int count=0;
    int i;
    int length;

    scanf("%s", str);
    if(strlen(str)!=3){
        return 0;
    }

    for(i=0; i<3; i++){
        if(str[i]=='A'){
            count++;
        }else if(str[i]=='B'){
            count--;
        }
    }

    if((-3<count && count<3) && count!=0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

int a[110000] = {};

int main(){
	
	int N, T;
	cin >> N >> T;
	
	for(int i = 0; i < N; i++){
		int l, r;
		cin >> l >> r;
		a[l]++;
		a[r]--;
	}
	
	int ans = 0, cur = 0;
	for(int i = 0; i <= T; i++){
		cur += a[i];
		ans = max(ans, cur);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3508
let rec power x n =
  if n <= 0 then 1
  else if n mod 2 = 0 then
    power (x*x) (n/2)
  else
    x * power x (n - 1)

let () =
  let a, b, c, k = Scanf.scanf "%d %d %d %d" (fun a b c k -> a, b, c, k) in
  let result = a + b + c + (max (max a b) c) * (power 2 k - 1) in
  Printf.printf "%d\n" result


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <set>
#include <algorithm>
#include <cstring>

using namespace std;

set<string> dict;
set<string> ldict;

int main()
{
    int n,i,m,s,q,w,t;
    string a[102];
    string b[102];
    int sum1[102];
    int sum2[102];
    memset(sum1,0,sizeof(int)*102);
    memset(sum2,0,sizeof(int)*102);
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        dict.insert(a[i]);
    }
    cin>>m;
    for(i=0;i<m;i++)
    {
        cin>>b[i];
        ldict.insert(a[i]);
    }
    s=0;
    for(set<string>::iterator it=dict.begin();it!=dict.end();it++)
    {
        for(i=0;i<n;i++)
        {
            if(a[i]==(*it))
            {
               sum1[s]++;
            }
        }
        s++;
    }
    t=0;
    for(set<string>::iterator it=ldict.begin();it!=ldict.end();it++)
    {
        for(i=0;i<m;i++)
        {
            if(b[i]==(*it))
            {
                sum2[t]++;
            }
        }
        t++;
    }
    q=0;
    for(set<string>::iterator it=dict.begin();it!=dict.end();it++,q++)
    {
         w=0;
         for(set<string>::iterator it1=ldict.begin();it1!=ldict.end();it1++,w++)
         {
            if(*it==*it1)
            {
                sum1[q]=sum1[q]-sum2[w];
            }
         }
    }
    sort(sum1,sum1+s);
    if(sum1[s-1]>0)
    {
        printf("%d\n",sum1[s-1]);
    }
    else
    {
        printf("0\n");
    }
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

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;
}

const int MOD = 998244353;
const ll INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

double A[1010];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N; cin >> N;
	double ans = 0;
	REP(i, N) {
		cin >> A[i];
		ans += 1 / A[i];
	}
	ans = 1.0 / ans;
	cout << setprecision(10) << ans << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    char s[3];
    int add=0;
    for(int i=0;i<3;i++){
        scanf("%c",&s[i]);
        if(s[i]=='o'){
            add+=100;
        }
    }
    add+=700;
    printf("%d",add);
    return 0;
}

Measured memory_bytes: 128
s = input()

acgt = set("ACGT")

ans = 0

for i in range(len(s)):
    l = 0
    for j in range(i, len(s)):
        if s[j] in acgt:
            l += 1
            if j == len(s)-1:
                ans = max(ans, l)
        else:
            ans = max(ans, l)
            break

print(ans)


Measured memory_bytes: 3060
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
X = sorted((x,i) for i,x in enumerate((int(x) for x in input().split()),1))

arr = []
for x,i in X:
    arr += [i] * (i-1)
for x,i in X:
    arr += [i] * (N-i)

x_to_i = dict(X)

arr = arr[::-1]
answer = []
counter = [0] * (N+1)
bl = True
for x in range(1,N*N+1):
    if x in x_to_i:
        i = x_to_i[x]
        counter[i] += 1
        bl &= (counter[i] == i)
    else:
        i = arr.pop()
        counter[i] += 1
    answer.append(i)

if bl:
    print('Yes')
    print(*answer)
else:
    print('No')

Measured memory_bytes: 10624
import java.util.Scanner;


public class Main {
	static long N,K;
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
			 N = sc.nextLong();
			 K = sc.nextLong();
		  sc.close();

		  //bを固定してaの数を求める
		 long acount = 0;

		  if(K == 0){
			  acount = N*N;
		  }
		  else{
			  for(long i = K+1 ; i < N+1 ; i++){
				  acount += (i-K) * (N/i);
				  if(N%i >= K){
					  acount += ((N%i)-K+1);
				  }
			  }
		  }
		  System.out.println(acount);

	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <unordered_map>
#include <iomanip>
#include <sstream>
#include <numeric>
using namespace std;
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi>
#define vs vector<string>
#define pi pair<ll,ll>
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define fs first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
int main() {
    ll n;
    cin>>n;
    vi v(n);
    for(ll i=0;i<n;i++){
        cin>>v[i];
    }
    vi a(n);
    a[0] = 0;
    a[1] = abs(v[0]-v[1]);
    for(ll i=2;i<n;i++){
        a[i] = min((a[i-2]+abs(v[i-2]-v[i])),(a[i-1]+abs(v[i-1]-v[i])));
    }
    cout<<a[n-1]<<endl;
}




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

int main() {
	int h, w; cin >> h >> w;
	char c[210][210];

	for (int y = 0; y < h; y++) {
		for (int x = 0; x < w; x++) {
			cin >> c[y][x];
			cout << c[y][x];
		}
		printf("\n");
		for (int x = 0; x < w; x++) {
			cout << c[y][x];
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main( ){
  while(1){
    int a,b,c[4],d[4],x=0,y=0;
    cin>>a>>b;
    if(a==0&&b==0)break;
    c[0]=a/1000;
    c[1]=(a%1000)/100;
    c[2]=(a%100)/10;
    c[3]=(a%10);
    d[0]=b/1000;
    d[1]=(b%1000)/100;
    d[2]=(b%100)/10;
    d[3]=(b%10);
    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
        if(c[i]==d[j]){
          if(i==j)x++;
          else y++;
        }
      }
    }
    printf("%d %d\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 3204
import math
import sys
input = sys.stdin.readline


def main():
    A, B, C = map(int, input().split())
    K = int(input())

    M = max(A, B, C)
    ans = A + B + C - M + M * (2 ** K)

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <stdio.h>

template <class Integer = long long int>
inline Integer get(void){
    Integer res = 0;
    int c = getc_unlocked(stdin);
    if(c == '-'){
        while((c = getc_unlocked(stdin) - '0') >= 0){ res = 10 * res + c; }
        return -res;
    }
    res = c - '0';
    while((c = getc_unlocked(stdin) - '0') >= 0){ res = 10 * res + c; }
    return res;
}

struct circle{
    long long int x, y;
    int radius;
    circle(void):x(),y(),radius(){}
    static double distance(const long long int dx, const long long int dy){
        return __builtin_sqrt(dx * dx + dy * dy);
    }
    inline void in0(void){x = get(); y = get(); }
    inline void in(void){ x = get(); y = get(); radius = get<int>(); }
    inline double distance(const circle& other){
        double d = distance(x - other.x, y - other.y) - (radius + other.radius);
        return (d < 0) ? 0 : d;
    }
};

inline void chmin(double& v, const double val){ if(v > val) v = val; }

using uint = unsigned int;
constexpr uint MAX_N = 1000;
constexpr double inf = 3e18 + 3e17 + 4e16;
circle Point[MAX_N + 2];
bool visited[MAX_N + 2];
double dist[MAX_N + 2];

int main(void){

    Point[0].in0(); Point[1].in0();

    uint n = get();
    Point[++n] = Point[1]; dist[n] = inf;

    for(uint i = 1; i < n; ++i) { Point[i].in(); dist[i] = inf;}

    for(uint _ = 0, s = 0; _ < n; ++_){
        double min = inf; uint nearest = 0; visited[s] = true;
        for(uint v = 1; v <= n; ++v) if(not visited[v]){
            const double d = Point[s].distance(Point[v]);
            chmin(dist[v], dist[s] + d);
            if(min > dist[v]){ min = dist[v]; nearest = v; }
        }
        s = nearest;
        if(s == n) break;
    }
    printf("%.16lf\n", dist[n]);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) ((a)<<(b))
#define Rshift(a,b) ((a)>>(b))
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define sz(a) int(a.size())
#define mset(x) memset(x, 0, sizeof(x))
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    char a;
    cin >> a;
    if (a >= 'a') cout << 'a' << endl;
    else cout << 'A' << endl;
}


Measured memory_bytes: 3660
import java.util.Scanner;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        String[] arr = S.split("");

        int max = 0;
        int max2 = 0;
        for (int i = 0; i < arr.length; i++) {
        	if (max2 > max) {
        		max = max2;
        	}
        	max2 = 0;
        	if (arr[i].equals("A") || arr[i].equals("C") || arr[i].equals("G") || arr[i].equals("T") ) {
        		max2++;
//        		System.out.println("arr[i]" + arr[i] + i);
        		for (int j = i+1; j < arr.length; j++) {
        			if (arr[j].equals("A") || arr[j].equals("C") || arr[j].equals("G") || arr[j].equals("T") ) {
        				//System.out.println("arr[j]"+arr[j] + j);
        				max2++;
        			} else {
        				if (max2 > max) {
        	        		max = max2;
        	        	}
        				break;
        			}
            	}
        		if (max2 > max) {
	        		max = max2;
	        	}
        	}
        }
//        if ((max == 0)&& arr[arr.length-1].equals("A") || arr[arr.length-1].equals("C") || arr[arr.length-1].equals("G") || arr[arr.length-1].equals("T")) {
//        	++max;
//        }
        System.out.println(max);
    }

}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll D, G;
    cin >> D >> G;
    G /= 100;
    vll p(D), c(D);
    for (size_t i = 0; i < D; i++)
    {
        cin >> p[i] >> c[i];
        c[i] /= 100;
    }
    ll ans = INF;
    for (ll i = 0; i < (1 << D); i++)
    {
        ll sum = 0, num = 0;
        for (int j = 0; j < D; j++)
        {
            if (i & (1 << j))
            {
                sum += c[j];
                sum += (j + 1) * p[j];
                num += p[j];
            }
        }
        ll goal = G - sum;

        if (goal < 0)
        {
            chmin(ans, num);
            continue;
        }
        ll now = 0;

        for (int j = D - 1; j >= 0; j--)
        {
            if (i & (1 << j))
                continue;
            ll k = min((goal - now + j) / (j + 1), p[j] - 1);
            num += k;
            now += k * (j + 1);
            if(now >=goal)
            break;
        }
        if (now < goal)
            num = INF;
        chmin(ans, num);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256