akhauriyash/Code-Regression huggingface dataset:
/// Thank you tanakh!!!
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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")
    };
}

use std::collections::BTreeMap;

fn main() {
    input!(n: usize, s: chars);
    assert_eq!(s.len(), n * 2);

    let mut prefix_map: BTreeMap<(String, String), usize> = BTreeMap::new();
    let mut suffix_map: BTreeMap<(String, String), usize> = BTreeMap::new();
    for mask in 0..(1 << n) {
        let mut a = String::new();
        let mut b = String::new();
        for i in 0..n {
            if mask & (1 << i) != 0 {
                a.push(s[i]);
            } else {
                b.push(s[i]);
            }
        }
        *prefix_map.entry((a, b)).or_insert(0) += 1;

        let mut a = String::new();
        let mut b = String::new();
        for i in (0..n).rev() {
            if mask & (1 << i) != 0 {
                a.push(s[i + n]);
            } else {
                b.push(s[i + n]);
            }
        }
        *suffix_map.entry((a, b)).or_insert(0) += 1;
    }

    let mut ans = 0;
    for (key, &count) in prefix_map.iter() {
        if let Some(&a) = suffix_map.get(key) {
            ans += count * a;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 69884
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int size = 100001;
            int len = sc.nextInt();
            int[] num;
            num = new int[len];
            int i;
        try{
            for(i = 0;i < len ;i++)num[i] = sc.nextInt();
            int buf = 0;
            int count = 0;
            for(i = 0;i < len ;i++){
                if(num[i] == i+1){
                    count++;
                    if(i == len-1){
                        num[i] = buf;
                        num[i] = num[i-1];
                        num[i-1] =buf;
                    }else{
                        num[i] = buf;
                        num[i] = num[i+1];
                        num[i+1] = buf;
                    }
                }
            }
            System.out.print(count);
        }
        catch(Exception e){
            System.out.print("error");
        }
	}
}

Measured memory_bytes: 50816
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <climits>
#include <ctime>
#include <random>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
//#define ll long long
#define eps 1e-9
#define inf 0x3f3f3f3f
#define mod 1000000007
using namespace std;

int main() {
    speed;
    int n, m, a, ac = 0, wa = 0;
    cin >> n >> m;
    string s;
    vector<int>v(n + 1, 0);
    vector<int>st(n + 1, 0);
    for (int i = 0; i < m; ++i) {
        cin >> a >> s;
        if (s == "AC") {
            if (st[a] != 1)
                ac++, st[a] = 1;
        }
        else {
            if (st[a] != 1)
                v[a]++;
        }
    }
    for (int i = 1; i <= n; ++i)
        if (st[i])
            wa += v[i];
    cout << ac << ' ' << wa;
}

Measured memory_bytes: 1024
#include <stdio.h>
main(){
  int i,n,m,l,r,tl[10000],tr[10000],total[20001],ans;
  while(1){
    scanf("%d%d",&n,&m);
    if(n == 0 && m == 0) break;
    
    for(i=0;i<n;i++){
      scanf("%d",&tl[i]);
    }
    for(i=0;i<m;i++){
      scanf("%d",&tr[i]);
    }
    
    l = 0;
    r = 0;
    i = 1;
    total[0] = 0;
    while(r < m || l < n){
      if(r >= m || (l < n && tl[l] < tr[r])) total[i++] = tl[l++];
      else total[i++] = tr[r++];
    }
    
    ans = 0;
    for(i=1;i<=l+r;i++){
      if(total[i]-total[i-1] > ans) ans = total[i]-total[i-1];
    }

    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 0
while True:
    a=input()
    if a==0:break
    L=[a]+[input() for i in range(4)]
    S=set(L)
    if len(S)<>2:
        print "\n".join(["3"]*5)
    else:
        if set([1,2])==S:
            for i in range(5):
                print 1 if L[i]==1 else 2
        elif set([1,3])==S:
            for i in range(5):
                print 1 if L[i]==3 else 2
        else:
            for i in range(5):
                print 1 if L[i]==2 else 2

Measured memory_bytes: 4252
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  ll a[n];
  rep(i,n) R a[i];
  ll d[n+1];
  mem(d);
  rep(i,n) d[i+1]=d[i]+a[i];
  ll ans=0;
  map<ll,ll> ma;
  rep(i,n+1) {
    ans+=ma[d[i]%m];
    ma[d[i]%m]++;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

int ch(int bx,int sx,int by,int sy,int n,int k,vector<int> x,vector<int> y){
	int sum=0;
	for(int i=0;i<n;i++){
		if(x[i]>=sx&&
			x[i]<=bx&&
			y[i]>=sy&&
			y[i]<=by)
		{
			sum++;
		}
	}
	if(sum>=k){
		//cout<<sum<<" "<<k<<endl;
		return 1;
	}else{
		return 0;
	}
}

int main(){
	int n,kk;
	cin>>n>>kk;
	vector<int> x(n);
	vector<int> y(n);
	
	for(int i=0;i<n;i++)cin>>x[i]>>y[i];
	
	long long int bx,by,sx,sy;
	
	long long int ans=1e18*9;
	//cout<<ans<<endl;
	
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			for(int k=0;k<n;k++){
				for(int l=0;l<n;l++){
					bx=max(x[i],x[j]);
					sx=min(x[i],x[j]);
					by=max(y[k],y[l]);
					sy=min(y[k],y[l]);
					
					if(ch(bx,sx,by,sy,n,kk,x,y)==1){
						long long int tmp=(bx-sx)*(by-sy);
						//cout<<tmp<<endl;
						ans=min(ans,tmp);
					}
				}
			}
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
a,b = map(int,input().split())

count = 0
for i in range(1,10001):
  if i *0.08//1 == a:
    if i *0.1//1 == b:
      print(i)
      if i *0.1//1 == b:
        break
    else:
        count = count +1
  else:
    count = count + 1

if count == 10000:
  print(-1)

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

int main()
{
  int a, b, c;
  int res=3;
  cin >> a >> b >> c;

  if(a == b) res--;
  if(a == c) res--;
  if(b == c) res--;

  if(res == 0) cout << res+1 << endl;
  else cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
*> AtCoder My Practice
       *> author: Leonardone @ NEETSDKASU
       *>
       IDENTIFICATION DIVISION.
       PROGRAM-ID. Answer.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
              FUNCTION ALL INTRINSIC.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
              01 Input-Values.
                     05 a      BINARY-SHORT.
                     05 b      BINARY-SHORT.
                     05 c      BINARY-SHORT.
                     05 x      BINARY-SHORT.
              01 Calc-Values.
                     05 i      BINARY-SHORT.
                     05 j      BINARY-SHORT.
                     05 k      BINARY-SHORT.
                     05 tmp1   BINARY-SHORT.
                     05 tmp2   BINARY-SHORT.
                     05 ans    BINARY-SHORT.
                     05 disp   PIC Z(10)9.
       PROCEDURE DIVISION.
       AnswerMain SECTION.
       000-Start.
       
              ACCEPT a.
              ACCEPT b.
              ACCEPT c.
              ACCEPT x.
              
              PERFORM WITH TEST AFTER VARYING i
              FROM 0 BY 1 UNTIL i >= a
      
              PERFORM WITH TEST AFTER VARYING j
              FROM 0 BY 1 UNTIL j >= b

              PERFORM WITH TEST AFTER VARYING k
              FROM 0 BY 1 UNTIL k >= c
              
              MOVE i TO tmp1
              MULTIPLY 500 BY tmp1
              MOVE j TO tmp2
              MULTIPLY 100 BY tmp2
              ADD tmp2 TO tmp1
              MOVE k TO tmp2
              MULTIPLY 50 BY tmp2
              ADD tmp2 TO tmp1
              IF tmp1 = x THEN
                     ADD 1 TO ans
              END-IF
              END-PERFORM
              END-PERFORM
              END-PERFORM.
               
              MOVE ans TO disp.
              DISPLAY TRIM(disp).
       END PROGRAM Answer.


Measured memory_bytes: 384
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// std::ios::sync_with_stdio(false);

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

/* K is fixed, so .. */

const int maxv = 1e5+5;
struct Edge { int v; LL c; };
vector<Edge> G[maxv];
int N,Q,K;
LL dist[maxv];

void dfs(const int u, const int p)
{
    const int n = G[u].size();
    FOR(i,0,n) {
        const int v = G[u][i].v;
        const int c = G[u][i].c;
        if (v != p) {
            dist[v] = dist[u] + c;
            dfs(v,u);
        }
    }
}

int main()
{
    while (cin >> N) {
        FOR(i,0,N+1)
            G[i].clear();
        FOR(_,0,N-1) {
            int u,v,c; cin >> u >> v >> c;
            Edge e1; e1.v = v; e1.c = c;
            Edge e2; e2.v = u; e2.c = c;
            G[u].push_back(e1);
            G[v].push_back(e2);
        }
        cin >> Q >> K;
        dist[K] = 0;
        dfs(K,-1);
        FOR(_,0,Q) {
            int x,y; cin >> x >> y;
            const LL ans = dist[x] + dist[y];
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

typedef long long ll;

int main(){
    ll n;
    int sum = 0;
    int w_num = 0, r_num = 0,r_fnum = 0, w_fnum = 0;
    bool r_flag = false;
    bool w_flag = false;
    vector<char> c;
    cin >> n;
    ll itr_f = 0, itr_e = n-1;
    c.resize(n);
    for(ll i = 0; i < n; i++){
        cin >> c[i];
        if(c[i] == 'R')r_num++;
        if(c[i] == 'W')w_num++;
    }
    for(ll i = 0; i < r_num; i++){
        if(c[i] == 'R')r_fnum++;
        if(c[i] == 'W')w_fnum++;
    }
    cout << w_fnum << endl;



    return 0;
}

Measured memory_bytes: 3564
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b;
    int tmp=0,i;
    
    scanf("%d",&a);
    scanf("%d",&b);
    
    for(i=0;i<2;i++){
    if(a>b)
    {tmp=tmp+a;
    a--;
    }
    else
    {tmp=tmp+b;
    b--;
    }
    
    }
    
    printf("%d",tmp);
    
    return 0;
}


Measured memory_bytes: 128
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

long P = 998244353L;
long[10^^5*3+50] F, RF;

long pow(long x, long n) {
    long y = 1;
    while (n) {
        if (n%2 == 1) y = (y * x) % P;
        x = x^^2 % P;
        n /= 2;
    }
    return y;
}

long inv(long x)
{
    return pow(x, P-2);
}

void init()
{
    F[0] = F[1] = 1;
    foreach (i, ref x; F[2..$]) x = (F[i+1] * (i+2)) % P;

    {
        RF[$-1] = 1;
        auto x = F[$-1];
        auto k = P-2;
        while (k) {
            if (k%2 == 1) RF[$-1] = (RF[$-1] * x) % P;
            x = x^^2 % P;
            k /= 2;
        }
    }
    foreach_reverse(i, ref x; RF[0..$-1]) x = (RF[i+1] * (i+1)) % P;
}

long comb(N)(N n, N k)
{
    if (k > n) return 0;
    auto n_b = F[n];    // n!
    auto nk_b = RF[n-k]; // 1 / (n-k)!
    auto k_b = RF[k];    // 1 / k!

    auto nk_b_k_b = (nk_b * k_b) % P; // 1 / (n-k)!k!

    return (n_b * nk_b_k_b) % P;  // n! / (n-k)!k!
}

void main()
{
    init();
    auto nabk = readln.split.to!(long[]);
    auto N = nabk[0];
    auto A = nabk[1];
    auto B = nabk[2];
    auto K = nabk[3];

    long r;
    foreach (a; 0..N+1) {
        auto k = a * A;
        if (k > K) continue;
        auto b = (K-k)/B;
        if (b > N) continue;
        k += b * B;
        if (k != K) continue;
        (r += comb(N, a) * comb(N, b) % P) %= P;
    }
    writeln(r);
}

Measured memory_bytes: 7400
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] array = new int[N];
		for (int i = 0; i < N; i++) {
			array[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(array);
		System.out.println(array[N / 2] - array[N / 2 - 1]);
		sc.close();
	}
}


Measured memory_bytes: 47552
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;
const int MOD = 998244353;

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v) {
    for (auto &e : t) fill(e, v);
}
// auto v = make_vec<int>(h, w);
// fill(v, 0);

signed main(){

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

  auto dp = make_vec<int>(n+1, 3001);
  dp[0][0] = 1;
  int ans = 0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j <= s; j++){
      if(j + a[i] <= s){
        dp[i+1][j + a[i]] += dp[i][j];
        dp[i+1][j + a[i]] % MOD;
      }
      dp[i+1][j] += dp[i][j] * 2;
      dp[i+1][j] %= MOD;
    }
  }
  cout << dp[n][s] << endl;

  return 0;
}

Measured memory_bytes: 73716
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
static const int MAX = 10000;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int>> adj[MAX]; // 重み付き有向グラフの隣接リスト表現

void dijkstra(){
    priority_queue<pair<int, int>> PQ;
    int color[MAX];
    int d[MAX];
    for(int i=0; i<n; i++){
        color[i] = WHITE;
        d[i] = INFTY;
    }

    d[0] = 0;
    PQ.push(make_pair(0, 0));
    color[0] = GRAY;

    while(!PQ.empty()){
        pair<int, int> f = PQ.top(); PQ.pop();
        int u = f.second;
        color[u] = BLACK;

        // 最小値を取り出し、それが最短でなければ無視
        if(d[u] < f.first * (-1)) continue;

        for(int j=0; j<adj[u].size(); j++){
            int v = adj[u][j].first;
            if(color[v] == BLACK) continue;
            if(d[v] > d[u] + adj[u][j].second){
                d[v] = d[u] + adj[u][j].second;

                // priority_queueはデフォルトで大きい値を優先するため-1を掛ける
                PQ.push(make_pair(d[v]*(-1), v));
                color[v] = GRAY;
            }
        }
    }

    for(int i=0; i<n; i++){
        cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
    }
}


int main(){
    int k, u, v, c;

    cin >> n;
    for(int i=0; i<n; i++){
        cin >> u >> k;
        for(int j=0; j<k;j++){
            cin >> v >> c;
            adj[u].push_back(make_pair(v,c));
        }
    }

    dijkstra();

    return 0;
}


Measured memory_bytes: 8092
N = gets.to_i
K = gets.to_i
keta = N.to_s.length
first = N.to_s[0].to_i
result = 0

nums_list = (1..9).to_a.repeated_permutation(K-1).to_a
(0..(keta-1)).to_a.combination(K) do |arr|
  if arr[-1] < keta-1
    result += 9**K
    next
  end
  result += (first - 1) * (9**(K-1))
  base = first * (10**arr[-1])
  nums_list.each do |nums|
    x = base
    nums.each_with_index do |nn, index|
      x += nn * (10**arr[index])
    end
    if x <= N 
      result += 1
    end
  end
end
puts result

Measured memory_bytes: 3964
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
const int maxn = 0x7F7F7F7F;
int n, m, l;
struct Point{
    int p, t;
    Point(){}
    Point(int p, int t){
        this->p = p;
        this->t = t;
    }
    void assign(int p, int t){
        this->p = p;
        this->t = t;
    }
}tasks[1001];
int dis[101][101];
vector<int> G[2002];
int match[2002];
bool used[2002];


bool compare(const Point &a, const Point &b){
    if(a.t<b.t && dis[a.p][b.p]<=b.t-a.t)
        return true;
    else
        return false; 
}


void floyd(){
    for(int k=0; k<n; k++){
        for(int i=0; i<n; i++){
            if(i!=k){
                for(int j=0; j<n; j++){
                    if(k!=j && i!=j){
                        if(dis[i][k]<maxn && dis[k][j]<maxn){
                            dis[i][j] = min(dis[i][j], dis[i][k]+dis[k][j]);
                        }
                    }
                }
            }
        }
    }
    return;
}


bool dfs(int u){
    used[u] = true;
    int v, w;
    for(int i=0; i<G[u].size(); i++){
        v = G[u][i];
        if(match[v]==-1 || !used[match[v]]&&dfs(match[v])){
            match[u] = v;
            match[v] = u;
            return true;
        }        
    }
    return false;
}


int Hungary(){
    memset(match, 255, sizeof(match));
    for(int u=0; u<2*l; u++){
        if(match[u]==-1){
            memset(used, 0, sizeof(used));
            dfs(u);
        }
    }
    int ans = l;
    /*
    for(int i=0; i<l; i++)
        printf("%d ", match[i]);
    printf("\n");
    */
    for(int i=0; i<l; i++)
        ans -= match[i]!=-1;
    return ans;
}


int main(){
    //freopen("in.txt", "r", stdin);
    int u, v, w, p, t;
    while(scanf("%d %d %d", &n, &m, &l), n!=0){
        memset(dis, 127, sizeof(dis));
        for(int i=0; i<n; i++)
            dis[i][i] = 0;
        for(int i=0; i<m; i++){
            scanf("%d %d %d", &u, &v, &w);
            dis[u][v] = w;
            dis[v][u] = w;
        }
        floyd();
        /*
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                printf("%d ", dis[i][j]);
            }
            printf("\n");
        }
        */ 
        for(int i=0; i<l; i++){
            G[i].clear(); G[i+l].clear();
            scanf("%d %d", &p, &t);
            tasks[i].assign(p, t);
        }

        for(int i=0; i<l; i++)
        for(int j=0; j<l; j++){
            if(i!=j){
                if(compare(tasks[i], tasks[j])){
                    G[i].push_back(j+l);
                    G[j+l].push_back(i);
                }
                else if(compare(tasks[j], tasks[i])){
                    G[j].push_back(i+l);
                    G[i+l].push_back(j);
                }
            }
        }
        printf("%d\n", Hungary());
    }
    return 0;
}


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

using namespace std;

int findMax(int day, int prevActivity, vector<int> &a, vector<int> &b, vector<int> &c, vector< vector<int> > &x)
{
	if(day == -1)
		return 0;
	if(x[day][prevActivity] != -1)
		return x[day][prevActivity];
	int t = INT_MIN;
	if(prevActivity != 0)
		t = max(t, a[day] + findMax(day-1,0,a,b,c,x));
	if(prevActivity != 1)
		t = max(t, b[day] + findMax(day-1,1,a,b,c,x));
	if(prevActivity != 2)
		t = max(t, c[day] + findMax(day-1,2,a,b,c,x));
	x[day][prevActivity] = t;
	return t;
}

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

	int i,n,k;
	cin>>n;
	vector<int> a(n), b(n), c(n);
	vector< vector<int> > x( n, vector<int> (3, -1));
	for(i=0;i<n;i++)
		cin>>a[i]>>b[i]>>c[i];
	int t = max(a[n-1]+findMax(n-2,0,a,b,c,x), b[n-1] + findMax(n-2,1,a,b,c,x));
	t = max(t, c[n-1]+findMax(n-2,2,a,b,c,x));
	cout<<t<<endl;
	return 0;
}


Measured memory_bytes: 16256
def main():
    a, b, c, d = map(int, input().split())
    turn = 0
    while (a > 0) and (c > 0):
        if turn % 2 == 0:
            c -= b
        else:
            a -= d
        turn += 1
    if a > 0:
        print('Yes')
    else:
        print('No')
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 61980
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
constexpr lint MOD = 1000000007;

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

lint power(lint x, lint n, lint MOD)
{
    lint ans = 1;
    while (n>0)
    {
        if (n & 1) (ans *= x) %= MOD;
        (x *= x) %= MOD;
        n >>= 1;
    }
    return ans;
}

vector<lint> factorial;
vector<lint> facInv;
void factorialPre(int nmax)
{
    factorial = facInv = vector<lint>(nmax + 1, 1);
    for (int i = 1; i <= nmax; i++)
    {
        factorial[i] = factorial[i-1] * i % MOD;
    }
    facInv[nmax] = power(factorial[nmax], MOD-2, MOD);
    for (int i = nmax - 1; i > 0; i--)
    {
        facInv[i] = facInv[i + 1] * (i + 1) % MOD;
    }
}

lint nCr(int n, int r)
{
    if (n<r || r<0) return 0;
    return (factorial[n] * facInv[r] % MOD) * facInv[n-r] % MOD;
}

lint nPr(int n, int r)
{
    if (n<r || r<0) return 0;
    return factorial[n] * facInv[n-r] % MOD;
}

int N, M;
vector<int> A;

int main()
{
    cin >> N >> M;
    A.resize(M+1, 1);
    REP(i, M) cin >> A[i+1];
    factorialPre(1 << N);

    vector<lint> dp(1 << N);
    dp[0] = 1;
    
    REP(m, M) {

        // 初手ゼータ変換
        REP(i, N) REP(b, 1<<N) if (b & (1 << i)) (dp[b] += dp[b ^ (1 << i)]) %= MOD;
        // 場合の数をかける
        REP(b, 1<<N) dp[b] = (b + 1 >= A[m + 1] - 1) ? (dp[b] * nPr(b + 1 - A[m], A[m+1] - A[m]-1)) % MOD : 0;
        // メビウス変換で戻す
        REP(i, N) REP(b, 1<<N) if (b & (1 << i)) (dp[b] += MOD - dp[b ^ (1 << i)]) %= MOD;
        // A[m+1] を入れる
        REP(b, 1<<N) dp[b] = (b+1 >= A[m+1]) ? (dp[b] * (b+2-A[m+1]) % MOD) : 0;
    }
    lint ans = 0;
    for (auto v : dp) (ans += v) %= MOD;
    cout << (ans * factorial[(1 << N) - A.back()] % MOD) * (1 << N) % MOD << endl;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        int number = 0;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (number > h[i])
                ans += number - h[i];
            number = h[i];
        }
        ans += number;
        System.out.println(ans);
    }
}


Measured memory_bytes: 21972
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,counter=0;
    cin>>a>>b>>c;
    for(a;a<=b;a++)
    {
        if(c%a==0)
            counter++;
        else
            continue;
    }
    cout<<counter<<endl;
 return 0;
}



