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

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

	std::map<int64_t, int> map;

	for (int i = 0; i < n; ++i) {
		int a;
		std::cin >> a;

		++map[a];
	}

	int64_t ans = 0;
	{
		auto it = std::find_if(map.rbegin(), map.rend(), [](auto&& p) { return p.second >= 4; });

		if (it != map.rend())
			ans = it->first * it->first;
	}
	{
		auto it1 = std::find_if(map.rbegin(), map.rend(), [](auto&& p) { return p.second >= 2; });
		auto it2 = std::find_if(++it1, map.rend(), [](auto&& p) { return p.second >= 2; });

		if (--it1 != map.rend() && it2 != map.rend())
			ans = std::max(ans, it1->first * it2->first);
	}

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

Measured memory_bytes: 6528
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
a = []
for _ in range(n):
    a.append(list(map(int,input().split())))
ans = 0
for aa in a:
    tmp = 0
    for bbb,aaa in zip(b,aa):
        tmp += bbb*aaa
    tmp += c
    if tmp > 0:
        ans += 1
print(ans)


Measured memory_bytes: 9180
N = int(input())
A = list(input())
B = list(input())
C = list(input())
count = 0

for i in range(N):
    if(A[i]!=B[i] and A[i]!=C[i] and B[i]!=C[i]):
        count += 2
    elif(A[i]==B[i] or C[i]==B[i] or A[i]==C[i]):
        count += 1

for i in range(N):
    if(A[i]==B[i] and A[i]==C[i]):
        count -= 1


