akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int d;
    cin >> d;
    while(d--){
        int x, y, w, h;
        cin >> x >> y >> w >> h;
        int n, ans = 0;
        cin >> n;
        for(int i = 0; i < n; i++){
            int catX, catY;
            cin >> catX >> catY;
            ans += x <= catX && catX <= x + w && y <= catY && catY <= y + h;
        }
        cout << ans << "\n";
    }
}


Measured memory_bytes: 3032
#include <stdio.h>
#include <stdint.h>

int64_t pwr(int64_t x, int k)
{
    if (k == 0) return 1;
    if (k % 2) return x * pwr(x, k - 1);
    return pwr(x * x, k / 2);
}

int main(void)
{
    int n, p, a;
    int odd = 0, even = 0;
    scanf("%d%d", &n, &p);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a);
        if (a % 2) odd++;
        else even++;
    }
    int64_t ans = odd? (int64_t)1 << (n - 1): (int64_t)(1 - p) << n;
    printf("%lld\n", ans);
    return 0;
}


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

int main() {
  string a;
  cin >> a;
  int n=a.size(), b=0;
  for (int i=0; i<n; i++) {
    if (a.at(i)=='+') {
      b++;
    }
    else {
      b--;
    }
  }
  cout << b << endl;
}


Measured memory_bytes: 256
N,K = map(int,input().split())

A = list(map(int,input().split()))

B = []
for i in range(N):
    SUM = 0
    for j in range(i,N):
        SUM += A[j]
        B.append(SUM)
        
B = list(sorted(B,reverse=True))

MAX = B[0]
two = 1
POW = 1
while(MAX>=two*2):
    two*=2
    POW+=1
#print(two,POW,B)

#MAXBITソート
for p in range(POW)[::-1]:
    C = list(filter(lambda x:x>=two,B))
    if len(C)>=K:
        break
    else:
        two//=2
        
POW = p+1

