akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
const int Inf = 1e9 + 5;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0); 
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> s(H);
    for (int i = 0; i < H; i++) {
        cin >> s[i];
    }
    int ans = W * H;
    for (int mask = 0; mask < (1 << (H - 1)); mask++) {
        int blockId = 0, cuts = 0;
        vector<int> blockOf(H);
        for (int i = 0; i < H; i++) {
            blockOf[i] = blockId;
            if (mask & (1 << i)) {
                cuts++;
                blockId++;
            }
        }
        vector<int> sum(blockId + 1);
        for (int j = 0; j < W; j++) {
            for (int i = 0; i < H; i++) {
                sum[blockOf[i]] += (s[i][j] - '0');
            }
            if (*max_element(sum.begin(), sum.end()) > K) {
                fill(sum.begin(), sum.end(), 0);
                cuts++;
                for (int i = 0; i < H; i++) {
                    sum[blockOf[i]] += (s[i][j] - '0');
                }
                if (*max_element(sum.begin(), sum.end()) > K) {
                    cuts = W * H;
                }
            }
        }
        ans = min(ans, cuts);

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

Measured memory_bytes: 256
#pragma GCC optimize("Ofast") 

////////////////////////////////////////////////////////////////////////////////

#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define bew ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mod (long)(1e9+7)
#define ip(ar,n) for(int i=0;i<n;++i)cin>>ar[i];
#define op(ar,n) for(int i=0;i<n;++i)cout<<ar[i]<<" ";
#define print(...) for(auto xas:{__VA_ARGS__})cerr<<xas<<" ";
#define test int t;cin>>t;while(t--)
#define tar(x) int x;cin>>x;
#define fil(ar,val) memset(ar,val,sizeof ar)
#define loop(n) for(int i=0;i<n;++i)
#define coutd(x,y) printf("%0.y lf",x);
#define verdict(x,y) if(flag)cout<<x;else cout<<y;


////////////////////////////////////////////////////////////////////////////////

typedef vector<int> vec; 
typedef pair<int, int> pa; 
typedef vector<pa> vecp; 
typedef set<int> se;
typedef map<int,int> ma;

////////////////////////////////////////////////////////////////////////////////

void manupulate(string &str)
{
    for(int i=0;i<str.size();++i)
    str[i]-=48;
}

bool isprime(int n)
{
    if(n<=1)
        return false;
    for(int i=2;i*i<=n;++i)
    if(n%i==0)
        return false;
    return true;
}

int expo(int a,int n)
{
    if(n==0)
        return 1;
    if(n==1)
        return a;
    int tmp=expo(a,n/2);
    tmp=(tmp*tmp)%mod;
    if(n&1)
        tmp=(tmp*a)%mod;
    return tmp;
}


////////////////////////////////////////////////////////////////////////////////



signed main() {
bew;


    tar(a);tar(b);tar(c);tar(d);
    
    bool win=false;
    
    for(int i=0;;++i)
    {
        if(i&1)
        {
            a-=d;
            if(a<=0)
            break;
            
        }
        else
        {
            c-=b;
            if(c<=0)
            {
                win=true;
                break;
                
            }
            
        
        }
        
        
        
    }


    if(win)
    cout<<"Yes";
    else
    cout<<"No";
























return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
int psum[MAXN][30];

int main()
{
    int n,m,k,a,b,x,y;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;

    cin>>n;

    for(int i=1;i<=n;i++)
        cin>>A[i];

    for(int i=1;i<=n;i++){
        for(int j=0;j<20;j++){
            psum[i][j] = psum[i-1][j];
            if((1<<j)&A[i])psum[i][j]++;
        }
    }

    int L,R,mid,ans;
    bool judge = true;

    ll res = 0;

    for(int i=1;i<=n;i++){

        L = i;
        R = n;
        ans = i;

        while(L<=R){
            mid = (L+R)/2;
            judge = true;
            for(int j=0;j<20;j++)
                judge&=(psum[mid][j]-psum[i-1][j]<=1);
            if(judge)ans = mid,L = mid+1;
            else R = mid-1;
        }
        res+=(ll)(ans-i+1);
    }

    cout<<res<<"\n";

    return 0;
}


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

int main() {
  int n, x, t;
  cin >> n >> x >> t;
  cout << (n + x - 1) / x * t << endl;
  return 0;
}

Measured memory_bytes: 3636
x,y,z,k=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]

a.sort()
a.reverse()
b.sort()
b.reverse()
c.sort()
c.reverse()

a2=a[:k]
b2=[]
for i in a2:
  for j in b[:k]:
    b2.append(i+j)
  b2.sort()
  b2.reverse()
  b2=b2[:k]

c2=[]
for i in b2:
  for j in c[:k]:
    c2.append(i+j)
  c2.sort()
  c2.reverse()
  c2=c2[:k]
for i in c2:
  print(i)

Measured memory_bytes: 3700
public class A {
  private static int[] list = new int[] { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
  public static void Main() {
    System.Console.WriteLine(list[int.Parse(System.Console.ReadLine()) - 1].ToString());
  }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;
vector<int> road[200001];
vector<int> train[200001];
int ccroad[200001];
int cctrain[200001];
int vis[200001];
void dfs(int node, int num){
    if (vis[node]){
        return;
    }
    vis[node] = true;
    ccroad[node] = num;
    for (int i : road[node]){
        dfs(i, num);
    }
}
void dfs2(int node, int num){
    if (!vis[node]){
        return;
    }
    vis[node] = false;
    cctrain[node] = num;
    for (int i : train[node]){
        dfs2(i, num);
    }
}
map<int, int> cnts[200001];
int main(){
  prep();
  int n, k, l;
  cin >> n >> k >> l;
  
  for (int i=0; i<k; i++){
      int a, b;
      cin >> a >> b;
      road[a].push_back(b);
      road[b].push_back(a);
  }
  for (int i=0; i<l; i++){
      int a, b;
      cin >> a >> b;
      train[a].push_back(b);
      train[b].push_back(a);
  }
  int cnt = 0;
  for (int i=1; i<=n; i++){
      if (vis[i]){
          continue;
      }
      dfs(i, cnt);
      cnt++;
  }
  cnt = 0;
  for (int i=1; i<=n; i++){
      if (!vis[i]){
          continue;
      }
      dfs2(i, cnt);
      cnt++;
  }
  
  for (int i=1; i<=n; i++){
      cnts[ccroad[i]][cctrain[i]]++;
  }
  for (int i=1; i<=n; i++){
      auto thiss = cnts[ccroad[i]].find(cctrain[i]);
      cout << thiss->second << " ";
  }
  return 0; 
}

Measured memory_bytes: 35456
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(std::vector<T>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}

void DFS(int V,vector<vector<int> >&GRAPH, vector<bool>& visited)
{
  visited[V] = 1;
  for (int i = 0; i < GRAPH[V].size(); i++)
  {
    int V_n = GRAPH[V][i];
    if(visited[V_n] == 0)
    DFS(V_n,GRAPH,visited);
  }
  return;
}
void solve(void)
{
  int N,K;
  cin>>N>>K;
  int A = 1;
  int B = 1;
  int C = 1;
  for (int i = 0; i < N; i++)
  {
    A = C*2;
    B = C+K;
    C = min(A,B);
    // DEBUG(C);
  }

  cout<<C<<endl;
  
  
  
  return;

   
}


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

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		String no = "";
		for( int i = 0; i < k; i++ ) {
			no += in.nextInt();
		}
		String testString = "^[^"+no+"]+$";
		while(!Integer.toString(n).matches(testString)) n++;
		System.out.println(n);
	}
}

Measured memory_bytes: 60020
#include <iostream>
#include <set>
#include <algorithm>
 
using namespace std;
 
int main() {
   #define int long long
    int W, H;
    cin >> W >> H;
    multiset<pair<int, bool>> S;
    for (int i = 0; i < W; i++) {
        int k;
        cin >> k;
        S.insert(make_pair(k, true));
    }
    for (int i = 0; i < H; i++) {
        int k;
        cin >> k;
        S.insert(make_pair(k, false));
    }
   
    long long res = 0;
    W++; H++;
    while (!S.empty()) {
        auto it = S.begin();
        if (it->second) {
            res += max(H, (long long) 0) * it->first;
            W--;
        } else {
            res += max(W, (long long) 0) * it->first;
            H--;
        }
        S.erase(S.begin());
    }
    cout << res << endl;
}

Measured memory_bytes: 12800
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

#define LL long long
#define SP setprecision
#define PI 3.141592653589793
string s;
LL W, H, x, y, a, b, c,n, num[10005];
double r;

int main() {
	cin >> n;
	LL mn = 9999999, mx = -9999999, sum = 0;
	for (int i = 0; i < n; i++) {
		LL a; cin >> a;
		mn = min(mn, a);
		mx = max(mx, a);
		sum += a;
	}
	cout << mn << " " << mx << " " << sum << endl;
	return 0;
}



Measured memory_bytes: 3152
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc = initScanner(os.Stdin)
	n := scanInt(sc)
	solve(n)
}