Measured memory_bytes: 3108
#include <algorithm>
#include <iostream>
#include <unordered_map>
#include <set>
#include <vector>
#include <utility>

using namespace std;

int main() {
  int H, W, M;
  cin >> H >> W >> M;

  unordered_map<int, int> cnt_h;
  unordered_map<int, int> cnt_w;
  unordered_map<int, set<int>> idx_h;
  unordered_map<int, set<int>> idx_w;
  
  vector<pair<int, int>> bombs(M);
  int mx_h = 0;
  int mx_w = 0;
  for (int m = 0; m < M; ++m) {
    int h, w;
    cin >> h >> w;
    --h, --w;
    bombs[m] = {h, w};
    ++cnt_h[h];
    ++cnt_w[w];
    if (mx_h <= cnt_h[h]) {
      mx_h = cnt_h[h];
      idx_h[mx_h].insert(h);
    }
    if (mx_w <= cnt_w[w]) {
      mx_w = cnt_w[w];
      idx_w[mx_w].insert(w);
    }
  }
  int possible_size = idx_h[mx_h].size() * idx_w[mx_w].size();
  if (possible_size > bombs.size()) {
	cout << mx_h + mx_w << endl;
  } else {
    int hit = 0;
    for (const pair<int, int>& bomb : bombs) {
      if (idx_h[mx_h].count(bomb.first) != 0
          && idx_w[mx_w].count(bomb.second) != 0)
        ++hit;
    }
    if (possible_size == hit) {
      cout << mx_h + mx_w - 1 << endl;
    } else {
      cout << mx_h + mx_w << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 74532
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int len = Integer.parseInt(sc.nextLine());
		int[] line = Stream.of(sc.nextLine().split(" ", 0)).mapToInt(Integer::parseInt).toArray();
		long sum = 0;
		long[] numsMap = new long[100000];
		for (int i : line) {
			numsMap[i - 1]++;
			sum += i;
		}
		int round = sc.nextInt();

		int[] replace_line = new int[2];

		for (int i = 0; i < round; i++) {
			replace_line[0] = sc.nextInt();
			replace_line[1] = sc.nextInt();
			if (numsMap[replace_line[0] - 1] > 0) {
				sum = sum - replace_line[0] * numsMap[replace_line[0] - 1] + replace_line[1] * numsMap[replace_line[0] - 1];
				System.out.println(sum);
				long let = numsMap[replace_line[0] - 1];
				if (numsMap[replace_line[1] - 1] > 0) {
					let += numsMap[replace_line[1] - 1];
				}
				numsMap[replace_line[1] - 1] = let;
				numsMap[replace_line[0] - 1] = 0;
			}else {
				System.out.println(sum);
			}

		}

	}

}

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

int main() {
  int n, k, ans;
  cin >> n >> k;
  vector<int> l(n);
  rep (i, n) cin >> l[i];
  sort(l.begin(), l.end(), greater<int>());
  rep (i, k) ans += l[i];

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


Measured memory_bytes: 256
N = int(input())
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
ans = 0
for i in range(N+1):
    if i == N:
        val = sum(A1+[A2[-1]])
    else:
        val = sum(A1[:i+1] + A2[i:])
    if val > ans:
        ans = val
print(ans)

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

int main(){
    int N, ans;
    cin >> N;
    ans = N%10;
    if(ans == 3){
        cout << "bon" << endl;
    } else if(ans == 0 || ans == 1 || ans == 6 || ans == 8){
        cout << "pon" << endl;
    } else{
        cout << "hon" << endl;
    }
}

Measured memory_bytes: 3672
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
using namespace std;

int main()
{
	int n, k, sum=0;
	cin >> n >> k;
	vector<int>x(n);
	for (int& p : x)cin >> p;
	for (int i = 0; i < n; i++) {
		sum += 2*min(abs(0 - x[i]), abs(k - x[i]));
	}
	cout << sum << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
int read(){
	int f=1,x=0; char c=getchar();
	while (c>'9' || c<'0') {if (c=='-') f=-1; c=getchar();}
	while (c>='0'&&c<='9') {x=x*10+c-'0'; c=getchar();}
	return f*x;
}
int a,b,c,d,ans;
int main(){
	cin>>a>>b>>c>>d;
	if(a<b)ans=a;
	else ans=b;
	if(c<d)ans+=c;
	else ans+=d;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 0x7fffffff
#define RG register
#define inf 0x7fffffff
#define mkp make_pair
#define maxn 100205
typedef unsigned int U;
using namespace std;
typedef long long ll;
const ll mod = 998244353;
const  double eps = 1e-8;
const double pi = acos(-1);
inline ll read(){
    ll x = 0, f = 1;
    char ch = getchar();
    while(ch > '9' || ch < '0') {if(ch == '-') f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x *10 + ch -'0';ch = getchar();}
    return x * f;
}
int n,m,d1,d2;
int ok[400005],num[605][605];
void pre(){
	for(int i=1;i*i<=200000;i++)
		ok[i*i]=i;
}
int col[2][4000005];
vector<pair<int,int> > Q[2];
bool in(int x,int y){
	if(x<0) return 0;
	if(x>=2*n) return 0;
	if(y<0) return 0;
	if(y>=2*n) return 0;
	return 1;
}
void dfs(pair<int,int> x,int u,int opt){
	int i,v;
	int X=x.first,Y=x.second;
	for(i=0;i<Q[opt].size();i++){
		int xx=X+Q[opt][i].first,yy=Y+Q[opt][i].second;
		if(!in(xx,yy)) continue;
		v=num[xx][yy];
		if(col[opt][v]) continue;
		col[opt][v]=col[opt][u]%2+1;
		dfs({xx,yy},v,opt);
	}
}
int sum(int x,int y){
	int i,j,cnt=0;
	for(i=0;i<2*n;i++)
		for(j=0;j<2*n;j++)
			if(col[0][num[i][j]]==x&&col[1][num[i][j]]==y) cnt++;
	return cnt;
}
void print(int x,int y){
	int cnt=0,i,j;
	for(i=0;i<2*n;i++)
		for(j=0;j<2*n;j++){
			if(col[0][num[i][j]]==x&&col[1][num[i][j]]==y) printf("%d %d\n",i,j),cnt++;
			if(cnt>=n*n) return ;
	}
	return ;
}
int main(){
	int i,j,u,v,e,w;
	//freopen("a.out","r",stdin);
	//freopen("a.ans","w",stdout);
	n=read(),d1=read(),d2=read();
	int cnt=0;
	for(i=0;i<2*n;i++)
		for(j=0;j<2*n;j++)
			num[i][j]=++cnt;
	pre();
	for(i=0;i*i<=d1;i++){
		if(!ok[d1-i*i]&&(d1-i*i)!=0) continue;
		Q[0].push_back({i,ok[d1-i*i]});
		Q[0].push_back({-i,ok[d1-i*i]});
		Q[0].push_back({i,-ok[d1-i*i]});
		Q[0].push_back({-i,-ok[d1-i*i]});
	}
	for(i=0;i*i<=d2;i++){
		if(!ok[d2-i*i]&&(d2-i*i)!=0) continue;
		Q[1].push_back({i,ok[d2-i*i]});
		Q[1].push_back({-i,ok[d2-i*i]});
		Q[1].push_back({i,-ok[d2-i*i]});
		Q[1].push_back({-i,-ok[d2-i*i]});
	}
	for(i=0;i<2*n;i++){
		for(j=0;j<2*n;j++){
			if(!col[0][num[i][j]]) col[0][num[i][j]]=1,dfs({i,j},num[i][j],0);
			if(!col[1][num[i][j]]) col[1][num[i][j]]=1,dfs({i,j},num[i][j],1);
		}
	}
	for(i=1;i<=2;i++)
		for(j=1;j<=2;j++){
			if(sum(i,j)>=n*n) {print(i,j);return 0;}
		}
	return 0;
}
/*
8
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1
*/

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

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

    if (n[0]=='1') n[0] = '9';
    else{
        n[0] = '1';
    }

    if (n[1]=='1') n[1] = '9';
    else{
        n[1] = '1';
    }

    if (n[2]=='1') n[2] = '9';
    else{
        n[2] = '1';
    }

    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>

int u(int a, int b);
long l(int a, int b, int gcd);

int main(){
  int a, b;
  int gcd;
  long lcm;
  
  while(scanf("%d", &a)!=EOF){
    scanf("%d", &b);
    gcd = u(a, b);
    lcm = l(a, b, gcd);
    std::cout << gcd << " " << lcm << std::endl;
  }
  
  return 0;
}

int u(int a, int b){
  while(1){
    if(a==0) return b;
    if(b==0) return a;
    if(a>=b){
      a = a % b;
    }else{
      b = b % a;
    }
  }
  
}

long l(int a, int b, int gcd){
  return (long)a * (long)b / (long)gcd;
}

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

int A[1000000+1], n;

int main() {
    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        scanf( "%d", &A[i] );
    }
    
    int q, k, sum = 0;
    cin >> q;
    for ( int i = 0; i < q; i++ ) {
        scanf( "%d", &k );
        if ( *lower_bound( A, A+n, k ) == k ) {
            sum++;
        }
    }
    
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 3540
n=int(input())
f=[list(map(int,input().split()))for i in range(n)]
p=[list(map(int,input().split()))for i in range(n)]
ans_2=-float("inf")
for i in range(1,1<<10):
    ans=0
    for k in range(n):
        cnt=0
        for j in range(10):
            if i&(1<<j) and f[k][j]==1:
                cnt+=1
        ans+=p[k][cnt]
    ans_2=max(ans,ans_2)
print(ans_2)


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <memory.h>
#include <set>
#include <ctime>
#include <map>
#include <cstring>
#include <iterator>
#include <queue>
#include <assert.h>
#include <bitset>
#include <complex>
#include <unordered_map>

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

using namespace std;

#define pb emplace_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define forab(i, a, b) for (int i = (a); i < (b); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int infi = 1e9 + 7;
const ll infl = (ll)1e8 + (ll)7;

vector<vector<int> > ar;

void upd(int &a, int b) {
    a = min(a, b);
}

int32_t main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    srand(time(NULL));
   // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    //freopen("customs.in", "r", stdin); freopen("customs.out", "w", stdout);
    int n, m;
    cin >> n >> m;
    int k;
    cin >> k;
    swap(n, m);
    ar.resize(n);
    forn(i, k) {
        int q, w;
        cin >> q >> w;
        swap(q, w);
        --q, --w;
        ar[q].pb(w);
    }
    forn(i, n)
        ar[i].pb(m);
    forn(i, n)
        sort(all(ar[i]));
    int ans = ar[0][0];
    int lst = 0;
    for (int i = 1; i < n; ++i) {
        lst++;
        if (lst >= m)
            break;
        int j = lower_bound(all(ar[i]), lst) - ar[i].begin();
        for (; j < ar[i].size() && ar[i][j] == lst; ++j) {
            ++lst;
        }
        if (lst >= m)
            break;
        upd(ans, ar[i][j]);
    }
    cout << ans << '\n';
    
    return 0;
}

Measured memory_bytes: 11392
c[9];main(n,m,i){for(;scanf("%d%d",&m,&n)*m;puts("")){int q[1024]={i=0},t=1,p=m;for(;n--;){*c=!scanf("%s",c+3);++i%3||strcat(c,"Fizz");i%5||strcat(c,"Buzz");*c||sprintf(c,"%d",i);for(strcmp(c+3,c)&&p>1&&(q[t]=p--);q[t=t%m+1];);}for(t=i=0;m--;q[++i]||(t=printf(" %d"+!t,i)));}}

Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define NFOR(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); --i)
#define rep(i, a) for (ll i = 0; i < a; i++)
#define endl "\n"
#define fi first
#define se second
#define MOD 1000000007
#define inf 1e12
#define pb push_back
#define Case cout<<"Case #"<<++cas<<": ";
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) v.begin(),v.end()

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;

#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}

const int maxn = 305;

double dp[maxn][maxn][maxn];

void solve() {
	ll mod = 1000000007;
	ll n;
	cin >> n;
	vl cnt(4, 0);
	rep(i, n) {
		ll temp;
		cin >> temp;
		cnt[temp]++;
	}

	rep(c, n + 1)
		rep(b, n + 1)
			rep(a, n + 1) {
				if (a + b + c > n) continue;

				ll em = n - (a + b + c);
				dp[a][b][c] = 0;
				if (a)
					dp[a][b][c] = dp[a - 1][b][c] * (1.0 * a) / (1.0 * n);
				if (b)
					dp[a][b][c] += dp[a + 1][b - 1][c] * (1.0 * b) / (1.0 * n);
				if (c)
					dp[a][b][c] += dp[a][b + 1][c - 1] * (1.0 * c) / (1.0 * n);

				if (a + b + c > 0)
					dp[a][b][c] += 1;
				if (em < n)
					dp[a][b][c] /= 1 - (1.0 * em) / (1.0 * n);
			}

	cout << setprecision(10) << fixed << dp[cnt[1]][cnt[2]][cnt[3]] << endl;
}

int main()
{
    fastio;
    ll t  = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 219392
#include <stdio.h>
#include <stdlib.h>

int cmpr_int(const void *a, const void *b)
{
  const int *x = a;
  const int *y = b;
  return *x - *y;
}

int main()
{
  int n, i, a[3];
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d%d%d", &a[0], &a[1], &a[2]);
    qsort(a, 3, sizeof(a[0]), cmpr_int);
    if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2]) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }
  return 0;
}

