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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
template <typename T> using vec = vector<T>;
typedef vec<int> vi;
typedef vec<ll> vl;


template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

const ll MAX_A = TEN(16)+1000;
const int MAX_N = 50;
ll n;
ll a[MAX_N];

ll count(ll m) {
  ll c = 0;
  forn(i,n) {
    c += max((a[i]-m)/(n+1), 0LL);
  }
  return c;
}


int main()
{
  cin >> n;
  forn(i,n) cin >> a[i];

  ll x = max(accumulate(a,a+n,0LL) - n*(n-1), 0LL);

  forn(i,n) a[i] += x;

  ll l = -1, r = MAX_A;
  while (r - l > 1) {
    ll m = (l + r) / 2;
    ll c = count(m);
    if (c <= x)
      r = m;
    else
      l = m;
  }

  ll ans = 0;
  forn(i,n) {
    ll c = max((a[i]-r)/(n+1), 0LL);
    ans += c;
    a[i] -= c*(n+1);
  }

  //cout << ans << ", " << x << endl;

  while (ans < x) {
    auto it = max_element(a,a+n);
    *it -= n+1;
    ans++;
  }

  auto it = max_element(a,a+n);
  while (*it >= n) {
    int idx = it-a;
    forn(i,n) {
      if (i == idx) a[i] -= n;
      else a[i]++;
    }
    it = max_element(a,a+n);
    ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn._

object Main extends App {
  val Seq(n, m) = readLine().split(" ").map(_.toInt).toSeq

  require(1 <= n && n <= 30)
  require(1 <= m && m <= 30)

  var i = 0
  var f = readLine().split(" ").map(_.toInt).toSeq.tail
  while (i < n - 1) {
    val arr = readLine().split(" ").map(_.toInt).toSeq
    f = f.intersect(arr.tail)
    i = i + 1
  }
  println(f.length)
}


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

int main()
{
    int h, w;
    while (1) {
        cin >> h >> w;
        if (!h && !w) break;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (!i || !j || i == h - 1 || j == w - 1) cout << "#";
                else cout << ".";
            }
            cout << '\n';
        }
        cout << '\n';
    }

    return 0;
}

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