print(count)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define For(i,j,k) for(int i=j;i<=k;++i)
using namespace std;
int read(){
	int x=0,fh=1; char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') fh=-1;
	for (;isdigit(ch);ch=getchar()) x=x*10+(ch^48);
	return x*fh;
}
int main(){
	char s[27],l; bool fl[27]={0}; scanf("%s",s+1); l=strlen(s+1);
	if (l==26){
		For(i,1,l){
			if (s[i]!=122-i+1) break;
			if (i==26) printf("-1\n"),exit(0);
		}
		for(int i=26;i>=1;--i){
			For(j,s[i]+1,122) if (fl[j-96]){
				For(k,1,i-1) printf("%c",s[k]);
				printf("%c",j); return 0;
			}
			fl[s[i]-96]=1;
		}
	}
	else{
		For(i,1,l) fl[s[i]-96]=1;
		printf("%s",s+1);
		For(i,1,26)
			if (!fl[i]) printf("%c",96+i),exit(0);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
#define  st first
#define  nd second
void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
 
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"
 
 
#define MOD   1000000007
const int LN =19;
#define int long long
const int  MAXN = 100004;
 
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef cc_hash_table<int, int, hash<int > > ht;

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  string s ; 
  cin >> s ; 
  for(auto j : s){
      if(j=='7'){
        cout<<"Yes";
        return 0 ; 
      }
  }
  cout<<"No";
  
}
 
 

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

int main() {
  int N, M, C; cin >> N >> M >> C;
  vector<int> B(M);
  int cnt = 0;
  for (int i = 0; i < M; i++) {
    cin >> B.at(i);
  }
  for (int i = 0; i < N; i++) {
    int sum = C;
    for (int j = 0; j < M; j++) {
      int A; cin >> A;
      int AB = A * B.at(j);
      sum += AB;
    }
    if (sum > 0) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

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

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

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

import qualified Data.ByteString.Char8 as B

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

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

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

main = do
	n :: Integer <- readLn
	print $ sum $ map ( check n ) $ takeWhile ( \i -> i * i <= n ) [ 1 .. ]

check n r = if q < m && q * m + r == n then m else 0
	where
		q = r
		m = ( n - r ) `div` q

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

#define int long long
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define str string
#define vint vector<int>
#define vchar vector<char>
#define vool vector<bool>
#define pb() pushback()

main(){
    int a,b,c,count=0,count2=0;
    str S;
    vool alph(26);
    rep(0,26)alph[i]=false;
    cin>>S;
    for(int i=0;S[i]!='\0';i++){
      if(alph[S[i]-'a']==false)alph[S[i]-'a']=true;
    }
    rep(0,26)if(count==0&&alph[i]==false){
      count=i;
      if(i==0)count2+=1;
    }
    char C=count+'a';
    if(count2==1)cout<<'a'<<endl;
    else if(count>0)cout<<C<<endl;
    else cout<<"None"<<endl;
}


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

int main() {
  
  int a,b[200],ans=0,i,ch=0;
  cin >> a;
  for(i=0;i<a;i++){
  cin >> b[i];
  }
  while(1){
    for(i=0;i<a;i++){
      if(b[i]%2==1){
        ch++;break;
      }
      b[i]/=2;
    }
    if(ch==1)break;
    else ans++;
  }
  cout << ans << endl;
      
}


Measured memory_bytes: 256
# 問題：https://atcoder.jp/contests/abc141/tasks/abc141_b

s = input()
i = 1
res = True
for ch in s:
    if i % 2 == 1 and ch == 'L':
        res = False
        break
    elif i % 2 == 0 and ch == 'R':
        res = False
        break
    i += 1

if res:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9004
size = input().split(' ')
H = int(size[0])
W = int(size[1])
S = []
for k in range(H):
    row = input()
    S.append(row)

T = []
for i in range(H):
    TI = ''
    for j in range(W):
        #print('S[i][j]={} i={} j={}'.format(S[i][j],i,j))
        count = 0
        for s in range(0,3):
            for t in range(0,3):
                #print('i+s-1={} j+t-1={}'.format(i+s-1,j+t-1))
                if (0 <= i + s - 1 < H) and (0 <= j + t - 1 < W) and (S[i+s-1][j+t-1] == '#'):
                    count +=1
        if S[i][j] == '#':
            TI = TI + '#'
        elif S[i][j] != '#':
            TI = TI + str(count)
    T.append(TI)
for u in range(H):
    print(T[u])


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int a[4][101],n;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	  scanf("%d",&a[1][i]);
	for (int i=1;i<=n;i++)
	  scanf("%d",&a[2][i]);
	for (int i=2;i<=n;i++)
	  a[1][i]+=a[1][i-1];
	a[2][1]+=a[1][1];
	for (int i=2;i<=n;i++)
	  a[2][i]+=max(a[1][i],a[2][i-1]);
	printf("%d",a[2][n]);
	return 0;
}

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

int main()
{
	int X, Y;
	cin >> X >> Y;
	
	/*
	2*a + 4*b = Y
	a + b = X
	b = X - a
	2*a + 4*(X - a) = Y
	2a + 4X -4a -Y = 0
	4X - Y = 2a
	a = (4X-Y)/2
	*/
	string out = "No";
	int a = (4*X - Y);
	if( a >= 0 && a%2 == 0 ) {
		a /= 2;
		int b = X - a;
		if( b >= 0 ) {
			out = "Yes";
		}
	}
	
	cout << out;
	
	return 0;
}


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

int main()
{
    string str;
    cin >> str;
    string tmp = str;
    reverse(tmp.begin(), tmp.end());
    for (size_t i = 0; i < str.size(); ++i)
    {
        char& ch = tmp[i];
        if (ch == 'b')
            ch = 'd';
        else if (ch == 'd')
            ch = 'b';
        else if (ch == 'p')
            ch = 'q';
        else if (ch == 'q')
            ch = 'p';
    }
    printf("%s\n", tmp == str ? "Yes" : "No");
    cin >> ws;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define sl set<ll>
#define vs vector<string>
#define vl vector<ll>
#define vi vector<int>
#define vpl vector<pair<ll,ll>>
#define pb push_back
#define PI 3.14159265358979323846
#define ll long long
#define ld long double
#define endl "\n"
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repp(i,a,b) for (ll i = (a); i >= (b); i--)
#define rop(i,a,b)  for(ll i=(a); i>(b); i--)
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define tt long long t; cin>>t; while(t--)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
const int maxn=1e5+100;


int main()
{
string a,b;
cin>>a>>b;
ll n=a.length();
ll x=b.length();
ll p[20000];
ll k=0;
for(ll i=0;i<=(n-x);i++)
{ll cnt=0;
    for(ll j=0;j<x;j++)
    {
if(a[i+j]!=b[j])cnt++;
    }
    p[k]=cnt;k++;
}
sort(p,p+k);
cout<<p[0];
}

Measured memory_bytes: 3552
#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream &operator << (ostream &os, const vector<T> &);
template<size_t n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, const tuple<T...> &){}
template<size_t n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream &os, const tuple<T...> &t){
    os << (n == 0 ? "" : " ") << get<n>(t); _ot<n+1>(os, t);
}
template<class...T> ostream &operator << (ostream &os, const tuple<T...> &t){
    _ot<0>(os, t); return os;
}
template<class T, class U> ostream & operator << (ostream &os, const pair<T,U> &p){
    return os << "(" << p.first << ", " << p.second << ") ";
}
template<class T> ostream &operator << (ostream &os, const vector<T> &v){
    for(size_t i = 0; i < v.size(); i++) os << v[i] << (i + 1 == v.size() ? "" : ", "); return os;
}
#ifdef DEBUG
#define dump(...) (cerr << #__VA_ARGS__ << " = " << make_tuple(__VA_ARGS__) \
                   << " (L : " << __LINE__ << ")" << endl)
#else
#define dump(...)
#endif
#define all(c) begin(c), end(c)
#define range(i,a,b) for(int i = a; i < (int)(b); i++)
#define rep(i,b) range(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using ll = long long;
// #define int ll
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
void fastios(){ ios_base::sync_with_stdio(0); cin.tie(0); }
int const mod = 1000000007;
auto const inf = numeric_limits<int>::max()/8;