func solve(n int) {
	var tmp string
	var keys []string
	m := make(map[string]int, n)

	max := 1
	for i:=0;i<n;i++ {
		tmp = scanString(sc)
		if m[tmp] == 0 {
			m[tmp] = 1
			keys = append(keys, tmp)
		} else {
			m[tmp]++
			if max < m[tmp] {
				max = m[tmp]
			}
		}
	}

	var ans []string
	for _, v := range keys {
		if m[v] == max {
			ans = append(ans, v)
		}
	}

	sort.Strings(ans)
	for _, v := range ans {
		fmt.Println(v)
	}
}

/*
arr := [string]{"a", "b", "c", "a"}
uniq := [] string{}

for _, ele := range arr {
    if !m[ele] {
        m[ele] = true
        uniq = append(uniq, ele)
    }
}
*/

// --------------- BASE DEFINITIONS ---------------

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanIntSlice(sc *bufio.Scanner, n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = scanInt(sc)
	}

	return is
}

func scanFloat64(sc *bufio.Scanner) float64 {
	sc.Scan()
	f, _ := strconv.ParseFloat(sc.Text(), 64)
	return f
}

func scanFloat64Slice(sc *bufio.Scanner, n int) []float64 {
	fs := make([]float64, n)
	for i := 0; i < n; i++ {
		fs[i] = scanFloat64(sc)
	}

	return fs
}