Measured memory_bytes: 584
import math
n=int(input())
a=list(map(int,input().split()))
a_s=list(set(a))
while len(a_s)!=1:
    gcd=math.gcd(a_s[-1],a_s[-2])
    lcm=int(a_s[-1]*a_s[-2]/gcd)
    a_s=a_s[:-2]
    a_s.append(lcm)
print(a_s[0])


Measured memory_bytes: 5664
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int[][] map = new int[h][w];
        int data[][] = new int[h][w];
        int dataW[][] = new int[h][w];
        // 1は障害物
        for (int i = 0; i < h; i++) {
            String s = sc.next();
            for (int j = 0; j < w; j++) {
                map[i][j] = s.charAt(j) == '#' ? 1 : 0;
            }
        }
        for (int i = 0; i < h; i++) {
            if (map[i][0] == 0) {
                data[i][0] = 1;
            }
            for (int j = 1; j < w; j++) {
                if (map[i][j] == 0) {
                    data[i][j] = data[i][j - 1] + 1;
                }
            }
        }
        for (int i = 0; i < h; i++) {
            for (int j = w - 2; j >= 0; j--) {
                if (data[i][j] != 0) {
                    data[i][j] = Math.max(data[i][j], data[i][j + 1]);
                }
            }
        }
        for (int i = 0; i < w; i++) {
            if (map[0][i] == 0) {
                dataW[0][i] = 1;
            }
            for (int j = 1; j < h; j++) {
                if (map[j][i] == 0) {
                    dataW[j][i] = dataW[j - 1][i] + 1;
                }
            }
        }
        for (int i = 0; i < w; i++) {
            for (int j = h - 2; j >= 0; j--) {
                if (dataW[j][i] != 0) {
                    dataW[j][i] = Math.max(dataW[j][i], dataW[j + 1][i]);
                }
            }
        }

        int ans = 0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                ans = Math.max(ans, data[i][j] + dataW[i][j]);
            }
        }
        System.out.println(ans - 1);

        sc.close();
    }
}