using Weight = int;
using Capacity = int;
struct Edge {
    int src, dst; Weight weight;
    Edge(int s, int d, int w) : src(s), dst(d), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

vector<Weight> dijkstra(const Graph &g, int s){
    const Weight inf = numeric_limits<Weight>::max()/4;
    typedef tuple<Weight,int> State;
    priority_queue<State> q;
    vector<Weight> dist(g.size(), inf);
    dist[s] = 0; q.emplace(0,s);
    while (q.size()) {
        Weight d; int v;
        tie(d,v) = q.top(); q.pop(); d *= -1;
        /* if(v == t) return d; */
        if (dist[v] < d) continue;
        for(auto & e : g[v]){
            if (dist[e.dst] > dist[v] + e.weight) {
                dist[e.dst] = dist[v] + e.weight;
                q.emplace(-dist[e.dst], e.dst);
            }
        }
    }
    return dist;
}


int main(){
    fastios();
    int n;
    cin >> n;
    Graph g(n);
    rep(i,n){
        int u,k;
        cin >> u >> k;
        rep(j,k){
            int v,c;
            cin >> v >> c;
            g[u].eb(u,v,c);
        }
    }
    auto dist = dijkstra(g,0);
    rep(i,n){
        cout << i << ' ' << dist[i] << '\n';
    }
}

Measured memory_bytes: 9880
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int x, y;
  cin >> x >> y;

  if (y % 2 == 0 && x * 2 <= y && y <= x * 4) cout << "Yes\n";
  else cout << "No\n";

  




  
  return 0;
}


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

typedef long long ll;

const ll MOD = 1e9 + 7;

ll N, M;
vector<ll> S, T;
vector<vector<ll>> Dp;

int main() {
  cin >> N >> M;
  S.resize(N);
  for (ll i = 0; i < N; ++i) cin >> S[i];
  T.resize(M);
  for (ll j = 0; j < M; ++j) cin >> T[j];
  Dp.resize(N + 1);
  for (auto &dp : Dp) dp.resize(M + 1);
  for (ll i = 0; i <= N; ++i) Dp[i][0] = 1;
  for (ll j = 0; j <= M; ++j) Dp[0][j] = 1;
  for (ll i = 1; i <= N; ++i) {
    for (ll j = 1; j <= M; ++j) {
      Dp[i][j] = (Dp[i - 1][j] + Dp[i][j - 1] + MOD - Dp[i - 1][j - 1]) % MOD;
      if (S[i - 1] == T[j - 1]) (Dp[i][j] += Dp[i - 1][j - 1]) %= MOD;
    }
  }
  cout << Dp[N][M] << endl;
  return 0;
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int n;
  cin>>n;
  string s;
  cin>>s;
  ll sr=0,sg=0,sb=0;
  rep(i,n) {
    if(s[i]=='R')sr++;
    if(s[i]=='G')sg++;
    if(s[i]=='B')sb++;
  }
  ll x=0;
  repeat(j,1,n-1) {
    repeat(d,1,n) {
      int i=j-d;
      int k=j+d;
      if(i<0||n<=k)
	break;
      if(s[i]!=s[j]&&s[i]!=s[k]&&s[j]!=s[k]) {
	x++;
      }
    }
  }
  cout << sr*sg*sb-x << endl;
  return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a[200000],b[200000];
	cin>>n;
	pair<int,int>ab[200000];
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
		ab[i]=make_pair(b[i],a[i]);
	}
	sort(ab,ab+n);
	int time=0;
	for(int i=0;i<n;i++){
		time+=ab[i].second;;
		if(time>ab[i].first){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}


Measured memory_bytes: 3328
import sys
read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
readlines=sys.stdin.buffer.readlines

N,K=map(int,readline().split())
A=list(map(int,readline().split()))
F=list(map(int,readline().split()))
#print(N,K)
#print("A:",A)
#print(F)

A.sort()
F.sort(reverse=True)
#print("A:",A)
#print("F:",F)

left=-1
right=10**18
#right=10**3

while left+1<right:
  mid=(left+right)//2
  tmp=[0]*(N)
  for i in range(N):
    tmp[i]=max(A[i]-mid//F[i],0)
    
  if sum(tmp)<=K:
    right=mid
  else:
    left=mid
  #print("mid:",mid,",tmp:",tmp)
#print("left:",left,",mid:",mid,",right:",right)
print(right)

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

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

const double PI = 3.1415926535897932384;

// 1次元vectorの出力
template <class S>
void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){
		cerr << v[i] << ' ';
	}
	cerr << endl;
}

// 2次元vectorの出力
template <class S>
void print(vector<vector<S>> &v) {
  	for (ll i = 0; i < (ll)v.size(); i++) {
    	for (ll j = 0; j < (ll)v[i].size(); j++) {
      		cerr << v[i][j] << ' ';
    	}
    	cerr << endl;
  	}
}

int main(void){
	int s,w; cin >> s >> w;
	cout << ((s <= w) ? "unsafe\n" : "safe\n"); 
}

Measured memory_bytes: 3648
n, q = map(int, input().split())
s = input()
v = [0] * (n)

for i in range(1, n):
  if s[i - 1] == "A" and s[i] == "C":
    v[i] = 1 + v[i - 1]
  else:
    v[i] = v[i - 1]

for i in range(q):
  l, r = map(int, input().split())
  print(v[r - 1] - v[l - 1])

Measured memory_bytes: 6188
a, b = map(int, input().split())
def xor0toN(N):
    if N % 2 == 1:
        return int((N+1)/2) % 2
    else:
        return int((N+1)/2) % 2 ^ N