func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func scanStringSlice(sc *bufio.Scanner, n int) []string {
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		ss[i] = sc.Text()
	}

	return ss
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 38728
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <cctype>
#include<math.h>
using namespace std;
int main() {
	string a;
	cin >> a;
	if (a[0] == a[1])cout << "Bad" << endl;
	else if (a[2] == a[1])cout << "Bad" << endl;
	else if (a[2] == a[3])cout << "Bad" << endl;
	else cout << "Good" << endl;
}

Measured memory_bytes: 256
//
//  header_useful.h
//  c++_acm
//
//  Created by 李弘辰 on 2019/7/23.
//  Copyright © 2019 李弘辰. All rights reserved.
//

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>

using namespace std;

#define ll long long
#define uchar unsigned char
#define ushort unsigned short
#define uint unsigned int
#define ulong unsigned long
#define ull unsigned long long

#define pi acos(-1)

#define mx(a,b) (a) > (b) ? (a) : (b)
#define mn(a,b) (a) < (b) ? (a) : (b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fre(a) freopen(a,"r",stdin)
#define cio ios::sync_with_stdio(false);

#define itn int
#define nit int
#define inr int
#define mian main
#define ednl endl
#define fro for
#define fir for
#define reutrn return
#define retunr return
#define reutnr return


/* header_useful_h */


int main()
{
    int k,n;
    int a[200010];
    scanf("%d %d",&k,&n);
    for (int i = 0;i < n;i ++) {
        scanf("%d",a + i);
    }
    sort(a,a + n);
    int maax = 0;
    for (int i = 1;i < n;i ++)
    {
        maax = max(a[i] - a[i - 1],maax);
    }
    maax = max(maax,k - a[n - 1] + a[0]);
    printf("%d\n",k - maax);
    return 0;
}


Measured memory_bytes: 1656
use std::io::stdin;
use std::io::BufRead;

fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    for i in 1.. {
        let mut buf = String::new();

        stdin.read_line(&mut buf).unwrap();

        let int = buf.trim().parse::<i32>().unwrap();
        if int == 0 {
            break;
        }
        println!("Case {}: {}", i, int);
    }
}


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

// clang-format off
#define forn(i, x, y) for(int i = x; i < y; i++)
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(NULL)
#define printVector(a) for(auto it = a.begin() ; it != a.end(); it++) { cout << *it << " "; } cout << endl;
// clang-format on

const long long MOD = 1000000007;

using LL = long long;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VVLL = vector<VLL>;

template <typename T>
void add(T &a, T b)
{
  a += b;
  if (a >= MOD)
    a -= MOD;
}

int main()
{
  IOS;

  int N;
  cin >> N;
  string s;
  cin >> s;

  VLL dp0(N, 1);

  forn(i, 0, N - 1)
  {
    VLL dp1(N);
    if (s[i] == '<')
    {
      for (int j = 0; j < N - i - 1; j++)
      {
        dp1[j] = dp0[j];
        if (j > 0)
          add(dp1[j], dp1[j - 1]);
      }
    }
    else
    {
      for (int j = N - i - 2; j >= 0; j--)
      {
        dp1[j] = dp1[j + 1];
        add(dp1[j], dp0[j + 1]);
      }
    }
    dp0 = dp1;
  }

  cout << dp0[0] << endl;

  return 0;
}


Measured memory_bytes: 3692
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] l = new int[n];
        int ans = 0;

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

        Arrays.sort(l);

        for (int i = 0; i < n-2; i++) {
            for (int j = i + 1; j < n-1; j++) {
                for (int k = j + 1; k < n; k++) {
                    if (l[k] >= (l[j]+l[i])) {
                        break;
                    }
                    ans++;
                }
            }
        }

        System.out.println(ans);

        sc.close();
    }    
}