Measured memory_bytes: 115340
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
#define forn(i,p,n) for(int i=(int)p;i<(int)n;++i)

int main() {
    fast;
    char str;
    cin >> str;
    if(str>=95 && str<=122){
    	cout<<"a";
    }
    else{
    	cout<<"A";
    }
        
}	

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main ()
{
    int n;
    cin>>n;
    int A[n];
    int shuma=0;
    for(int i=0;i<n;i++)
    {
        cin>>A[i];
    }
    for(int i=1;i<n-1;i++)
    {
        int j=i-1;
        int k=i+1;
        if((A[i]>A[j] && A[i]<A[k]) ||(A[i]<A[j] && A[i]>A[k]))
        {
            shuma++;
        }
    }
    cout<<shuma<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <iomanip>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#define INF 1000000000

using namespace std;
int main() {

	int n, a[20], x[20][20], y[20][20];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		for (int j = 0; j < a[i]; j++) {
			cin >> x[i][j] >> y[i][j];
		}
	}

	int ans = 0;

	for (int bit = 0; bit < (1 << n); bit++) {


		int syo = 0;
		int data[20];
		for (int i = 0; i < n; i++) {
			if (bit & (1 << i)) {
				syo++;
				data[i] = 1;
			}
			else { data[i] = 0; }
		}

		//for (int i = 0; i < n; i++) { cout << data[i] << endl;}

		//cout << bit << ":" << syo;

		for (int i = 0; i < n; i++) {
			if (data[i] == 1) {
				for (int j = 0; j < a[i]; j++) {
					if (y[i][j] != data[x[i][j] - 1]) {
						goto mujun;
					}
				}
			}
		}

		ans = max(ans, syo);

		//cout << " Yes";

	mujun:;

		//cout << endl;


	}

	cout << ans << endl;

	return 0;
}


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