print(xor0toN(a - 1) ^ xor0toN(b))



Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define vi vector<ll>
#define vvi vector<vi>
#define Q queue<ll>
#define DQ deque<ll> 
#define pb push_back
#define pf push_front
#define popf pop_front
#define popb pop_back
#define mp make_pair
#define mt make_tuple
#define f first
#define s second
#define ub upper_bound
#define lb lower_bound
#define loop(x,y,z) for(ll i=x; i<=y; i+=z)
#define rloop(x,y,z) for(ll i=x; i>=y; i-=z)
#define all(x) x.begin(), x.end()
#define sum(x) accumulate(all(x),0LL)
#define minE(x) *min_element(all(x))
#define maxE(x) *max_element(all(x))
#define mem(a,b) memset(a,b,sizeof(a))
#define watch(x) cout<<(#x)<<" is "<<x
#define endl "\n"

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

void display(vi &v,string c){
	for(auto x:v) cout<<x<<c;
}

string solve(vi &v){
	ll maxi=v[0];
	loop(1,v.size()-1,1){
		if (maxi-v[i]>1) return "No";
		maxi=max(maxi,v[i]);
	}
	return "Yes";
}

int main(){
	IOS
	ll n;
	cin>>n;
	vi v(n);
	loop(0,n-1,1) cin>>v[i];
	if (is_sorted(all(v))) cout<<"Yes";
	else cout<<solve(v);
	return 0;
}


Measured memory_bytes: 1024
N = int(input())
nlist = list(map(int, input().split()))

list = [0]*N
sum = 0
result = []

for i in range(N):
    list[nlist[i]-1] += 1

for j in range(N):
    sum += list[j]*(list[j]-1)/2

for k in range(N):
    result.append(int(sum+1-list[nlist[k]-1]))

for l in range(N):
    print(result[l])

Measured memory_bytes: 26268
#include <stdio.h>