Measured memory_bytes: 25548
n, k = map(int, input().split())
s = input() + '#'

num = [0]
for i in range(1, n + 1):
    if s[i - 1] != s[i]:
        num.append(i)

ans, lennum = num[1], len(num)
for i in range((s[0] == '1') + 1, lennum, 2):
    tmp = num[min(i - 1 + 2 * k, lennum - 1)] - num[max(i - 2, 0)]
    ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 79828
#include <vector>
#include <string>
#include <iostream>

using namespace std;


int countAB(string str) {
    int cnt = 0;
    for (int i=0; i<str.length()-1; i++) {
        if (str[i] == 'A' and str[i+1] == 'B') {
            cnt += 1;
        }
    }
    return cnt;
}


int main() {
    int N;
    cin >> N;
    string s[N];
    vector<string> BstrA {}, BstrX {}, XstrA {}, XstrX {};
    for (int i=0; i<N; i++) {
        cin >> s[i];
        if (s[i].front() == 'B' and s[i].back() == 'A') {
            //cout << "DEBUG BstrA push" << endl;
            BstrA.push_back(s[i]);
        } else if (s[i].front() == 'B') {
            //cout << "DEBUG BstrX push" << endl;
            BstrX.push_back(s[i]);
        } else if (s[i].back() == 'A') {
            //cout << "DEBUG XstrA push" << endl;
            XstrA.push_back(s[i]);
        } else {
            //cout << "DEBUG XstrX push" << endl;
            XstrX.push_back(s[i]);
        }
    }

      //cout << "DEBUG" << endl;
    // top string
    string cur_str {};
    if (XstrA.size() > 0) {
        cur_str = XstrA.back();
        XstrA.pop_back();
    } else if (BstrA.size() > 0) {
        cur_str = BstrA.back();
        BstrA.pop_back();
    } else if (BstrX.size() > 0) {
        cur_str = BstrX.back();
        BstrX.pop_back();
    } else {
        cur_str = XstrX.back();
        XstrX.pop_back();
    }

    //cout << "DEBUG" << endl;
    int ans = 0;
    bool Aflag = false;
    ans += countAB(cur_str);
    if (cur_str.back() == 'A') {
        Aflag = true;
    }

    //cout << "DEBUG" << endl;
    for (int i=0; i<BstrA.size(); i++) {
        cur_str = BstrA[i];
        if (Aflag) {
            ans += 1;
        }
        ans += countAB(cur_str);
        Aflag = true;
    }

      //cout << "DEBUG" << endl;
    int bxi = 0;
    int xai = 0;
    while (true) {
        if (not (bxi < BstrX.size()) and not (xai < XstrA.size())) {
            break;
        }

        if (bxi < BstrX.size()) {
            cur_str = BstrX[bxi];
            if (Aflag) {
                ans += 1;
            }
            ans += countAB(cur_str);
            Aflag = false;
            bxi += 1;
        }

        if (xai < XstrA.size()) {
            cur_str = XstrA[xai];
            ans += countAB(cur_str);
            Aflag = true;
            xai += 1;
        }
    }

    //cout << "DEBUG" << endl;
    for (int i=0; i<XstrX.size(); i++) {
        cur_str = XstrX[i];
        ans += countAB(cur_str);
    }

    cout << ans << endl;
}


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

using namespace std; 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define forin(i, n) for ( i = 0; i < (int)n; ++i )
typedef long long ll;

