akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
    int n,t,a,h[1000],min = 0;
    int i,j;

    scanf("%d %d %d",&n,&t,&a);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&h[i]);
    }

    for (i = 0; i < n; i++)
    {
        if(fabs(a - t + h[min] * 0.006) > fabs(a - t + h[i] * 0.006))min = i;
        
    }
    printf("%d",min + 1);
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority queue
#include<deque>//double_ended queue
using namespace std;
int main()
{ 
    int n;
    cin>>n;
    int p[n];
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    int ans=0;
    for(int i=0;i<n-1;i++){
        if(p[i]==i+1){
            p[i]=p[i+1];
            p[i+1]=i+1;
            ans++;
        }
    }
    if(p[n-1]==n){ans++;}
    cout<<ans<<endl;
}

Measured memory_bytes: 640
def main():
  import bisect
  import sys
  from itertools import accumulate
  input = sys.stdin.readline
  def hsnum(x):
    num = 0
    for i in a:
      y = x-i
      num += n-bisect.bisect_left(a,y)
    return num
  n,m = map(int, input().split())
  a = list(map(int, input().split()))
  a.sort()
  suma = [0]+list(accumulate(a))
  lx = 0
  rx = 2*10**5+2
  error = 0
  while lx+1 < rx:
    mx = (lx+rx)//2
    if hsnum(mx) < m:
      rx = mx
    elif hsnum(mx) > m:
      lx = mx + 1
    else:
      lx = mx
      break
  if hsnum(lx)<m:
    lx -= 1
  error = hsnum(lx)-m
  ans = 0
  for i in a:
    rema = lx - i
    j = bisect.bisect_left(a,rema)
    ans += (n-j)*i-suma[j]
  ans += suma[n]*n
  print(ans-error*lx)
if __name__ == "__main__":
    main()

Measured memory_bytes: 59052
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() { 
    int X, Y, Z;
    cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y;
    return 0; 
    }

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

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

            var amari = N % 500;

            var str = "No";

            if (A >= amari) str = "Yes";

            Console.WriteLine(str);

        }

    }

}



Measured memory_bytes: 11092
import java.io.*;
import java.util.*;

public class  Main{
	static int mod=(int)1e9+7;
	static long[][]comb;
	static void nCr2(int N)		// O(N * N)
	{
		comb = new long[N][N];
		comb[0][0] = 1;
		for (int i = 1; i < N; i++)
		{
			comb[i][0] = 1;
			for (int j = 1; j <= i; j++)
				comb[i][j] = (comb[i-1][j] + comb[i-1][j-1])%mod;		//may use mod
		}
	}
    public static void main(String[] args) throws Exception{
        //MScanner sc = new MScanner("chess.in");
        MScanner sc = new MScanner(System.in);
        PrintWriter pw=new PrintWriter(System.out);
        //int n=sc.nextInt();int[]in=new int[n];
        //for(int i=0;i<n;i++)in[i]=sc.nextInt();
        int n=sc.nextInt();int b=sc.nextInt();int r=n-b;
        nCr2(2002);
        for(int i=1;i<=b;i++) {
        	long ans=(comb[r+1][i]*comb[b-1][i-1])%mod;
        	pw.println(ans);
        }
        pw.flush();
    }
    static class tri implements Comparable<tri>{
    	int type;int x;int y;
    	tri(int t,int a,int b){
    		type=t;x=a;y=b;
    	}
		@Override
		public int compareTo(tri o) {
			if(type!=o.type)
				return type-o.type;
			return o.x-x;
		}
		public String toString() {
			return "("+x+" "+y+")";
		}
    }
    static class MScanner {
		StringTokenizer st;
		BufferedReader br;
 
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 82132
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k;
    cin >> k;
    int l;
    l=50;
    vll a(l);
    ll t = k/50LL;
    REP(i,l){
        a[i]=49LL+t;
    }
    ll r = k%50;
    REP(i,r){
        sort(ALL(a));
        a[0]+=50;
        for(int i=1;i<l;i++){
            a[i]--;
        }
    }
    cout << l << endl;
    REP(i,l){
        cout << a[i] << ((i==l-1)?("\n"):(" "));
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace AtCoder2020Ned
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(" ");
            var takahashi = new Duelist("takahashi", int.Parse(input[0]), int.Parse(input[1]));
            var aoki = new Duelist("aoki", int.Parse(input[2]), int.Parse(input[3]));

            var match = new Match(takahashi, aoki);
            var isMatchCompleted = false;

            for (; isMatchCompleted == false; )
            {
                isMatchCompleted = Duel(match);

                if (isMatchCompleted == false)
                {
                    match.TurnChange();
                }
            }

            if (match.Attacker.Name == "takahashi")
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

            Console.Read();
        }