for p in range(POW):
    D = list(filter(lambda x:(x//two)%2==1,C))
    #print(D)
    LEN = len(D)
    if LEN>=K:
        C = D[:]
        if LEN==K:break
    two//=2

ans = C[0]
for c in C[1:K]:
    ans &= c
    
print(ans)

Measured memory_bytes: 35172
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
string S;
int M;

int main(void){
	//IO("test.in", "test.out");
	M = INT_MAX;
	cin >> S;
	for(int i = 0; i < S.length() - 2; i++){
		int n = stoi(S.substr(i, 3));
		if(abs(n - 753) < M) M = abs(n - 753);
	}
	printf("%d\n", M);
}

Measured memory_bytes: 256
import sys
n=int(input())
c=[int(i) for i in sys.stdin]
#連続した数を除去したlist
d=[]
#前の数を保存する変数
stack=0
for i in c:
  if i!=stack:
    d.append(i)
  stack=i
#0で初期化
x=[0]*200001
sum=1
p=10**9+7
for i in range(0,len(d)):
  x[d[i]]= (x[d[i]]+sum)%p
  sum=x[d[i]]%p
print(sum)

Measured memory_bytes: 18072
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main(void){
	int A,B;
	scanf("%d %d", &A,&B);
	if (A+B >= 10) {
		printf("error\n");
	}else{
		printf("%d\n",A+B);
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;

const LLI mod = 998244353;

int64_t power(int64_t n, int64_t p, int64_t m){
  int64_t ret = 1;
  while(p>0){
    if(p&1) (ret *= n) %= m;
    (n *= n) %= m;
    p /= 2;
  }
  return ret;
}



int main(){
  int N;
  while(cin >> N){
    vector<int> D(N); cin >> D;

    map<int,int> count;
    REP(i,N){
      count[D[i]] += 1;
    }

    LLI ans = 0;

    if(D[0] == 0 and count[0] == 1){
      int c = 1;

      ans = 1;

      FORE(i,1,N){
        if(c != N and count[i] == 0){
          ans = 0;
          break;
        }

        (ans *= power(count[i-1], count[i], mod)) %= mod;
        c += count[i];
      }
    }

    
    
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 5376
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long a = scanner.nextLong();
        long b = scanner.nextLong();
        long count = (n-n%(a+b))/(a+b);
        long instance = n%(a+b);
        count *= a;
        if (instance<=a){

            count += instance;
        }else{
            count += a;
        }
        System.out.println(count);
    }

}

Measured memory_bytes: 25044
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-variable"
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<PII> B(n),R(n);
    REP(i,n) cin >> R[i].first >> R[i].second;
    REP(i,n) cin >> B[i].first >> B[i].second;
    sort(ALL(R));
    sort(ALL(B));
    int ans=0,j=0;
    // cout << '\n';
    // REP(i,n) {
    //     cout << R[i].first << ' ' << R[i].second << '\n';
    // }
    // cout << '\n';
    // REP(i,n) {
    //     cout << B[i].first << ' ' << B[i].second << '\n';
    // }
    // cout << '\n';

    for ( int i=n-1; i>=0; i-- ) {
        vector<PII> v;
        int j=0;
        for ( j=0; j<B.size(); j++ ) {
            if ( B[j].first>R[i].first ) {
                v.push_back(make_pair(B[j].second,j));
            }
        }
        if ( v.size()==0 ) continue;
        sort(ALL(v));
        auto it=upper_bound(ALL(v),make_pair(R[i].second,-1));
        if ( it==v.end() ) continue;
        // cout << R[i].first << ' ' << R[i].second << '\n';
        // cout << B[it->second].first << ' ' << B[it->second].second << '\n';
        ans++;
        B.erase(B.begin()+it->second);
    }
    cout << ans << '\n';
    return 0;
}


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

using namespace std;

const int inf = 1 << 30;

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> h(N);

	for (auto &x : h) {
		cin >> x;
	}

	vector<int> dp(N, inf);

	dp[0] = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N && j <= i + K; ++j) {
			dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
		}
	}

	cout << dp[N - 1] << endl;
}

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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair	
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld;	
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
	 
const ll MAX = 100400;
const ll inf = 1e18+5;

int main() {
	fastio;
	ll a[5],ans;
	f(i,0,5){
		cin>>a[i];
	}
	sort(a,a+5);
	f(i,0,5){
		if(a[i]!=a[i-1]+1) ans=i;
	}
	if(a[4]!=5) ans=5;
	cout<<ans;
	return 0;
	}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
template <typename T>
void warshall_floyd(vector<vector<T>> &g, T inf) {
    rep(k, g.size()) {
        rep(i, g.size()) {
            rep(j, g.size()) {
                if (g[i][k] == inf || g[k][j] == inf) continue;
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }
}

/*
vector<vector<ll>> G(V, vector<ll>(V,INF));
rep(i,V) G[i][i]=0;
rep(i,E)G[from][to]=cost;
warshall_floyd(G, )
*/

int main() {
    init();
    vvc<ll> G(10, vl(10));
    ll H, W;
    cin >> H >> W;
    rep(i, 10) rep(j, 10) cin >> G[i][j];
    warshall_floyd(G, INF);

    ll ans = 0;
    rep(i,H)rep(j,W){
        ll a;
        cin >> a;
        if (a == -1) continue;
        ans += G[a][1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// https://www.codechef.com/viewsolution/21892667
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int maxn=1e5+10;
int dfn[maxn],n,m,T,fr[maxn],tg[maxn],to[maxn],dd[maxn];
vector<pii>G[maxn];
void dfs(int u,int f){
   dfn[u]=1;
   for(auto v:G[u])if(!dfn[v.first]){
      dfs(v.first,u);
      if(!tg[v.first])dd[v.second]=0;
      else dd[v.second]=1,tg[v.first]^=1,tg[u]^=1;
   }
}
int main(){
   int T = 1;
   // scanf("%d",&T);
   while(T--){
      scanf("%d%d",&n,&m);
      for(int i=1;i<=n;++i)G[i].clear(),tg[i]=0,dfn[i]=0;
      for(int i=1,u,v;i<=m;++i){
         scanf("%d%d",&u,&v);
         fr[i]=u,to[i]=v;
         G[u].push_back(pii(v,i));
         G[v].push_back(pii(u,i));
         dd[i]=0,tg[v]^=1;
      }
      int flg=1;
      for(int i=1;i<=n;++i)flg&=tg[i]==0;
      if(flg==1){
         for(int i=1;i<=m;++i){
            if(dd[i] == 0){
               printf("%d %d\n", to[i], fr[i]);               
            }
            else{
               printf("%d %d\n", fr[i], to[i]);
            }
         }
      } else {
         dfs(1,0);
         
         int flg=1;
         for(int i=1;i<=n;++i)flg&=tg[i]==0;
         if(flg==1){
         for(int i=1;i<=m;++i){
            if(dd[i] == 0){
               printf("%d %d\n", to[i], fr[i]);               
            }
            else{
               printf("%d %d\n", fr[i], to[i]);
            }
         }
         } else puts("-1");
      }
   }
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  ll a[n],b[n],c[n];
  rep(i,n){
    cin >> a[i] >> b[i] >> c[i];
  }
  ll dp[3],ndp[3];
  dp[0]=a[0];dp[1]=b[0];dp[2]=c[0];
  rep1(i,n-1){
    ndp[0]=max(dp[1],dp[2])+a[i];
    ndp[1]=max(dp[2],dp[0])+b[i];
    ndp[2]=max(dp[0],dp[1])+c[i];
    swap(dp,ndp);
  }
  cout << *max_element(dp,dp+3) << endl;
  
  
  return 0;
    

}


Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });

            int N;int R;
            Multi(out N, out R);
            var ans = N >= 10 ? R : R + 100 * (10 - N);

            Console.WriteLine(ans);


            Console.Out.Flush();
            Console.ReadKey();
        }

        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public char GetChar() { return Console.ReadLine().Trim()[0]; }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V,W>(out T a, out U b, out V c, out W d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);
        }
        static void Multi<T, U, V, W,X>(out T a, out U b, out V c, out W d,out X e)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);e = cv<X>(ar[4]);
        }
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <stack>
#include <set>
#include <algorithm>
using namespace std;
#define ll long long int