int main(void) {
  int a, b, c, k;

  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  scanf("%d", &k);

  while(k > 0){
    if((a > b && a > c)){
      a = a*2;
    } else if (b > c){
      b = b*2;
    } else {
      c = c*2;
    }
     k--;

  }

  printf("%d", a+b+c);
  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define fst first
#define snd second
#define MP make_pair //incase c++11 or later is not available

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;
#define PI = 3.14159265358979323846
/*------------------------------------------------------------------------------*/

int main(){
  string s;

  cin >> s;

  if(s.size() < 4){
    cout << "No" << endl;
    return 0;
  }

  if(s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I'){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc088/tasks/abc088_d
#include <bits/stdc++.h>

using namespace std;
// #define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

using pii = pair<int, int>;
const vector<pii> dir = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

int bfs(vector<vector<bool>> flags, pii start, pii end) {
    queue<tuple<int, int, int>> q;
    q.push({start.first, start.second, 0});
    // 後戻りを防ぐため壁にする
    flags[start.first][start.second] = false;
    // 到達不可能の場合は-1
    int ret = -1;
    while (!q.empty()) {
        auto t = q.front();
        q.pop();
        int y = get<0>(t);
        int x = get<1>(t);
        int d = get<2>(t);
        if (y == end.first && x == end.second) {
            ret = d;
            break;
        }
        for (auto &a : dir) {
            int ny = y + a.first;
            int nx = x + a.second;
            if (flags[ny][nx]) {
                q.push({ny, nx, d + 1});
                // 後戻りを防ぐため壁にする
                flags[ny][nx] = false;
            }
        }
    }
    return ret;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int Y, X;
    cin >> Y >> X;
    // 周囲を壁扱いにするため+2する
    vector<vector<bool>> flags(Y + 2, vector<bool>(X + 2));
    int wall = 0;
    FOR(y, 1, Y + 1) {
        string s;
        cin >> s;
        REP(x, s.size()) {
            if (s[x] == '.') {
                flags[y][x + 1] = true;
            } else {
                wall++;
            }
        }
    }
    int ans = bfs(flags, {1, 1}, {Y, X});
    if (ans == -1) {
        cout << -1 << endl;
    } else {
        cout << Y * X - wall - 1 - bfs(flags, {1, 1}, {Y, X}) << endl;
    }

    return 0;
}


Measured memory_bytes: 3680
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
  ll t;
  cin >> n >> t;
  vl a(n);
  ll pm = 0;
  rep(i,n) cin >> a[i];
  ll md = 0;
  ll mc = 0;
  for(int i=n-1;i >= 0;i--){
    if(pm < a[i]){
      pm = a[i];
    }else{
      if(md < pm-a[i]){
        md = pm-a[i];
        mc = 1;
      }else if(md == pm-a[i]){
        mc++;
      }
    }
  }
  cout << mc << endl;
	return 0;
}


Measured memory_bytes: 1024
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    r, g, b = input().split()
    n = int(r + g + b)
    if n % 4 == 0:
        print(YES)
    else:
        print(NO)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4196
n,d = gets.split.map(&:to_i)
x = Array.new(n,[])
n.times do |i|
  x[i] = gets.split.map(&:to_i)
end
count = 0
x.combination(2).to_a.each do |xx|
  sum = 0
  d.times do |i|
    sum += (xx[0][i] - xx[1][i]) ** 2
  end
  count += 1 if (sum ** (1/2.0)).to_s[-1] == "0"
end
puts count


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

#define ll long long
#define ld long double
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define IOS ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define MOD 1000000007
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define all(x) x.begin(),x.end()
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

ld dp[301][301][301] = {0};
ll n;

ld find(ll x,ll y,ll z)
{
    if(dp[x][y][z]>0)
        return dp[x][y][z];
    if(x==0 && y==0 && z==0)
        return 0;
    ld ans = 0;
    ld base = x+y+z;
    if(x>0) ans += (ld)x*find(x-1,y,z);
    if(y>0) ans += (ld)y*find(x+1,y-1,z);
    if(z>0) ans += (ld)z*find(x,y+1,z-1);

    return dp[x][y][z] = (ans+n)/(ld)base;
}

int main(){

    IOS;

    ll t,m,k;
    t=1;
    while(t--)
    {
        cin >> n;
        vector<ll> cnt(4,0);
        for(ll i=1;i<=n;i++)
        {
            cin >> k;
            cnt[k]++;
        }
        ld ans = find(cnt[1],cnt[2],cnt[3]);
        precision(ans,12);
    }
    return 0;
}


Measured memory_bytes: 426240
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, S[100];

void push(int x){
  S[++top] = x;
}

int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a, b;
  top = 0;
  char s[100];
  
  while( scanf("%s", s) != EOF ){
    if( s[0] == '+' ){
      a = pop();
      b = pop();
      push(a + b);
    }else if( s[0] == '-' ){
      b = pop();
      a = pop();
      push(a -b);
    }else if(s[0] == '*' ){
      a = pop();
      b = pop();
      push(a*b);
    }else{
      push(atoi(s));
    }
  }

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

Measured memory_bytes: 548
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#define forn(i, n) for (long long i = 0; i < (long long) (n); ++i)
#define pb emplace_back
#define endl '\n'

template<typename T> void _dbg(const char*_s,T _h) { cerr<<_s<<" = "<<_h<<"\n"; }

template<typename T, typename... Ts> void _dbg(const char*_s,T _h,Ts... _t) {
    for(int _b=0;((_b+=*_s=='(')-=*_s==')')!=0||*_s!=',';)cerr<<*_s++;
    cerr<<" = "<<_h<<",";_dbg(_s+1,_t...);
}

#define int long long

#ifdef LOCAL
    #define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
    #define dbg(...)
#endif

const int N = 500 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n, m;
int a[N];

bool read() {
    if (!(cin >> n >> m))
        return false;

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

    return true;
}

int gcd(int a, int b) {
    while (b > 0) {
        a %= b;
        swap(a, b);
    }

    return a;
}

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

void solve(int id = 0) {
    int t = a[0];

    for (int i = 1; i < n; ++i) {
        t = lcm(t, a[i]);

        if (t > 2 * m) {
            cout << "0\n";
            return ;
        }
    }

    for (int i = 0; i < n; ++i)
        if ((t / a[i]) % 2 == 0) {
            cout << "0\n";
            return ;
        }

    int k = (2 * m) / t;
    cout << (k + 1) / 2 << endl;
}

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

    int T;
    //cin >> T;
    T = 1;

    while (read())
        solve(T++);

    return 0;
}



Measured memory_bytes: 1024
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,k=parseMap(split(readline()))
    a=parseMap(split(readline()))
    for i in k+1:n
        if a[i-k]>=a[i]
            println("No")
        else
            println("Yes")
        end
    end
end
main()

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;
const int MOD = 1e9 + 7;

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

    cout << ((a % 2 == 0 || b % 2 == 0) ? "Even" : "Odd") << endl;
    return (0);
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a,b;cin>>a>>b;
  int c=stoi(a+b);
  int i=1;
  string ans="Yes";
  while(true){
    if(i*i==c)break;
    i++;
    if(i==1000){ans="No";break;}
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
N,M = (int(i) for i in input().split())
a = set([int(input()) for i in range(M)])
hoge = [0] * N
if 1 not in a:
    hoge[0] = 1
if 2 not in a and N >= 2:
    hoge[1] = hoge[0] + 1

for i in range(2,N):
    if i + 1  not in a:
        hoge[i] = hoge[i - 1] + hoge[i - 2]

print(hoge[N-1] % (10**9 + 7))

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

int main(){
  int n,k;
  cin>>n>>k;
  vector<int>x(n);
  for(int i=0;i<n;i++){
  cin>>x[i];
  }
  sort(x.begin(),x.end());
  int ans=0;
  for(int j=0;j<k;j++){
  ans+=x[j];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<map>
#include <iomanip>
#include<utility>//swapでaとbの値を入れ替える
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define Yes(a) if(a)cout<<"YES"<<endl; else cout<<"NO"<<endl;
using namespace std;
int wa(int n) {
	double ans = 0;
	rep(i, 1, n + 1)ans += i;
	return ans;
}

int main() {
	int n, k;
	double y = 0;
	int a = 0,b=0;
	cin >> n >> k;
	vector<double > p(n),snm(n+1,0);
	rep(i, 0, n) {
		cin >> p[i];
		snm[i+1] += wa(p[i])/p[i];
	    snm[i+1] += snm[i];
	}
	rep(i, 0, n - k + 1) {
		y = max(y, snm[i + k] - snm[i]);
	}
	cout << fixed << setprecision(15) << y << endl;

	return 0;
}

Measured memory_bytes: 3328
#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.tsie(nullptr);cout.tie(nullptr)
#define watch(x) cout << (#x) << " is #" << (x) <<"#" <<endl
#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 mod = 1e9+7;
const ll MAX = 2e2+7;
const ll inf = 1e18+7;


int main(){
ll x;
cin>>x;
if(x==1) cout<<"0\n";
else cout<<"1\n";
return 0; 

}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void){
  int n, i;
  scanf("%d", &n);
  int array[n];
  for(i = 0; i < n; i++){
    scanf("%d", &array[i]);
  }
  for(i = (n - 1); 0 <= i; i--){
    if(i != (n - 1))
      printf(" ");
    printf("%d", array[i]);
  }
  printf("\n");
  return 0;
}

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

int main (void){
  int n = 0,a = 0;
  cin >> n;
  a = n % 10;
  if(a == 3){
    cout << "bon\n";
  }else if(a == 0 || a == 1 || a == 6 || a == 8){
    cout << "pon\n";
  }else{
    cout << "hon\n";
  }

  return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	stack<int>st;
	vector<int>vx;
	vector<int>vy;
	int bx;
	char a[N + 1];
	f(i, N + 1)a[i] = 0;
	int n, k;
	int x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%s", a);
	n = strlen(a);
	k = 0;
	if (a[n - 1] == '1'){
		printf("-1\n");
		return 0;
	}
	if (a[0] == '0'){
		printf("-1\n");
		return 0;
	}
	f(i, n - 1){
		if (a[i] != a[n - i - 2]){
			printf("-1\n");
			return 0;
		}
	}
	bx = 0;
	for(int i=1;i<n-1;i++){
		if (a[i] == '1'){
			while (!st.empty()){
				x = st.top();
				vx.push_back(x + 1);
				vy.push_back(i + 1);
				st.pop();
			}
			vx.push_back(bx + 1);
			vy.push_back(i + 1);
			bx = i;
		}
		else st.push(i);
	}
	vx.push_back(bx + 1);
	vy.push_back(n);

	f(i, n - 1){
		printf("%d %d\n", vx[i], vy[i]);
	}


	return 0;
}

Measured memory_bytes: 2720
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b,c, d;
  cin >> a>> b>> c >> d;
  int l=a+b;
  int r=c+d;
  if(l<r) cout <<"Right" <<endl;
  else if(l==r) cout << "Balanced" << endl;
  else cout << "Left" << endl;
  return 0;
}


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

int main(){

    int a,b,x;
    cin >> a >> b ;

    bool flag = false;

    for(int i = 0;i <= a;i++){
        x = 0;
        for(int j = 0; i+j <= a; j++){
        x = i*2 + j*4;
        if(i+j == a && x == b) flag = true;
        }
    }

    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3628
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

""" 提出版
if b - a <= k:
    if c - a <= k:
        if d - a <= k:
            if e - a <= k:
                if c - b <= k:
                    if d - b <= k:
                        if e - b <= k:
                            if d - c <= k:
                                if e - c <= k:
                                    if e - d <= k:
                                        print("Yay!")
                                    else:
                                        print(":(")
                                else:
                                    print(":(")
                            else:
                                print(":(")
                        else:
                            print(":(")
                    else:
                        print(":(")
                else:
                    print(":(")
            else:
                print(":(")
        else:
            print(":(")
    else:
        print(":(")
else:
    print(":(")
"""

if e - a <= k:
    print("Yay!")
else:
    print(":(")


Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

int n, i, a, res[200005], maxx;

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



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

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

    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }

    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());

    int sumA = 0, sumB = 0;
    for (int i = 0; i < N; i += 2) {
        sumA += vec.at(i);
    }
    for (int i = 1; i < N; i += 2) {
        sumB += vec.at(i);
    }

    cout << sumA - sumB << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final String s = scanner.nextLine();
        final int k = scanner.nextInt() - 1;
        final Set<String> set = new HashSet<>();

        for (int i = 0; i < s.length(); i++) {
            for (int j = 1; j <= 5 && i + j <= s.length(); j++) {
                set.add(s.substring(i, i + j));
            }
        }

        final List<String> list = new ArrayList<>(set);
        list.sort(Comparator.naturalOrder());

        System.out.println(list.get(k));
    }
}