        /// <summary>
        /// battle
        /// </summary>
        /// <param name="match">Match instance</param>
        /// <returns>The Match is completed or not</returns>
        static bool Duel (Match match)
        {
            match.Defender.HP -= match.Attacker.ATK;

            return match.Defender.HP <= 0 ? true : false;
        }
    }

    class Duelist
    {
        public Duelist(string name, int hp, int atk)
        {
            this.name = name;
            this.HP = hp;
            this.ATK = atk;
        }

        internal string Name
        {
            get
            {
                return this.name;
            }
        }

        internal int HP { get; set; } = 0;
        internal int ATK { get; set; } = 0;

        private string name = string.Empty;
    }

    class Match
    {
        public Match(Duelist attacker, Duelist defender)
        {
            this.Attacker = attacker;
            this.Defender = defender;
        }
        internal Duelist Attacker { get; set; } = new Duelist("unknown", 0, 0);
        internal Duelist Defender { get; set; } = new Duelist("unknown", 0, 0);

        public void TurnChange()
        {
            var temp = this.Attacker;
            this.Attacker = this.Defender;
            this.Defender = temp;
        }
    }
}


Measured memory_bytes: 27452
if __name__ == '__main__':
    a = [int(i) for i in input().split()]
    a11 = a[1]
    a12=a11+a[0]

    a21 = a[2]
    a22 = a21 + a[0]

    if (a11 <= a21 and a12 >= a21) or (a11 <= a22 and a12 >= a22):
        print(0)
    elif a11 <= a21 and a22 <=a22:
        print(abs(a12 -a21))
    else:
        print(abs(a11-a22))

Measured memory_bytes: 3064
n = gets.to_i

ary = []
n.times do |i|
    s, p = gets.split(' ')
    ary << [i, s, p.to_i]
end

ary.sort_by!{|x| [x[1], -x[2]]}

ary.each do |f|
    puts f[0] + 1
end

Measured memory_bytes: 1788
using System;
//using System.Collections.Generic;
//using System.Linq;

namespace solution
{
  class Class1
  {
    static void Main()
    {
      string[] s = Console.ReadLine().Split();
      double x1 = double.Parse(s[0]);
      double y1 = double.Parse(s[1]);
      double x2 = double.Parse(s[2]);
      double y2 = double.Parse(s[3]);

      Console.WriteLine(Math.Sqrt(Math.Pow((x1 - x2), 2.0) + Math.Pow((y1 - y2), 2.0)));
    }
  }
}


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


def prime_factorize(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr


n = int(readline())

p = prime_factorize(n)

if n == 1:
    print(0)
    exit()

ans = 0
for f, c in p:
    cnt = 0
    while c >= cnt+1:
        c -= cnt+1
        cnt += 1
    ans += cnt
print(ans)


Measured memory_bytes: 9552
#include <bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
signed main(){
    int n,m; cin>>n>>m;
    vector<int> k(n);
    vector<vector<int>> a(n,vector<int>(0));
    rep(i,n){
        cin>>k.at(i);
        rep(j,k.at(i)){
            a.at(i).push_back(0);
            cin>>a.at(i).at(j);
        }
    }
    int ans=0; bool b=false;
    for(int i=1; i<=m; i++){
        for(int j=0; j<n; j++){
            b=false;
            for(int l=0; l<k.at(j); l++){
                if(a.at(j).at(l)==i){
                    b=true;
                    break;
                }
            }
            if(!b) break;
        }
        if(!b) continue;
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		int[] a = new int[n + 1];
		for (int i = 0; i < a.length; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		int m = 0;
		Map<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i < a.length; i++) {
			if (map.containsKey(a[i])) {
				m = i - map.get(a[i]) + 1;
				break;
			}
			map.put(a[i], i);
		}
		int mod = 1000000007;
		int n1 = n + 1;
		int r = n1 - m;
		NCR ncr = new NCR(n1, mod);

		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 1; i <= n1; i++) {
			long val1 = ncr.calc(n1, i);
			long val2 = ncr.calc(r, i - 1);
			long ans = val1 - val2 + mod;
			ans %= mod;
			pw.println(ans);
		}
		pw.flush();
	}

	static class NCR {
		long[] p, pi;
		int m;

		public NCR(int n, int mod) {
			n++;
			m = mod;
			p = new long[n];
			pi = new long[n];
			p[0] = 1;
			pi[0] = 1;
			for (int i = 1; i < n; i++) {
				p[i] = p[i - 1] * i % m;
			}
			pi[n - 1] = BigInteger.valueOf(p[n - 1])
					.modInverse(BigInteger.valueOf(m)).longValue();
			for (int i = n - 1; i > 1; i--) {
				pi[i - 1] = pi[i] * i % m;
			}
		}

		public long calc(int n, int r) {
			if (n < r) return 0;
			return p[n] * pi[r] % m * pi[n - r] % m;
		}
	}
}