int main() {
  int a,b,t;
  cin >> a >> b >> t;

  int ans = ( t/a ) * b;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 888
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort()

answer = 0
for b in range(1, len(L)):
    for a in range(b):
        # c は b より大きい index であり、かつ `L[a] + L[b] < L[c]` である
        # c を二分探索で探す
        r = bisect.bisect_left(L, L[a] + L[b], 0, N)
        l = b + 1

        answer += max(0, r - l)

print(answer)


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <map>
#include <algorithm>

using namespace std;
typedef map<string, void(*)> funcs_type;

void print(string &s, int a, int b){
	if(a < 0 || a > b || b > s.size()) return;
	for(int i = a; i <= b; i++)
		cout << s[i];
	cout << endl;
}

void reverse(string &s, int a, int b){
	if(a < 0 || a > b || b > s.size()) return;
	for(int i = a, j = b; i < j; i++, j--)
		swap(s[i], s[j]);
}

void replace(string &s, int a, int b, string p){
	if(a < 0 || a > b || b > s.size()) return;
	if(b - a + 1 != p.size()) return;
	for(int i = 0; i < b-a+1; i++)
		s[a+i] = p[i];
}

int main(){
	string str, cmd, p;
	int n, a, b;
	cin >> str;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> cmd;
		if(cmd == "print"){
			cin >> a >> b;
			print(str, a, b);
		}
		if(cmd == "reverse"){
			cin >> a >> b;
			reverse(str, a, b);
		}
		if(cmd == "replace"){
			cin >> a >> b >> p;
			replace(str, a, b, p);
		}
	}
	return 0;
}

Measured memory_bytes: 1216
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        Integer[] H = new Integer[N];
        long sum = 0;
        for(int i=0; i<N; i++){
            H[i] = sc.nextInt();
        }
        Arrays.sort(H,  Collections.reverseOrder());
        
        for(int i=K; i<N; i++) {
            sum += H[i];
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 90412
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> S(N), T(M);

    for (int i = 0; i < N; i++) {
        scanf("%d", &S[i]);
    }

    for (int i = 0; i < M; i++) {
        scanf("%d", &T[i]);
    }

    long long dp[N][M];
    long long sum[N][M];

    dp[0][0] = S[0] == T[0] ? 2 : 1;
    sum[0][0] = dp[0][0];

    for (int i = 1; i < N; i++) {
        dp[i][0] = S[i] == T[0] ? 1 : 0;
        sum[i][0] = sum[i - 1][0] + dp[i][0];
    }
    for (int j = 1; j < M; j++) {
        dp[0][j] = S[0] == T[j] ? 1 : 0;
        sum[0][j] = sum[0][j - 1] + dp[0][j];
    }

    for (int i = 1; i < N; i++) {
        for (int j = 1; j < M; j++) {
            if (S[i] == T[j]) dp[i][j] = sum[i - 1][j - 1];
            else dp[i][j] = 0;
            sum[i][j] = ((sum[i - 1][j] + sum[i][j - 1]) % MOD + dp[i][j]) % MOD >= sum[i - 1][j - 1]
                        ? ((sum[i - 1][j] + sum[i][j - 1]) % MOD + dp[i][j]) % MOD - sum[i - 1][j - 1]
                        : ((sum[i - 1][j] + sum[i][j - 1]) % MOD + dp[i][j]) % MOD + MOD - sum[i - 1][j - 1];
        }
    }

    cout << sum[N - 1][M - 1] << endl;

    return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

int main(int argc, char const *argv[]) {
	ll a, b, c; cin >> a >> b >> c;
	ll k; cin >> k;

	vector<ll> v;
	v.push_back(a);
	v.push_back(b);
	v.push_back(c);
	sort(v.begin(), v.end());

	ll d = v[2];
	rep(i, k) d *= 2;
	cout << v[0] + v[1] + d << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int last[26];

int calcScore(int D, vector<int> c, vector<vector<int>> s, vector<int> t){
	int sat = 0;
	memset(last, 0, sizeof(last));

//	vector<int> res; res.clear();
	rep (d, (int)t.size()){
		int j = t[d];
		last[j] = d + 1;
		rep (i, 26){
			sat -= (d + 1 - last[i]) * c[i];
		} // end rep
		sat += s[d][j];
	} // end rep
	return sat;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int D; cin >> D;
	vector<int> c(26, 0);
	rep (i, 26){
		cin >> c[i];
	} // end rep
	vector<vector<int>> s(D, vector<int>(26, 0));
	rep (i, D){
		rep (j, 26){
			cin >> s[i][j];
		} // end rep
	} // end rep

	vector<int> res; res.clear();
	vector<int> best; best.clear();

	rep (i, D){
        int bestScore = -(int)1e7;
		rep (j, 26){
            if (j == 0){
                res.push_back(j);
            }else{
    			res[(int)res.size() - 1] = j;
            } // end if
			int score = calcScore(D, c, s, res);
			if (score > bestScore){
				bestScore = score;
				best = res;
			} // end if
		} // end rep
		res = best;
	} // end rep
    rep (i, (int)best.size()){
        cout << best[i]+1 << endl;
    } // end rep

	return 0;
}


Measured memory_bytes: 3828
using System;

class ITP1_6_D
{
    public static void Main()
    {
        string[] Num = Console.ReadLine().Split(' ');
        int n = int.Parse(Num[0]);
        int m = int.Parse(Num[1]);

        int[,] matrixA = new int[n, m];
        int[] matrixB = new int[m];
        int[] matrixC = new int[n];

        for (int i = 0; i < n; i++)
        {
            string[] Input = Console.ReadLine().Split(' ');
            for (int j = 0; j < m; j++) {
                matrixA[i, j] = int.Parse(Input[j]);
            }
        }

        for (int i = 0; i < m; i++) {
            matrixB[i] = int.Parse(Console.ReadLine());
        }

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                matrixC[i] += matrixA[i, j] * matrixB[j];
            }
        }

        for (int i = 0; i < n; i++) {
            Console.WriteLine(matrixC[i]);
        }
    }
}