int main(){
    string s;
    cin >> s;
    string ans = "";
    for (int i = 0; i < s.size(); i++) {
        if (i % 2 == 0) {
            ans = ans + s[i];
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
  
#define REP(i,n) for(int i=0;i<(int)(n);i++)
  
  
int main()
{
    int h;
    while(1==1)
    {
        scanf("%d\n",&h);
        if(h==0)break;
        int ban[15][5]={};
        int del=0;
        long int ans=0;
        REP(y,h)REP(x,5)scanf("%d ",&ban[y][x]);
        do{
            del=0;
            REP(y,h)
            {
                int center=ban[y][2];
                int centnum=1;
                if(ban[y][1]==center)
                {
                    centnum++;
                    if(ban[y][0]==center)centnum++;
                }
                if(ban[y][3]==center)
                {
                    centnum++;
                    if(ban[y][4]==center)centnum++;
                }
                if(centnum>=3 && center!=0)
                {
                    ban[y][2]=0;
                    if(ban[y][1]==center)
                    {
                        ban[y][1]=0;
                        if(ban[y][0]==center)ban[y][0]=0;
                    }
                    if(ban[y][3]==center)
                    {
                        ban[y][3]=0;
                        if(ban[y][4]==center)ban[y][4]=0;
                    }
                    ans+=centnum*center;
                    del++;
                }
            }
            REP(x,5)REP(i,1000)REP(y,h-1)if(ban[y][x]!=0&&ban[y+1][x]==0)swap(ban[y][x],ban[y+1][x]);
            /*
            REP(y,h)
            {
                REP(x,5)
                {
                    printf("%d ",ban[y][x]);
                }
                printf("\n");
            }
            printf("###\n");
            */
        }while(del>0);
        printf("%ld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 3148
#include <iostream>
#include <string>

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main()
{
	string A, B, C;
	cin >> A >> B >> C;


	cout << A[0];
	cout << B[0];
	cout << C[0] << "\n";
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int K, N;
	cin >> N >> K;
	vi p(N);
	rep(i, N)
		cin >> p[i];
	sort(p.begin(), p.end(), less<int>());



	ll ans = 0;
	rep(i, K)
		ans += p[i];

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

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

using namespace std;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define PB push_back
#define PF push_front

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const ll INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

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

int main(){
  string s;
  cin>>s;
  
  ll n;
  n=s.size();
  
  vector<ll> t(n);
  
  vector<pair<ll,ll> > v;
  ll a=0;
  
  rep(i,n-1){
    if(s[i]=='L'&&s[i+1]=='R'){
      v.PB(make_pair(a,i));
      a=i+1;
    }else if(i==n-2){
      v.PB(make_pair(a,n-1));
    }
  }
  
  vector<ll> b(v.size());
  
  rep(i,v.size()){
    for(ll j=v[i].first;j<=v[i].second;j++){
      if(s[j]=='L'){
		b[i]=j-1;
        break;
      }
    }
  }
  
  ll l,r,nl,nr,tr=0,tl=0;

  rep(i,v.size()){
    r=b[i]-v[i].first;
    l=v[i].second-b[i]-1;
  	tr=1;
    tl=1;
    if(r%2==0){
      tr+=r/2;
      tl+=r/2;
    }else{
      tr+=(r-1)/2;
      tl+=(r+1)/2;
    }
    if(l%2==0){
      tr+=l/2;
      tl+=l/2;
    }else{
       tr+=(l+1)/2;
      tl+=(l-1)/2;
    }
    
    t[b[i]]=tr;
    t[b[i]+1]=tl;
  }
   
  
  rep(i,n){
	cout<<t[i]<<' ';
  }

  cout<<endl;
  	
}
    





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

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

int main() {
    int n;
    cin >> n;
    int a[n];
    int gcd_left[n+1] = {};
    int gcd_right[n+1] = {};
    rep(i,n) cin >> a[i];
    rep(i,n+1) {
        if (i > 0) {
            gcd_left[i] = gcd(gcd_left[i-1], a[i-1]);
            gcd_right[n-i] = gcd(gcd_right[n-i+1], a[n-i]);
        }
    }
    int ans = 0;
    rep(i,n) {
        int g = gcd(gcd_left[i], gcd_right[i+1]);
        ans = max(g, ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1408
console.log((args=>{
  const S = args.trim().split``.map(c=>c.charCodeAt()-97);
  const N = S.length;
  const a = Array(26).fill(-1);
  for ( let i = 0; i < 26; i++ ) {
    let d = 0;
    for ( let j = 0; j < N; j++ ) {
      d = S[j] === i ? 0 : d + 1;
      if ( a[i] < d ) a[i] = d;
    }
  }
  return Math.min(...a.filter(v=>v>=0));
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 29408
#include<bits/stdc++.h>
using namespace std;
char s[210000];
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>s;
	long long ans=0,suma=0,i=0;
	while(i<strlen(s)){
		while(s[i]=='A'){
			i++;suma++;
		}
		if(s[i]=='B'&&s[i+1]=='C'){
			ans+=suma;i+=2;
		}
		else{
			suma=0;i++;
		}
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 384
#include <iostream>

int main () {
    int n;
    std::cin >> n;
    if (n == 3 || n == 5 || n == 7) {
        std::cout << "YES" << std::endl;
    } else {
    	std::cout << "NO" << std::endl; 
    }
    return 0; 
}


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

int main(){
    int N;
    cin>>N;
    vector<int> P(N);
    for(int i=0;i<N;i++){
        cin>>P.at(i);
    }
    int min=P.at(0);
    int cnt=0;
    for(int i=0;i<N;i++){
        if(P.at(i)<=min){
            min=P.at(i);
            cnt++;
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 1024
//use proconio::input;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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")
    };
}

const SIZE: usize = 3000;

fn main() {
    input! {
        s: String,
        t: String,
    }
    let s: Vec<char> = s.chars().collect();
    let t: Vec<char> = t.chars().collect();

    let mut dp = vec![vec![(0, None); SIZE + 1]; SIZE + 1];

    let mut f = false;
    if s[0] == t[0] {
        f = true;
        dp[0][0] = (1, None);
    }
    let mut fi = f;
    for i in 1..s.len() {
        if s[i] == t[0] {
            fi = true;
        }
        if fi {
            dp[i][0] = (1, Some((i - 1, 0)));
        }
    }
    for j in 1..t.len() {
        if s[0] == t[j] {
            f = true;
        }
        if f {
            dp[0][j] = (1, Some((0, j - 1)));
        }
    }
    for i in 1..s.len() {
        for j in 1..t.len() {
            let mut dpij = (0, None);
            if s[i] == t[j] {
                dpij = (dp[i - 1][j - 1].0 + 1, Some((i - 1, j - 1)));
            }
            if dp[i][j - 1].0 > dpij.0 {
                dpij = (dp[i][j - 1].0, Some((i, j - 1)));
            }
            if dp[i - 1][j].0 > dpij.0 {
                dpij = (dp[i - 1][j].0, Some((i - 1, j)));
            }
            dp[i][j] = dpij;
        }
    }

    // traceback
    let mut r = String::new();
    let mut dpij = Some((s.len() - 1, t.len() - 1));
    while let Some(ij) = dpij {
        dpij = dp[ij.0][ij.1].1;
        if let Some(next) = dpij {
            if dp[ij.0][ij.1].0 > dp[next.0][next.1].0 {
                r = [s[ij.0].to_string(), r].concat();
            }
        }
    }

    if dp[0][0].0 > 0 {
        r = [s[0].to_string(), r].concat();
    }
    println!("{}", r);
}


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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/

// vector
template <typename T>
istream & operator>>(istream & is, vector<T> & vec) {
	for (T& x : vec) is >> x;
	return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
	os << "(" << pair_var.first << ", " << pair_var.second << ")";
	return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
	os << "{";
	for (int i = 0; i < vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
	}
	os << "}";
	return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
	os << "{";
	repi(itr, map_var) {
		os << *itr;
		itr++;
		if (itr != map_var.end()) os << ", ";
		itr--;
	}
	os << "}";
	return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
	os << "{";
	repi(itr, set_var) {
		os << *itr;
		itr++;
		if (itr != set_var.end()) os << ", ";
		itr--;
	}
	os << "}";
	return os;
}

#define DUMPOUT cerr

void dump_func() {
	DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
	DUMPOUT << head;
	if (sizeof...(Tail) > 0) {
		DUMPOUT << ", ";
	}
	dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif



signed main() {

	int X, Y;
	cin >> X >> Y;

	int ans=0;
	if (X == 1) ans += 300000;
	else if (X == 2) ans += 200000;
	else if (X == 3) ans += 100000;

	if (Y == 1) ans += 300000;
	else if (Y == 2) ans += 200000;
	else if (Y == 3) ans += 100000;

	if (X == 1 && Y == 1) ans += 400000;

	cout << ans << endl;

}

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

#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll unsigned long long
#define endl "\n"

void solve()
{
	ll a;
	cin>>a;
	ll t1=a;
	ll t2=a*a;
	ll t3=a*a*a;
	cout<<t1+t2+t3;
}

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

Measured memory_bytes: 3604
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {
	
	void run() {
		Scanner sc = new Scanner(System.in);
		
		int INF = 1<<29;
		
		for(;;) {
			int n = sc.nextInt(), m = sc.nextInt(), c = sc.nextInt();
			if((n|m|c) == 0) break;
			
			Es[] G = new Es[n];
			for(int i=0;i<n;i++) G[i] = new Es();
			for(int i=0;i<m;i++) {
				int f = sc.nextInt()-1, t = sc.nextInt()-1, cost = sc.nextInt();
				G[f].add(new E(f, t, cost));
			}
			
			PriorityQueue<S> que = new PriorityQueue<S>();
			int[][] d = new int[n][n+1];
			for(int[] a: d) fill(a, INF);
			que.add(new S(0, 0, 0)); d[0][0] = 0;
			
			for(;!que.isEmpty();) {
				S cur = que.remove();
//				debug(cur.p, cur.e, cur.c);
				if(d[cur.p][cur.e] != cur.c) continue;
				if(cur.p == n-1 && cur.c < c) {
					System.out.println(cur.e);
					break;
				}
				
				for(E next: G[cur.p]) {
					if(d[next.t][cur.e] > cur.c + next.c) {
						d[next.t][cur.e] = cur.c + next.c;
						que.add(new S(next.t, cur.e, cur.c+next.c));
					}
					if(d[next.t][cur.e+1] > cur.c) {
						d[next.t][cur.e+1] = cur.c;
						que.add(new S(next.t, cur.e+1, cur.c));
					}
				}
			}
		}
	}
	
	class S implements Comparable<S>{
		int p, e, c;
		S(int p, int e, int c) {
			this.p = p;
			this.e = e;
			this.c = c;
		}

		public int compareTo(S o) {
			// TODO Auto-generated method stub
			if(e != o.e) return e - o.e;
			return c-o.c;
			
		}
	}
	
	class Es extends ArrayList<E> {}
	
	class E {
		int f, t, c;
		E(int f, int t, int c) {
			this.f = f;
			this.t = t;
			this.c = c;
		}
	}
	
	void debug(Object...os) {
		System.err.println(deepToString(os));
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 72684
n = gets.to_i
a = []
n.times { a << gets.to_i }
score = 0
more = a.sort.reverse
less = a.sort
ans = []
i = 0
op_more = 0 # 0のとき左から
op_less = 0 # 0のとき左から
while i < n
  if i % 2 == 0
    if op_less == 0
      ans.unshift(less.shift)
    else
      ans.push(less.shift)
    end
    op_less = 1 - op_less
  else
    if op_more == 1
      ans.unshift(more.shift)
    else
      ans.push(more.shift)
    end
    op_more = 1 - op_more
  end
  i += 1
end

score = [score, ans.each_cons(2).map { |(x, y)| (x - y).abs }.inject(:+)].max

ans = []
i = 0
more = a.sort.reverse
less = a.sort
op_more = 0 # 0のとき左から
op_less = 0 # 0のとき左から
while i < n
  if i == n - 1
    ans.push(more.shift)
  elsif i % 2 == 0
    if op_less == 0
      ans.unshift(less.shift)
    else
      ans.push(less.shift)
    end
    op_less = 1 - op_less
  else
    if op_more == 1
      ans.unshift(more.shift)
    else
      ans.push(more.shift)
    end
    op_more = 1 - op_more
  end
  i += 1
end
score = [score, ans.each_cons(2).map { |(x, y)| (x - y).abs }.inject(:+)].max

ans = []
i = 0
op_more = 0 # 0のとき左から
op_less = 0 # 0のとき左から
more = a.sort.reverse
less = a.sort
while i < n
  if i == n - 1
    ans.unshift(more.shift)
  elsif i % 2 == 0
    if op_less == 0
      ans.unshift(less.shift)
    else
      ans.push(less.shift)
    end
    op_less = 1 - op_less
  else
    if op_more == 1
      ans.unshift(more.shift)
    else
      ans.push(more.shift)
    end
    op_more = 1 - op_more
  end
  i += 1
end
score = [score, ans.each_cons(2).map { |(x, y)| (x - y).abs }.inject(:+)].max

p score

Measured memory_bytes: 13536
#include<iostream>
#define int long long
using namespace std;

signed main()
{
	char s[1000010];
	char a;
	int N, Q;
	int x = 0;
	int ans = 0;
	int k[100];
	int l[4];
	//int t[1000010][4];


	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> s[i];
	}
	x = N;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		cin >> k[i];

		int td = 0, tm = 0, tc = 0;
		int count = 0;
		int ans = 0;

		for (int j = 0; j < x; j++) {
			if (s[j] == 'D') {
				td++;
			}
			if (j >= k[i]) {
				if (s[j - k[i]] == 'D') {
					td--;
				}
			}


			if (j >= k[i]) {
				if (s[j - k[i]] == 'D') {
					tm -= count;
				}
			}



			if (s[j] == 'M') {
				tm += td;
				count++;
			}
			if (j >= k[i]) {
				if (s[j - k[i]] == 'M') {
					count--;
				}
			}



			if (s[j] == 'C') {
				ans += tm;
			}
			
		}
		cout << ans << endl;

	}

	

	/*for (int i = 1; i <= x; i++) {
		if (s[i] == 'D') {
			l[0] ++;
			t[i][0] = t[i-1][0] + 1;
		}
		else {
			t[i][0] = 
		}
		if (s[i] == 'M') {
			l[1] += l[0];
			t[i][0] += 
		}
	}*/

//	system("pause");
    return 0;
}



Measured memory_bytes: 1280
# -*- coding: utf-8 -*-
h, w = map(int, input().split())
a = []
a = [[True] * (w + 2)]
for i in range(h):
    a.append([True] + [x == '#' for x in input()] + [True])
a.append([True] * (w + 2))
q = []

for i in range(1, h + 1):
    for j in range(1, w + 1):
        if a[i][j]:
            q.append((i, j))

count = 0
while True:
    qq = []
    for i, j in q:
        if not a[i-1][j]:
            a[i-1][j] = True
            qq.append((i - 1, j))
        if not a[i+1][j]:
            a[i+1][j] = True
            qq.append((i + 1, j))
        if not a[i][j-1]:
            a[i][j-1] = True
            qq.append((i, j - 1))
        if not a[i][j+1]:
            a[i][j+1] = True
            qq.append((i, j + 1))
    q = qq
    if len(q) <= 0:
        break
    count += 1

print(count)


Measured memory_bytes: 105972
A, B = map(int, input().split())
x_a = int((A-1) * 100 / 8)
x_b = int((B+1) * 100 / 10)
l = [i for i in range(min(x_a, x_b)-1, max(x_a, x_b)+1)]
for n in l:
    if int(n * 0.08) == A and int(n * 0.10) == B:
        print(n)
        break
else:
    print(-1)

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

public class Test
{
	public static void Main()
	{
		// your code goes here
		
		string s = Console.ReadLine();
		string t = Console.ReadLine();
		int counter = 0;
		
		for(int i=0;i!=3;i++){
			if( s.Substring(i,1) == t.Substring(i,1) ){counter++;}
		}
		
		Console.WriteLine(counter);
		
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <time.h>
#include <chrono>
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(ll i=a;i>b;i--)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,l,r) for(int i=(1);i<(r);i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
static const double pi = 3.141592653589793;
using namespace std;
using namespace std::chrono;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = (1LL << 31) - 1;
const ll mod = 1e9 + 7;


ll H, W,M;
pair<ll, ll> X[300005], Y[300005];
vector<ll> B;


inline ll get_time_millisec(void) {
	return static_cast<ll>(duration_cast<milliseconds>(steady_clock::now().time_since_epoch()).count());
}

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

	cin >> H >> W>>M;
	B.resize(M);
	FOR(i, 0, M) {
		ll x, y; cin >> y >> x;
		x--; y--;
		X[x].first++;
		Y[y].first++;

		B[i] = y * W + x;
	}
	FOR(i, 0, H) {
		Y[i].second = i;
	}
	FOR(i, 0, W) {
		X[i].second = i;
	}
	sort(B.begin(), B.end());

	sort(X, X + W);
	reverse(X, X + W);

	sort(Y, Y + H);
	reverse(Y, Y + H);

	ll maxX = X[0].first;
	ll maxY = Y[0].first;


	


	bool judge = true;

	ll saTimeStart = get_time_millisec();

	ll saTimeCurrent = saTimeStart;

	for (int i = 0; X[i].first == maxX; i++) {
		for (int j = 0; Y[j].first == maxY; j++) {
			ll x = X[i].second, y = Y[j].second;

			if (!binary_search(B.begin(), B.end(), y*W + x)) {
				cout << maxX + maxY << endl;

				return 0;
			}

			
			saTimeCurrent = get_time_millisec();
			if (saTimeCurrent == saTimeStart + 1900) {
				cout << maxX + maxY - 1 << endl;
				return 0;
			}
		}
	}

	cout << maxX + maxY - 1 << endl;

	return 0;
}








Measured memory_bytes: 15100
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    int N;
    while(cin >> N){
        int cnt[7] = {0};
        string in;
        vector<int> a(N),b(N);
        for(int i = 0 ; i < N ; i++){
            cin >> in;
            a[i] = in[0]-'0';
            b[i] = in[1]-'0';
            cnt[a[i]]++;
            cnt[b[i]]++;
        }
        if(N == 1){
            cout << "Yes" << endl;
            continue;
        }
        bool check = false;
        for(int i = 0 ; i < N ; i++){
            if(a[i] == b[i]){
                if(cnt[a[i]] == 2){
                    check = true;
                    break;
                }
            }
        }
        if(check){
            cout << "No" << endl;
            continue;
        }
        int odd = 0,even = 0;
        for(int i = 0 ; i < 7 ; i++){
            if(cnt[i]&1) odd++;
            else even++;
        }
        cout << ((even == 7 || odd == 2) ? "Yes" : "No") << endl;
    }
    return 0;
}

Measured memory_bytes: 2992
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	n <- readInteger
	let
		ps = filter ( ( == 0 ) . ( n `mod` ) ) $ takeWhile ( \p -> p * p <= n ) [ 1 .. ]
		qs = map ( n `div` ) ps
	print $ subtract 2 $ minimum $ zipWith (+) ps qs

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class T>
void read(T &res) {
  int f = 1; res = 0;
  char c = getchar();
  while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar(); }
  while(c >= '0' && c <= '9') { res = res * 10 + c - '0'; c = getchar(); }
  res *= f;
}
LL a[64];
LL k;
const LL Mod = 1e9+7;
int main() {
  int n;
  read(n);
  for(int i = 0; i < n; i++) {
    read(k);
    for(int j = 0; j <= 60; j++) {
      if((1ll << j) & k) a[j]++;
    }
  }
  LL sum = 0;
  for(int i = 0; i <= 60; i++) {
    sum = (sum + (1ll << i) % Mod *(n - a[i]) % Mod * a[i] % Mod) % Mod;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
    string s;
    cin >> s;
    int cnt = 0;
    int ans = -1;
    for (char c: s) {
        if (c == 'A' or c == 'C' or c == 'G' or c == 'T') cnt++;
        else {
            if (ans < cnt) ans = cnt;
            cnt = 0;
        }
    }
    if (ans < cnt) ans = cnt;
    cout << ans << '\n';
   
    return 0;
}

Measured memory_bytes: 3580
/*Practice hard*/
#include <bits/stdc++.h>
using namespace std;

//_______MACROS_______//
#define   fast  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define   int   long long int
#define   pb    push_back
#define   f     first
#define   s     second
#define   PI    3.14159265358979323846264338327950L

signed main()
{
    //code here
    fast ;
    int a, b, h, m;
    cin >> a >> b >> h >> m ;
    long double rad = PI * 2 * ((long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long double)m / 60.0);
    long double rsq = (long double)(a * a + b * b) - (long double)(2 * a * b) * cos(rad);
    cout << setprecision(20) <<sqrt(rsq) << endl;
	return 0;
}


Measured memory_bytes: 4180
#include<stdio.h>
#include<algorithm>
using namespace std;
int a[100005]={0};
int main()
{
	int n;
	while(~scanf("%d",&n))
	{
		for(int  i=1;i<=n;i++)
		scanf("%d",&a[i]);
		sort(a+1,a+1+n);
		if(a[n/2]==a[n/2+1]) 
		printf("0\n");
		else
		printf("%d\n",a[n/2+1]-a[n/2]);
	}
 } 

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
// x^y≡x^(y%(p-1))mod p
// but there is a condition that x needs to be coprime to p
///assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
typedef long long int ll;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
#define  pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define tests() int test_cases ; cin >> test_cases ; while(test_cases--)
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define MAXN 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define sp " "
#define MS(x,y) fill_n(*x, sizeof x / sizeof **x, y);
#define mem(x,y) memset(x,y,sizeof(x));
#define INF 1000000000000000000
ll power(ll x, ll y,ll p) 
{ 
    ll res = 1;     // Initialize result 
    x = x % p;
    if (y==0)return 1;
    if(x==0)return 0;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p;    
        y = y>>1; // y = y/2 
        x = (x*x) % p;  // Change x to x^2 
    } 
    return res; 
}
int gcd(int a, int b) { if (a == 0)return b;return gcd(b % a, a);} 

ll modinv(ll a,ll p){return power(a,p-2,p);}
ll n,m,q;
vll a,b,c,d;
ll ans = 0;
vll perm;
void generate(ll cur, ll idx){
    if (idx==n)
    {
        ll cur = 0;

        fo(i,0,q-1){
            if (perm[b[i]]-perm[a[i]]==c[i])
            {
                cur+=d[i];
            }
        }
        ans = max(ans,cur);
        return;
    }
    fo(d,cur,m){
        perm[idx] = d;
        generate(d,idx+1);
    }
    return;
}
int solve(){
    cin>>n>>m>>q;
    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);
    f(i,0,q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--;
        b[i]--;
    }
    perm.resize(n);
    generate(1,0);
    cout<<ans<<endl;
    return 0;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);



    
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif



    // tests(){solve();}
    solve();
    return 0;
}/*#ifndef ONLINE_JUDGE
    #endif*/

    // make_pair make_tuple  tuple<int,int,int> 

Measured memory_bytes: 3676
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
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;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
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 end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N[5], min = 10,last = 150, ans = 0;
    REP(i, 5){
        in >> N[i];
    }

    REP(i, 5){
        if( N[i]%10<min && N[i]%10!=0 ){
            last = N[i];
            min = N[i]%10;
        }
    }

    //out << " " << last << endl;
  
    ll flag = 0;

    REP(i, 5){
        if(N[i]%10 != 0){
            if(N[i] != last){
                ans += N[i] + 10 - (N[i]%10);
            }else if(flag==0){
                ans += N[i];
                flag = 1;
            }else{
                ans += N[i] + 10 - (N[i]%10);
            } 
        }else{
            ans += N[i];
        }
    }
    out << ans << endl;

 
    //vector<ll> X(N);

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;

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

    ll N;
    cin >> N;
    vector<ll> A(3 * N);
    for (auto&& a : A) {
        cin >> a;
    }

    vector<ll> dp(N + 1);
    dp[0] = accumulate(A.begin(), A.begin() + N, 0LL);
    priority_queue<ll, vector<ll>, greater<ll> > que;
    for_each(A.begin(), A.begin() + N, [&](ll a) { que.push(a); });

    for (ll i = 1; i <= N; i++) {
        ll top = que.top();
        ll val = A[i + N - 1];
        dp[i] = dp[i - 1];
        if (top < val) {
            dp[i] += val - top;
            que.pop();
            que.push(val);
        }
    }

    vector<ll> dp2(N + 1);
    dp2[0] = accumulate(A.rbegin(), A.rbegin() + N, 0LL);
    priority_queue<ll> que2;
    for_each(A.rbegin(), A.rbegin() + N, [&](ll a) { que2.push(a); });

    for (ll i = 1; i <= N; i++) {
        ll top = que2.top();
        ll val = A[2 * N - i];
        dp2[i] = dp2[i - 1];
        if (top > val) {
            dp2[i] += val - top;
            que2.pop();
            que2.push(val);
        }
    }

    ll ans = -1e18;
    for (ll i = 0; i <= N; i++) {
        ans = max(ans, dp[i] - dp2[N - i]);
    }

    cout << ans << endl;
}



Measured memory_bytes: 6516
// D - Gathering Children
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

void out(int s, int l, int e, int o){
	rp(i, s, l-1) cout<<"0 ";
	cout<< (l%2? e:o) <<" "<< (l%2? o:e) <<" ";
}

int main(){
	int s = 0, l = -1, r = -1, e, o, n, C;
	for(n=0, C=getchar(); C=='R' || C=='L'; C=getchar(), ++n){
		if(r<0 && C=='R'){
			if(l>=0) out(s,l,e,o);
			s = l + 1;
			r = n; l = -1;
			e = o = 0;
		}
		else if(l<0 && C=='L'){
			l = n; r = -1;
		}
		if(n%2) o++; else e++;
	}
	out(s,l,e,o);
	rp(i, l+1, n) cout<<"0 ";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
typedef long double ld;

int A, B, C, D;
char V;

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> V;
	A = V - '0';
	cin >> V;
	B = V - '0';
	cin >> V;
	C = V - '0';
	cin >> V;
	D = V - '0';
	for (int i = 0; i < (1<<3); i++) {
		int T = A;
		for (int j = 0; j < 3; j++)
			if (i & (1<<j)) {
				T -= (j == 0 ? B : j == 1 ? C : D);
			} else {
				T += (j == 0 ? B : j == 1 ? C : D);
			}
		if (T == 7) {
			cout << A;
			for (int j = 0; j < 3; j++) {
				if (i & (1<<j))
					cout << '-';
				else cout << '+';
				if (j == 0) cout << B;
				else if (j == 1) cout << C;
				else cout << D;
			}
			cout << "=7\n";
			return 0;
		}
	}
}


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

using namespace std;

int main(void){

    int n;
    char str[150*4 + 1];
    
    while(true) {

        scanf("%d\n", &n);

        if (n != 0) {
            fgets(str, sizeof(str) / sizeof(char), stdin);
        }
         if(n == 0) {   
            return 0;
        }
        //0????????????1?????????
        int left = 0, right = 0;
        int ans = 0;
        int current = 0;

        for(int i = 0; i < n; i++) {
            if(str[i*3] == 'l') {
                left = 1 - left;
            }

            if(str[i*3] == 'r') {
                right = 1 - right;
            }

            if(left == right && left != current) {
                ans++;
                current = 1 - current;
            }
        }
        
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000011
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
 int n,q;
 int ne[200002];

  vector <int> G[200002]{};
 ll val[200002];

void dfs(int z){
  int si=G[z].size();
  for(int i=0;i<si;i++){
    int pv=G[z][i];
    if(ne[pv]==0){
      ne[pv]=z;
    val[pv]+=val[z];
      dfs(pv);
    }
  }
 
  }





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

 
  rep(i, n+1){
    ne[i]=0;}
  ne[1]=10000000;

  for(int i=1;i<=n-1;i++){
    int a,b;
    cin>>a>>b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
 
  rep(i, n+1){
    val[i]=0;}
  
  rep(i, q){
    int p,x;
    cin>>p>>x;
    val[p]+=x;
  }
  
  dfs(1);
  
  for(int j=1;j<=n-1;j++){
  cout<<val[j]<<" ";}
  cout<<val[n]<<endl;
    
  
  
  
  
 
}

Measured memory_bytes: 25088
#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    int a[300000];
    long long sum = 0;
    for (int i = 0; i < 3 * N; i++)
    {
        cin >> a[i];
    }

    sort(a, a + 3 * N);
    for (int i = 0; i < N; i++)
    {
        sum += (long long)a[3 * N - 2 - 2 * i];
    }
    cout << sum << endl;
    
    return 0;
}


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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 1e6+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int sum = 0;
        string s;
        cin>>s;
        for(char c:s)sum += c-'0';
        cout<<(sum%9?"No":"Yes")<<endl;
    }
    return 0;
}


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

int n;
int a[111];

int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	int answer = 0;
	for (int i = 1, j = 1; i <= n; ) {
		while (a[i] == a[j] && j <= n) j++;
		answer += (j - i) / 2;
		i = j;
	}
	cout << answer << "\n";
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from collections import Counter, defaultdict, deque
import math

import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

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


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def f(a, b):
    if a == 0 and b == 0:
        return (1, 0, 0)
    if b == 0:
        return (1, 1, 0)
    g = math.gcd(a, b)
    a //= g
    b //= g
    if a == 0 and b < 0:
        s = 1
    else:
        s = 1 if a * b >= 0 else -1
    a = abs(a)
    b = abs(b)
    return s, a, b


class Mod:
    def __init__(self, m):
        self.m = m

    def add(self, a, b):
        return (a + b) % self.m

    def sub(self, a, b):
        return (a - b) % self.m

    def mul(self, a, b):
        return ((a % self.m) * (b % self.m)) % self.m

    def div(self, a, b):
        return self.mul(a, pow(b, self.m-2, self.m))

    def pow(self, a, b):
        return pow(a, b, self.m)


@mt
def slv(N, AB):
    adb = Counter()
    for a, b in AB:
        s, a, b = f(a, b)
        adb[(s*a, b)] += 1
    error_print(adb)
    M = Mod(1000000007)
    ans = 1
    done = set()
    for k, v in adb.items():
        if k in done:
            continue
        if k == (0, 0):
            continue
        a, b = k
        if a < 0:
            s = 1
            a = abs(a)
        elif a == 0:
            s = 1
        else:
            s = -1
        n = adb[(s*b, a)]
        done.add(k)
        done.add((s*b, a))
        t = M.sub(M.pow(2, v) + M.pow(2, n), 1)
        ans = M.mul(ans, t)

    return M.add(M.sub(ans, 1), adb[(0, 0)])


def main():
    N = read_int()
    AB = [read_int_n() for _ in range(N)]
    print(slv(N, AB))


if __name__ == '__main__':
    main()


Measured memory_bytes: 223304
def in_range(x: int, lower: int, upper: int) -> bool:
    return lower <= x and x <= upper


def digit_sum(n: int) -> int:
    s = 0
    while n > 0:
        s += n % 10
        n //= 10
    return s


def some_sums(N: int, A: int, B: int) -> int:
    return sum(n+1 for n in range(N) if in_range(digit_sum(n+1), A, B))


if __name__ == "__main__":
    N, A, B = map(int, input().split())
    ans = some_sums(N, A, B)
    print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i,n) for (int i=0; i<(n); i++)
#define reps(i,s,n) for (int i=(s); i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define repr(i,s,n) for (int i=(s)-1; i>=(n); i--)
#define print(a) cout << (a) << endl;
#define all(v) v.begin(), v.end()


const ll mod = 1e9+7;
struct mint {
  ll x;
  mint(ll x=0) : x((x%mod+mod)%mod) {}
  mint &operator+=(const mint &p) { if((x += p.x) >= mod) x -= mod; return *this; }
  mint &operator-=(const mint &p) { if((x += mod - p.x) >= mod) x -= mod; return *this; }
  mint &operator*=(const mint &p) { x = x * p.x % mod; return *this; }
  mint &operator/=(const mint &p) { *this *= p.inverse(); return *this; }
  mint operator-() const { return mint(-x); }
  mint operator+(const mint &p) const { return mint(*this) += p; }
  mint operator-(const mint &p) const { return mint(*this) -= p; }
  mint operator*(const mint &p) const { return mint(*this) *= p; }
  mint operator/(const mint &p) const { return mint(*this) /= p; }
  bool operator==(const mint &p) const { return x == p.x; }
  bool operator!=(const mint &p) const { return x != p.x; }
  mint inverse() const {
    ll a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return mint(u);
  }
  mint pow(ll n) const {
    mint ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
  friend ostream &operator<<(ostream &os, const mint &p) { return os << p.x; }
  friend istream &operator>>(istream &is, mint &a) {
    ll t;
    is >> t;
    a = mint(t);
    return (is);
  }
};
mint dp[2001][2001];

int main() {
  int N, M;
  cin >> N >> M;
  int S[N], T[M];
  rep(i,N)
    cin >> S[i];
  rep(i,M)
    cin >> T[i];
  dp[0][0] = 1;
  rep1(i,N) {
    dp[i][0] = 1;
  }
  rep1(j,M) {
    dp[0][j] = 1;
  }
  rep1(i,N) {
    rep1(j,M) {
      if (S[i-1] != T[j-1]) {
        dp[i][j] += dp[i-1][j];
        dp[i][j] += dp[i][j-1];
        dp[i][j] -= dp[i-1][j-1];
      } else {
        dp[i][j] += dp[i-1][j];
        dp[i][j] += dp[i][j-1];
      }
    }
  }
  print(dp[N][M]);
  return 0;
}

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

int rooms[4][3][10];

int main()
{
    int n, b, f, r, v;
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> b >> f >> r >> v;
        rooms[b - 1][f - 1][r - 1] += v;
    }

    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++) {
                cout << " " << rooms[i][j][k];
            }
            cout << '\n';
        }
        if (i < 3) cout << "####################\n";
    }

    return 0;
}

Measured memory_bytes: 3036
N = int(input())
A = []
for _ in range(N):
  i = input()
  A.append(int(i))

def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

print(lcm(A)) 

Measured memory_bytes: 5296
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

int main () {
    ios::sync_with_stdio(0), cin.tie(0);
    ll n;
    cin >> n;
    set<string> s;
    while (n --) {
    	string t;
    	cin >> t;
    	s.insert(t);
	}
	cout << s.size();
    return (0);
}

Measured memory_bytes: 19284
#include <cstdio>
#include <iostream>
#include <stack>
#include <vector>
#include <algorithm>
#define INT long long
#define PP pair<double, pair<INT, pair<INT, INT> > >
using namespace std;

string s;
int main()
{
    cin>>s;
    if( s[0] == '9' or s[1] == '9' ) cout<<"Yes\n";
    else cout<<"No\n";
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
v = list(map(int,input().split()))
a = v[0::2]
b = v[1::2]
ca = Counter(a).most_common()
cb = Counter(b).most_common()
if len(ca) == len(cb) == 1:
    if ca[0][0] == cb[0][0]:
        print(n//2)
    else:
        print(0)
elif len(ca) == 1:
    if ca[0][0] == cb[0][0]:
        print(n//2 - cb[1][1])
    else:
        print(n // 2 - cb[0][1])
elif len(cb) == 1:
    if ca[0][0] == cb[0][0]:
        print(n//2 - ca[1][1])
    else:
        print(n // 2 - ca[0][1])
else:
    if ca[0][0] == cb[0][0]:
        print(n - max(ca[1][1]+cb[0][1], cb[1][1] + ca[0][1]))
    else:
        print(n - ca[0][1] - cb[0][1])


Measured memory_bytes: 21084
#include <iostream>

using namespace std;

int main(void){
    int days, A, B, maxA, maxB;
	cin >> days;
	cin >> A;
	cin >> B;
	cin >> maxA;
	cin >> maxB;

	int dayA = (A % maxA == 0) ? (A / maxA) : (A / maxA + 1);
	int dayB = (B % maxB == 0) ? (B / maxB) : (B / maxB + 1);
	int dayHw = days - ((dayA >= dayB) ? dayA : dayB);

	cout << dayHw << endl;
}

Measured memory_bytes: 1160
arr = gets.chomp.split('')
prev = arr[0]
index = 0
list = []
(1..arr.count).each do |i|
  if i < arr.count
    if prev + arr[i] == '><'
      list << arr.slice(index...i)
      index = i
    end
    prev = arr[i]
  else
    list << arr.slice(index...i)
  end
end
sum = 0
list.each do |i|
  l = i.count('<')
  r = i.count - l
  sum += (l + 1) * l / 2
  sum += (r + 1) * r / 2
  sum -= [l, r].min
end
puts sum

Measured memory_bytes: 48388
n, *H = map(int, open(0).read().split())

inc = True
peaks = []
for h0, h1 in zip(H, H[1:]):
    if inc:
        if h0 > h1:
            peaks.append(h0)
            inc = False
    else:
        if h0 < h1:
            peaks.append(-h0)
            inc = True
if inc:
    peaks.append(H[-1])
print(sum(peaks))


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

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

	string s; cin >> s;

	FOR_LT(i, 0, s.size()) {
		if (i & 1) {
			if (s[i] == 'R') {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			if (s[i] == 'L') {
				cout << "No" << endl;
				return 0;
			}
		}
	}

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

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, k;
	cin >> n >> k;
	vi p(n);
	rep(i, n) cin >> p[i];
	sort(all(p));
	int tot = 0;
	rep(i, k) tot += p[i];
	cout << tot << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3644