const int N = 100005;

struct Edge {
	int u, v, w;

	Edge (int u, int v, int w) :
		u(u), v(v), w(w) {} 

	bool operator < (const Edge& rhs) const {
		return w < rhs.w;
	}
};

int n, m, k;
int color[N];
int par[N * 2];
vector<Edge> E;

int find(int u) {
	return (u == par[u]) ? u : par[u] = find(par[u]);
}

bool join(int u, int v) {
	u = find(u), v = find(v), par[u] = v; return (u != v);
}

int main() {
	ios::sync_with_stdio(false);
	cin >> n >> m >> k;
	for (int i = 1; i <= n; ++i) cin >> color[i];
	for (int i = 1; i <= m; ++i) {
		int u, v, w; cin >> u >> v >> w;
		E.push_back(Edge(u, v, w));
	}
	sort(E.begin(), E.end());
	for (int i = 1; i <= n + k; ++i) par[i] = i;
	int cnt = k - 1;
	long long res = 0;
	for (int i = 0; i < m; ++i) {
		int u = E[i].u, v = E[i].v, w = E[i].w;
		if (color[u]) u = color[u] + n;
		if (color[v]) v = color[v] + n;
		if (!join(u, v)) continue;
		res += w, cnt--;
		if (!cnt) break;
	}
	if (cnt) cout << -1;
	else cout << res;
}

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

