akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<queue>
#define LL unsigned long long
using namespace std;
inline int read( )
{
  int sum=0;char c=getchar( );bool f=0;
  while(c<'0'||c>'9') {if(c=='-') f=1;c=getchar( );}
  while(c>='0'&&c<='9') {sum=sum*10+c-'0';c=getchar( );}
  if(f) return -sum;
  return sum;
}
int n,p,a[55];
LL f[50][5];
int main( )
{
  int i,j;
  n=read( );p=read( );
  for(i=1;i<=n;i++) a[i]=read( )%2;
  f[0][0]=1;
  for(i=1;i<=n;i++)
    for(j=0;j<=1;j++)
      {
	f[i][j]+=f[i-1][j];
	f[i][j]+=f[i-1][(j-a[i]+2)%2];
      }
  printf("%llu",f[n][p]);
  return 0;
}


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

int main() {
  int h,w,n;
  cin >> h >> w >> n;
  int mx = max(h,w);
  for(int i=0;i<=mx;i++){
    if( i*mx >= n ){
      cout << i << endl;
      return 0;
    }
  }
  
  return 0;
}

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

int main()
{
  int n[32];
  n[0] = 1;
  n[1] = 1;
  n[2] = 1;
  n[3] = 2;
  n[4] = 1;
  n[5] = 2;
  n[6] = 1;
  n[7] = 5;
  n[8] = 2;
  n[9] = 2;
  n[10] = 1;
  n[11] = 5;
  n[12] = 1;
  n[13] = 2;
  n[14] = 1;
  n[15] = 14;
  n[16] = 1;
  n[17] = 5;
  n[18] = 1;
  n[19] = 5;
  n[20] = 2;
  n[21] = 2;
  n[22] = 1;
  n[23] = 15;
  n[24] = 2;
  n[25] = 2;
  n[26] = 5;
  n[27] = 4;
  n[28] = 1;
  n[29] = 4;
  n[30] = 1;
  n[31] = 51;
  
  int K;
  cin >> K;
  cout << n[K-1] << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class EChangeALittleBit {
public:
    void solve(std::istream& in, std::ostream& out) {
        ll N;
        in >> N;
        vector<ll> C(N);
        REP(i,0,N) in >> C[i];
        sort(all(C), greater<ll>());

        ll answer = 0;
        REP(i,0,N) {
            ll add = C[i];
            add *= i+2;
            add %= MOD;
            answer += add;
            answer %= MOD;
        }
        REP(i,0,N-1) {
            answer *= 4;
            answer %= MOD;
        }
        out << answer << "\n";
    }
};


int main() {
	EChangeALittleBit solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  int N;
  cin >> N;
  vector<string> U(N);
  for(int i = 0; i < N; i++){
    cin >> U[i];
  }
  int M;
  cin >> M;
  vector<string> T(M);
  for(int i = 0; i < M; i++){
    cin >> T[i];
  }
  int s = -1;
  for(int i = 0; i < M; i++){
    bool flag = false;
    for(int j = 0; j < N; j++){
      if(T[i] == U[j]){
        if(s == -1)cout << "Opened by " << T[i] << endl;
        else cout << "Closed by " << T[i] << endl;
        s *= -1;
        flag = true;
        break;
      }
    }
    if(!flag)cout << "Unknown " << T[i] << endl;
  }
}

Measured memory_bytes: 3240
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_set>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>
	
int main() {
	string x, y;
	ll a, b;
	cin >> x >> y >> a >> b;
	string s;
	cin >> s;
	if (s == x)a--;
	else b--;
	cout << a << " " << b << endl;
}



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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

vi adj[100500];
int dp[100500][2];

int f(int u, bool c, int par){
	if(dp[u][c] != -1) return dp[u][c];
	int ret = 1;
	for(int v : adj[u]){
		if(v == par) continue;
		if(c) ret = mul(ret, f(v, !c, u));
		else ret = mul(ret, add(f(v, !c, u), f(v, c, u)));
	}
	return dp[u][c] = ret;
}

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

	int n;
	cin >> n;
	for(int i = 0; i < n - 1; i++){
		int a, b;
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	memset(dp, -1, sizeof dp);
	int res = add(f(1, false, 1), f(1, true, 1));
	cout << res;
}

Measured memory_bytes: 14848
n = int(input())
a = list(map(int,input().split()))
b = [0]*(n+1)
for i in range(n):
    b[i+1]=b[i]+a[i]
buf = 10**18
cnt = 1
ans = 0
b = sorted(b)
for i in range(n+1):
    if buf==b[i]:
        cnt += 1
    else:
        ans += cnt*(cnt-1)//2
        buf = b[i]
        cnt = 1
ans += cnt*(cnt-1)//2
print(ans)

Measured memory_bytes: 26136
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      String a = sc.next();
      int count = 0;
        for (int i = 0; i < a.length()/2; i++) {
          	if(a.charAt(i) != a.charAt(a.length()-i-1)){
				count += 1;
            }
        }
      System.out.print(count);
    }
  
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
   
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define deb(x) cout << #x << "=" << x << endl
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define vi vector<int>
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 1000000007
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define int long long
const int N=(int)1e5+5,INF=(int)1e18+7;