int main()
{
    //IOS
    
    map<string, int> ans;
    int n; cin >> n;

    int i;
    forin(i,n)
    {
        string s; cin >> s;
        ans[s]++;
    }

    cout << "AC x " << ans["AC"] << '\n';
    cout << "WA x " << ans["WA"] << '\n';
    cout << "TLE x " << ans["TLE"] << '\n';
    cout << "RE x " << ans["RE"] << '\n';    
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
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 <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll,ll> P;
typedef long double ld;

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll h, w;
	cin >> h >> w;
	string s[400];
	UnionFind uf(h * w);
	rep (i, h) cin >> s[i];
	rep (i, h) {
		rep (j, w) {
			if (j + 1 < w && ((s[i][j] == '#') ^ (s[i][j + 1] == '#'))) {
				uf.unite(i * w + j, i * w + j + 1);
			}
			if (i + 1 < h && ((s[i][j] == '#') ^ (s[i + 1][j] == '#'))) {
				uf.unite(i * w + j, (i + 1) * w + j);
			}
		}
	}
	map<ll, P> m;
	rep (i, h * w) {
		if (s[i / w][i % w] == '#') m[uf.find(i)].first++;
		else m[uf.find(i)].second++;
		// eprintf("%d ", uf.find(i));
	}
	// eprintf("\n");
	ll ans = 0;
	for (auto i : m) {
		// eprintf("(%d,%d)", i.second.first, i.second.second);
		ans += i.second.first * i.second.second;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x; 
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x; 
        return true;
    }
    return false;
}
template<typename Val>
bool bitcheck(Val bit, size_t idx) {
    return bit & (1 << idx);
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;

void solve() {
    int n, k; cin >> n >> k;
    vector<int> a(n); FOR(i, 0, n) cin >> a[i];

    sort(a.begin(), a.end());
    int sum = 0;
    FOR(i, 0, k) sum += a[i];
    cout << sum << endl;
}

signed main() {
    solve();
    return 0;
}

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

int main() {
  int n,x;
  cin >> n >> x;
  vector<int> v (n);
  for(int i=0; i<n; i++){
    cin >> v.at(i);
  }
  int ans = 0;
  int a = 0;
  for(int i=0; i<n; i++){
    if(a + v.at(i) <= x){
      ans++;
      a += v.at(i);
    }
    else{
      break;
    }
  }
  cout << ans + 1 << endl;
}


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

#define F first
#define S second
#define pb push_back
#define mp make_pair

ll gcd(ll a, ll b){
	if (a == 0) return b;
	return gcd(b%a, a);
}

ll lcm(ll a, ll b){
	return (a/gcd(a, b))*b;
}

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

	ll a[] = {7,77,777,7777,77777,777777,7777777};

	ll k,i;
	cin >> k;

	ll x = k%10;

	if(!(x == 1 || x == 3 || x == 7 || x == 9))
	{
		cout << -1 << endl;
	}
	else
	{
		ll st =0 ;
		for(i=0;i<7;i++)
		{
			if(a[i] >= k)
			{
				st = i+1;
				break;
			}
		}

		ll rem = a[st-1] % k;
		if(rem == 0)
		{
			cout << st << endl;
			return 0;
		}
		else
		{

			for(i = 1;i<1e8;i++)
			{
				rem*=10;
				rem+=7;

				rem %= k;

				if(rem == 0)
					break;
			}

			cout << st+i << endl;
			return 0;		
		}

		cout << -1 << endl;
	}

}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n, sum = 0;
    cin >> n;
    vector<int> a(n);
    for(auto&& i : a){
        cin >> i;
        sum += i;
    }
    int avg = sum / n, avg2 = sum / n + 1;
    int cnt = 0, cnt2 = 0;
    for(auto&& i : a){
        cnt += (i - avg) * (i - avg);
        cnt2 += (i - avg2) * (i - avg2);
    }
    cout << min(cnt, cnt2) << "\n";
}

Measured memory_bytes: 256
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::cmp::{max, min};
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        n: i64,
        Y: i64,
    }
    for y in 0..n+1 {
        for x in 0..n+1 {
            let z = n - x - y;
            if Y == 10000 * x + 5000 * y + 1000 * z && z >= 0{
                println!("{} {} {}", x, y, z);
                return;
            } else {

            }
        }
    }
    println!("-1 -1 -1");
}

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

using namespace std;

int p[20005];
int a[20005];
int b[20005];

int main()
{
          int n;
          cin>>n;
          for(int i=0;i<n;i++)
                    cin>>p[i];
          a[1]=1;
          for(int i=2;i<=n;i++)
                    a[i]=a[i-1]+30000;
          for(int i=1;i<=n;i++)
                    b[i]=a[n-i+1];

          int cnt=1;
          for(int i=0;i<n;i++)
                    b[p[i]]+=cnt++;

          for(int i=1;i<=n;i++)
                    cout<<a[i]<<" ";
          cout<<endl;
          for(int i=1;i<=n;i++)
                    cout<<b[i]<<" ";
}


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


#define SIZE 12

char A[SIZE],B[SIZE],C[SIZE];


int main(){

	scanf("%s %s %s",A,B,C);

	char last_a,last_b;
	for(int i = 0; A[i] != '\0'; i++){

		last_a = A[i];
	}
	for(int i = 0; B[i] != '\0'; i++){

		last_b = B[i];
	}

	if(last_a == B[0] && last_b == C[0]){

		printf("YES\n");

	}else{

		printf("NO\n");
	}

	return 0;
}


Measured memory_bytes: 3688
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <unordered_map>
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if(a+b == 15){
        cout << "+" << endl;
    }else if(a*b == 15){
        cout << "*" << endl;
    }else{
        cout << "x" << endl;
    }
}


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

#ifdef ONLINE_JUDGE
    #undef DBG
#endif

#define sz(x) ((int) (x).size())
#define forn(i, n) for (int i = 0; i < n; ++i)
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fr first
#define sc second

using ll = long long;

const int N = 100100;
int n, k, q;
int a[N];
int sub[N];
int b[N];