Measured memory_bytes: 44452
#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 ll                 long long
#define LL                 long long
#define pii                pair<int, int>
#define pll                pair<ll, ll>
#define pil                pair<int, ll>
#define pli                pair<ll, int>
#define vi                 vector<int>
#define vl                 vector<ll>
#define vii                vector<pii>
#define vll                vector<pll>
#define vil                vector<pil>
#define vli                vector<pli>
#define pb                 push_back
#define mp                 make_pair
#define ff                 first
#define ss                 second
#define sz(x)              (int)x.size()
#define TN                 typename
#define all(v)             v.begin(), v.end()
#define fill(a, b)         memset(a, b, sizeof(a))
#define endl               '\n'
#define Int                in()
#define Long               Lin()
#define policy_set         tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define policy_multiset    tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>

template <TN T> T gcd(T a, T b) {return !b ? a : gcd(b, a % b);}
template <TN T> T lcm(T a, T b) {return a * (b / gcd(a, b));}
template <TN T> inline void smin(T &a, T b) {a = a < b ? a : b;}
template <TN T> inline void smax(T &a, T b) {a = a > b ? a : b;}

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", " ;
    err(++it, args...);
}

inline int in() {int n; scanf("%d", &n); return n;}
inline ll Lin() {ll n; scanf("%lld", &n); return n;}
inline double Din() {double n; scanf("%lf", &n); return n;}

const int mod        = (int)1e9 + 7;
const ll  Mod        = (ll)1e9 + 7;

inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (ll)a * b % mod;}

const int inf        = (int)2e9 + 5;
const ll  Inf        = (ll)1e18 + 5;
const int N          = 2e5 + 5;

int main() {
	char arr[7];
	cin>>arr;
	if (arr[2]==arr[3]&&arr[4]==arr[5])
	{
		cout<<"Yes"<<endl;
	}
	else
		cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
//----------ACCIDENTAL COMPETITIVE PROGRAMMER---------------------

#include<bits/stdc++.h>

/*
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
*/
using namespace std;

#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair


const LL MOD = (1e9) + 7 ;
const LD EPS = 0.0000001 ;
const int N = 101;
const int W = 100000 + 50;

LL cache[N][W];

int n, w;

LL weight[N];
LL value[N];

LL solve(int idx, int total)
{
	if (idx > n)
		return 0;
	LL &ans = cache[idx][total];
	if (ans != -1)
		return ans;
  	
	ans = solve(idx + 1, total);
  	if (total + weight[idx] <= w)
  	 ans = max (ans, solve(idx + 1, total + weight[idx]) + value[idx]);
	return ans;
}

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    for (int i = 0; i < N; i++){
    	for (int j = 0; j < W; j++)
    		cache[i][j] = -1;
    }

    cin >> n >> w;
    for (int i = 1; i <= n; i++){
    	cin >> weight[i] >> value[i];
    }

    cout << solve(1, 0) << endl;

	return 0;
}


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

int main() {
  int x;cin>>x;
  while(1){
    bool ans=true;
    for(int i=2;i<x;i++){
      if(x%i==0)ans=false;
    }
    if(ans){
      cout<<x<<endl;
      return 0;
    }
    x++;
  }
}

Measured memory_bytes: 3620
while True:
    try:
        alist = input().split()
        blist = input().split()
        hit = brow = 0
        
        for i in range(4):
            for j in range(4):
                if alist[i] == blist[j]:
                    if i == j:
                        hit += 1
                    else:
                        brow += 1
        print(hit,brow)
    except EOFError:
        break


Measured memory_bytes: 5556
X = int(input())
for a in range(10**3):
  for b in range(10**3):
    if a**5-b**5 == X:
      ans = [a, b]
      break
    if a**5+b**5 == X:
      ans = [a, -b]
      break
print(ans[0], ans[1])

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

using namespace std;

int n,m,i,j,cnt[2];
vector <pair<int, int> > a;