int n,m;
vector<int>v[N];
int dp[N];
int vis[N];
int in[N];
vector<int>order;


void dfs(int i)
{
    vis[i]=1;
    for(auto x:v[i])
    {
        dp[x]=max(dp[x],dp[i]+1);
        --in[x];
        if(in[x]==0)
        dfs(x);
    }
    
}





void solve()
{
   cin>>n>>m;
   
   for(int i=0;i<m;i++)
   {
       int a,b;
       cin>>a>>b;
       in[b]++;
       v[a].pb(b);
   }
  
   for(int i=1;i<=n;i++)
   {
       if(!vis[i] and in[i]==0)
       dfs(i);
   }
   
  
   int ans=0;
   for(int i=1;i<=n;i++)ans=max(ans,dp[i]);
   
   cout<<ans;
   
   
   
}

int32_t main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    
	int t=1;
	//cin>>t;
	while(t--)solve();
	    
   
}


Measured memory_bytes: 16056
import java.util.HashSet;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        List<String> w = Stream.generate(() -> null).limit(n).map(i -> scanner.next()).collect(Collectors.toList());
        a: if (new HashSet<>(w).size() == n) {
            Character last = null;
            for (String s : w) {
                if (last != null && !last.equals(s.charAt(0)))
                    break a;
                last = s.charAt(s.length() - 1);
            }
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 27220
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e3 + 10;
vector<int> a[N];
bool visit[N];
vector<int> st;
bool instack[N];

bool check(const vector<int>& ret) {
  set<int> A(ret.begin(), ret.end());
  for (auto& u : ret) {
    int cnt = 0;
    for (auto& v : a[u]) {
      if (A.count(v)) ++cnt;
    }
    if (cnt > 1) return false;
  }
  return true;
}

bool DFS(int u) {
  if (visit[u]) {
    if (instack[u]) {
      vector<int> ret;
      for (int k = st.size() - 1; st[k] != u; --k) {
        ret.push_back(st[k]);
      }
      ret.push_back(u);
      reverse(ret.begin(), ret.end());
      if (check(ret)) {
        printf("%d\n", (int)ret.size());
        for (auto& it : ret) {
          printf("%d\n", it + 1);
        }
        return true;
      }
      return false;
    }
    return false;
  }
  visit[u] = true;
  st.push_back(u);
  instack[u] = true;
  for (auto& v : a[u]) {
    if (DFS(v)) return true;
  }
  instack[u] = false;
  st.pop_back();
  return false;
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x; --y;
    a[x].push_back(y);
  }
  bool found = false;
  for (int i = 0; i < n; ++i) {
    if (DFS(i)) {
      found = true;
      break;
    }
  }
  if (!found) puts("-1");
  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int X = sc.nextInt();

        if (K * 500 >= X) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

int main(){
  int n, c = 0;
  string s;
  cin >> n >> s;
  for(int i = 2; i < n; ++i){
    if(s[i-2] == 'A' && s[i-1] == 'B' && s[i] == 'C') ++c;
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define int long long int
using namespace std;

void desperate_optimization(bool submitting=true,int precision=10)
{
  if(!submitting) return;
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.setf(ios::showpoint);
  cout.precision(precision);
}
int32_t main()
{
  desperate_optimization(false);
  //freopen("input.txt","r",stdin);
  int n,w;
  cin>>n>>w;
  int weight[n+1],value[n+1];
  for(int i=1;i<=n;i++) cin>>weight[i]>>value[i];

  int dp[n+1][w+1];
  for(int j=0;j<=w;j++) dp[0][j]=0;
  for(int i=1;i<=n;i++)
  {
    for(int j=0;j<=w;j++)
    {
      //Current ka weight is weight[i]
      if(j>=weight[i])
      {
        dp[i][j]=max(dp[i-1][j],dp[i-1][j-weight[i]]+value[i]);
      }
      else
        dp[i][j]=dp[i-1][j];
    }
  }

  cout<<dp[n][w];


  return 0;
}

// 3 8
// 3 30
// 4 50
// 5 60

Measured memory_bytes: 79104
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

typedef pair<int,int> P;

// ツ閉カツ篠堋療アsツづーツ閉カツ篠喞ツ凝ヲツ静伉づィツづ閉ェツ環つオツづ陛板つキ
vector<string> split_string(string s, char c){
	string str;
	vector<string> vs;
	s.push_back( c );
	
	for(int i=0 ; i < s.size() ; i++ ){
		if( s[i] == c ){
			if( !str.empty() ){
				vs.push_back( str );
				str.clear();
			}
		}else{
			str.push_back( s[i] );
		}
	}
	return vs;
}

// stringツづーintツづ可陛渉環キ
int s_to_i(string s){
	int n=0;
	for(int i=0 ; i < s.size() ; i++ ){
		n *= 10;
		n += s[i] - '0';
	}
	return n;
}

int main(){
	string s;
	bool flag = false;
	map<int,bool> month1, month2;
	vector<int> v;
	
	while( getline(cin,s) ){
		int id;
		
		// ツ凝ウツ板陳行ツづ個づつォ
		if( s.empty() ){
			flag = true;
			continue;
		}else{
			vector<string> vs = split_string( s , ',' );
			id = s_to_i( vs[0] );
		}
		
		if( flag == false ){
			month1[id] = true;
			v.push_back( id );
		}else{
			month2[id] = true;
			v.push_back( id );
		}
	}
	
	vector<P> vp;
	for(map<int,bool>::iterator it = month1.begin() ; it != month1.end() ; ++it ){
		int id = it->first;
		if( month2.count(id) ){
			int cnt = count( v.begin() , v.end() , id );
			P p( id , cnt );
			vp.push_back( p );
		}
	}
	sort( vp.begin() , vp.end() );
	for(int i=0 ; i < vp.size() ; i++ ){
		cout << vp[i].first << " " << vp[i].second << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(int (i) = 1; (i) < (n); ++(i))
#define rrep1(i,n) for(int (i) = (n) - 1; (i) >= 1; --(i))
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

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

int main()
{
    string s;
    ll ans = 0;
    cin >> s;
    if (s.size() == 1) {
        cout << 0 << endl;
        return 0;
    }
    
    rep1(i, s.size()){
        if (s[i] == s[i - 1]) {
            ++ans;
            if (s[i] == '1')s[i] = '0';
            else s[i] = '1';
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

using ll = long long;

int main(){
    ll n;
    cin >> n;
    ll ans = 0, arr[n];
    for(ll i = 1; i <= n; ++i){
        ll tmp; cin >> tmp;
        arr[i - 1] = tmp - i;
    }
    ll ans1 = 0;
    sort(arr, arr + n);
    if(n % 2){
        for(ll i = 0; i < n; ++i){
            ans += abs(arr[i] - arr[n / 2]);
        }
        cout << abs(ans);
    }else{
        for(ll i = 0; i < n; ++i){
            ans += abs(arr[i] - arr[n / 2]);
            ans1 += abs(arr[i] - arr[n / 2 - 1]);
        }
        cout << min(abs(ans), abs(ans1));
    }

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  ll n,w,i,j;
  cin>>n>>w;
  ll wt[n+1],v[100001],dp[n+1][100001]={0};
  for(i=0;i<n;i++)
  {
    cin>>wt[i]>>v[i];
  }
  for(i=0;i<=100000;i++)
  {
    if(i<=v[0])
      dp[0][i]=wt[0];
    else
      dp[0][i]=INT_MAX;
  }
  for(i=1;i<n;i++)
  {
    for(j=0;j<=100000;j++)
    {
      if(j<=v[i])
      {
        dp[i][j]=min(dp[i-1][j],wt[i]);
      }
      else 
      {
        dp[i][j]=min(dp[i-1][j],wt[i]+dp[i-1][j-v[i]]);
      }
    }
  }
  ll c=0;
  for(i=0;i<=100000;i++){
    if(dp[n-1][i]<=w)
      c++;}
  cout<<c-1<<endl;
}
      

Measured memory_bytes: 79104
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int n;
    cin>>n;
    if(n%2==1){
        cout<<0<<endl;
        return 0;
    }
    int ans=0;
    n/=2;
    while(n>0){
        n/=5;
        ans+=n;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

const int MAX = 100005;
const int NIL = -1;

struct Node {int p, l, r; };

Node T[MAX];
int n, D[MAX];

void print(int u) {
  int i, c;
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].p << ", ";
  cout << "depth = " << D[u] << ", ";

  if ( T[u].p == NIL) cout << "root, ";
  else if ( T[u].l == NIL ) cout << "leaf, ";
  else cout << "internal node, ";

  cout << "[";
  for ( i = 0, c = T[u].l; c!= NIL; i++, c = T[c].r) {
    if (i) cout << ", ";
    cout << c;
  }

  cout << "]" << endl;
}

void rec(int u, int p) {
  D[u] = p;
  if (T[u].r != NIL) rec(T[u].r, p);
  if (T[u].l != NIL) rec(T[u].l, p+1);
}

int main() {
  int i, j, d, v, c, l, r;
  cin >> n;
  rep(i,n) T[i].p = T[i].l = T[i].r = NIL;

  rep(i,n) {
    cin >> v >> d;
    rep(j,d) {
      cin >> c;
      if (j == 0) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }

  rep(i, n) {
    if (T[i].p == NIL) r = i;
  }

  rec(r,0);

  rep(i,n) print(i);
}


Measured memory_bytes: 7784
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
double pie=3.14159265358979;
long long mod=998244353;
//
int main(){
	int a;
	cin>>a;
	cout<<a+a*a+a*a*a<<endl;
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

int main(void){
    int h,w;
    cin >> h >> w;
    vector<vector<char>> S(h,vector<char>(w));
    rep(i,h){
        rep(j,w){
            cin >> S[i][j];
        }
    }
    int a = h * w;
    vector<vector<int>> mat(a, vector<int>(a,a));
    int offset[4][2] = {{-1,0},{1,0},{0,-1},{0,1}};
    rep(i, a){
        int xi = i/w;
        int yi = i%w;
        if(S[xi][yi] == '#') continue;
        for(auto ff: offset){
            int xj = xi + ff[0];
            int yj = yi + ff[1];
            if(0 <= xj && xj < h && 0 <= yj && yj < w){
                int j = xj * w + yj;
                if(S[xj][yj] == '.'){
                    mat[i][j] = 1;
                }
            }
        }
    }
    rep(k,a){
        rep(i,a){
            rep(j,a){
                if(mat[i][j] > mat[i][k] + mat[k][j]){
                    mat[i][j] = mat[i][k] + mat[k][j];
                }
            }
        }
    }
    
    int ans = 0;
    rep(i,a){
        rep(j,a){
            if(mat[i][j] < a){
                ans = max(ans, mat[i][j]);
            }
        }
    }
    cout << ans << endl;
    // rep(i,a){
    //     rep(j,a){
    //         cout << mat[i][j] << ' ';
    //     }
    //     cout << endl;
    // }
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
#define int long long
#define double long double
 
int gcd(int x, int y){
    if (y == 0)
        return x;
    x = x % y;
    gcd(y, x);
}
 
int check(int i,int ans){
    if(i<2) return ans;
    ans=i*check(i-2,ans);
}
main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a>=c) cout<<a-c<<" "<<b<<endl;
    else if(a+b>=c)cout<<0<<" "<<b+a-c<<endl;
    else cout<<0<<" "<<0<<endl;
}

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

int dp[150][2];

signed main(){
  
  int l, k;
  
  dp[0][0] = 1;
  
  cin>>l>>k;
  
  for(int i=0;i<l;i++){
    
    for(int j=0;j<2;j++){
      
      if( j == 0 ){
	dp[i+1][1] += dp[i][j];
	dp[i+k][1] += dp[i][j];
      }
      else{
	dp[i+1][0] += dp[i][j];
      }
      
    }
    
  }
  
  int ans = 0;
  
  for(int i=0;i<=l;i++) ans += dp[i][1];

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



Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define ii pair<int,int>
#define ll long long int
#define F first
#define S second
using namespace std;
const int M = 1e5 + 7, mod = 1e9 + 7;


int main(){

  #ifndef ONLINE_JUDGE
  //freopen("i.txt", "r", stdin);
  //freopen("o.txt", "w", stdout);
  #endif

  string s;
  cin >> s;
  s[3] = '8';
  cout << s << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip> 
#include <bits/stdc++.h>
using namespace std;
double pi=3.14159265358979323846264338;


bool issqt(long long k){
	if(k<=3)return true;
	long long s=(long long)sqrt(k);
	//cout<<k<<" "<<s<<endl;
	for(long long i=2;i<=s;i++)
		if(k%i==0)return false;
	return true;
}
 
 
int main() {
	bool ok[200001];
	long long arr[200001];

	bool ok2[1000001];
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>arr[i];
	sort(arr+1,arr+1+n);
	for(int i=1;i<=n;i++){
		if(ok2[arr[i]]){ok[i]=true;if(i!=1&&arr[i]==arr[i-1]&&!ok[i-1])ok[i-1]=true;continue;}
		for(long long j=1;j*arr[i]<=1000000;j++)if(!ok2[j*arr[i]])ok2[j*arr[i]]=true;
		
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(!ok[i])ans++;
	}
	cout<<ans<<endl;
  return 0;
}




Measured memory_bytes: 6396
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


tmp_str = input()
print(tmp_str[::-1])


Measured memory_bytes: 6332
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
        String S = stdIn.next();
	String T = stdIn.next();
	int count=0;
	for(int i=0;i<S.length();i++){
	    char s=S.charAt(i);
	    char t=T.charAt(i);
	    if(s==t){
		count++;
	    }
	}
	System.out.println(count);
    }
}
	


Measured memory_bytes: 21844
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kidman
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll

const int md = 1000000007;
const int INF = 1<<30;

class DFaceProducesUnhappiness {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n,k;
        in>>n>>k;
        string s;
        in>>s;
        int ans=0;


        rep(i,n){
            while(i+1<n && s[i]==s[i+1]){
                ans++;
                i++;
            }
        }

        out<<min(ans+2*k,n-1)<<endl;

	}
};


int main() {
	DFaceProducesUnhappiness solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <algorithm>  // std::unique
#include <cmath>
#include <limits.h>
#include <queue>
#include <unordered_map>
#include <sstream>      // std::ostringstream
#include <bitset>
#include <iomanip>
#include <functional>
#include <set>


#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

using ll = long long;
constexpr auto PrimeBigNum10_9_7 = 1000000007;

#define OUTPUT_DEBUG_LOG

template <typename T>
void DisplayAnswer(const T& v) {
	cout << v << endl;
}
template <typename T>
void DisplayAnswers(const vector<T>& vs) {
	for (const auto& v : vs) {
		cout << v << endl;
	}
}

template <typename T>
void DisplayAnswerOneLine(const vector<T>& vs) {
	for (const auto& v : vs) {
		cout << v << ' ';
	}
	cout << endl;
}


std::vector<std::string> split(const std::string &str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}


// 素数判定
template <typename T>
bool IsPrimeNumber(T value) {

	for (int i = 2; i * i <= value; ++i) {
		if ((value % i) == 0) {
			return true;
		}
	}
	return false;
}

// 桁数判定
template <typename T>
T GetFigureLength(T value) {
	T figure = 1;
	while (value >= 10) {
		value /= 10;
		++figure;
	}
	return figure;
}

// 素因数分解結果
template <typename T>
map<T, T> GetPrimeFactorize(T value) {

	map<T, T> res;

	for (T i = 2; i * i <= value; ++i) {
		if ((value%i) != 0)	continue;

		T count = 0;
		while ((value % i) == 0) {
			value /= i;
			++count;
		}

		res[i] = count;
	}

	if (value != 1) {
		res[value] = 1;
	}
	return res;
}


void DebugPrint(const vector<ll>& vec) {
	cout << "{";
	for (auto itr = vec.begin(); itr != vec.end(); ++itr) {
		cout << *itr << ",";
	}
	cout << "}" << endl;
}

// valueが2のx乗以下である計算
ll calc2x(ll value) {
	ll n = 0;
	while (value > 0) {
		value /= 2;
		++n;
	}
	return n;
}



struct Vec2 {
	double x;
	double y;

	void rotate(double rad) {
		double s = sin(rad);
		double c = cos(rad);
		double tmpX = this->x*c - this->y*s;
		double tmpY = this->x*s + this->y*c;
		this->x = tmpX;
		this->y = tmpY;
	}
};

void funcA() {

	ll N;
	cin >> N;
	DisplayAnswer(N + N * N + N * N*N);
}

void funcB() {
	string str1, str2;
	cin >> str1 >> str2;

	ll count = 0;
	for (ll i = 0; i < str1.size(); ++i) {
		if (str1[i] != str2[i]) {
			count++;
		}
	}
	DisplayAnswer(count);
}
int main(void) {

	funcB();
	return 0;
}


Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef vector<int>   vi;
typedef vector<long long> vll;
typedef vector<pair<int,int> > vii;
#define ll long long
#define pb push_back
#define mp  make_pair
#define ff first
#define ss second
#define pq priority_queue
#define sf(x) scanf("%d",&x)
int inf = (1e9) + 7;



int main(){
	int n;
	string a;
	string b;
	cin >> n;
	cin >> a;
	cin >> b;
	ll ans = 1;
	for (int i = 0; i < n; ++i)
	{
		if(i == 0 and a[i] == b[i])
		{
			ans *= 3;
		}	
		else if(i == 0 and a[i] != b[i])
		{
			ans *= 6;
			i++;
		}
		else if(a[i] != b[i])
		{
			if(a[i-1] != b[i-1])
				ans *= 3;
			else
				ans *= 2;
			i++;
		}
		else if(a[i] == b[i])
		{
			if(a[i-1] != b[i-1])
				ans *= 1;
			else
			{
				ans *= 2;
			}
		}
		ans %= inf;
	}
	printf("%lld\n",ans );
}

Measured memory_bytes: 256
//Md Fahad
// CSE 18

#include<bits/stdc++.h>

using  namespace  std;

#define PI              acos(-1.0)
#define lcm(a,b)        (a * (b / __gcd(a,b)))
#define en '\n'

#define READ_IN freopen("Input.txt","r",stdin);
#define READ_OUT freopen("Output.txt","w",stdout);
#define Infi                0x3f3f3f3f

const int dx[] = {+1,-1,+0,+0};                         // 4 X directions
const int dy[] = {+0,+0,+1,-1};                         // 4 Y directions
const int dx8[] = {+0,+0,+1,-1,-1,+1,-1,+1};            // King X Moves
const int dy8[] = {-1,+1,+0,+0,+1,+1,-1,-1};            // King Y Moves
const int kx[] = {-2, -2, -1, -1,  1,  1,  2,  2};      // Knight X Moves
const int ky[] = {-1,  1, -2,  2, -2,  2, -1,  1};      // Knight Y Moves



int  Set    (int N,int pos) {return N=N | (1<<pos);}    /// turn a bit on
int  reset  (int N,int pos) {return N= N & ~(1<<pos);}  /// turn a bit off
bool check  (int N,int pos) {return (bool)(N & (1<<pos));} /// check, if a bit is on or not

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define trace(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define trace(x...)
#endif

typedef long long int           ll;
typedef unsigned long long int  llu;



int main(void)
{
    //READ_IN;

    set<int> a;

    for(int i=0;i<3;i++){
        int x; cin >> x;
        a.insert(x);
    }

    if(a.size()==2){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

double const EPS = 1.0e-10;

class Point
{
public:
    double y, x;
    Point(){
        y = x = 0.0;
    }
    Point(double y0, double x0){
        y = y0;
        x = x0;
    }
    double dist(const Point& p) const{
        return sqrt(pow(y - p.y, 2) + pow(x - p.x, 2));
    }
    Point operator/(double a) const{
        return Point(y / a, x / a);
    }
};

class Line
{
public:
    double a, b, c; // a*x + b*y + c = 0
    Line(double a0, double b0, double c0){
        a = a0;
        b = b0;
        c = c0;
    }
};

Line perpendicularBisector(const Point& p1, const Point& p2)
{
    return Line(p2.x-p1.x, p2.y-p1.y, (p1.y*p1.y + p1.x*p1.x - p2.y*p2.y - p2.x*p2.x) / 2);
}

bool linesIntersection(const Line& l1, const Line& l2, Point& intersection)
{
    double s = l1.a*l2.b - l2.a*l1.b;
    if(abs(s) < EPS)
        return false;

    intersection = Point(l2.a*l1.c - l1.a*l2.c, l1.b*l2.c - l2.b*l1.c) / s;
    return true;
}

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

    while(--n >= 0){
        Point p1, p2, p3;
        cin >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y;

        Line l1 = perpendicularBisector(p1, p2);
        Line l2 = perpendicularBisector(p2, p3);
        Point p;
        linesIntersection(l1, l2, p);

        printf("%.3f %.3f %.3f\n", p.x, p.y, p.dist(p1));
    }

    return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
 
using namespace std;
 
int calcMax(int a,int b){
    int tmp;
    if(a > b){
        while(b != 0){
            tmp = b;
            b = a%b;
            a = tmp;
        }
        return a;
    }else{
        while(a != 0){
            tmp = a;
            a = b%a;
            b = tmp;
        }
        return b;
    }
}
 
 
 
int calcMin(int a,int b){
    int max_common = calcMax(a,b);
    return (a/max_common)*b;
}
 
int main(){
    int a,b;
    while(scanf("%d %d",&a,&b)!=EOF){
        printf("%d %d\n",calcMax(a,b),calcMin(a,b));
    }
 
    return 0;
}


Measured memory_bytes: 2696
#include <iostream>
#include "vector"
#include <algorithm>

using namespace std;
int main()
{
	int N;
	cin >> N;

	vector<int> A(N), B(N), C(N);

	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	for (int i = 0; i < N; i++)
	{
		cin >> B[i];
	}

	for (int i = 0; i < N; i++)
	{
		cin >> C[i];
	}
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());

	long ans = 0;
	for (int i = 0; i < N; i++)
	{
		auto Iter1 = lower_bound(A.begin(), A.end(), B[i]);
		auto Iter2 = upper_bound(C.begin(), C.end(), B[i]);
		long k1 = Iter1 - A.begin();
		long k2 = C.end() - Iter2;
		ans += k1 * k2;
	}

	cout << ans << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <list>
#include <string>
using namespace std;
int main(){

  int n,x,i;
  list <int> a;
  list<int>::iterator it;
  string com;

  cin>>n;
  for(i=0;i<n;i++){
    cin>>com;
    if(com=="deleteFirst") a.pop_front();
    else if(com=="deleteLast") a.pop_back();
    else{
      cin>>x;
      if(com=="insert") a.push_front(x);
      else for(it=a.begin();it!=a.end();it++) if(*it==x){
            a.erase(it);
            break;
          }
    }
  }
  i=0;
  for(it=a.begin();it!=a.end();it++){
    if(i++) cout<<" ";
    cout<<*it;
  }
  cout<<endl;

  return 0;

}

Measured memory_bytes: 34356
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
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; }

int main(){
  ll x; cin >> x;
  ll ans = x/11;
  x -= ans*11;
  int cnt = 0;
  if(0 < x && x <= 6) cnt++;
  else if(6 < x) cnt += 2;
  cout << ans*2+cnt;
  cout << "\n";
  return 0;
}


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

using namespace std;

const int MAXN = (int) 2e5;
const int INF = (int) 1e9;

int sp[MAXN + 1][26];

string str;

unordered_map <int, int> dp;

inline int check(int x) {
    if(dp[x] == 0) {
       if(x == 0)
         return 0;
       return INF;
    }
    return dp[x];
}

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, j;
    ios::sync_with_stdio(false);
    cin >> str;
    int n = str.size();
    str = " " + str;
    for(i = 1; i <= n; i++) {
       for(j = 0; j < 26; j++)
          sp[i][j] = sp[i - 1][j];
       sp[i][str[i] - 'a']++;
       sp[i][str[i] - 'a'] %= 2;
    }
    int ans = MAXN + 1;
    for(i = 1; i <= n; i++) {
       int cnf = 0;
       for(j = 0; j < 26; j++)
           cnf += (1 << j) * sp[i][j];
       int val = check(cnf);
       for(j = 0; j < 26; j++)
           val = min(val, check(cnf ^ (1 << j)) + 1);
       dp[cnf] = val;
     //  printf("%d\n" ,val);
       if(i == n) {
            if(val == 0)
               val = 1;
            cout << val;
            return 0;
       }
    }
    //cin.close();
    //cout.close();
    return 0;
}



Measured memory_bytes: 190492
n = int(input())
if n==2: print(-1)
else:
	for i in range(1,n+1):
		num = 0
		if i%2==1:
			for j in range(1,n+1):
				if i!=j and num!=n-2:
					print(j,end=" ")
					num += 1
				elif i!=j:
					print(j)
					break
		else:
			if i==n: print(n-1,end=" ")
			else: print(n,end=" ")
			for j in range(1,n+1):
				if i!=j and num!=n-3:
					print(j,end=" ")
					num += 1
				elif i!=j:
					print(j)
					break

Measured memory_bytes: 3644
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
              int a = sc.nextInt();
              int b = sc.nextInt();
              if(a<=8 && b<=8){
                System.out.println("Yay!");
              } else {
                System.out.println(":(");
              }
            }
        }


Measured memory_bytes: 21844
using System;
using System.Text;

namespace PanaContest2020
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = Console.ReadLine();

            var n = int.Parse(s);
            var p = new Problem4(n);
            Console.WriteLine(p.GetAnswer());
        }
    }

    public class Problem4
    {
        private readonly StringBuilder _sb = new StringBuilder();
        private readonly int _n;

        public Problem4(int n)
        {
            _n = n;
            Dfs(string.Empty, 'a');
        }

        public string GetAnswer()
        {
            return _sb.ToString();
        }

        private void Dfs(string s, char max)
        {
            if (s.Length == _n)
            {
                _sb.AppendLine(s);
            }
            else
            {
                for (var c = 'a'; c <= max; c++)
                {
                    Dfs(s + c, c == max ? (char) (max + 1) : max);
                }
            }
        }
    }
}


Measured memory_bytes: 21716
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n, m, i, j, imax = 0;
		n = scan.nextInt();
		m = scan.nextInt();
		int[] game = new int[n + 1];
		int[] member = new int[m + 1];
		int[] memberf = new int[m + 1];
		int[] result = new int[n + 1];
		for(i = 0; i < n; i++){
			game[i] = scan.nextInt();
		}
		for(i = 0; i < m; i++){
			member[i] = scan.nextInt();
		}
		scan.close();
		for(i = 0; i < n; i++){
			for(j = 0; j < m; j++){
				if(memberf[j] == 0 && game[i] <= member[j]){
					result[i]++;
					memberf[j] = 1;
				}
			}
		}
		for(i = 0; i < n; i++){
			if(result[i] > result[imax]){
				imax = i;
			}
		}
		System.out.println(imax + 1);
	}
}

Measured memory_bytes: 25076
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
struct Edge { int to, cost; };
bool operator<(const Edge& e1, const Edge& e2) { return e1.cost < e2.cost; }
int N, M, Z, p, a, b, w, s[7], t[7], y[15], p1[7], p2[7], r[15], x[2][7], d[1111][1111]; vector<Edge> G[1111];
int main() {
	cin >> N >> M >> Z >> p; p--; r[0] = p;
	for (int i = 0; i < M; i++) {
		cin >> a >> b >> w; a--, b--;
		G[a].push_back(Edge{ b, w });
		G[b].push_back(Edge{ a, w });
	}
	for (int i = 0; i < Z; i++) {
		cin >> s[i] >> t[i]; s[i]--, t[i]--;
	}
	y[0] = p;
	for (int i = 0; i < Z; i++) y[i + 1] = s[i];
	for (int i = 0; i < Z; i++) y[i + Z + 1] = t[i];
	for (int g = 0; g < Z * 2 + 1; g++) {
		int i = y[g];
		priority_queue<Edge> que; que.push(Edge{ i, 0 });
		fill(d[i], d[i] + N, 999999999); d[i][i] = 0;
		while (!que.empty()) {
			int v = que.top().to; que.pop();
			for (auto &e : G[v]) {
				if (d[i][e.to] > d[i][v] + e.cost) {
					d[i][e.to] = d[i][v] + e.cost;
					que.push(Edge{ e.to, d[i][e.to] });
				}
			}
		}
	}
	long long ret = 999999999;
	for (int i = 0; i < (1 << (2 * Z)); i++) {
		int dep = 0; bool flag = true;
		for (int j = 0; j < 2 * Z; j++) {
			if (i & (1 << j)) dep--;
			else dep++;
			if (dep < 0) flag = false;
		}
		if (dep != 0) flag = false;
		if (!flag) continue;
		for (int j = 0; j < Z; j++) p1[j] = p2[j] = j;
		do {
			int cr1 = 0;
			for (int j = 0; j < 2 * Z; j++) {
				if (!(i & (1 << j))) {
					x[0][p1[cr1]] = j;
					r[j + 1] = s[p1[cr1++]];
				}
			}
			do {
				int cr2 = 0;
				for (int j = 0; j < 2 * Z; j++) {
					if (i & (1 << j)) {
						x[1][p2[cr2]] = j;
						r[j + 1] = t[p2[cr2++]];
					}
				}
				bool e = true;
				for (int j = 0; j < Z; j++) {
					if (x[0][j] > x[1][j]) {
						e = false;
						break;
					}
				}
				if (!e) continue;
				bool ok = true;
				long long res = 0;
				for (int j = 0; j < 2 * Z; j++) {
					res += d[r[j]][r[j + 1]];
				}
				ret = min(ret, res);
			} while (next_permutation(p2, p2 + Z));
		} while (next_permutation(p1, p1 + Z));
	}
	if (ret == 999999999) cout << "Cannot deliver" << endl;
	else cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3316
use std::cmp::max;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    loop {
        let h:usize = read();
        let w:usize = read();
        if h == 0 && w == 0 {
            break;
        }
        println!("{}", "#".repeat(w));
        for _ in 0..h-2 {
            println!("#{}#", ".".repeat(w-2));
        }
        println!("{}", "#".repeat(w));
        println!("");
    }
}



Measured memory_bytes: 5032
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl;
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
template<class T>
void dump(vector<T> &vec){
	for(int i=0;i<vec.size();i++){
		cout << vec[i];
		if(i+1<vec.size())cout << ' ';
		else cout << endl;
	}
	return;
}
template<class T>
void input(vector<T>& vec,int n){
	vec.resize(n);
	for(int i=0;i<n;i++){
		cin >> vec[i];
	}
}
void fastio(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
}
int N,M;
ll A[100100];
int main(){
	cin >> N >> M;
	priority_queue<ll> q;
	for(int i=0;i<N;i++){
		cin >> A[i];
		q.push(A[i]);
	}
	for(int i=0;i<M;i++){
		ll a = q.top();
		q.pop();
		q.push(a/2);
	}
	ll ans = 0ll;
	while(!q.empty()){
		ans += q.top();
		q.pop();
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<pair<int,int>> pairs(n);
  int tmp;
  for(int i=0; i<n; i++){
    cin >> tmp;
    pairs.at(i) = make_pair(tmp,i+1);
  }
  sort(pairs.begin(),pairs.end());
  for(int i=0; i<n; i++){
    cout << pairs.at(i).second << ' ';
  }
  cout << endl;
}


Measured memory_bytes: 1664
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))

ans = 0
for i in range(1, len(A1)+1):
    tmp_A1 = A1[0:i:]
    tmp_A2 = A2[i-1:len(A2):]
    #print(tmp_A1)
    #print(tmp_A2)
    tmp_ans = sum(tmp_A1) + sum(tmp_A2)
    if ans < tmp_ans:
        ans = tmp_ans

print(ans)

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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

char kr(int x,int y);

int h,w;
char s[52][52];

main() {
    cin >> h >> w;
    rep1(i,h) rep1(j,w) cin >> s[i][j];
    rep1(i,h) rep1(j,w) if (s[i][j] == '.') s[i][j] = kr(i,j);
    rep1(i,h) {
        rep1(j,w) cout << s[i][j];
        cte
    }
}

char kr(int x,int y) {
    int dx[3]={1,0,-1},dy[3]={1,0,-1},cnt=0;
    rep(i,3) rep(j,3) if (s[x+dx[i]][y+dy[j]] == '#') cnt++;
    return (char)(cnt+'0');
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
            out.flush();
        }
    }

    private void solve(InputReader in, PrintWriter out) {
        int a = in.nextInt();
        int b = in.nextInt();
        int t = in.nextInt();

        out.println(t / a * b);
    }
}