Measured memory_bytes: 9212
# include <iostream>
# include <cmath>
typedef long long ll;
using namespace std;

int main () {
    ll x;
    cin >> x;
    float rate = 0.01;
    ll P = 100;
    ll time(0);
    // time = log2((double) x / (double) P) / log2(1.01);
    while (P < x) {
        P += P / 100;
        time++;
    }
    cout << time << "\n";
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[b]+=siz[a];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=998244353;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int 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;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
signed main(){
	int n;
	cin>>n;
	int a[100010];
	rep(i,n)cin>>a[i];
	int cnt1=0,cnt2=0;
	rep(i,n){
		if(a[i]%2==0)cnt1++;
		else cnt2++;
	}
	if(cnt2%2==0)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI3(N, M, K);
  for (int a = 0; a <= N; ++a) {
    for (int b = 0; b <= M; ++b) {
      if ((N - a) * b + (M - b) * a == K) {
        print("Yes");
        return 0;
      }
    }
  }
  print("No");
  return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(1000000)

def main():
    s = readline().rstrip().decode()
    K = int(readline())
    #sに含まれる文字を一文字ずつ抽出する.
    #ここで抽出した文字を組み合わせて辞書順に文字列を構成していく
    l = sorted(list(set(s)))

    #cnd:=構成した文字列を辞書順に格納するリスト
    cnd = []

    #f(sub):=subから構成可能なK文字以下のSの部分文字列を構成する関数

    #計算量について
    #長さNの文字列から作るsubstringのうち長さが5以下のsubstringの数を計算する
    #長さ5のsubstirngは(N-5+1)個
    #長さ4のsubstringは(N-4+1)個
    #同様に長さ1まで考えて、合計すると約5N個となる

    def f(sub):
        cnd.append(sub)
        if len(sub) <= K: 
            #lから選んでsubに一文字追加する
            for i in l:
                nx = sub+i
                #if nx in s:はO(N)
                if nx in s:
                	f(nx)
    #O(N^2K)
    for i in l:
        f(i)
    print(cnd[K-1])
if __name__ == '__main__':
    main()


Measured memory_bytes: 4284
K,N=map(int,input().split())
A=list(map(int,input().split()))

L=[0]*N
L[0]=A[0]+K-A[N-1]
for i in range(1,N):
  L[i]+=A[i]-A[i-1]
  
ans=K-max(L)
print(ans)

Measured memory_bytes: 26444
#include<algorithm>
#include<cstdio>
#define LL long long
using namespace std;
const int mod=1e9+7;
int n,m,N,sl,fh,ans,a[20],fac[1<<16],ifc[1<<16],num[1<<16],dp[1<<16];
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
int _pow(int k,int i)
{
	int t=1;
	for(;i;i>>=1,k=1ll*k*k%mod)
		if(i&1)
			t=1ll*t*k%mod;
	return t;
}
LL C(int x,int y) {return 1ll*fac[x]*ifc[y]%mod*ifc[x-y]%mod;}
void upd(int &x,int y) {x+=y; if(x>=mod) x-=mod;}
int main()
{
	n=rd();m=rd();N=1<<n;fac[0]=1;
	for(int i=m;i;--i) a[i]=rd();
	for(int i=1;i<N;++i) fac[i]=1ll*i*fac[i-1]%mod,num[i]=num[i>>1]+(i&1);
	ifc[N-1]=_pow(fac[N-1],mod-2);
	for(int i=N-1;i;--i) ifc[i-1]=1ll*i*ifc[i]%mod;
	if(!m) {printf("%lld\n",1ll*N*fac[N-1]%mod); return 0;}
	dp[0]=1;
	for(int i=1;i<=m;++i)
		for(int j=N-1;~j;--j)
			if(dp[j])
				for(int k=1;k<=n;++k)
					if(!((j>>k-1)&1)&&N-a[i]-j>=(1<<k-1)-1)
						dp[j|(1<<k-1)]=(dp[j|(1<<k-1)]+dp[j]*C(N-a[i]-j,(1<<k-1)-1)%mod*fac[1<<k-1])%mod;
	for(int i=0;i<N;++i) dp[i]=1ll*dp[i]*fac[N-i-1]%mod;
	for(int i=0;i<N;++i)
		if(num[i]&1) upd(ans,mod-dp[i]);
		else upd(ans,dp[i]);
	printf("%lld\n",1ll*N*ans%mod);
	return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define INF ((1LL<<62)-(1LL<<31))

//辺の情報を個別に持つタイプ
typedef struct edge{ll s,g,c;}E;
typedef struct graph{
	int vcnt,ecnt;
	E  e[500010];//適宜変える
	int id[100010];//適宜変える
}G;

int esort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}

G g;
ll start;
void readgraph(){
	//適宜変える
	ll n,m;
	scanf("%lld%lld%lld",&n,&m,&start);
	rep(i,0,m){
		ll x,y,c;
		scanf("%lld%lld%lld",&x,&y,&c);
		g.e[i].s=x;
		g.e[i].g=y;
		g.e[i].c=c;
	}
	g.vcnt=n;
	g.ecnt=m;
	qsort(g.e,g.ecnt,sizeof(E),esort);

	int p=0;
	rep(i,0,g.vcnt){
		while(p<g.ecnt&&g.e[p].s<i)p++;
		g.id[i]=p;
	}
	g.id[g.vcnt]=g.ecnt;//番兵
}

//プラキュー（二分ヒープ）（優先度変更ありバージョン）
ll heapN,heap[1<<20],heapinv[1<<20];
int PQhikaku(int i,int j);//jの方が優先度が高いならtrueを返す
void PQchange(int n);
void heap_utod(int n){
	if(2*n>heapN)return;
	int rflag=(2*n+1<=heapN)&&(PQhikaku(2*n,2*n+1));
	if(PQhikaku(n,2*n+rflag)){
		ll temp=heap[2*n+rflag];
		heap[2*n+rflag]=heap[n];
		heap[n]=temp;
		heapinv[heap[n]]=n;
		heapinv[heap[2*n+rflag]]=2*n+rflag;	
		heap_utod(2*n+rflag);
	}
}
void heap_dtou(int n){
	if(n==1||PQhikaku(n,n/2))return;
	ll temp=heap[n];
	heap[n]=heap[n/2];
	heap[n/2]=temp;
	heapinv[heap[n]]=n;
	heapinv[heap[n/2]]=n/2;
	heap_dtou(n/2);
}
ll PQpop(){
	ll rr=heap[1];
	heapinv[heap[1]]=0;
	heap[1]=heap[heapN--];
	heapinv[heap[1]]=1;
	heap_utod(1);
	return rr;
}
void PQpush(ll n){
	heap[++heapN]=n;
	heapinv[heap[heapN]]=heapN;
	heap_dtou(heapN);
}

//早い方のダイクストラ
//グラフと始点を引いて各点への最短距離・最短経路を返す
//プラキューが必要
//O((E+V)logV)
ll daikusutorappp[1<<20];
void daikusutora2(ll s){
	rep(i,0,g.vcnt)daikusutorappp[i]=i==s?0:INF;
	rep(i,0,g.vcnt)PQpush(i);
	while(heapN){
		ll mv=PQpop();
		for(ll t=g.id[mv];t<g.ecnt&&g.e[t].s==mv;t++){
			if(daikusutorappp[g.e[t].g]>daikusutorappp[mv]+g.e[t].c){
				daikusutorappp[g.e[t].g]=daikusutorappp[mv]+g.e[t].c;
				PQchange(g.e[t].g);
			}
		}
	}
}
int PQhikaku(int i,int j){return daikusutorappp[heap[i]]>daikusutorappp[heap[j]];}
void PQchange(int n){if(heapinv[n])heap_dtou(heapinv[n]);}

int main(){
	readgraph();
	daikusutora2(start);
	rep(i,0,g.vcnt)printf(daikusutorappp[i]==INF?"INF\n":"%lld\n",daikusutorappp[i]);
}


Measured memory_bytes: 18684
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int MAXN=100010, LOG=20;

int n, m, k, u, v, x, y, t, a, b, ans;
int A[MAXN], sum[MAXN];
bool mark[MAXN];
string S, T;
vector<int> G[MAXN];

void add(int l, int r){
	G[l].pb(r+1);
	G[r+1].pb(l);
}

int dfs(int node){
	mark[node]=1;
	for (int v:G[node]) if (!mark[v]) sum[node]+=dfs(v);
//	debug2(node, sum[node])
	return sum[node];
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>S>>m;
	int len=S.size();
	n=len/2;
	for (int i=0; i<n; i++) T+=S.back(), S.pop_back();
	if (len&1) S.pop_back();
	debug(S)
	debug(T)
	
	for (int i=1; i<=n; i++) A[i]=S[n-i]-T[n-i];
	for (int i=1; i<=n+1; i++) sum[i]=A[i]-A[i-1];
	while (m--){
		cin>>x>>y;
		if (len%2){
			if (x==n+1 && y==n+1) continue ;
			if (x==n+1) x++;
			if (y==n+1) y--;
			if (x>n) x--;
			if (y>n) y--;
		}
		if (x<=n && y<=n) x=n-x+1, y=n-y+1, swap(x, y);
		else if (x>n && y>n) x-=n, y-=n;
		else{
			x=n-x+1;
			y-=n;
			if (x>y) swap(x, y);
			x++;
		}
		add(x, y);
	}
	debug(len)
	for (int i=1; i<=n+1; i++) if (!mark[i] && dfs(i)%26) kill("NO")
	kill("YES")
	
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<vector<int>> t(4, vector<int>(13));
  vector<char> a={'S', 'H', 'C', 'D'};
  rep(i, n){
    char c;
    int k;
    cin >> c >> k;
    if(c=='S') t[0][k-1]++;
    if(c=='H') t[1][k-1]++;
    if(c=='C') t[2][k-1]++;
    if(c=='D') t[3][k-1]++;
  }

  rep(i, 4){
    rep(j, 13){
      if(t[i][j]==0) cout << a[i] << " " << j+1 << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define for_range(i, a, b) for (int i = (a); i < (b); i++)
#define for_range_rev(i, a, b) for (int i = (b)-1; i >= (a); i++)
using namespace std;
using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using u32 = uint_fast32_t;
const u64 MOD = 1'000'000'007;
// const u64 MOD = 998'244'353;

int ceil_pow2(int n) {
    int x = 0;
    while ((1u << x) < (u32)(n)) x++;
    return x;
}

struct disjoint_set {
    int n;
    vector<int> d;

    disjoint_set() : n(0) {}
    disjoint_set(int sz) : n(sz), d(n, -1) {}

    int find(int a) {
        assert(0 <= a && a < n);
        if (d[a] < 0) return a;
        return d[a] = find(d[a]);
    }

    int unite(int a, int b) {
        assert(0 <= a && a < n);
        assert(0 <= b && b < n);
        int x = find(a), y = find(b);
        if (x == y) return x;
        if (-d[x] < -d[y]) swap(x, y);
        return d[y] = x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < n);
        assert(0 <= b && b < n);
        return find(a) == find(b);
    }

    int size(int a) {
        assert(0 <= a && a < n);
        return -d[find(a)];
    }

    vector<vector<int>> groups() {
        vector<int> f(n), g(n);
        for_range(i, 0, n) {
            f[i] = find(i);
            g[f[i]]++;
        }
        vector<vector<int>> r(n);
        for_range(i, 0, n) r[i].reserve(g[i]);
        for_range(i, 0, n) r[f[i]].push_back(i);
        r.erase(remove_if(r.begin(), r.end(),
                          [&](vector<int>& v) { return v.empty(); }),
                r.end());
        return r;
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    disjoint_set ds(n);
    for_range(i, 0, q) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0)
            ds.unite(u, v);
        else
            cout << (int)ds.same(u, v) << '\n';
    }
}

Measured memory_bytes: 4056
def Get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def Get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def Get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def Get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end

a,b,c=Get_i()
puts c<=a+b ? "Yes" : "No"

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

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	int ans;

	for (int i = 0; i < N; i++) {
		if (i == 0) {
			ans = K;
		}
		else {
			ans *= (K - 1);
		}
	}
	
	cout << ans << endl;

	return 0;
}

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

int main()
 {
	//code
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n1,n;
	cin>>n1;
	int sum=0;
	n=n1;
	while(n)
    {
        sum=sum+n%10;
        n=n/10;
    }
    if(sum==1 && n1>1)
    {
        cout<<"10\n";
    }
    else
        cout<<sum<<"\n";
    return 0;
 }



Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i, max = 0, cnt = 0;
	char t[11];
	
	scanf("%s", t);
	
	for(i = 0; i < strlen(t); i++){
		if(t[i] == 'A' || t[i] == 'C' || t[i] == 'G' || t[i] == 'T'){
			cnt++;
			if(cnt > max){
				max = cnt;
			}
		}else
			cnt = 0;
	}
	
	printf("%d", max);

	return 0;
}

Measured memory_bytes: 128
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int N, M;  cin >> N >> M;
    vi X(M); REP(i, M) cin >> X[i];

    if (N >= M){
        cout << 0 << endl;
        return 0;
    }

    sort(X.begin(), X.end());

    vi dist = vi(M-1);
    REP(i, M-1) dist[i] = X[i+1] - X[i];
    
    sort(dist.begin(), dist.end());

    int ans = 0;
    REP(i,(M-1)-(N-1)) {
        ans += dist[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
using namespace std;
int ans;
signed main(){
	int n,X;
	cin>>n>>X;
	vector<int>x(n+1),sa(n);
	for(int i=0;i<n;i++){
		cin>>x[i];
	}
	x[n]=X;
	sort(x.begin(),x.end());
	for(int i=0;i<n;i++){
		sa[i]=x[i+1]-x[i];
	}
	while(sa.size()>1){
		for(int i=1;i<sa.size();i+=2){
				sa[i-1]=__gcd(sa[i],sa[i-1]);
		}
		for(int i=1;i<sa.size();i+=2){
			sa.erase(sa.begin()+i);
		}
	}
	cout<<sa[0]<<endl;
}

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

int  main()
{
    int a,b,c,d,e,f,g,h,i,j;
    map<int,int>m;
    map<int,int>::iterator it;
    vector<int>v;
    int n,k,tc;
    cin >> n;
    int ans= n;
    for(int i =0; i <= n; i++)
    {
        int cnt = 0;
        int tmp = i;
        while(tmp > 0)
        {
            cnt += tmp%6;
            tmp /= 6;
        }
        tmp = n-i;
        while(tmp > 0)
        {
            cnt += tmp%9;
            tmp /= 9;
        }
        if(cnt < ans)
        {
            ans = cnt;
        }
    }
    cout << ans<<endl;
    return 0;
}


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

int main(){
    int N,L;
    cin >> N >> L;
    string s[101];
    for(int i=0; i<N; i++){
        cin >> s[i];
    }
    sort(s,s+N);
    for(int i=0; i<N; i++){
        cout << s[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

signed main(){
    int x,y,z,K; cin>>x>>y>>z>>K;
    vector<int> a(x),b(y),c(z);
    rep(i,x)cin>>a.at(i);
    rep(i,y)cin>>b.at(i);
    rep(i,z)cin>>c.at(i);
    sort(all(a),greater<int>());
    sort(all(b),greater<int>());
    sort(all(c),greater<int>());
    vector<int> vec;
    rep(i,x){
        rep(j,y){
            rep(k,z){
                if((i+1)*(j+1)*(k+1)>K)break;
                vec.push_back(a.at(i)+b.at(j)+c.at(k));
            }
        }
    }
    sort(all(vec),greater<int>());
    rep(i,K){
        cout<<vec.at(i)<<endl;
    }
}

Measured memory_bytes: 1404
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 1000000007;

int trie[1000010][26];
int vi[1000010][26], pa[1000010], cnt[1000010];
char vc[1000010];

int QV[200010];

int T_sz = 1;

//1番目の頂点がすべてのもと

int Trie(string& X, int c, int ind) {
	if (ind == X.size()) {
		return c;
	}
	if (trie[c][X[ind] - 'a']) {
		return Trie(X, trie[c][X[ind] - 'a'], ind + 1);
	}
	T_sz++;
	vc[T_sz] = X[ind];
	pa[T_sz] = c;
	trie[c][X[ind] - 'a'] = T_sz;
	return Trie(X, T_sz, ind + 1);
}

int sear(int c, char ch) {
	if (vc[c] == ch) {
		vi[c][ch - 'a'] = cnt[c];
		for (int i = 0;i < 26;i++) {
			if (trie[c][i] == 0)continue;
			sear(trie[c][i], ch);
		}
		return cnt[c];
	}
	int A = 0;
	for (int i = 0;i < 26;i++) {
		if (trie[c][i] == 0)continue;
		A += sear(trie[c][i], ch);
	}
	vi[c][ch - 'a'] = A;
	return A;
}

int main() {
	int N;
	cin >> N;
	string S;

	int x, xp;

	for (int i = 0;i < 1000010;i++) {
		for (int j = 0;j < 26;j++) {
			trie[i][j] = 0;
			vi[i][j] = 0;
		}
		pa[i] = cnt[i] = 0;
	}

	for (int i = 0;i < N;i++) {
		cin >> S;
		S.push_back('$');
		reverse(all(S));
		x = Trie(S, 1, 1);
		QV[i] = x;
	}

	//各頂点、その文字を含む文字列はいくつあるか
	for (int i = 0;i < N;i++) {
		x = QV[i];
		cnt[x]++;
		while (x != 1) {
			x = pa[x];
			cnt[x]++;
		}
	}

	for (int i = 0;i < 26;i++) {
		sear(1, i + 'a');
	}
	
	ll ans = 0;
	for (int i = 0;i < N;i++) {
		x = QV[i];
		xp = pa[x];
		for (int j = 0;j < 26;j++) {
			if (trie[xp][j] == 0)continue;
			ans += (ll)vi[trie[xp][j]][vc[x] - 'a'];
		}
		ans--;
	}
	cout << ans << endl;
}

Measured memory_bytes: 277016
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

d = 0 # 直前に食べた料理
s = sum(B) # 満足度の合計

for i in range(N-1):
  if A[i]+1==A[i+1]:
    s += C[A[i]-1]

print(s)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 922337203685477;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define maxN 200007
using namespace std;
int main() {
  fastio;
  string s, t;
  cin >> s >> t;
  ll n = s.length(), m = t.length();
  ll ans = INT_MAX;
  for (ll i = 0; i <= n - m; ++i) {
    ll c = 0;
    for (ll j = 0; j < m; ++j) {
      if (t[j] != s[i + j])
        ++c;
    }
    ans = min(ans, c);
  }
  cout << ans;
}

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

int main(void){
    int N, ans=0;
    std::cin >> N;
    std::vector<int> d(N);
    for (int i=0; i<N; ++i){
        std::cin >> d.at(i);
    }
    std::sort(d.begin(), d.end());

    if (d.at(N / 2) != d.at(N / 2 - 1)) {
        ans = d.at(N / 2) - d.at(N / 2 - 1);
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3792
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

int main() {
    int N;
    cin >> N;
    int ans = 0;
    int a = 0; 
    for(int i=0; i < N; i++) {
        cin >> a;
        // if (ans != 0) {
        //     a = a * ans * 3;
        // }

        while(true) {
            if(a % 2 == 1) {
                break;
            } else {
                a = a / 2;
                ans++;
            }
        }
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

signed main() {
	int n, k;
	cin >> n >> k;
	char c[100002];
	rep(i, n) {
		cin >> c[i];
	}
	int ans = 0;
	int now = 0;
	for (int i = 1; i < n; i++) {
		if (c[i] != c[i - 1]) {
			ans += now;
			now = 0;
		}
		else {
			now++;
		}
	}
	ans += now;
	cout << min(n - 1, ans + 2 * k) << endl;

	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 a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();

    if ((a + b) > (c + d)) {
      System.out.println("Left");
    } else if ((a + b) == (c + d)) {
      System.out.println("Balanced");
    } else {
      System.out.println("Right");
    }

  }
}

Measured memory_bytes: 35696
# coding=utf-8

a, b = map(int, input().split())
if a > b:
    big_num = a
    sml_num = b
else:
    big_num = b
    sml_num = a

while True:
    diviser = big_num % sml_num
    if diviser == 0:
        break
    else:
        big_num = sml_num
        sml_num = diviser

print(sml_num)

Measured memory_bytes: 7624
import java.util.Scanner;


	public class Main {
		
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
	        
			double a = sc.nextDouble();
			double b = sc.nextDouble();
			double h = sc.nextDouble();
			double m = sc.nextDouble();
			
			double ret2 = Math.pow(a, 2)+Math.pow(b, 2)-2.0*a*b*Math.cos(Math.toRadians(Math.abs((60.0*h-11.0*m)/2)));
			double ret = Math.sqrt(ret2);
			System.out.println(ret);
			
		}
		
	}


Measured memory_bytes: 37448