int main(){
	scanf("%d%d", &n, &m);
	
	for(i = 0; i < n; i++){
		int x;
		scanf("%d", &x);
		a.push_back({x, 0});
	}
	
	for(i = 0; i < m; i++){
		int x;
		scanf("%d", &x);
		a.push_back({x, 1});
	}
	
	sort(a.begin(), a.end());
	long long res = 0;
	
	for(i = 0; i < a.size(); i++){
		int cost = a[i].first;
		int id = a[i].second;
		
		if(id == 0){
			res += (long long)cost * (m - cnt[1 - id] + 1);
		}
		else{
			res += (long long)cost * (n - cnt[1 - id] + 1);
		}
		cnt[id]++;
		
	}
	
	printf("%lld\n", res);
}


Measured memory_bytes: 2928
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vb= vector<bool>;
using vl= vector<ll>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

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


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code ---*/
	K := nextInt()
	X := nextInt()
	for i := X - (K - 1); i < X+K; i++ {
		if i != X-(K-1) {
			fmt.Fprint(out, " ")
		}
		fmt.Fprint(out, i)
	}
	fmt.Fprintln(out)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// Genericsがないので筋肉で...
// interfaceでの取扱がようわからんし
func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

// mapからkeysとvaluesを返す感じのやつ
// なんかしらんけどmap[interface{}]interface{}しか受け付けない。なんのためのinterface{}やねん
// なので呼ぶときのmapはmap[int]stringとかじゃダメ
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
	return
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

int main(void){
  int n,i;
  vector<int> a;

  cin>>n;

  a.resize(n);

  for(i=0;i<n;i++){
    cin>>a[i];
  }

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

  for(i=0;i<n-1;i++){
    if(a[i]==a[i+1]){
      cout<<"NO"<<endl;
      return 0;
    }
  }

  cout<<"YES"<<endl;

  return 0;
}


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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

typedef pair<int, int> P;
#define INF 1e9
#define INF_LL 1LL<<60
#define ll long long

int main() {
    int n;
    cin >> n;
    string s[n];
    REP(i, n) cin >> s[i];

    int cnt[n][26];
    REP(i, n) REP(j, 26) cnt[i][j] = 0;

    REP(i, n) {
        REP(j, s[i].size()) {
            int c = (int)(s[i][j] - 'a');
            cnt[i][c]++;
        }
    }

    int ans[26];

    REP(i, 26) {
        int tmp = 100;
        REP(j, n) {
            tmp = min(tmp, cnt[j][i]);
        }
        ans[i] = tmp;
    }

    REP(i, 26) {
        REP(j, ans[i]) {
            printf("%c", i+'a');
        }
    }
    
    cout << endl;

    return 0;
}

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

using namespace std;