int main() {
    memset(sub, 0, sizeof(sub));
    scanf("%d%d%d",&n, &k, &q);
    forn(i, q) scanf("%d", &a[i]);
    forn(i, q) {
        a[i]--;
        if(a[i] > 0) { 
            sub[0]++;
            sub[a[i]]--;
        }
        sub[a[i] + 1]++;
    }
    ll x = 0;
    forn(i, n) {
        x += sub[i];
        b[i] = k - x;
    }
    forn(i, n) puts(b[i] >= 1 ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 1792
N,A,B=map(int,input().split())

L=[]
for i in range(N):
    a,b,c=map(int,input().split())
    L.append([a,b,c])
#print(L)

dp=[[100000 for i in range(401)]for j in range(401)]
dp[0][0]=0

for n in range(N):
    for i in range(401):
        for j in range(401):
            if dp[400-i][400-j]<100000:
                if 400-i+L[n][0]<=400 and 400-j+L[n][1]<=400:
                    if dp[400-i+L[n][0]][400-j+L[n][1]]>dp[400-i][400-j]+L[n][2]:
                        dp[400-i+L[n][0]][400-j+L[n][1]]=dp[400-i][400-j]+L[n][2]
ans=100000
for i in range(1,401):
    for j in range(1,401):
        if i*B==j*A and ans>dp[i][j]:
            ans=dp[i][j]
if ans<100000:
    print(ans)
else:
    print(-1)
#print(dp)

Measured memory_bytes: 43740
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
using namespace std;
#define N 200050
typedef long long ll;
int n;
char w[N];
int main() {
	scanf("%s",w+1);
	n=strlen(w+1);
	int i;
	ll ans=0,now=0,lst=0;
	for(i=n;i;i--) {
		if(w[i]=='A') {
			if(lst==0) ans+=now;
			else now=0;
			lst=0;
		}
		else if(w[i]=='B') {
			if(lst==1) now++;
			else now=0;

			lst=0;
		}else {
			if(lst==1) now=0;

			lst=1;
		}
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#define M 1000001
#define N 10001
int main(){
  char T[M],P[N];
  int i,j,t,p;
  scanf("%s",T);
  scanf("%s",P);
  t=strlen(T);
  p=strlen(P);
  for(i=0;i<=t;i++){
    if(strncmp(&T[i],P,p)==0)
      printf("%d\n",i);
  }
  return 0;
}

Measured memory_bytes: 1548
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,L;
  string str;
  cin >> N >> L;
  list<string> S;
  for(int i;i<N;i++){
    cin >> str;
    S.push_back(str);
  }
  S.sort();
  list<string>::iterator itr;
  for(itr=S.begin();itr!=S.end();itr++){
    cout << *itr;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int INF=1e18;
const int MOD=1e9+7;

signed main(){
    int N;cin>>N;
    int ans=1;
    while(ans*2<=N)ans*=2;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,r=0,c=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n-1;i++)
    {
        if(a[i]-a[i+1]>=0)
        {
            c++;
        }
        else
        {
            c=0;
        }
        if(r<c)
        {
            r=c;
        }
    }
    cout<<r<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<functional>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;


struct Rule{
	vector<int> x;
	int y;
};


void CYK(int trans[25][25],vector<Rule> &rule,vector<int> s){
	memset(trans,0,sizeof(int)*25*25);
	rep(i,s.size()){
		trans[i][i] |= 1<<s[i];
	}
	bool dp[26][11];
	rep(j,s.size()){
		rep(i,s.size()){
			rep(k,rule.size()){
				if(j+1<rule[k].x.size())continue;
				memset(dp,false,sizeof(dp));
				dp[0][0]=true;
				rep(g,j+1){
					rep(h,rule[k].x.size()){
						if(!dp[g][h])continue;
						rep(f,j+1-g){
							if(trans[(i+g)%s.size()][(i+g+f)%s.size()]>>rule[k].x[h]&1)
								dp[g+f+1][h+1]=true;
						}
					}
				}
				if(dp[j+1][rule[k].x.size()]) trans[i][(i+j)%s.size()] |= 1<<rule[k].y;
			}
		}
	}
}
int main(){
	int n,m,r;
	vector<int> a,b;
	vector<Rule> rule;
	int transa[25][25],transb[25][25];
	int dp[26][26];
	while(cin>>n>>m>>r,n|m|r){
		a.resize(n);
		b.resize(m);
		rep(i,n)cin>>a[i];
		rep(i,m)cin>>b[i];
		rule.resize(r);
		rep(i,r){
			int k,v;
			cin>>k;
			rule[i].x.resize(k);
			rep(j,k){
				cin>>v;
				rule[i].x[j]=v;
			}
			cin>>rule[i].y;
		}
		CYK(transa,rule,a);
		CYK(transb,rule,b);
		int ans=-1;
		int sa=a.size(),sb=b.size();
		rep(i,n){
			rep(j,m){
				memset(dp,-1,sizeof(dp));
				dp[0][0]=0;
				rep(k,n){
					rep(f,m){
						if(dp[k][f]==-1)continue;
						rep(g,n-k){
							rep(h,m-f){
								if(transa[(i+k)%sa][(i+k+g)%sa] & transb[(j+f)%sb][(j+f+h)%sb]) dp[k+g+1][f+h+1]=max(dp[k+g+1][f+h+1],dp[k][f]+1);
							}
						}
					}
				}
				ans=max(ans,dp[n][m]);
			}
		}
		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define x first
#define y second
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //assert(freopen("input.txt","r",stdin));
    //assert(freopen("output.txt","w",stdout));
    string s,t;
    int i,ans=0;
    cin>>s>>t;
    for(i=0;i<s.size();i++){
        if(s[i]!=t[i]){
            ans++;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3796
using System;
using System.Linq;
using System.Collections.Generic;

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var d = new Dictionary<string, int>();
            var maxValue = 0;
            foreach(var i in Enumerable.Range(0,n)){
                var s = Console.ReadLine().Trim();
                if(!d.ContainsKey(s)){
                    d.Add(s, 1);
                }else{
                    d[s] += 1;
                }
                maxValue = Math.Max(maxValue, d[s]);
            }

            var l = new List<string>();
            foreach(var item in d){
                if(item.Value == maxValue){
                    l.Add(item.Key);
                }
            }

            l.Sort(StringComparer.OrdinalIgnoreCase);
            foreach(var str in l){
                Console.WriteLine(str);
            }
        }
    }
}


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

int main() {
    int64_t X, Y;
    cin >> X >> Y;

    for (int64_t i = 0; i <= X; i++) {
        int64_t j = X - i;
        if (4 * i + 2 * j == Y) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}

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

int main() {
    
    int N, K;
    int sum=0;
    
    cin >> N >> K;
    
    vector<int> p(N, 0);
    rep(i, N){
        cin >> p[i];
    }
    
    sort(p.begin(), p.end());
    
    rep(i, K){
        sum += p[i];
    }
    
    cout << sum << endl;
    
    
    return 0;
}

Measured memory_bytes: 3604
// inputに入力データ全体が入る
function Main(input) {
	var toping = 0;
	for(var i = 0;i<3;i++){
		if(input[i] == 'o'){
			toping = toping + 100
		}
	}
	
	//出力
	console.log(toping + 700);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
n,x = map(int,input().split())
a = list(map(int,input().split()))
s = sum(a)
for i in range(n-1):
  if a[i] + a[i+1] < x:
    continue
  if a[i] > x:
    a[i] = x
  a[i+1] = x - a[i]
print(s-sum(a))

Measured memory_bytes: 14252
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return true; } return false;
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
vll color(210);
vvll g(210,vll(0));
bool dfs(ll i,ll p,ll c){
    if(color[i]!=0){
        if(color[i]==c)return 1;
        else return 0;
    }
    color[i]=c;
    bool f=1;
    for(auto e:g[i]){
        if(e==p)continue;
        if(c==1){
            f&=dfs(e,i,2);
        }
        else{
            f&=dfs(e,i,1);
        }
    }
    return f;
}
int main(){
  ll n;
  cin>>n;
  vvll t(n,vll(n,INF));
  rep(i,n){
    t[i][i]=0;
  }
  rep(i,n){
    rep(j,n){
      char a;
      cin>>a;
      if(a=='1'){
        t[i][j]=1;
        g[i+1].pb(j+1);
        g[j+1].pb(i+1);
      }
    }
  }
  if(dfs(1,0,1)){
    rep(k,n){
      rep(i,n){
        rep(j,n){
          t[i][j]=min(t[i][j],t[i][k]+t[k][j]);
        }
      }
    }
    ll ans=0;
    rep(i,n){
      rep(j,n){
        ans=max(ans,t[i][j]);
      }
    }
    COUT(ans+1);
  }
  else COUT(-1);
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int n,t;
int a[100100];
int maxx;
int max_profit;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>t;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	int cnt=0;
	for(int i=n;i>=1;i--){
		maxx=max(maxx,a[i]);
		max_profit=max(max_profit,maxx-a[i]);
	}
	maxx=0;
	for(int i=n;i>=1;i--){
		maxx=max(maxx,a[i]);
		if(maxx-a[i]==max_profit){
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <map>
#include <queue>
using namespace std;

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

int main(){
	map<string,int> used;
	queue<string> que;
	que.push("01234567");
	for(int i = 0;;i++){
		int siz = que.size();
		if(!siz) break;
		for(int j = 0;j < siz;j++){
			string s = que.front();que.pop();
			if(used.find(s) != used.end()) continue;
			used[s] = i;
			for(int k = 0;k < 8;k++){
				if(s[k] == '0'){
					for(int l = 0;l < 4;l++){
						int x = k / 4 + dx[l],y = k % 4 + dy[l];
						if(x >= 0 && x < 2 && y >= 0 && y < 4){
							string t = s;
							t[k] = t[x * 4 + y];
							t[x * 4 + y] = '0';
							que.push(t);
						}
					}
				}
			}
		}
	}
	string s;
	while(getline(cin,s)){
		string t;
		for(int i = 0;i < s.length();i++){
			if(s[i] != ' ') t += s.substr(i,1);
		}
		cout << used[t] << endl;
	}
	return 0;
}

Measured memory_bytes: 5384
// AOJ 2446: Enumeration
// 2017.11.26 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

long long a[22];
int p[22];

long long gcd(long long a, long long b)
{
	long long r;
	while (b != 0) r = a % b, a = b, b = r;
	return a;
}

int main()
{
	int n, i, j, f, lim;
	long long m, t;
	double ans, pp;

	scanf("%d%lld", &n, &m);
	for (i = 0; i < n; i++) scanf("%lld", a+i);
	for (i = 0; i < n; i++) scanf("%d", p+i);
	
	ans = 0;
	for (lim = 1 << n, i = 1; i < lim; i++) {
		f = 0, pp = 1;
		for (j = 0; j < n; j++) if ((i >> j) & 1) { f++, pp *= p[j]/100.0; }
		for (t = 1, j = 0; j < n; j++) {
			if ((i >> j) & 1) {
//				t = t / gcd(t, a[j]) * a[j];
				t /= gcd(t, a[j]);
				if (t > (1LL<<62)/a[j]) { t = -1; break; }
				t *= a[j];
			}
		}
		if (t > 0) {
			if (f & 1) ans += pp * (m / t);
			else       ans -= pp * (m / t);
		}
	}
	printf("%.10lf\n", ans);
	return 0;
}

Measured memory_bytes: 1820
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
// typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;

int main(){
  int a,b,c; cin>>a>>b>>c;
  if(a>max(b,c)){
    cout<<b*c/2<<endl;
  }else if(b>max(a,c)){
    cout<<a*c/2<<endl;
  }else{
    cout<<a*b/2<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> a(2, vector<int>(n, 0));
    rep(i, 2)rep(j, n){
        cin >> a[i][j];
    }
    
    int ans = 0;
    rep(i, n){
        int sum = 0;
        rep(j, n){
            if(j < i) sum += a[0][j];
            else if(j == i) sum += a[0][j] + a[1][j];
            else sum += a[1][j];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using namespace std;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(ll i=0;i<n;i++)
#define Rip(i,n) for(ll i=1;i<n;i++)
#define all(V) V.begin(),V.end()
#define ll long long
#define ld long double
#define MOD 998244353
#define mod MOD
#define sec setprecision
constexpr double eps = 1e-9;
constexpr double PI = 3.141592653589793238462643383279;
ll gcd(ll a, ll b) {
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
int ketasuu(ll h) {
	if (h < 0)return(-(ketasuu(-h)));
	else if (h < 10)return(1);
	else return(1 + ketasuu(h / 10));
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
vector<ll> soinnsuubunnkai(ll n) {
	vector<ll>a;
	while (n % 2 == 0) {
		a.push_back(2);
		n /= 2;
	}
	ll f = 3;
	while (f * f <= n) {
		if (n % f == 0) {
			a.push_back(f);
			n /= f;
		}
		else f += 2;
	}
	if (n != 1)
		a.push_back(n);
	return(a);
}
// 二項係数計算
long long com(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
ll pow(ll a, ll b) {
	a = a % mod;
	if (b == 0)return(1);
	else if (b % 2 == 0)return(pow((a * a) % mod, b / 2));
	else return(a * (pow(a, b - 1)));
}
void solve() {
	int p, q, r;
	cin >> p >> q >> r;
	cout << p + q + r - max({ p,q,r }) << endl;
}
int main() {
	solve();
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int n = sc.nextInt();
		int q = sc.nextInt();

		int[] sum = new int[n];

		String s = sc.next();

		sum[0] = 0;
		for (int i = 1; i < s.length(); i++) {
			sum[i] = sum[i - 1];
			if (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C') {
				sum[i]++;
			}
		}

		for (int i = 0; i < q; i++) {
			int st = sc.nextInt();
			int e = sc.nextInt();
			out.println(sum[e - 1] - sum[st - 1]);
		}

		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}


Measured memory_bytes: 66432
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let l: f64 = read();
    let a = l / 3.0;
    println!("{}", a * a * a);
}


Measured memory_bytes: 4352