Measured memory_bytes: 24532
# from fractions import gcd
# mod = 10 ** 9 + 7
# N = int(input())
# a = list(map(int,input().split()))
# a,b,c = map(int,input().split())
# ans = [0] * N
# math.ceilで切り上げ
# dp = [[0] * 4 for i in range(3)] #2次元配列初期化
# dp = [[[0] * 2 for i in range(3)] for j in range(5)]
# (ord('A'))でASCII出力 Aは65
import math
import numpy as np
import statistics
import string
import sys
from array import array
from collections import deque
from functools import wraps
import time

def intinput():
    return int(input())
def listintinput():
    return list(map(int, input().split()))
def splitintinput():
    return map(int, input().split())
def factorialsurplus(x, y, z):  # xからyまでの階乗をzで割ったあまりを求める
    ret = 1
    for i in range(x, y + 1):
        ret = (ret * i) % z
    return (ret)
def isprime(x):
    if x == 1:
        return False
    if x == 2:
        return True
    sq = int(math.sqrt(x))
    for i in range(2,sq+1):
        if x % i == 0:
            return False
    return True
def hcfnaive(a,b):#最大公約数 math.gcdが使えない時の手段として入れとく。pythonが更新されたらいらなくなるはず
    if(b==0):
        return a
    else:
        return hcfnaive(b,a%b)