int main(void) {
    int H, W;
    cin >> H >> W;

    vector<vector<char>> s(H+2, vector<char>(W+2, '.'));

    for (int h = 1; h <= H; h++) {
        for (int w = 1; w <= W; w++) {
            cin >> s[h][w];
        }
    }

    for (int h = 1; h <= H; h++) {
        for (int w = 1; w <= W; w++) {
            if (s[h][w] == '.') {
                continue;
            }
            if (s[h+1][w] != '#' && s[h-1][w] != '#' && s[h][w+1] != '#' && s[h][w-1] != '#') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;

bool my_binary_search(const vector<int>& S, int T, int l, int r){
    if (l > r) return false;
    int pos = (l + r) / 2;
    if (T == S[pos]) return true;
    if (T > S[pos])  return my_binary_search(S, T, pos + 1, r);
    return my_binary_search(S, T, l, pos - 1);

}

int main(){
    int n;
    cin >> n;
    vector<int> S(n);
    for (auto& s : S) cin >> s;
    int q;
    cin >> q;
    int cnt = 0;
    for (int i = 0; i < q; i++) {
        int T;
        cin >> T;
        if (my_binary_search(S, T, 0, n - 1)) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int N, M, K, Q, W, H, R, C;
int dp[110][11000];

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

    cin >> N >> W;
    vector<int> v(N), w(N);
    REP(i, N) cin >> v.at(i) >> w.at(i);

    REP(i, N) {
        REP(j, W + 1) {
            chmax(dp[i + 1][j], dp[i][j]);
            if (j + w[i] <= W) chmax(dp[i + 1][j + w[i]], dp[i + 1][j] + v[i]);
        }
    }
    cout << dp[N][W] << endl;

    return 0;
}



Measured memory_bytes: 7380
N = int(input())
nums = [0 for i in range(100)]
for i in range(1, N + 1):
    i = str(i)
    nums[int(i[0] + i[-1])] += 1
ans = 0
for i in range(1, 10):
    for j in range(i, 10):
        i = str(i)
        j = str(j)
        if i != j:
            ans += nums[int(i + j)] * nums[int(j + i)] * 2
        else:
            n = nums[int(i + j)]
            ans += n * (n - 1)
            ans += n
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main(){
    int S,h,m,s;
    scanf("%d",&S);
    h=S/3600;
    m=(S-h*3600)/60;
    s=S-h*3600-m*60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}




Measured memory_bytes: 2108
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>

#define INF_LL 9000000000000000000
#define INF 2000000000

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)

using namespace std;

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

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int chain[10002];

int no(int idx){
	int c = 1;
	int p = idx - 1;
	int q = idx + 1;
	int res = 0;
	while(chain[p] == chain[idx]){
		p--;
		c++;
	}
	while(chain[q] == chain[idx]){
		q++;
		c++;
	}
	while(c >= 4){
		res += c;
		c = 0;
		if(chain[q] != chain[p]) return res;
		if(chain[q] == chain[p] && chain[p] == -1) return res;

		int org = chain[p];
		while(chain[p] == org){
			p--;
			c++;
		}
		while(chain[q] == org){
			q++;
			c++;
		}
	}
	return res;
}

int main(void){
	int H, W, N;
	int target = 1;
	int res = 0;
	int sx, sy;
	queue<PII> que;
	cin >> H >> W >> N;
	string field[1002];
	field[0] = string(1002, 'X');
	field[H+1] = string(1002, 'X');
	REP(i, H){
		cin >> field[i+1];
		field[i+1] = 'X' + field[i+1] + 'X';
		if(field[i+1].find('S') != -1){
			que.push(PII(field[i+1].find('S'), i+1));
			sx = que.front().first;
			sy = que.front().second;
		}
	}

	while(target <= N){
		int take[1002][1002];
		REP(i, 1002){
			fill(take[i], take[i]+1002, INF);
		}
		take[que.front().first][que.front().second] = 0;
		while(!que.empty()){
			PII p = que.front(); que.pop();
			int dx[4] = {-1, 0, 0, 1};
			int dy[4] = {0, -1, 1, 0};
			REP(i, 4){
				int x = p.first + dx[i];
				int y = p.second + dy[i];
				if(field[y][x] == 'X') continue;
				if(take[x][y] != INF) continue;
				else{
					if(field[y].substr(x, 1) == to_string(target)){
						res += take[p.first][p.second]+1;
						queue<PII>().swap(que);
						sx = x;
						sy = y;
						target++;
						break;
					}else{
						take[x][y] = min(take[x][y], take[p.first][p.second] + 1);
						que.push(PII(x, y));
					}
				}
			}
		}
		que.push(PII(sx, sy));
	}
	cout << res << endl;
}

Measured memory_bytes: 8952
#include<iostream>
#include<stdlib.h>
#include<cmath>
using namespace std;

int const size = 1000000;
int const N = size;

bool* hurui(int an)
{
        const int MAX_SIZE = sqrt(size);
        static bool vec[size];

        //初期化
        for(int i=0;i <= size; i+=2)
        {
                vec[i] = false;
        }
        for(int i=1;i <= size; i+=2)
        {
                vec[i] = true;
        }

        vec[1] = false;
        vec[2] = true;

        for(int i=3;i < MAX_SIZE;i+=2)
        {
                if(vec[i]){
                        for(int j=2; i*j < size ; j++)
                        {
                                vec[i*j] = false;
                        }
                }
        }

        return vec;
}

int main()
{
        bool* vec = hurui(1);
        int l,m,n;
        while(cin >> l >> m >> n){
                if(l==0 && m == 0 && n == 0)
                        break;
                int count = 0;
                for(int i = 0; i < size; i++)
                {
                        if(vec[l+i*m]){
                                count++;
                        }

                        if(count == n){
                                cout << (l + m*i) << endl;
                                break;
                        }
                }
        }

        return 0;
}

Measured memory_bytes: 2136
//
// Created by Tian Wang on 16/4/17.
//

#include <iostream>
using namespace std;



int main() {
    int n;
    int out;
    while(cin >> n){
        out=0;
        for(int i = 0; i <= 9 && i <= n; i ++) {
            for(int j = 0; j<=9 && j <= n; j++) {
                for(int k = 0; k<=9 && j <= n; k++) {
                    if(i+j+k <= n && i+j+k >= n-9) {
                        out+=1;
                    }
                }
            }
        }
        cout << out << endl;
    }
}

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

int main() {
  int64_t A, B;
  cin >> A >> B;
  
  int64_t x = A * B;
  int l, s;
  if (A > B) {
    l = A;
    s = B;
  } else {
    l = B;
    s = A;
  }
  /*cout << "A = " << A << endl;
  cout << "B = " << B << endl;
  cout << "x = " << x << endl;
  cout << "l = " << l << endl;*/
  
  int64_t ans = x;
  for (int64_t i = x; i >= l; i -= s) {
    if (!(i % A) && !(i % B)) {
      ans = i;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#1行目に複数の整数の場合
p, q, r = map(int, input().split())

#a→b→c、a→c→b、b→a→c、b→c→a、c→a→b、c→b→a
#これらの経路の内最短を求めればより
#a→b、b→aはともにp時間のため
#a→b→c、c→b→aの経路にかかる時間は同値
#p,  q, rの全てのcombination（組み合わせ）の内最小値を求める
#min(value, value, value)で最小値を求める
print(min(p + q, q + r, r + p))


Measured memory_bytes: 38384
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

        List<String> strings = new ArrayList<>();

        for (int i = 0; i < s.length(); i++) {
            for (int j = 1; j < 6; j++) {
                if (i + j > s.length()) {
                    break;
                }

                String sub = s.substring(i, i + j);
                if (!strings.contains(sub)) {
                    strings.add(sub);
                }
            }
        }

        String[] output = new String[K];
        for (int i = 0; i < K; i++) {
            String min = "zzzzz";
            for (String string : strings) {
                if (string.compareTo(min) < 0) {
                    min = string;
                }
            }
            output[i] = min;
            strings.remove(min);
        }

        System.out.print(output[K - 1]);
    }
}


Measured memory_bytes: 25548
import collection.mutable.ArrayBuffer
import scala.reflect.ClassTag
import scala.language.implicitConversions


trait Graph {
    case class Edge[T:Numeric](from : Int, to : Int, cost : T)

    class Edges[T:Numeric](val data : ArrayBuffer[Edge[T]]) {
        def size = data.size
    }
    object Edges {
        def apply[T:Numeric](xs : Edge[T]*) = new Edges(ArrayBuffer(xs:_*))
        implicit def toUnderLying[T](x:Edges[T]) = x.data
    }

    class WeightedGraph[T:Numeric](val size : Int, val data : Array[Edges[T]]) {
        def this(size : Int) = this(size, Array.fill(size)(Edges()))
    }
    object WeightedGraph {
        def apply[T:Numeric](size : Int) = new WeightedGraph[T](size)
        implicit def toUnderLying[T](x:WeightedGraph[T]) = x.data
    }

    class UnWeightedGraph[T:Numeric](val size : Int, val data: Array[ArrayBuffer[T]]) {
        def this(size : Int) = this(size, Array.fill(size)(ArrayBuffer[T]()))
    }
    object UnWeightedGraph {
        def apply[T:Numeric](size : Int) = new UnWeightedGraph[T](size)
        implicit def toUnderLying[T](x:UnWeightedGraph[T]) = x.data
    }
   
    class Matrix[T:Numeric:ClassTag](val row : Int, val col : Int, val data : Array[Array[T]]) {
        def this(row : Int, col : Int) = this(row, col, Array.fill(row, col)(implicitly[Numeric[T]].zero))
        def this(size : Int) = this(size, size)
    }
    object Matrix {
        def apply[T:Numeric:ClassTag](row : Int, col : Int)(init : T) = 
            new Matrix[T](row, col, Array.fill(row, col)(init))
        def apply[T:Numeric:ClassTag](size : Int)(init : T) : Matrix[T] = Matrix[T](size, size)(init)
        implicit def toUnderLying[T](x:Matrix[T]) = x.data
    }
}

object Prim extends Graph {
    import scala.collection.mutable.PriorityQueue
    def prim[T](g : WeightedGraph[T])(implicit num : Numeric[T]) : T = {
        import num._
        val used = new Array[Boolean](g.size)
        val que = PriorityQueue()(Ordering.Tuple2[T, Int].reverse)
        que += ((zero, 0))
        var res = zero
        while (!que.isEmpty) {
            val (d, v) = que.dequeue
            if (!used(v)) {
                res = res + d
                used(v) = true
                for (e <- g(v)) {
                    que += ((e.cost, e.to))
                }
            }
        }
        res
    }
}

import Prim._

object Main {
    def main(args: Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        val V, E = sc.nextInt
        val edges = WeightedGraph[Int](V)
        for (_ <- 1 to E) {
            val s, t, c = sc.nextInt
            edges(s) += Edge(s, t, c)
            edges(t) += Edge(t, s, c)
        }
        val res = prim(edges)
        println(res)
    }
}



Measured memory_bytes: 287696
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;


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

        Double r= new Double(in.nextInt());

        System.out.println((Double)((2*22*r)/7));





    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}

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

int main() {
  double d;
  int a;
  int b;
  cin >> a;
  cin >> b;
  if((a+b)%2==0)d=(a+b)/2;
  else d=(a+b+1)/2;
  cout << d << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <vector>
#define ll long long
#define pb push_back
#define f first
#define s second
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
const int N = 1e5 + 5;
vector<string> s = {"AC", "WA", "TLE", "RE"};

map<string, int> is;

int main() {
    fast;
    int n; cin >> n;
    for(int i = 0; i < n; i++)
    {
        string k; cin >> k;
        is[k]++;
    }
    for(auto e : s){
        cout << e << " x " << is[e] << endl;
    }
    return 0;
}


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

template<class T> istream& operator>>(istream &is,vector<T> &st){
  for(size_t i=0;i<st.size();++i) is >> st[i];
  return is;
}
template<class T> ostream& operator<<(ostream &os, const vector<T> &st){
  for(size_t i=0;i<st.size();++i){
    if(i==st.size()-1) os << st[i];
    else os << st[i] << " ";
  }
  return os;
}

const std::uint_fast64_t MOD = 1e9 + 7;
/**
 * usage: modint<mod> x(1);
 * x.aで値を取り出し. modint同士で計算をやる.
 * http://noshi91.hatenablog.com/entry/2019/03/31/174006
 */
template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

vector<pair<int, int>> prime_factorization(int n) {
    vector<pair<int, int>> ret;
    int i = 2;
    for (; i * i <= n; i++) {
        int cnt = 0;
        while (n % i == 0) ++cnt, n /= i;
        if (cnt) ret.push_back({i, cnt});
    }
    ret.push_back({n, 1});
    return ret;
}

int pow_mod(int n, int k, int m) {
    int r = 1;
    for(; k > 0; k >>= 1) {
        if(k & 1)
            r = (r * n) % m;
        n = (n * n) % m;
    }
    return r;
}


signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    map<int, int> m;
    for (int a : A) {
        for (auto& p: prime_factorization(a)) {
            m[p.first] = max(p.second, m[p.first]);
        }
    }
    modint<MOD> lcm(1);
    for (auto& p: m) {
        lcm *= modint<MOD>(pow_mod(p.first, p.second, MOD));
    }
    modint<MOD> ans(0);
    for(int i = 0; i < N; i++) {
        ans += lcm / modint<MOD>(A[i]);
    }
    cout << ans.a << endl;
    
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt() + sc.nextInt() + sc.nextInt() + sc.nextInt();
		int b = sc.nextInt() + sc.nextInt() + sc.nextInt() + sc.nextInt();
		System.out.println(Math.max(a, b));
	}
}

Measured memory_bytes: 26200
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  string s,t;
  cin >> s >> t;
  cout << t+s << endl;
  return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N - 1);
    rep(i, N - 1){
        cin >> A.at(i);
    }

    vector<int> B(N);
    rep(i, N - 1){
        B.at(A.at(i) - 1)++;
    }
    rep(i, N){
        cout << B.at(i) << endl;
    }

    return 0;
}


