akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//Input
		Scanner sc = new Scanner(System.in);
		String inputS = sc.next();
		String[] S = inputS.split("");
		sc.close();

		//Logic
		String B = S[0]+S[1];
		int b1 = Integer.parseInt(B);

		B = S[2]+S[3];
		int b2 = Integer.parseInt(B);

		boolean IsYYMM = true;
		boolean IsMMYY = true;

		if(!(1 <= b1 && b1 <= 12)) {
			IsMMYY = false;
		}

		if(!(1 <= b2 && b2 <= 12)) {
			IsYYMM = false;
		}

		if(b1 == 0) {
			IsMMYY = false;
		}

		if(b2 == 0) {
			IsYYMM = false;
		}

		if(IsYYMM && IsMMYY) {
			System.out.print("AMBIGUOUS");
		}else if(IsYYMM) {
			System.out.print("YYMM");
		}else if(IsMMYY) {
			System.out.print("MMYY");
		}else {
			System.out.print("NA");
		}

	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int N;
  cin >> N;
  vector<int> V(N), C(N);
  for(int i=0; i<N; i++)
    cin >> V[i];
  for(int i=0; i<N; i++)
    cin >> C[i];
  int ans = 0;
  for(int i=0; i<N; i++)
    if(V[i] > C[i])
      ans += V[i] - C[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
module Main where

import qualified Data.Vector as V 
import qualified Data.Map as M
import Control.Monad
import Data.Maybe
readint :: IO Int
readint = read <$> getLine

readvec :: IO [Int]
readvec = (fmap read . words) <$> getLine

main :: IO()
main = do
  [a,b,k] <- readvec
  l <- forM [1..100] $ \i -> do
    if a `mod` i == 0 && b `mod` i == 0
       then pure $ Just i
       else pure Nothing
  -- print $ catMaybes l
  print $ (reverse $ catMaybes l) !! (k-1)



Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    ll a[n + 1];
    rep(i, 0, n + 1) {
        cin >> a[i];
    }
    ll b[n];
    rep(i, 0, n) {
        cin >> b[i];
    }

    ll ans = 0;
    rep(i, 0, n) {
        ll tmp = min(a[i], b[i]);
        a[i] -= tmp;
        b[i] -= tmp;
        ans += tmp;
        ll tmp2 = min(a[i + 1], b[i]);
        a[i + 1] -= tmp2;
        b[i] -= tmp2;
        ans += tmp2;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N; cin >> N;
  long long int A[N+1], B[N];
  for (int i=0; i<N+1; i++) cin >> A[i];
  for (int i=0; i<N; i++) cin >> B[i];
  long long int ans = 0;
  for (int i=0; i<N; i++) {
    if (B[i] > A[i]) {
      ans += A[i];
      B[i] -= A[i];
      A[i] = 0;
      if (B[i] > A[i+1]) {
        ans += A[i+1];
        B[i] -= A[i+1];
        A[i+1] = 0;
      } else {
        ans += B[i];
        A[i+1] -= B[i];
        B[i] = 0;
      }
    } else {
      ans += B[i];
      A[i] -= B[i];
      B[i] = 0;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<vector>
#include<cmath>
#include<algorithm>
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rrep(i, a, b) for(int i=b-1; i>=a; i--)
#define REP(i, n) for(int i=0; i<n; i++)
#define rREP(i, n) for(int i=n-1; i>=0; i--)
#define MAX 100001
typedef long long ll;
using namespace std;

int main(void){
  int n;  cin >> n;
  int t[MAX], x[MAX], y[MAX];
  bool flag = true;
  t[0] = 0; x[0] = 0; y[0] = 0;
  rep(i, 1, n+1){
    cin >> t[i] >> x[i] >> y[i];
  }
  rep(i, 1, n+1){
    if(!flag) break;
    int dTime = t[i]-t[i-1];
    int dis = abs(x[i]+y[i]-x[i-1]-y[i-1]);
    if(dis > dTime || dTime%2 != dis%2){
      flag = false;
    }
  }
  if(flag)  cout << "Yes" << endl;
  else  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 1408
def popcount_parity(x):
    x ^= x >> 1
    x ^= x >> 2
    x ^= x >> 4
    x ^= x >> 8
    x ^= x >> 16
    x ^= x >> 32
    x ^= x >> 64
    x ^= x >> 128
    x ^= x >> 256
    x ^= x >> 512
    x ^= x >> 1024
    x ^= x >> 2048
    x ^= x >> 4096
    x ^= x >> 8192
    x ^= x >> 16384
    x ^= x >> 32768
    x ^= x >> 65536
    x ^= x >> 131072
    x ^= x >> 262144
    x ^= x >> 524288
    return x & 1

N = int(input()) - 1
s = 1
while N:
    l = N & -N
    s *= 1 + (1 << l)
    N ^= l

A = input()
if "2" in A:
    a = int(A.replace("1", "0").replace("3", "0").replace("2", "1"), 2)
    print(popcount_parity(a & s))
else:
    a = int(A.replace("1", "0").replace("3", "1"), 2)
    print(popcount_parity(a & s) * 2)

Measured memory_bytes: 6096
import sys
input = sys.stdin.readline


n, m = map(int, input().split())

A = []
for i in range(m):
    p, y = map(int, input().split())
    A.append([p, y, i])
A.sort()

x = 1
A[0].append(x)
for i in range(1, m):
    if A[i][0] == A[i - 1][0]:
        x += 1
    else:
        x = 1
    A[i].append(x)
A.sort(key = lambda x: x[2])

for a in A:
    p, x = a[0], a[3]
    print(format(p, "06") + format(x, "06"))


Measured memory_bytes: 31156
import static java.util.Arrays.deepToString;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	public void run() {
		for (;sc.hasNext();) {
			char[][] table = new char[3][];
			table[0] = sc.next().toCharArray();
			if (table[0][0] == '0') return;
			table[1] = sc.next().toCharArray();
			table[2] = sc.next().toCharArray();
			String ans = "NA";
			if (win(table, 'b')) ans = "b";
			else if (win(table, 'w')) ans = "w";
			System.out.println(ans);
		}
	}
	
	boolean win(char[][] table, char ch) {
		for (int i = 0; i < 3; i++) {
			int cnt = 0;
			for (int j = 0; j < 3; j++) {
				if (table[i][j] == ch) {
					cnt++;
				}
			}
			if (cnt == 3) return true;
		}
		for (int j = 0; j < 3; j++) {
			int cnt = 0;
			for (int i = 0; i < 3; i++) {
				if (table[i][j] == ch) {
					cnt++;
				}
			}
			if (cnt == 3) return true;
		}
		
		if (table[0][0] == ch && table[1][1] == ch && table[2][2] == ch) return true;
		if (table[0][2] == ch && table[1][1] == ch && table[2][0] == ch) return true;
		return false;
	}
}

Measured memory_bytes: 17176
#include <iostream>
using namespace std;
#define ull unsigned long long
int y,N;
int main()
{
	cin >> N >> y;
	for(int i = 0;i <=N;++i)
	{
		for(int j = 0; j<=N-i; ++j)
		{
			ull sum = 1000*i + 5000*j;
			if(sum > y)
				continue;
			else if(sum == y && (i+j) == N)
			{
				cout << 0 << ' ' << j << ' ' << i << endl;
				return 0;
			}else if((y-sum)%10000==0 && (i+j+(y-sum)/10000)==N)
			{
				cout << (y-sum)/10000 << ' ' << j << ' ' << i << endl;
				return 0;
			}

		}

	}
	cout << -1 << ' ' << -1 << ' ' << -1 << endl;
}

Measured memory_bytes: 256
from bisect import bisect_left
import sys
X,N=list(map(int,input().split()))
if N==0:
    print(X)
    sys.exit()
P=list(map(int,input().split()))
P=sorted(P)
x=bisect_left(P,X)
if x>=len(P):
    print(X)
    sys.exit()
if P[x]!=X:
    print(X)
    sys.exit()
A=X
B=X
while True:
    A-=1
    B+=1
    x1=bisect_left(P,A)
    x2=bisect_left(P,B)
    if x1<len(P) and P[x1]!=A:
        print(A)
        break
    if x2<len(P) and P[x2]!=B:
        print(B)
        break
    if x2==len(P):
        print(B)
        break


Measured memory_bytes: 9232
//https://atcoder.jp/contests/abc128/tasks/abc128_d

import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;
import java.util.Arrays;

class Main{
    static int N,K;
    static int[] V;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        K = sc.nextInt();
        V = new int[N];
        for (int i=0;i<N;i++){
            V[i] = sc.nextInt();
        }
        int ans = 0;
        for (int i=0;i<=K;i++){
            for (int j=0;j<=K;j++){
                int score = 0;
                ArrayList<Integer> owned = new ArrayList<>();
                if (i+j>Math.min(N,K)){
                    break;
                }
                for (int k=0;k<i;k++){
                    score += V[k];
                    owned.add(V[k]);
                }
                for (int k=0;k<j;k++){
                    score += V[N-k-1];
                    owned.add(V[N-k-1]);
                }
                int drop = K-(i+j);
                if (drop<0){
                    drop = 0;
                }
                Collections.sort(owned);
                for (int k=0;k<Math.min(drop,owned.size());k++){
                    if (owned.get(k)<0){
                        score -= owned.get(k);
                    }
                }
                ans = Math.max(ans,score);
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 26068
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#define ll long long
using namespace std;
int a;
int main()
{
    cin>>a;
    if (a==3 || a==5 || a==7)
        cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}





Measured memory_bytes: 768
import sys

class Node:
    def __init__(self):
        pass

def preorderTreeWalk(id, tree):
    if id != -1:
        print id,
        preorderTreeWalk(tree[id].left, tree)
        preorderTreeWalk(tree[id].right, tree)

def inorderTreeWalk(id, tree):
    if id != -1:
        inorderTreeWalk(tree[id].left, tree)
        print id,
        inorderTreeWalk(tree[id].right, tree)

def postorderTreeWalk(id, tree):
    if id != -1:
        postorderTreeWalk(tree[id].left, tree)
        postorderTreeWalk(tree[id].right, tree)
        print id,

if __name__ == "__main__":
    lines = sys.stdin.readlines()
    N = int(lines[0])
    del lines[0]

    tree = []
    for i in range(N):
        tree.append(Node())

    root = N * (N - 1) / 2
    for line in lines:
        info = map(int, line.split())
        id = info[0]
        tree[id].id = id
        tree[id].left = info[1]
        tree[id].right = info[2]
        if info[1] != -1:
            root -= info[1]
        if info[2] != -1:
            root -= info[2]

    print "Preorder"
    print "",
    preorderTreeWalk(root, tree)
    print

    print "Inorder"
    print "",
    inorderTreeWalk(root, tree)
    print

    print "Postorder"
    print "",
    postorderTreeWalk(root, tree)
    print

Measured memory_bytes: 6428
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int W, a, b; cin >> W >> a >> b;
    if(a+W < b) cout << abs(b-(W+a));
    else if(b+W < a) cout << abs(b+W - a);
    else cout << 0;
    cout << endl;
    return 0;
}




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

#define ll long long
#define endl "\n"
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define f first
#define s second
#define vecll vector<ll>
#define pairll pair<ll,ll>
#define vecpairll vector<pair<ll,ll>>
#define mapllll map<ll,ll>
#define mapstrll map<string,ll>
#define mapllvecll map<ll,vecll>
#define setll set<ll>
#define fio ios_base::sync_with_stdio (false); cin.tie (NULL); cout.tie(NULL);

using namespace std;

ll const N=1e5+5;
ll const inf=1e18+5;
ll const MOD=1e9+7;

ll t,n,m,x,y,z,w,k;

int main()
{
    fio

    cin>>x>>y;

    if(x>=1 && x<=9 && y>=1 && y<=9)    cout<<x*y;
    else    cout<<-1;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
int main(){
	int n ,k;
	int ans;
	std::cin >> n >> k;
	std::vector<int> v(n);
	for(int i=0; i<n; ++i){
		std::cin >> v[i];
	}
	std::sort(v.begin(), v.end());
	for(int i=0;i<n-k+1;++i){
		int tmp;
		tmp = v[i+k-1] - v[i];
		if(i == 0){
			ans = tmp;
		}
		if(ans > tmp){
			ans = tmp;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 640
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var s = next();
	var t = next();
	var output = 0;
	for(var i = 0; i < s.length; i++){
		if(s[i] == t[i]){
			output++;
		}
	}
	myout(output);
}


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

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

  bool can = false;

  for (int i = 1; i <= 1000000; ++i) {
    if (100 * i <= X && X <= 105 * i) {
      can = true;
      break;
    }
  }

  if (can)
    puts("1");
  else
    puts("0");
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int N;
	cin >> N;

	int dir = 0;
	int prev = 0;
	cin >> prev;

	int result = 1;
	for (int i = 1; i < N; i++)
	{
		int curr;
		cin >> curr;

		if (prev < curr)
		{
			if (dir == 2)
			{
				dir = 0;
				result++;
			}
			else
			{
				dir = 1;
			}
		}
		else if (prev > curr)
		{
			if (dir == 1)
			{
				dir = 0;
				result++;
			}
			else
			{
				dir = 2;
			}
		}

		prev = curr;
	}

	cout << result;

	return 0;
}


Measured memory_bytes: 256
def side(a, b, c):
  return (c[1]-a[1])*(b[0]-a[0])-(b[1]-a[1])*(c[0]-a[0])>0
def isInner(x): return (side(p0, p1, x)==side(p1, p2, x)==side(p2, p0, x))

for _ in [0]*input():
  P = map(int, raw_input().split())
  p0 = P[0:2]
  p1 = P[2:4]
  p2 = P[4:6]
  x1 = P[6:8]
  x2 = P[8:]
  print ['NG','OK'][isInner(x1)!=isInner(x2)]

Measured memory_bytes: 4304
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int MOD = 1000000007;
int INF = numeric_limits<int>::max() / 10;


signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int N;
  cin >> N;
  string S[N];
  rep(i, N) cin >> S[i];
  int A[N][26] = {};
  rep(i, N){
    rep(j, S[i].size()){
      A[i][S[i][j] - 'a']++;
    }
  }
  string ans{};
  rep(i, 26){
    int num = INF;
    rep(j, N){
      num = min(num, A[j][i]);
    }
    rep(j, num){
      ans += 'a' + i;
    }
  }
  cout << ans <<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N;
#define ll long long
ll data[1009];
int num[50];
bool solve(ll n)
{
    int i,j,k;
    int tot=0;
    while(n)
    {
        num[++tot]=n%10;
        n/=10;
    }
    for(i=tot-1;i>=1;i--)
    {
        if(num[i]-1!=num[i+1])return false;
    }
    return true;
}
int main()
{
    cin>>N;
    int i,j,k;
    for(i=1;i<=N;i++)
        scanf("%lld",&data[i]);
    ll ans=-1;
    for(i=1;i<=N;i++)
    {
        for(j=i+1;j<=N;j++)
        {
            if(solve(data[i]*data[j]))
            {
                ans=max(ans,data[i]*data[j]);
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3204
from collections import deque, defaultdict
import copy
import bisect
#sys.setrecursionlimit(10 ** 9)
import math
import heapq

import sys
def input():
	return sys.stdin.readline().strip()

N = int(input())
P = list(map(int, input().split()))
X = list(map(int, input().split()))

tree = [[] for i in range(N)]


for i in range(N - 1):
	tree[P[i] - 1].append(i + 1)

sum_list = [0]*N
que = deque([0])
que2 = deque([0])
while len(que) > 0:
	node = que.popleft()
	if len(tree[node]) > 0:
		for edge in tree[node]:
			que.append(edge)
			que2.append(edge)

for i in range(N - 1, -1, -1):
	node = que2[i]
	if len(tree[node]) > 0:
		for edge in tree[node]:
			sum_list[node] += sum_list[edge]
	sum_list[node] += X[node]

score = [[0,0] for i in range(N)]
for i in range(N - 1, -1, -1):
	node = que2[i]
	if len(tree[node]) == 0:
		score[node] = [X[node], 0]
	else:
		rest = X[node]
		dp = [[0 for i in range(len(tree[node]) + 1)] for j in range(rest + 1)]
		dp[0][0] = 1
		for x in range(rest + 1):
			for n in range(1, len(tree[node]) + 1):
				dp[x][n] = 0
				if x - score[tree[node][n-1]][0] >= 0:
					dp[x][n] = dp[x - score[tree[node][n-1]][0]][n - 1]
				if x - score[tree[node][n-1]][1] >= 0:
					dp[x][n] = dp[x][n] | dp[x - score[tree[node][n-1]][1]][n - 1]
		judge = 0
		#print(dp)
		for x in range(rest, -1, -1):
			#print(x, len(tree[node]))
			if dp[x][len(tree[node])] == 1:
				judge = 1
				under_sum = 0
				for n in range(len(tree[node])):
					under_sum += sum(score[tree[node][n]])
				under_sum += rest - x
				under_sum -= X[node]
				score[node] = [X[node], under_sum]
				break
		if judge == 0:
			print("IMPOSSIBLE")
			exit()
print("POSSIBLE")

Measured memory_bytes: 67804
#include<bits/stdc++.h>
 
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-funroll-loops")
#pragma GCC target("avx,sse4")
 
#define mms(a,n) memset(a,0,sizeof((a)[0])*(n))
#define mmp(a,b,n) memcpy(a,b,sizeof((b)[0])*(n))
#define lowbit(x) ((x)&-(x))
#define pb push_back
#define fi first
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define fo(i,l,r) for(register int i=l,_lim_=r;i<=_lim_;i++)
#define fd(i,r,l) for(register int i=r,_lim_=l;i>=_lim_;i--)
#define fos(i,l,r,d) for(register int i=l,_lim_=r;i<=r;i+=d)
#define fol(i,l,r) for(register ll i=l,_lim_=r;i<=_lim_;i++)
#define fdl(i,r,l) for(register ll i=r,_lim_=l;i>=_lim_;i--)
#define fosl(i,l,r,d) for(register ll i=l,_lim_=r;i<=r;i+=d)
#define Clear(a) memset(a,0,sizeof(a))
#define Copy(a,b) memcpy(a,b,sizeof(b))
#define ALL(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())

using namespace std;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ldb;
typedef double db;
typedef pair<int,int> pi;
typedef vector<int> VI;
typedef vector<VI> VII;

const int N=16666,P=998244353;
const int mod(P);

uint fpow(uint a,int t){
	uint r(1);
	for(;t;t>>=1,a=(ull)a*a%mod)if(t&1)r=(ull)r*a%mod;
	return r;
}

int n,m,k;
uint fac[N],ifac[N],inv[N],tx[N],ty[N],tz[N],dp[N],ret;
uint *ww[20],*iww[20],pol[N<<2],*pl=pol;
void init(int n){
	int i,p,l;uint w;
	for(l=2,p=0;l<=n;l<<=1,p++){
		ww[p]=pl;w=fpow(3,(P-1)/l);
		for(i=*pl=1;i<l>>1;i++)pl[i]=(ull)pl[i-1]*w%mod;pl+=l>>1;
		iww[p]=pl;w=fpow(w,P-2);
		for(i=*pl=1;i<l>>1;i++)pl[i]=(ull)pl[i-1]*w%mod;pl+=l>>1;
	}
}
void fft(uint a[],int n,int dft){
	int i,j,k,l,p;uint t,*w;
	for(i=1,j=n>>1;i<n-1;i++){
		if(i<j)swap(a[i],a[j]);
		for(k=n>>1;(j^=k)<k;k>>=1);
	}
	for(l=2,p=0;l<=n;l<<=1,p++){
		w=dft==1?ww[p]:iww[p];
		for(j=0,i=l>>1;j<n;j+=l)for(k=0;k<i;k++){
			uint&y=a[j+k];
			t=(ull)a[j+k+i]*w[k]%mod;
			(a[j+k+i]=y+P-t)<P?:a[j+k+i]-=P; 
			(y+=t)<P?:y-=P;
		}
	}
	if(dft==-1)for(i=0,t=fpow(n,P-2);i<n;i++)a[i]=(ull)a[i]*t%mod;
}

uint C(int n,int m){
	if(n<m)return 0;
	return (ull)fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
 
int main(){
	scanf("%d%d",&n,&m);
	fac[0]=fac[1]=ifac[0]=ifac[1]=inv[1]=1;
	fo(i,2,(n<<1)+2){
		fac[i]=(ull)fac[i-1]*i%mod;
		inv[i]=P-(ull)(P/i)*inv[P%i]%mod;
		ifac[i]=(ull)ifac[i-1]*inv[i]%mod;
	}
	dp[0]=1;
	for(k=1;k<=n<<1;k<<=1);
	init(k);
	fo(i,1,m){
		mms(tx,k);mms(ty,k);
		fo(j,0,n)tx[j]=(ull)dp[j]*ifac[j]%mod;
		fo(j,1,n)ty[j]=ifac[j+2];
		fft(tx,k,1);fft(ty,k,1);
		fo(j,0,k-1)tz[j]=(ull)tx[j]*ty[j]%mod;
		fft(tz,k,-1);
		fo(j,0,k-1)dp[j]=((ull)dp[j]*((j+1)*j/2+1)+(ull)tz[j]*fac[j+2])%mod;
	}
	fo(i,0,n)ret=(ret+(ll)dp[i]*C(n,i))%mod;
	printf("%u\n",ret);
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 0; i < s.size();i++)
    {
        s[i] += n % 26;
        if(s[i] > 'Z')
            s[i] -= 26;
    }
    cout << s;
}

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

int mod = 1000000007;
int64_t large = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int64_t N, M;
    cin >> N >> M;
    int64_t ans;
    if (N == 1 && M == 1)
        ans = 1;
    else if (N == 1 || M == 1)
        ans = max(N - 2, M - 2);
    else
        ans = (N - 2) * (M - 2);
    cout << ans;
}

Measured memory_bytes: 256
s = str(input())
odd = "RUD"
even = "LUD"
flag = True

for i in range(len(s)):
 if i%2 == 0 and s[i] not in odd:
  flag = False
 elif i%2 != 0 and s[i] not in even:
  flag = False

if flag:
 print("Yes")
else:
 print("No")









Measured memory_bytes: 2940
eval"A,B,C,D,E,F="+`tr \\  ,`;d={};f=->a,b=0{a*100+b>F||a*E<b||d[[a,b]]||=(f[a+A,b];f[a+B,b];f[a,b+C];f[a,b+D];b.quo a)};f[A];f[B];a,b=d.max_by{|_,v|v}[0];p a*100+b,b

Measured memory_bytes: 5388
import java.util.*;

public class Main {
    private static HashMap<Integer, List<Integer>> graph;
    public static void main(String[] args) throws Exception{
        Scanner scanner = new Scanner(System.in);
        int V = scanner.nextInt();
        int E = scanner.nextInt();

        graph = new HashMap<>(V);
        for(int i = 0; i < V; ++i){
            graph.put(i, new LinkedList<>());
        }

        for(int i = 0; i < E; ++i){
            int u = scanner.nextInt();
            int v = scanner.nextInt();
            graph.get(u).add(v);
        }

        boolean[] visited = new boolean[V];

        for(int i = 0; i < V; ++i){
            boolean[] recStack = new boolean[V];
            if(!visited[i] && cyclicUtil(i, visited, recStack)){
                System.out.println("1");
                return;
            }
        }

        System.out.println("0");
        return;
    }

    private static boolean cyclicUtil(int cur, boolean[] visited, boolean[] recStack){
        visited[cur] = true;
        recStack[cur] = true;

        for(Integer adj : graph.get(cur)){
            if(recStack[adj]){
                return true;
            }
            else if(!visited[adj] && cyclicUtil(adj, visited, recStack)){
                return true;
            }
        }

        recStack[cur] = false;
        return false;
    }
}

Measured memory_bytes: 31452
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define mii map<int,int>
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define inf (long long) 1e18
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define rep(i,n)  for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int N = 1e9 + 7;

int pow(int x, int y) { int res = 1; while (y > 0) { if (y & 1) res = ((res) * (x)); res %= N; y = y >> 1; x = ((x) * (x)); } return res; }
int powm(int x, int y, int p)  {  int res = 1; x = x % p; while (y > 0) {if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p;}   return res; }



void solve()
{
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n)
        cin>>v[i];
    vector<int> ans(n);
    ans[1]=abs(v[1]-v[0]);
    for(int i=2;i<n;i++)
    {
        ans[i]=min(ans[i-1]+abs(v[i-1]-v[i]),abs(v[i-2]-v[i])+ans[i-2]);
    }
    cout<<ans[n-1];
    return;
}



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

Measured memory_bytes: 4792
#include <bits/stdc++.h>
        typedef long long LL;
        using namespace std;
        int main(){
        	LL n,a,b,sum;
        	LL g,s,ba,q,m;
        	while(cin>>n>>a>>b){
        		sum = 0;
        		for(int i=1; i<=n; ++i){
        			if(i==10000&&a<=1&&b>=1)sum+=i;
        			else{
        			g = i%10;
        			s = (i%100)/10;
        			ba = (i%1000)/100;
        			q = i/1000;
        			m = g+s+ba+q;
        			if(m>=a&&m<=b) sum+=i;
        			else continue;
					}
        		}
        		cout<<sum<<endl;
        		
        	}
        	return 0;	
        }

Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
	"strconv"
)
func main(){
	var a int
	var op string
	var b int
	for {

		fmt.Scan(&a , &op , &b)
		if op != "?" {
			if op == "+"{
				fmt.Println(strconv.Itoa(a + b))
			} else if op == "-"{
				fmt.Println(strconv.Itoa(a - b))
			} else if op == "*"{
				fmt.Println(strconv.Itoa(a * b))
			} else {// "/"
				fmt.Println(strconv.Itoa(a / b))
			
			}
		} else {
			os.Exit(0)
		}
	}
}





Measured memory_bytes: 1136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll const N=2e5+50;
ll INF=0x3f3f3f3f;
ll n,k,x,cnt1=0,cnt2=0,cnt3=0;
ll a[N],b[N];
bool cmp(ll a,ll b) {  return a>b;  }
ll check1(ll m)
{
    ll p=1,ans=0;
    for(int i=1;i<=cnt2;i++)
    {
        while( a[p]*b[i] > m&&p<=cnt1 )
            p++;
        ans+=(cnt1-p+1);
    }
   // cout<<ans<<endl;
    return ans;
}
ll check(ll m)
{
    ll p=cnt1,ans=0,ans1=0;
    for(int i=1;i<=cnt1;i++)
    {
        while(a[i]*a[p]>m&&p>=1)
            p--;
        ans+=(p);
        if(p>=i)
            ans--;
     //   cout<<i<<" "<<p<<endl;
    }
    p=cnt2;
    for(int i=1;i<=cnt2;i++)
    {
        while(b[i]*b[p]>m&&p>=1)
            p--;
        ans1+=(p);
        if(p>=i)
            ans1--;
       // cout<<i<<" "<<p<<endl;
    }
    ans=ans/2+ans1/2;
   // cout<<ans<<endl;
    return ans;
}
int main()
{
    //cout<<(-11)/2<<endl;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        if(x>0)
            a[++cnt1]=x;
        else
            if(x<0)
                b[++cnt2]=x;
            else
                ++cnt3;
    }
  //  cout<<cnt1<<" "<<cnt2<<" "<<cnt3<<endl;
    ll l,r,mid;
    if(cnt1*cnt2>=k)///负数区
    {
        sort(a+1,a+1+cnt1);
        sort(b+1,b+1+cnt2);
        l=-1e18+5,r=-1;
        while(l < r )
        {
            mid=(l+r-1)/2;
            if( check1(mid) >= k)
                r=mid;
            else
                l=mid+1;
          //  cout<<l<<" "<<r<<" "<<mid<<endl;
        }
        cout<<l<<endl;
    }
    else
    {
        k-=cnt1*cnt2;
        if( k <= ((n-cnt3)+(n-1))*cnt3/2 ) ///0
        {
            cout<<"0"<<endl;
            return 0;
        }
        else///正数
        {
            k-=((n-cnt3)+(n-1))*cnt3/2;
         //   cout<<k<<endl;
            for(int i=1;i<=cnt2;i++)
                b[i]*=-1;
            sort(b+1,b+1+cnt2);
            sort(a+1,a+1+cnt1);
            // cout<<"**"<<check(ll(448283280358331062))<<endl;
           // cout<<"**"<<check(ll(448283280358331064))<<endl;
           // cout<<"**"<<check(ll(448283280358331066))<<endl;
            l=1,r=1e18+5;
            while(l<r)
            {
                mid=(l+r)/2;
                if( check(mid)>=k )
                {
                    r=mid;
                }
                else
                    l=mid+1;
               // cout<<l<<" "<<r<<" "<<mid<<endl;
            }
            ll i;
            for(i=l+10;;i--)
            {
                if(check(i)<k)
                    break;
            }
            cout<<r<<endl;

        }
    }
    return 0;
}


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

int main() {
  int n, ans = 0;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  for(int i = 1; i < n - 1; i++){
    if(a.at(i - 1) < a.at(i) && a.at(i) < a.at(i + 1) || a.at(i - 1) > a.at(i) && a.at(i) > a.at(i + 1)) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
A = []
B = []
for i in range(n):
    A.append(input().split())
for i in range(m):
    B.append(int(input()))

C = []
for i in range(n):
    C.append(0)
    for j in range(m):
        C[i] += int(A[i][j]) * B[j]
    print(C[i])

Measured memory_bytes: 8080
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main ( void )
{
	string out[] = {
		"0111111", "0000110", "1011011", "1001111", "1100110",
		"1101101", "1111101", "0100111", "1111111", "1101111"
	};
	
	int n;
	while (cin >> n, n != -1)
	{
		string s = "0000000";
		for ( int i = 0, x; i < n; ++i )
		{
			cin >> x;
			
			for ( int j = 0; j < s.size(); ++j )
			{
				if (s[j] != out[x][j])
					s[j] = '1';
				else
					s[j] = '0';
			}
			cout << s << endl;
			s = out[x];
		}
	}
	return 0;
}

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

#define ll long long int

int main()
{
    ll n,k;
    cin>>n>>k;

    if(k>n)
    {
        ll a=abs(k-n);
        if(a>n)
            cout<<n<<endl;
        else
            cout<<a<<endl;
    }
    else
    {
        n=n%k;
        ll a=abs(k-n);
        if(a>n)
            cout<<n<<endl;
        else
            cout<<a<<endl;
    }
}


Measured memory_bytes: 256
import bisect
N = int(input())
A = sorted(list(map(int, input().split())))
n = A[-1]
x = bisect.bisect_left(A, n / 2)
if x == 0:
    print(n, A[0])
elif x == N:
    print(n, A[-1])
else:
    if n / 2 - A[x - 1] <= A[x] - n / 2:
        print(n, A[x - 1])
    else:
        print(n, A[x])


Measured memory_bytes: 14428
turn=int(input())
ten=[0,0]

for _ in range(turn):
    hikaku = input().split()
    if hikaku[0] < hikaku[1]:
        ten[1] +=3

    elif hikaku[0] > hikaku[1]:
        ten[0] +=3

    else:
        ten[0]+=1
        ten[1]+=1

print(" ".join(map(str,ten)))

Measured memory_bytes: 7608
#include <bits/stdc++.h>
using namespace std;
int main () {
  int X, Y, ans = 0;
  cin >> X >> Y;
  if(X == 1)ans += 300000;
  else if(X == 2)ans += 200000;
  else if(X == 3)ans += 100000;
  if(Y == 1)ans += 300000;
  else if(Y == 2)ans += 200000;
  else if(Y == 3)ans += 100000;
  if(X == 1 && Y == 1)ans += 400000;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
MAX_N=2*10**5
P=10**9+7
def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
def inv(x):
    return egcd(x,P)[0]
Fact=[0 for i in range(MAX_N+1)]
Finv=[0 for i in range(MAX_N+1)]
Fact[0]=1
Finv[0]=1
for i in range(MAX_N):
    Fact[i+1]=(Fact[i]*(i+1))%P
    Finv[i+1]=inv(Fact[i+1])%P
def C(n,k):
    return (Fact[n]*(Finv[k]*Finv[n-k])%P)%P
def H(n,r):
    return C(n+r-1,r-1)
ans=1
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct
D=factorize(M)
for seq in D:
    k=seq[1]
    ans=ans*C(k+N-1,N-1)
    ans=ans%P
print(ans)



Measured memory_bytes: 19008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}

int countBits(int in){
  int res=0;
  rep(i,10){
    int msk=1<<i;
    if((in&msk)!=0){
      res++;
    }
  }
  return res;
}

int main() {
  int k;cin>>k;
  queue<ll> q;
  set<ll> contains;
  rep(i,10){
    q.push(i+1);
    contains.insert(i+1);
  }
  ll ans=0;
  while(k>0){
    ll val=q.front();
    q.pop();
    k--;
    ll next=val*10+val%10-1;
    if(val%10!=0){
      if(contains.find(next)==contains.end()){
        q.push(next);
        contains.insert(next);
      }
    }
    next++;
    if(contains.find(next)==contains.end()){
      q.push(next);
      contains.insert(next);
    }
    next++;
    if(val%10!=9){
      if(contains.find(next)==contains.end()){
        q.push(next);
        contains.insert(next);
      }
    }
    ans=val;
  }
  cout<<ans<<endl;
  return 0;
}


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  int a, b;
  cin >> a >> b;
  if (abs(b - a) % 2 == 0)
  {
    pr(min(a, b) + abs(a - b) / 2);
  }
  else
    pr("IMPOSSIBLE");
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 


signed main(){
    FASTER;
    int a,b,c,d;cin>>a>>b>>c>>d;
    int g=c*d/__gcd(c,d);
    int ans=(b/c)-(a-1)/c;
    ans+=(b/d)-(a-1)/d;
    ans-=(b/g)-(a-1)/g;
    cout<<(b-a+1)-ans;
    
}


Measured memory_bytes: 3576
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	int N;
	cin >> N;
	vector<int> T(N+1);
	vector<int> X(N+1);
	vector<int> Y(N+1);
	T[0] = 0;
	X[0] = 0;
	Y[0] = 0;
	for (int i=0;i<N;i++) cin >> T[i+1] >> X[i+1] >> Y[i+1] ;

	int d_t, y_t, x_t;
	bool flag = true;
	for(int i=0;i<N;i++){
		d_t = T[i+1] - T[i];
		x_t = abs(X[i+1] - X[i]);
		y_t = abs(Y[i+1] - Y[i]);
		// cout << (X[i]+Y[i])%2 << "," << (T[i]%2) << endl;
		// cout << d_t << "," << x_t + y_t << endl;
		if(d_t < x_t+y_t || (X[i]+Y[i])%2!=(T[i]%2)){
			flag = false;
			break;
		}
	}
	if (flag==true){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1408
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Integer[] a = new Integer[3];
		a[0] = sc.nextInt();
		a[1] = sc.nextInt();
		a[2] = sc.nextInt();
		int K = sc.nextInt();
		Arrays.sort(a, Collections.reverseOrder());
		for (int i=0; i<K; i++) {
			a[0] = a[0]*2;
		}
		int res = 0;
		for (int i=0; i<a.length; i++) {
			res += a[i];
		}
		System.out.println(res);
	}
}


Measured memory_bytes: 21716
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int n; cin >> n;
    vint a(n); vin(a);
    const int MOD = 1e9 + 7;

    vvint sum(60, vint(2, 0));
    rfor(x, a) {
        rep(i, 60) {
            if(x & 1LL << i) {
                sum[i][1]++;
            } else {
                sum[i][0]++;
            }
        }
    }
    int ans = 0;
    rep(i, 60) {
        int t = (1LL << i) % MOD;
        t = t * sum[i][0] % MOD;
        t = t * sum[i][1] % MOD;
        ans = (ans + t) % MOD;
    }

    print(ans);
    return 0;
}


Measured memory_bytes: 2560
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0082

"""
import sys
from sys import stdin
from collections import deque
input = stdin.readline


def calc_remaining(data, carriges):
    # ??????????????£????????°?????????
    total = 0
    for d, c in zip(data, carriges):
        if d > c:
            total += d - c
    return total


def solve(data):
    carriges = deque([1, 4, 1, 4, 1, 2, 1, 2])

    min_remaining = float('inf')
    min_carrige_value = float('inf')

    for i in range(8):
        remaining = calc_remaining(data, carriges)
        if remaining < min_remaining:
            min_remaining = remaining
            min_carrige_value = int(''.join(map(str, carriges)))
        elif remaining == min_remaining:
            carrige_value = int(''.join(map(str, carriges)))
            if carrige_value < min_carrige_value:
                min_carrige_value = carrige_value
        carriges.rotate(1)

    return min_remaining, min_carrige_value


def main(args):
    for line in sys.stdin:
        # data = [2, 3, 1, 4, 0, 1, 0, 1]
        # data = [4, 2, 3, 2, 2, 2, 1, 1]
        data = [int(x) for x in line.split()]
        _, result = solve(data)
        print(' '.join(map(str, list(str(result)))))



if __name__ == '__main__':
    main(sys.argv[1:])
    

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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7,inf=mod*mod*3ll;;
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

ll N,M;
ll H[100005];
ll check[100005];//1なら良い展望台でない
ll ans;

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N>>M;

rep(i,N) cin>>H[i];
rep(i,M){
	ll a,b;
	cin>>a>>b; a--; b--;
	if(H[a]<H[b]) check[a]=1;
	if(H[a]>H[b]) check[b]=1;
	if(H[a]==H[b]){
		check[a]=1;
		check[b]=1;
	}
}

rep(i,N){
	if(check[i]==0) ans++;
}
cout<<ans<<endl;


}
	


Measured memory_bytes: 5216
import collections

n,m,s=map(int,input().split())
g=[[] for _ in range(n+1)]
dic={}
for _ in range(m):
  u,v,a,b=map(int,input().split())
  g[u].append(v)
  g[v].append(u)
  dic[(u,v)]=(a,b)
  dic[(v,u)]=(a,b)
arr=[[0,0]]+[list(map(int,input().split())) for _ in range(n)]
cost=[[10**18]*2501 for _ in range(n+1)]
for i in range(min(2500,s)+1):
  cost[1][i]=0
q=collections.deque()
q.append(1)
while len(q)!=0:
  v=q.popleft()
  c,d=arr[v]
  for i in range(c,2501):
    cost[v][i]=min(cost[v][i],cost[v][i-c]+d)
  for u in g[v]:
    a,b=dic[(v,u)]
    flag=False
    for i in range(a,2501):
      if cost[u][i-a]>cost[v][i]+b:
        cost[u][i-a]=cost[v][i]+b
        flag=True
    if flag==True:
      q.append(u)

for i in range(2,n+1):
  print(min(cost[i]))

Measured memory_bytes: 75504
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

const ll p=924844033,r=5;

ll Pow(ll n,ll m){
	ll res=1;
	while(m>0){
		if(m&1) (res*=n)%=p;
		(n*=n)%=p;
		m>>=1;
	}
	return res;
}

ll Inv(ll x){return Pow(x,p-2);}

void ntt(vl& a,bool B){
	int n=a.size(),h=0;
	while(1<<h<n) h++;
	for(int i=0;i<n;i++){
		int j=0;
		for(int k=0;k<h;k++) if(i&1<<k) j+=1<<(h-k-1);
		if(i<j) swap(a[i],a[j]);
	}
	for(int i=1;i<n;i*=2){
		ll w=Pow(r,(p-1)/(i*2));
		if(B) w=Inv(w);
		for(int j=0;j<n;j+=i*2){
			ll wn=1;
			for(int k=0;k<i;k++){
				ll s=a[j+k],t=a[i+j+k]*wn%p;
				a[j+k]=(s+t)%p;
				a[i+j+k]=(s-t+p)%p;
				(wn*=w)%=p;
			}
		}
	}
	if(B){
		ll v=Inv(n);
		for(int i=0;i<n;i++) (a[i]*=v)%=p;
	}
}

vl Conv(vl a,vl b){
	int s=a.size()+b.size()-1,t=1;
	while(t<s) t*=2;
	a.resize(t);
	b.resize(t);
	ntt(a,0);ntt(b,0);
	for(int i=0;i<t;i++) (a[i]*=b[i])%=p;
	ntt(a,1);
	a.resize(s);
	return a;
}

const int M=200005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%p;
}

ll Div(ll n,ll m){
	return n*Pow(m,p-2)%p;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%p);
}

int n;
vi s;
vvi g;

int dfs(int v,int w){
	s[v]++;
	for(auto u:g[v]) if(u!=w) s[v]+=dfs(u,v);
	return s[v];
}

int main(){
	cin>>n;
	s=vi(n);
	g=vvi(n);
	Init();
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(0,-1);
	vl a(n+1),b(n+1);
	for(int i=0;i<n;i++){
		int S=n-1;
		for(auto v:g[i]) if(s[i]>s[v]) a[s[v]]++,S-=s[v];
		if(S) a[S]++;
	}
	for(int i=1;i<=n;i++){
		(a[i]*=F[i])%=p;
		b[i]=Inv(F[n-i]);
	}
	vl c=Conv(a,b);
	for(int i=1;i<=n;i++) cout<<(n*nCk(n,i)%p-Div(c[n+i],F[i])+p)%p<<endl;
}

Measured memory_bytes: 36968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int p,a,b;
int main(){
    ios::sync_with_stdio(false);
    cin>>n;
    cin>>a>>b;
    int x=0,y=0,z=0;
    for(int i=1;i<=n;i++){
        cin>>p;
        if(p<=a){
            x++;
        } else if(p>b){
            z++;
        } else{
            y++;
        }
    }
    cout<<min(x,min(y,z))<<endl;
}


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

ll f(ll K, ll point)
{
    int count = 0;
    while (point < K) {
        count++;
        point *= 2;
    }
    return count;
}

void main_()
{
    ll N, K;
    cin >> N >> K;

    double prob_total = 0.0;
    for (ll i = 1; i <= N; ++i) {
        auto win_num = f(K, i);
        auto prob = pow(0.5, win_num);
        prob_total += prob;
    }

    cout << setprecision(15) << prob_total / N << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define all(vec) vec.begin(), vec.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl
#define isEven(t) t % 2 == 0

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

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int X, Y;
	cin >> X >> Y;
	int ans = 0;

	while(1){
		if(Y-X<0){
			break;
		}
		X *= 2;
		ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <string> 
using namespace std;
#define LL long long
const long long INF = 1LL << 60;
int main()
{

  LL N,K;
  LL A[100100]{};
  LL DP[100100]{};
  cin>>N>>K;
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  for(int i=0;i<N+K;i++){
    DP[i]=INF;
  }
  DP[0]=0;

  DP[1]=abs(A[1]-A[0]);
  for(int i=0;i<N;i++){
    for(int j=1;j<K+1;j++){
      if(i-j<0)continue;
      DP[i]=min(DP[i],abs(A[i]-A[i-j])+DP[i-j]);
    }
  }

  cout<<DP[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1792