K,S = splitintinput()

time_sta = time.perf_counter()
ans = 0

for i in range(K+1):
    for j in range(min(S-i + 1, K + 1)):
        if S - i - j <= K:
            ans += 1
print(ans)


time_end = time.perf_counter()
#print(time_end - time_sta)


Measured memory_bytes: 14904
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    String[] str = in.readLine().split(" ");
    int[] l = new int[n];
    for(int i=0; i<n; i++) {
      l[i] = Integer.parseInt(str[i]);
    }
    
    Arrays.sort(l);
    
    int count = 0;
    for(int i=0; i<n-2; i++) {
      for(int j=i+1; j<n-1; j++) {
        for(int k=j+1; k<n; k++) {
          if(l[i]+l[j]>l[k] && l[i]!=l[k] && l[i]!=l[j] && l[j]!=l[k]) {
            count++;
          }
        }
      }
    }
    
    System.out.println(count);
  }
}

Measured memory_bytes: 33468
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>
#include <cstring>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    ll kabu = 0;
    ll money = 1000;
    bool upflg = false;
    bool dnflg = true;
    rep(i, n) {
        if (i == n - 1) {
            if (kabu != 0) {
                money += kabu * (ll)a[i];
            }
        }
        else {
            if (dnflg && (ll)a[i] < (ll)a[i+1]) {
                kabu = money / (ll)a[i];
                money = money % (ll)a[i];
                dnflg = false;
                upflg = true;
            }
            if (upflg && (ll)a[i] > (ll)a[i+1]) {
                money += kabu * (ll)a[i];
                kabu = 0LL;
                dnflg = true;
                upflg = false;
            }
        }
        //cout << i << " " << money << " " << kabu << endl;
    }
    cout << money << endl;
    return 0;
}


Measured memory_bytes: 3584
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int X = Integer.parseInt(sc.get());
		int Y = Integer.parseInt(sc.get());
		int min = Integer.MAX_VALUE;
		if (Y >= X) min = Math.min(min, Y - X);
		if (-Y >= X) min = Math.min(min, -Y - X + 1);
		if (Y >= -X) min = Math.min(min, Y - (-X) + 1);
		if (-Y >= -X) min = Math.min(min, (-Y) - (-X) + 2);
		System.out.println(min);
	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			private StringTokenizer tokenizer;

			public String get() {
				try {
					return (tokenizer = tokenizer != null && tokenizer.hasMoreTokens() ? tokenizer : new StringTokenizer(reader.readLine())).nextToken();
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
		});
	}
}


Measured memory_bytes: 23508
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a); i<=int(b); i++)
#define pb push_back
#define mp make_pair
#define x first
#define p second
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,int> pli;

const int maxn = 200009, MOD = 1e9 + 7;
priority_queue<pli, vector<pli>, greater<pli> > Q;
vector<pii> e[maxn]; LL dis[maxn], dis2[maxn];
int u[maxn], v[maxn], w[maxn], rk[maxn], rk2[maxn];
int vis[maxn], pre[maxn], suf[maxn];
int n, m, s, t, ans;

bool cmp(int a, int b) {
	return dis[a] < dis[b];
}

bool cmp2(int a, int b) {
	return dis2[a] < dis2[b];
}

void Dijkstra(int s, LL d[maxn]) {
	memset(d, 0x3f, sizeof dis);
	memset(vis, 0, sizeof vis);
	int u = s; Q.push(mp(0, s)); d[s] = 0;
	while (!Q.empty()) {
		u = Q.top().second; Q.pop();
		if (vis[u]) continue; vis[u] = 1;
		for (auto k : e[u])
			if (d[u] + w[k.p] < d[k.x]) {
				d[k.x] = d[u] + w[k.p];
				Q.push(mp(d[k.x], k.x));
			}
	}
}

void solve(int s, LL d[maxn], int f[maxn], int rk[maxn]) {
	int u; f[s] = 1;
	rep (i, 1, n) {
		u = rk[i];
		for (auto k : e[u])
			if (d[u] + w[k.p] == d[k.x])
				f[k.x] = (f[k.x] + f[u]) % MOD;
	}
}

int calc(int x) {
	return 1LL * x * x % MOD;
}