Measured memory_bytes: 4844
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int N, K;
    vector<int> price(N);

    cin >> N >> K;

    int p;
    for (size_t i = 0; i < N; i++)
    {
        cin >> p;
        price.push_back(p);
    }

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

    int sum = 0;
    for (size_t i = 0; i < K; i++)
    {
        sum += price[i];
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
ll L,R;
ll f[64][2][2][2][2];
int l[100],r[100];
ll dfs(int x,int fl,int fr,int s,int ht)
{
	if(x<0)return 1;
	// x：第x位 （二进制转十进制下权值是1的为第0位）
	// fl： y之前是否有填过小于 R的某一位的数字   例如：R:11000 y:10??? fl即为1 表示后面数字可以往大了填
	// fr： x之前是否有填过大于 L的某一位的数字   类似fl
	// s： 之前x是否有某一位 < y的某一位 如果有，后面的位数就没有相对大小限制了 (确保 x<=y)
	//ht：确保 x，y 最高位一样都为1  （满足推导的要求）
	ll &ans=f[x][fl][fr][s][ht];
	if(ans) return ans;
	for(int i=0;i<2;i++)//y
	{
		for(int j=0;j<2;j++)//x
		{
			int tl=fl,tr=fr,ts=s,tt=ht;
			if(!tt&&i&&i!=j)continue;
			if((j&i)!=j)continue;
			if(!tl&&j<l[x])continue;
			if(!tr&&i>r[x])continue;
			if(!ts&&j>i)continue;
			if(j>l[x])tl=1;if(i<r[x])tr=1;if(j<i)ts=1;if(j)tt=1;
			ans+=dfs(x-1,tl,tr,ts,tt);
		}
	}
	ans%=mod;
	return ans;
}

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>L>>R;
	for(int i=63;i>=0;i--)
	{
		l[i]=(bool)((1ll<<i)&L);r[i]=(bool)((1ll<<i)&R);
	}
	cout<<dfs(63,0,0,0,0)<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#define pq priority_queue
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;


int main(){
  int a,b,c,k,m;
  cin>>a>>b>>c;
  cin>>k;
  m=max(max(a,b),c);
  m*=pow(2,k);
  cout<<a+b+c-max(max(a,b),c)+m<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	if(s.size()<4) {
		cout<<"No"<<endl;
		return 0;
	}
	if(s.substr(0,4)=="YAKI") cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int n, x, y;
vector<int> p, q, a;
int main() {
	int i, t;
	cin>> n;
	for(i=0; i<n; i++) cin>> t, p.push_back(t);
	for(i=0; i<n; i++) cin>> t, q.push_back(t), a.push_back(i+1);
	i = 0;
	do {
		i++;
		if(a==p) x = i;
		if(a==q) y = i;
	} while(next_permutation(a.begin(), a.end()));
	cout<< abs(y-x);
	return 0;
}

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

ll g[3002][3002]{};
ll a[3002][3002][4]{};


int main() {
    int R, C, K;
    cin >> R >> C >> K;
    int r, c, v;
    for (int i = 0; i < K; i++) {
        cin >> r >> c >> v;
        g[r][c] = v;
    }

    for (int i = 0; i <= R; i++) {
        for (int j = 0; j <= C; j++) {
            for (int k = 0; k <= 3; k++) {
                a[i + 1][j][0] = max(a[i + 1][j][0], a[i][j][k]);
                a[i][j + 1][k] = max(a[i][j + 1][k], a[i][j][k]);
                a[i + 1][j][1] = max(a[i + 1][j][1], a[i][j][k] + g[i + 1][j]);
                if (k != 3) {
                    a[i][j + 1][k + 1] = max(a[i][j + 1][k + 1], a[i][j][k] + g[i][j + 1]);
                }
            }
        }
    }
    ll best = 0;
    for (int i = 0; i <= 3; i++) {
        best = max(best, a[R][C][i]);
    }
    cout << best << "\n";
    return 0;
}

Measured memory_bytes: 355552
// Vicfred
// https://atcoder.jp/contests/abc160/tasks/abc160_d
import std.algorithm;
import std.math;
import std.stdio;

void main() {
    int n, x, y;
    readf("%s %s %s", &n, &x, &y);
    readln;

    int ans = 0;
    int[] dist = new int[n];

    for(int j = 1; j <= n; j++) {
        for(int i = 1; i < j; i++) {
            int minima = min(j-i, abs(y-j)+abs(x-i)+1);
            //minima = min(minima, abs(y-i)+abs(x-j)+1);
            dist[minima] += 1;
        }
    }

    for(int i = 1; i <= n-1; i++)
        dist[i].writeln;
}



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

int main(){

    int s;
    cin >> s;
    int hour = s / 3600;
    int minute = (s - 3600 * hour) / 60;
    int second = s - 3600 * hour - 60 * minute;
    cout << hour << ":" << minute << ":" << second << endl;
    
    return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int k[4][4],a[4];
int main()
{
	for(int i=1;i<=3;i++)
		for(int j=1;j<=3;j++)
			scanf("%d",&k[i][j]);
	for(a[1]=-100;a[1]<=100;a[1]++)
		for(a[2]=-100;a[2]<=100;a[2]++)
			for(a[3]=-100;a[3]<=100;a[3]++)
			{
				int b[4];
				b[1]=k[1][1]-a[1],b[2]=k[2][2]-a[2],b[3]=k[3][3]-a[3];
				bool flag=1;
				for(int i=1;i<=3;i++)
					for(int j=1;j<=3;j++)
					if(a[i]+b[j]!=k[i][j])flag=0;
				if(flag){printf("Yes\n");return 0;}
			}
	printf("No\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {

	ll R;
	std::cin >> R;

	std::cout << std::fixed << std::setprecision(15) << 2 * R * 3.1415926535 << endl;

	return 0;
}


Measured memory_bytes: 3772