class InputReader implements AutoCloseable {
    private final Scanner sc = new Scanner(System.in);

    String next() {
        return this.sc.next();
    }

    int nextInt() {
        return Integer.parseInt(this.sc.next());
    }

    long nextLong() {
        return Long.parseLong(this.sc.next());
    }

    double nextDouble() {
        return Double.parseDouble(this.sc.next());
    }

    @Override
    public void close() {
        this.sc.close();
    }
}


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

using namespace std;

vector<int> vect(1e5+10);

vector<int> dp(1e5+10);

int main(){
	int n,k;
	cin>>n>>k;
	for(int i = 1;i<=n;i++){
		cin>>vect[i];
	}
	dp[2] = abs(vect[2]-vect[1]);
	for(int i = 3;i<=n;i++){
		dp[i] = abs(vect[i]-vect[i-1])+ dp[i-1];
		for(int j = i-2;j>=max(1,i-k);j--)
		dp[i] = min(abs(vect[i]-vect[j])+dp[j], dp[i]);
	}
	// for(int i = 1;i<=n;i++){
	// 	cout<<dp[i]<<" ";
	// }
	// cout<<endl;

	cout<<dp[n]<<endl;
	return 0;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
  
int main()
{
  long long N, B, R;
  cin >> N >> B >> R;

  long long A = B + R;
  long long Ba = N / A;
  long long Bb = N % A;
  
  long long Bc = Ba * B;
  if(Bb < B)
    Bc = Bc + Bb;
  else
    Bc = Bc + B;
    
  cout << Bc << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  int x,y,z,k; cin >> x >> y >> z >> k;
  vector<ll> a(x), b(y), c(z);
  rep(i, x) cin >> a[i];
  rep(i, y) cin >> b[i];
  rep(i, z) cin >> c[i];

  rep(i, x) rep(j, y) rep(k, z){
    continue;
  }

  vector<ll> a_b;
  rep(i, x) rep(j, y) a_b.pb(a[i]+b[j]);
  sort(all(a_b),greater<ll>());

  vector<ll> ans;
  rep(i, min(x*y,k)) rep(j, z) ans.pb(a_b[i]+c[j]);
  sort(all(ans),greater<ll>());

  rep(i, k){
    std::cout << ans[i] << '\n';
  }
}


Measured memory_bytes: 43240