using namespace std;

void swap(int& a, int& b) {
  int tmp = a;
  a = b;
  b = tmp;
}

int partition(vector<int>& sequence, int first_index, int last_index) {
  int pivot = sequence[last_index];

  int partition_tail = first_index;
  for(int i = first_index; i < last_index; i++) {
    if(sequence[i] <= pivot) {
      swap(sequence[i], sequence[partition_tail]);
      partition_tail++;
    }
  }

  swap(sequence[last_index], sequence[partition_tail]);

  return partition_tail;
}

int main() {
  int sequence_num;
  vector<int> sequence;

  cin >> sequence_num;
  sequence.resize(sequence_num);

  for(int i = 0; i < sequence_num; i++) {
    cin >> sequence[i];
  }

  int pivot_index = partition(sequence, 0, sequence_num - 1);

  for(int i = 0; i < sequence_num; i++) {
    if(i == pivot_index) {
      cout << '[';
    }
    cout << sequence[i];
    if(i == pivot_index) {
      cout << ']';
    }

    if(i != sequence_num - 1) {
      cout << ' ';
    }
  }
  cout << endl;
}



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

int main() {
	ll n, m;
	cin >> n >> m;
	vector<pair<ll, ll>> v;
	for (ll i = 0; i < m; ++i) {
		ll a, b;
		cin >> a >> b;
		--a; --b;
		v.push_back({ a,b });
	}
	sort(v.begin(), v.end());
	ll Min = v[0].second;
	ll ans = 1;
	for (ll i = 1; i < m; ++i) {
		if (Min <= v[i].first) {
			++ans;
			Min = v[i].second;
		}
		else {
			Min = min(Min, v[i].second);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 2420
main(n,m,e,j,t){while(scanf("%d",&n),n)for(;n--;puts(m==100|e==100|j==100|m+e>179|t>239?"A":t>209|t>149&(m>79|e>79)?"B":"C"))scanf("%d%d%d",&m,&e,&j),t=m+e+j;}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#define REP(i, a, b) for (auto i = (a); i < (b); ++i)
using namespace std;

const int inf = 1e9;
const int N = 600;
bool adj[N][N];
int deg[N];
double E[N][2];

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

	int n, m; cin >> n >> m;

	while(m--) {
		int s, t; cin >> s >> t; --s, --t;
		adj[s][t] = 1;
		++deg[s];
	}

	auto solve = [&](bool b) {
		REP(k, 1, n) {
			int i = n - k - 1;
			E[i][b] = 1;
			REP(j, i + 1, n - 1)
				if (adj[i][j])
					E[i][b] += E[j][b] / deg[i];
		}
	};

	solve(0);
	double ans = E[0][0];

	REP(i, 0, n - 1) {
		if (deg[i] == 1) continue;

		int mxpos; double mx = -1;
		REP(j, i + 1, n) {
			if (adj[i][j] && mx < E[j][0]) {
				mxpos = j;
				mx = E[j][0];
			}
		}

		--deg[i]; adj[i][mxpos] = 0;
		solve(1);
		++deg[i]; adj[i][mxpos] = 1;

		ans = min(ans, E[0][1]);
	}

	cout << fixed << setprecision(10) << ans;
}

Measured memory_bytes: 640
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        String T = sc.next();
        char[]ss = S.toCharArray();
        char[]tt = T.toCharArray();       

        for(int i=0; i<N; i++){
                System.out.print(ss[i]);
                System.out.print(tt[i]);
        }
	}
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n;
    int a;

    int ans = 0;

    Scd(n);
    Rep(i,n){
        Scd(a);
        while(a % 2 == 0){
            a /= 2;
            ans++;
        }
    }

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

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>


using namespace std;
using ll = long long;

string str;

int main() {
	cin >> str;
	ll bcount = 0;
	ll ans = 0;
	for (ll i = 0; i < str.length(); i++)
	{
		if (str[i] == 'B') {
			bcount++;
		}
		else {
			ans += bcount;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640