int main() {
	scanf("%d%d%d%d", &n, &m, &s, &t);
	rep (i, 1, m) {
		scanf("%d%d%d", &u[i], &v[i], &w[i]);
		e[u[i]].pb(mp(v[i], i)); 
		e[v[i]].pb(mp(u[i], i));
	}
	Dijkstra(s, dis); 
	Dijkstra(t, dis2);
	
	rep (i, 1, n) rk[i] = rk2[i] = i;
	sort(rk+1, rk+n+1, cmp); 
	sort(rk2+1, rk2+n+1, cmp2);
	
	solve(s, dis, pre, rk); 
	solve(t, dis2, suf, rk2);
	
	ans = calc(pre[t]);
	
	//sovle point
	rep (i, 1, n)
		if (dis[i] == dis2[i] && dis[i] * 2 == dis[t])
			ans = (ans + MOD - 1LL * calc(pre[i]) * calc(suf[i]) % MOD) % MOD;
	
	//solve edge
	rep (i, 1, m) {
		if (dis[u[i]] + w[i] == dis[v[i]] && dis2[v[i]] + w[i] == dis2[u[i]] && dis[u[i]] + w[i] + dis2[v[i]] == dis[t]) {
			if (max(dis[u[i]], dis2[v[i]]) < min(dis[v[i]], dis2[u[i]]))
				ans = (ans + MOD - 1LL * calc(pre[u[i]]) * calc(suf[v[i]]) % MOD) % MOD;
		}
		if (dis[v[i]] + w[i] == dis[u[i]] && dis2[u[i]] + w[i] == dis2[v[i]] && dis[v[i]] + w[i] + dis2[u[i]] == dis[t]) {
			swap(u[i], v[i]);
			if (max(dis[u[i]], dis2[v[i]]) < min(dis[v[i]], dis2[u[i]]))
				ans = (ans + MOD - 1LL * calc(pre[u[i]]) * calc(suf[v[i]]) % MOD) % MOD;
		}
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 20976
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  if (tail == LEN) tail=0;
  else tail++;
}

P dequeue(){
  P x = Q[head];
  if (head == LEN) head=0;
  else head ++;
  return x;
}


int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 0; i < n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  tail=n;
  while (head!=tail){
    u = dequeue();
    if (u.t <= q){
      elaps += u.t;
      printf("%s %d\n",u.name,elaps);
    }
    else {
      elaps += q;
      u.t -= q;
      enqueue(u);
    }
  }
  
  return 0;
}

Measured memory_bytes: 10756
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	int len;
	int cnt=0;
	cin>>s;
 	len=s.length();
  for(int i=0;i<len/2;i++){
		if(s[i]!=s[len-i-1]){
			cnt++;
		}
	}
 
	cout<<cnt<<endl;
 
	
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h> // sqrt
using namespace std;

int main() {
    vector<vector<int>> data(3,vector<int>(3));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> data.at(i).at(j);
        }
    }
    int N;
    cin >> N;
    vector<int> num(N);
    for (int i = 0; i < N; i++) {
        cin >> num.at(i);
    }
    vector<vector<bool>> check(3,vector<bool>(3,false));
    bool finish = false;
    for (int x : num) {
        finish = false;
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (x == data.at(i).at(j)) {
                    check.at(i).at(j) = true;
                    break;
                }
            }
            if(finish) {
                break;
            }
        }
    }
    bool bingo = false;
    for (int i = 0; i < 3; i++) {
        if (check.at(i).at(0) && check.at(i).at(1) && check.at(i).at(2)) {
            bingo = true;
            break;
        }
        if (check.at(0).at(i) && check.at(1).at(i) && check.at(2).at(i)) {
            bingo = true;
            break;
        }
    }
    if (check.at(0).at(0) && check.at(1).at(1) && check.at(2).at(2)) {
        bingo = true;
    }
    if (check.at(0).at(2) && check.at(1).at(1) && check.at(2).at(0)) {
        bingo = true;
    }
    if (bingo) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var x, a, b float64
	fmt.Scan(&x, &a, &b)
	if math.Abs(x-a) > math.Abs(x-b) {
		fmt.Println("B")
	} else {
		fmt.Println("A")
	}
}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(9, 0);
  rep(i, N){
    cin >> A[i];
    if (A[i] <= 399) B[0] = 1;
    else if (A[i] <= 799) B[1] = 1;
    else if (A[i] <= 1199) B[2] = 1;
    else if (A[i] <= 1599) B[3] = 1;
    else if (A[i] <= 1999) B[4] = 1;
    else if (A[i] <= 2399) B[5] = 1;
    else if (A[i] <= 2799) B[6] = 1;
    else if (A[i] <= 3199) B[7] = 1;
    else B[8]++;
  }
  
  int sum = 0;
  rep(i, 8){
    sum += B[i];
  }
  int min_sum;
  if (sum >= 1) min_sum = sum;
  else min_sum = 1;
  sum += B[8];
  cout << min_sum << " " << sum << endl;
  
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	char a,b;
	cin >> a >> b;
	if((a == 'H' && b == 'H') || (a == 'D' && b == 'D')){
		cout << 'H' <<endl;
	}
	else{
		cout << 'D' << endl;
	}
	return 0;
}

Measured memory_bytes: 256
def gcd_2(a,b):
    if a<=b:
        x_min=a
        x_max=b
    else:
        x_min=b
        x_max=a
        
    while True:
#         print(x_min,x_max)
        if x_max % x_min ==0:
            return x_min
        
        x_temp = x_max % x_min
        
        x_max = x_min
        x_min = x_temp
        
def gcd(a,b,c):
    d=gcd_2(a,b)
    ans=gcd_2(d,c)
    return ans
  
N=int(input())
sum_gcd=0
for a_1 in range(1,N+1):
    for a_2 in range(1,N+1):
        for a_3 in range(1,N+1):
            sum_gcd+=gcd(a_1,a_2,a_3)
print(sum_gcd)

Measured memory_bytes: 75540