akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestCS
{
    class Program
    {
        public static void Main(string[] args)
        {
            int[,,] peoples = new int[4,3,10];
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                List<int> nums = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
                int b = nums[0];
                int f = nums[1];
                int r = nums[2];
                int v = nums[3];
                peoples[b - 1, f - 1, r - 1] += v;
            }
            for(int i = 0;i <4; i++)
            {
                for(int j = 0;j < 3; j++)
                {
                    for(int k =0;k < 10; k++)
                    {
                        Console.Write(" " + peoples[i,j,k]);
                    }
                    Console.WriteLine();
                }
                if (i < 3)
                { Console.WriteLine("####################");
                }
            }
        }
    }
}



Measured memory_bytes: 16312
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
int s[105];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  int sum = 0;
  REP(i, n) {
    cin >> s[i];
    sum += s[i];
  }

  if(sum % 10 != 0) {
    cout << sum << endl;
    return 0;
  }

  int ans = 0;
  REP(i, n) {
    if((sum - s[i]) % 10 != 0){
      ans = max(ans, sum - s[i]);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
K = int(input())

if K % 2 == 0 or K % 5 == 0:
    print(-1)
    exit()

ans = 0
ai = 0
while True:
    ai = (ai * 10 + 7) % K
    ans += 1
    if ai % K == 0:
        print(ans)
        exit()


Measured memory_bytes: 9056
from itertools import accumulate

n,m,k=map(int,input().split())
a_acum=list(accumulate(list(map(int,input().split()))))
b_acum=list(accumulate(list(map(int,input().split()))))

def ask_number(data,value):
    start,end=0,len(data)
    while True:
        mid=(start+end)//2
        if start == mid:
            break
        if data[mid] > value:
            end=mid
        else:
            start=mid
    if start == 0 and data[0] > value:
        return 0
    else:
        return end
    
ans=ask_number(b_acum,k)

for i in range(n):
        sub = k - a_acum[i]
        if sub < 0:
            break
        else:
            ans=max(ans,ask_number(b_acum,sub)+i+1)
print(ans)

Measured memory_bytes: 126000
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
using ll = long long;
int main(){
    int n;
    cin >> n;
    int ans=0;
    rep(i,n){
        int x;
        cin >>x;
        if(x%2==1 && i%2==0){
            ans ++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
import java.util.*;
//import java.math.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    if(N <= 999) {
      System.out.println("ABC");
    } else {
      System.out.println("ABD");
    }
    
      }


  }


Measured memory_bytes: 23764
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

x,y = LI()
ans = None

if x == 0:
    ans = abs(y)
    ans += 1 if y<0 else 0
elif x>0:
    if abs(x) == abs(y):
        ans = 1
    elif abs(x) < abs(y):
        ans = abs(y)-abs(x)
        ans += 1 if y<0 else 0
    else:
        ans = 1 + abs(x)-abs(y)
        ans += 1 if y>0 else 0
else:
    if abs(x) == abs(y):
        ans = 1
    elif abs(x) < abs(y):
        ans = 1 + abs(y)-abs(x)
        ans += 1 if y<0 else 0
    else:
        ans = abs(x) - abs(y)
        ans += 1 if y>0 else 0

print(ans)



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

int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;

  int sum[n + 1];  // 0+i文字目までのAC数
  sum[0] = sum[1] = 0;
  for (int i = 1; i < (int)s.size(); i++) {
    sum[i + 1] = sum[i];
    if (s[i - 1] == 'A' && s[i] == 'C') sum[i + 1]++;
  }

  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    cout << sum[r] - sum[l] << '\n';
  }

  return 0;
}

Measured memory_bytes: 4076
#include <bits/stdc++.h>
    #define ll  long long int
    #define N 100000
    #define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
    #define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
    #define po pop_back
    #define pb push_back
    #define lb lower_bound
    #define fi first
    #define se second
    #define debug(x) cout << #x << " = " << x << endl
    #define ub upper_bound
    #define ibs ios_base::sync_with_stdio(false)
    #define cti cin.tie(0)
    #define all(x) x.begin(),x.end()
    #define PI 3.14159265
    #define cot cout.tie(0)
    using namespace std;
      /**
        * @author :: Sawlani
        *
        */
      vector <ll> v[N+1];
      stack <ll> topo;
      bool vis[N+1];

      void dfs(ll i)
      {
          for(auto j:v[i])
          {
              if(!vis[j])
              {
                  vis[j]=true;
                  dfs(j);
              }
          }
          topo.push(i);
      }
    int main()
    {
        ll n,m;
        cin >> n >> m;

        f(i,1,m)  {
        ll x,y;
        cin >>  x >> y;
        v[x].pb(y);
      }

        memset(vis,false,sizeof(vis));

        f(i,1,n)
        {
            if(!vis[i])
            {
                vis[i]=true;
                dfs(i);

            }
        }

        vector <ll> res;

        while(!topo.empty())
        {
            res.pb(topo.top());
            topo.pop();

        }
        ll dis[n+1];

         f(i,1,n)  dis[i]=INT_MIN;
         ll ans=INT_MIN;
        f(i,0,n-1)
        {
            if(dis[res[i]]==INT_MIN)
                dis[res[i]]=0;
            for(auto j:v[res[i]])
            {
                if(dis[res[i]]+1>dis[j])
                    dis[j]=dis[res[i]]+1,ans=max(ans,dis[j]);

            }
       }


       cout << ans;}


Measured memory_bytes: 9636
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0]*n

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                w = cmt + ': ' + str(x)
            else:
                w = str(x)
            print(w)
        return x

def prob():
    d = Debug()
    d.off()
    A, B, T = getIntList()
    d.dmp((A, B, T),'A, B, T')
    return T//A*B

ans = prob()
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <vector>

using namespace std;

class Cell {
  public:
    int h;
    int w;
    bool is_wall;
    Cell(int _h, int _w) { h = _h; w = _w; }
    Cell() { h = 1; w = 1; }
};

int main()
{
  int height, width;
  scanf("%d %d\n", &height, &width);
  vector<vector<Cell>> cell(height, vector<Cell>(width));
  for (int x = 0; x < height; x++) {
    for (int y = 0; y < width; y++) {
      char ch = getchar();
      if (ch == '#') {
        cell.at(x).at(y).is_wall = true;
      } else if (ch == '.') {
      } else {
        fprintf(stderr, "Unexpected char '%c'\n", ch);
        exit(1);
      }
    }
    getchar();
  }
  int result = 0;
  for (int x = 0; x < height; x++) {
    for (int y = 0; y < width; y++) {
      if (cell.at(x).at(y).is_wall) {
        continue;
      }
      if (1 <= x && !cell.at(x-1).at(y).is_wall) {
        cell.at(x).at(y).h = cell.at(x-1).at(y).h;
      } else {
        int h = 0;
        for (int xx = x; xx < height; xx++) {
          if (cell.at(xx).at(y).is_wall) {
            break;
          }
          h++;
        }
        cell.at(x).at(y).h = h;
      }
      if (1 <= y && !cell.at(x).at(y-1).is_wall) {
        cell.at(x).at(y).w = cell.at(x).at(y-1).w;
      } else {
        int w = 0;
        for (int yy = y; yy < width; yy++) {
          if (cell.at(x).at(yy).is_wall) {
            break;
          }
          w++;
        }
        cell.at(x).at(y).w = w;
      }
      result = max(result, cell.at(x).at(y).h + cell.at(x).at(y).w - 1);
    }
  }
  printf("%d\n", result);
  return 0;
}


Measured memory_bytes: 47232
#include <iostream>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main(){
    stack<int> S1;
    stack<pair<int, int> > S2;
    char ch;
    int sum=0;
    for(int i=0; cin >> ch; i++){
        if(ch == '\\'){
            S1.push(i);
        } else if(ch == '/' && S1.size() > 0){
            int j = S1.top(); S1.pop();
            sum += i - j;
            int a = i-j;
            while(S2.size() > 0 && S2.top().first>j){
                a += S2.top().second; S2.pop();
            }
            S2.push(make_pair(j, a));
        }
    }
    vector<int> ans;
    while(S2.size() > 0){
        ans.push_back(S2.top().second); S2.pop();
    }
    reverse(ans.begin(), ans.end());
    cout << sum << endl;
    cout << ans.size();
    for(int i=0; i<ans.size(); i++){
        cout << " " << ans[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3216
#include <algorithm>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

int main() {
  std::string s, t;
  std::cin >> s >> t;
  if (std::count(s.begin(), s.end(), '1') > 0 &&
      std::count(t.begin(), t.end(), '1') == 0) {
    std::cout << "-1\n";
    return 0;
  }
  int n = s.size();
  std::vector<int> lsh(n, n + 1), rsh(n, n + 1);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (t[j] == '1') {
        if (i >= j) {
          lsh[i] = std::min(lsh[i], i - j);
        } else {
          lsh[i] = std::min(lsh[i], n - (j - i));
        }
        if (j >= i) {
          rsh[i] = std::min(rsh[i], j - i);
        } else {
          rsh[i] = std::min(rsh[i], n - (i - j));
        }
      }
    }
  }
  constexpr int kInf = 1'000'000'000;
  int ans = kInf;
  for (int rot = 0; rot < n; ++rot) {
    {
      int res = rot;
      std::vector<std::pair<int, int>> more;
      for (int i = 0; i < n; ++i) {
        if (s[(i + rot) % n] != t[i]) {
          ++res;
          if (lsh[(i + rot) % n] <= rot) continue;
          more.emplace_back(rsh[(i + rot) % n], lsh[i]);
        }
      }
      std::sort(more.begin(), more.end());
      std::vector<int> suff(more.size() + 1, 0);
      for (int i = more.size() - 1; i >= 0; --i) {
        suff[i] = std::max(suff[i + 1], more[i].second);
      }
      int extra = suff[0];
      for (int i = 0, j = 0; i < more.size(); i = j) {
        for (j = i; j < more.size() && more[j].first <= more[i].first; ++j)
          ;
        extra = std::min(extra, more[i].first + suff[j]);
      }
      ans = std::min(ans, 2 * extra + res);
    }
    {
      int res = rot;
      std::vector<std::pair<int, int>> more;
      for (int i = 0; i < n; ++i) {
        if (s[(i + n - rot) % n] != t[i]) {
          ++res;
          if (rsh[(i + n - rot) % n] <= rot) continue;
          more.emplace_back(lsh[(i + n - rot) % n], rsh[i]);
        }
      }
      std::sort(more.begin(), more.end());
      std::vector<int> suff(more.size() + 1, 0);
      for (int i = more.size() - 1; i >= 0; --i) {
        suff[i] = std::max(suff[i + 1], more[i].second);
      }
      int extra = suff[0];
      for (int i = 0, j = 0; i < more.size(); i = j) {
        for (j = i; j < more.size() && more[j].first <= more[i].first; ++j)
          ;
        extra = std::min(extra, more[i].first + suff[j]);
      }
      ans = std::min(ans, 2 * extra + res);
    }
  }
  std::cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a,b,c,d,x,y;
  int i;
  
  scanf("%d %d %d %d", &a, &b, &c, &d);
  
  for(i=1;;i++){
   
   if(c-b<=0){
     printf("Yes");
     break;
   }else if(a-d<=0){
     printf("No");
     break;
   }else{
   }
   c-=b;
   a-=d;
  }
  
  return 0;
}

Measured memory_bytes: 1736
def 解():
    sS = input().rstrip()
    dsS = set()
    for s in sS:
        if s not in dsS:
            dsS.add(s)
    iK = int(input())
    iL = len(sS)
    iC = 0
    for s in sorted(list(dsS)):
        sDic = set()
        indexes = []
        for i in range(iL):
            if sS[i] == s :
                if i != 0 and i != iL-1:
                    if sS[i-1] != s or sS[i+1] != s:
                        indexes.append(i)
                else:
                    indexes.append(i)
        if iK < iL :
            for i in indexes:
                for j in range(1,iK+1):
                    if i+j <= iL:
                        sDic.add(sS[i:i+j])
            aS = sorted(list(sDic))
            if iK <= len(aS) :
                print(aS[iK - iC -1])
                exit()
            else:
                iC += len(aS)
        else:
            for i in indexes:
                for j in range(1,iL -i+1):
                    sDic.add(sS[i:i+j])
            aS = sorted(list(sDic))
            iLS = len(aS)
            if iC + iLS < iK:
                iC += iLS
                continue
            else:
                print(aS[iK -iC-1])
                exit()
解()


Measured memory_bytes: 3188
from collections import defaultdict
from collections import deque
N, M = map(int, input().split())
edges = defaultdict(list)
ans = [0]*(N+1)
num = 1
q = deque([1])
currentdepth = {1}
nextdepth = set()
for _ in range(M):
  a, b = map(int, input().split())
  edges[a].append(b)
  edges[b].append(a)
while q:
  current = q.popleft()
  for nextver in edges[current]:
    if ans[nextver]==0:
      q.append(nextver)
      ans[nextver] = current
print('Yes')
print(*(ans[2:]),sep='\n')

Measured memory_bytes: 40340
"use strict";
const main = input => {
    const n = parseInt(input[0].split(' ')[0]),
    d = parseInt(input[0].split(' ')[1]);
    let x = new Array();
    for(let i=0; i<n; i++) {
      x[i] = input[i+1].split(' ').map(val => parseInt(val));
    }
    // console.log(n,d,x);
    let ans=0;
    for(let i=0; i<n-1; i++) {
      for(let j=i+1; j<n; j++) {
        let value=0;
        for(let k=0; k<d; k++) {
          value+=Math.pow(Math.abs(x[i][k]-x[j][k]),2);
        }
        value=Math.pow(value,0.5);
        // console.log(value);
        if (Number.isInteger(value)) {
          ans++;
        }
      }
    }
    console.log(ans);
    
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

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

int main() {
  int a,b;
  cin>>a;
  cin>>b;
  
  float x=(a+b)/2.0f;
  int x_int=x;
  
  if(x-x_int!=0)
    cout<<x_int+1;
  else
    cout<<x_int;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String Sa=sc.next();
		String Sb=sc.next();
		String Sc=sc.next();
		StringBuilder SBa=new StringBuilder(Sa);
		StringBuilder SBb=new StringBuilder(Sb);
		StringBuilder SBc=new StringBuilder(Sc);
		String abc=SBa.substring(0, 1);
		SBa.delete(0, 1);
		
		while(true){
			if(abc.equals("a")){
				if(SBa.length()==0){
					System.out.println("A");
					return;
				}
				abc=SBa.substring(0,1);
				SBa.delete(0,1);
			}else if(abc.equals("b")){
				if(SBb.length()==0){
					System.out.println("B");
					return;
				}
				abc=SBb.substring(0,1);
				SBb.delete(0, 1);
			}else if(abc.equals("c")){
				if(SBc.length()==0){
					System.out.println("C");
					return;
				}
				abc=SBc.substring(0,1);
				SBc.delete(0, 1);
			}
		}
	}
}


Measured memory_bytes: 23764
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

int n, m;

int main() {
  cin >> n >> m;
  cout << (n - 1) * (m - 1);
}


Measured memory_bytes: 3500
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include<map>
#include<type_traits>

using namespace std;

int main() {
	string S,G;
	cin >> S;
	int w;
	cin >> w;
	for (int i = 0; i < S.size(); i+=w) {
		G += S[i];
	}
	cout << G << endl;
	return 0;
}

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

int main(void){
   
    int n;
    cin>>n;
    
    long long int po=1;
    long long int t=pow(10, 9)+7;
    
    for(int i=0; i<n; i++){
        
        po=(po%t)*(i+1);
    
    }
    
    cout<<po%t<<endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a = []
b = []
for i in range(n):
    a.append(list(map(int, input().split())))
for i in range(m):
    b.append(int(input()))
for i in range(n):
    c = 0
    for j in range(m):
        c += a[i][j] * b[j]
    print(c)


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

int main (){
	int n;
	while(cin>>n && n){
		vector<int> v(n);
		for(int i=0;i<n;i++){
			string s;
			cin>>s;
			v[i]=s.size();
		}

		for(int i=0;i<n;i++){
			int count=0;
			int j=i;
			vector<bool> ok(5,false); 
			while(j<=n-1){
				count+=v[j];
				j++;
				if(count==5)ok[0]=true;
				if(ok[0] && count==12)ok[1]=true;
				if(ok[1] && count==17)ok[2]=true;
				if(ok[2] && count==24)ok[3]=true;
				if(ok[3] && count==31)ok[4]=true;
				if(ok[4]){
					cout<<i+1<<endl;
					goto END;
				}
			}
		}
		END:;
	}
}


Measured memory_bytes: 3176
from collections import defaultdict

class LCM_mod:
    """
    最小公倍数の計算を行う
    オーバーフローが発生しないように素因数分解し,
    因数の積を逐次余りに置き換えて最小公倍数を導出する.
    """
    def __init__(self, max_num, p=10**9+7):
        self.max_num = max_num + 1
        self.p = p
        self.prime = [0 for _ in range(self.max_num)]
        self.max_map = defaultdict(int)
        self.sieve()

    def rep_sqr(self, base, k):
        # 繰り返し二乗法
        if k == 0:
            return 1
        elif k % 2 == 0:
            return (self.rep_sqr(base, k / 2) ** 2) % self.p
        else:
            return (self.rep_sqr(base, k - 1) * base) % self.p

    def sieve(self):
        """
        エラトステネスの篩　O(n)
        nまでに含まれる素数を導出
        """
        self.prime[0], self.prime[1] = 1, 1
        for i in range(2, self.max_num):
            if self.prime[i] == 0:
                for j in range(i * 2, self.max_num, i):
                    if self.prime[j] == 0:
                        self.prime[j] = i
                self.prime[i] = i

    def lcm_list_mod(self, arr):
        """
        listのそれぞれの要素について、素因数分解する
        それぞれの因数について最大であれば更新する
        """
        for i in range(len(arr)):
            num = arr[i]
            d = defaultdict(int)

            while num > 1:
                fact = self.prime[num]
                d[fact] += 1
                num //= fact

            for i in d.keys():
                self.max_map[i] = max(self.max_map[i], d[i])

        ans = 1
        for i in self.max_map.keys():
            ans = (ans * self.rep_sqr(i, self.max_map[i])) % self.p
        return ans


def rep_sqr(base, k, mod):
    if k == 0:
        return 1
    elif k % 2 == 0:
        return (rep_sqr(base, k / 2, mod) ** 2) % mod
    else:
        return (rep_sqr(base, k - 1, mod) * base) % mod

# a^(-1) == a^(m-2)

def flt(a, mod):
    return rep_sqr(a, mod-2, mod)


n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7

lcm_mod = LCM_mod(10**6, MOD)

lcm_all = lcm_mod.lcm_list_mod(a)

b = list(map(lambda x: lcm_all * flt(x, MOD), a))
ans = 0
for i in range(len(b)):
    ans += b[i]
    ans %= MOD
print(ans)


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

using namespace std;

long long n, a, b;

int main() {
//	freopen("inp.txt", "r", stdin);
	
	cin >> n >> a >> b;
	
	long long rem = abs(b - a);
	if (rem % 2 == 0) {
		cout << (b - a) / 2;
	} else {
		long long mm = n - b + (b - a + 1) / 2;
		long long nn = a - 1 + (b - a + 1) / 2;
		cout << min(mm, nn);
	}
	
	return 0;
}

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

int main()
{
  int n,t;
  cin>>n;
  int a[n];
  for(int i=0; i<n-1; i++)cin>>a[i];
  t=a[0];
  for(int i=1; i<n-1; i++) t += min(a[i],a[i-1]);
  t+=a[n-2];

  cout<<t<<endl;

  return 0;

}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);		// 整数の入力


int A= sc.nextInt();
int B= sc.nextInt();
int C= sc.nextInt();
int K= sc.nextInt();
int max=A;
int sonota=B+C;
int sum=0;

	if(max<B){
		max=B;
		sonota=A+C;
	}
	if(max<C){
		max=C;
		sonota=A+B;
	}

	for(int i=0; i<K; i++){
		sum=max*2+sonota;
		max=max*2;
	}
	System.out.println(sum);
	}

}


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

#define what_is(x)    cerr<<#x<<" is "<<x<<"\n";
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int dp[100005][3];
int solve(){
    cin>>n;
    int a[n+1][3];
    rep(i,1,n){
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    dp[1][0]=a[1][0];
    dp[1][1]=a[1][1];
    dp[1][2]=a[1][2];
    rep(i,2,n){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+a[i][2];
    }
    cout<<max({dp[n][0],dp[n][1],dp[n][2]});
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 4992
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int x, y, z;
int k;
ll a[1000], b[1000];
vector<ll> c;

ll ans[3000];

void solve(){
	vector<ll> ab;
	rep(i, x)rep(j, y) ab.push_back(a[i]+b[j]);
	sort(ab.rbegin(), ab.rend());
	sort(c.rbegin(), c.rend());
	priority_queue<ll> q;
	rep(i, min(k, x*y)){
		rep(j, min(k, z)){
			q.push(-(ab[i]+c[j]));
			if(q.size() > k) q.pop();
		}
	}
	for(int i = k-1; i >= 0; i--){
		ans[i] = -q.top();
		q.pop();
	}
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> x >> y >> z >> k;
    c.resize(z);
    rep(i, x) cin >> a[i];
    rep(i, y) cin >> b[i];
    rep(i, z) cin >> c[i];
    solve();
    rep(i, k) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 10476
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include<iomanip>
#include<sstream>
#include <fstream>
#define ll long long
#define pb push_back
#define clr(a, b) memset((a), (b), sizeof(a))
#define debugs(x) cout << "Line" << __LINE__ << "	" << #x << "=" << x << endl
#define break break
#define continue continue
#define itn int
#define endl '\n'
#define Endl endl
#define vint vector<ll>
#define pii pair<int, int> 
using namespace std;

int n, k, m;
int a[200005];

void solve(int T)
{
	int l, r, d;
	cin >> l >> r >> d;
	cout << r / d - (l-1) / d  << endl;
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	int numoftest = 1;

	//cin >> numoftest;


	for (int siven = 1; siven <= numoftest; ++siven)
		solve(siven);
	return 0;
}

/*


*/

Measured memory_bytes: 3172
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		int H=sc.nextInt();
		int W=sc.nextInt();
		int N=sc.nextInt();
		int[]a=new int[N];
		for(int i=0;i<N;i++){
			a[i]=sc.nextInt();
		}
		int[][]color=new int[W][H];
		int x=0;
		int y=0;
		for(int i=0;i<N;i++){
			while(a[i]>0){
				color[x][y]=i+1;
				a[i]--;
				
				if(y%2==0){
					if(x==W-1){
						y++;
					}else{
						x++;
					}
				}else{
					if(x==0){
						y++;
					}else{
						x--;
					}
				}
			}
		}
		for(int yi=0;yi<H;yi++){
			for(int xi=0;xi<W;xi++){
				System.out.print(color[xi][yi]);
				if(xi!=W-1)System.out.print(" ");
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 30488
#include <stdio.h>

int main(){
  int a,b,d,r;
  double f;

  scanf("%d%d",&a,&b);
  d=a/b;
  r=a%b;
  f=(double)a/b;
  printf("%d %d %f\n",d,r,f);

  return 0;
}

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

void fnInput(int &a_riLoadingCnt, int &a_riTrackCnt, vector<int> &a_rviLoading)
{
  cin >> a_riLoadingCnt >> a_riTrackCnt;

  a_rviLoading.resize(a_riLoadingCnt);
  for (int i = 0; i < a_riLoadingCnt; i++)
    cin >> a_rviLoading[i];
}

int fnSimuAlloc(const vector<int> &a_cnrviLoading, int a_iTrackCnt, int a_iMinLoading)
{
  int iCurLoading;
  int iTrackCnt = 0;

  for (int i = 0; i < a_cnrviLoading.size();    )
  {
    if (a_cnrviLoading[i] > a_iMinLoading)  return 0;

    iTrackCnt++;
    iCurLoading = 0;
    while (i < a_cnrviLoading.size())
    {
      iCurLoading += a_cnrviLoading[i];
      if (iCurLoading > a_iMinLoading)  break;

      i++;
    }
  }
  return (iTrackCnt <= a_iTrackCnt);
}

void fnAllocation(const vector<int> &a_cnrviLoading, int a_iTrackCnt, int &a_riMinLoading)
{
  const int cniMinLoading = 0;
  const int cniMaxLoading = 1000000000;

  int iLow  = cniMinLoading;
  int iHigh = cniMaxLoading;
  a_riMinLoading = cniMaxLoading;

  while (iLow < iHigh)
  {
    int iMid = (iLow + iHigh) / 2;
    if (fnSimuAlloc(a_cnrviLoading, a_iTrackCnt, iMid))
    {
      a_riMinLoading = min(a_riMinLoading, iMid);
      iHigh = iMid;
    }
    else
      iLow = iMid + 1;
  }
}

void fnResultOut(int a_iMinLoading)
{
  cout << a_iMinLoading << endl;
}

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

  int iLoadingCnt, iTrackCnt;
  vector<int> viLoading;
  int iMinLoading = 0;

  fnInput(iLoadingCnt, iTrackCnt, viLoading);
  fnAllocation(viLoading, iTrackCnt, iMinLoading);
  fnResultOut(iMinLoading);

  return 0;
}

Measured memory_bytes: 1524
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n,d,x,a[100],cnt = 0;
  cin >>n>>d>>x;
  for(int i=0;i<n;i++) cin >> a[i];
  for(int i=0;i<n;i++) cnt += (1+(d-1)/a[i]);
  cout << (cnt+x);
}

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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

li M=1e9+7;

vi fact(500001),invfact(500001);

li init()
{
    fact[0]=1;

    f(i,1,500000)
    {
        fact[i]=(fact[i-1]*i)%M;
    }

    invfact[500000]=fastpow(fact[500000],M-2,M);

    fr(i,499999,0)
    {
        invfact[i]=(invfact[i+1]*(i+1))%M;
    }
}

li ncr(li n,li r)
{
    return (((fact[n]*invfact[n-r])%M)*invfact[r])%M;
}

int main()
{    
    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li n,k;

    cin>>n>>k;

    init();

    li tp=min(k,n-1);

    li ans=0;

    f(i,0,tp)
    {
        ans+=((ncr(n,i)*ncr(n-i+i-1,i))%M);
        ans%=M;
    }

    cout<<ans;

    return 0;
}

Measured memory_bytes: 8064
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 20;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

int main()
{
	int A, B, C;
	scanf("%d%d%d", &A, &B, &C);
	int mx = max({A, B, C});
	if(mx*3%2 != (A+B+C)%2) mx++;
	printf("%d\n", (mx*3 - A-B-C)/2);
}


Measured memory_bytes: 256
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


# MOD = 998244353
def cummax(it, first=-float('inf')):
    """
    累積 max
    :param collections.Iterable it:
    :param float first:
    :return:
    """
    cm = first
    ret = []
    for v in it:
        cm = max(v, cm)
        ret.append(cm)
    return ret


N = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().split()))
SIZE = 2 ** N

# dp[k]: i | j | k == k となる i, j のうち A[i] + A[j] が最大となる i, j
#: :type: list of ((int, int), (int, int))
dp = [None] * SIZE
for k in range(1, SIZE):
    dp[k] = list(sorted([(A[0], 0), (A[k], k)]))

# 高速ゼータ変換、配る版
# for k in range(1, SIZE):
#     mask = k
#     while mask < SIZE - 1:
#         # kに立ってないビットを1つだけ立てる
#         next_k = (mask + 1) | k
#         mask |= next_k
#
#         a1, a2 = dp[k]
#         b1, b2 = dp[next_k]
#         if a1 > b2:
#             # dp[next_k] = a1, a2
#             dp[next_k] = dp[k]
#         elif b1 > a2:
#             # dp[next_k] = b1, b2
#             pass
#         elif a2 > b2:
#             dp[next_k] = b2, a2
#         elif b2 > a2:
#             dp[next_k] = a2, b2

# 高速ゼータ変換
d = 1
while d < SIZE:
    for k in range(1, SIZE):
        if k & d == 0 or k - d == 0:
            continue
        # k に立っているビットを1つだけ消したもの
        prev_k = k - d

        a1, a2 = dp[k]
        b1, b2 = dp[prev_k]
        if a1 > b2:
            # dp[k] = a1, a2
            pass
        elif b1 > a2:
            # dp[k] = b1, b2
            dp[k] = dp[prev_k]
        elif a2 > b2:
            dp[k] = b2, a2
        elif b2 > a2:
            dp[k] = a2, b2
    d <<= 1

ans = [0] * SIZE
for k in range(1, SIZE):
    (a1, _), (a2, _) = dp[k]
    ans[k] = a1 + a2

ans = cummax(ans[1:])
print(*ans, sep='\n')


Measured memory_bytes: 138380
# @oj: atcoder
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-09-03 17:51
# @url:https://atcoder.jp/contests/abc148/tasks/abc148_e
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
from decimal import *
# region fastio

BUFSIZE = 8192

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------------------
def main():
    # refer:
    # https://blog.csdn.net/qq_43765333/article/details/103658132?utm_medium=distribute.pc_feed_404.none-task-blog-BlogCommendFromBaidu-2.nonecase&depth_1-utm_source=distribute.pc_feed_404.none-task-blog-BlogCommendFromBaidu-2.nonecas
    n=int(input())
    if n%2==1:
        print (0)
    else:
        n=n//2
        ans=0
        while n>=5:
            ans+=n//5
            n=n//5
        print (ans)
if __name__ == "__main__":
    main()

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

using namespace std;

vector<int> same;

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

	for(int i = 0;i < n;i++){
		int tn;
		cin >> tn;
		if(tn - 1 == i) same.push_back(i);
	}
	
	int ans = same.size();
	int s = same.size();
	
	for(int i = 0;i < s-1;i++){
		if(same[i+1] - same[i] == 1){
			ans--;
			i++;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 892
//#pragma GCC optimise("Ofast,unroll-loops,no-stack-protector,fast-math");
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,popcnt,avx,avx2,tune=native")
          
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
          
using namespace std;
using namespace __gnu_pbds;
          
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
          
using matrix = vector<vector<ll>>;
template<typename T>
using kawaii_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
          
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
//#define int long long
 
void FAST_IO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.setf(ios::fixed);
    //cout.precision(20);
    #ifndef _offline
    //freopen("chess.in", "r", stdin);
    //freopen("chess.out", "w", stdout);
    #endif
}   

const int MAXN = 1e5 + 100;
vector<int> g[MAXN];
int used[MAXN], dist[MAXN];
bool flag = true;

void dfs(int u) {
    for (int to : g[u]) {
        if (used[to] == 0) {
            used[to] = (used[u] ^ 3);
            dfs(to);
        }
        else if (used[to] == used[u]) {
            flag = false;
        }
    }
}

pii calc(int u, int color) {
    queue<int> q;
    used[u] = color;
    dist[u] = 0;
    q.push(u);
    int mx = 0, v = u;
    while (q.size()) {
        u = q.front();
        q.pop();
        for (int to : g[u]) {
            if (used[to] != color) {
                used[to] = color;
                dist[to] = dist[u] + 1;
                q.push(to);
                if (dist[to] > mx) {
                    mx = dist[to];
                    v = to;
                }
            }
        }
    }
    return {mx, v};
}

signed main() {
    FAST_IO();
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < n; ++j) {
            if (s[j] == '1') {
                g[i].push_back(j);
            }
        }
    }
    used[0] = 1;
    dfs(0);
    if (!flag) {
        cout << -1 << '\n';
        return 0;
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        ans = max(ans, calc(i, 100 + i).first);
    }
    cout << ans + 1 << '\n';
}

Measured memory_bytes: 2816
N, M = map(int, input().split())
gates = []
for _ in range(M):
    gates.append(tuple(map(int, input().split())))

L = 1
R = N
for l, r in gates:
    if l > L:
        L = l
    if r < R:
        R = r
if R >= L:
    print(R - L + 1)
else:
    print(0)


Measured memory_bytes: 16612
#include <iostream>
#include <sstream>  // istringstream
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main()
{   
    string S, T;
    cin >> S >> T;

    string ans = "Yes";
    for(int i=0; i<S.length(); ++i){
        if(S[i] != T[i]){
            ans = "No";
        }
    }
    if(S.length()+1 != T.length()){
        ans = "No";
    }

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

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/


signed main() {
	int n; cin >> n;
	for (int i = 2; n; i++) {
		if (i % 5 == 1 && prime(i)) {
			cout << i << " ";
			n--;
		}
	}
	cout << endl;
}

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

#define INF (1 << 29)
#define rep2(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) rep2(i,0,n)
#define EPS 1e-10

using namespace std;

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

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

int main()
{
    ll W,H;
    cin >> W >> H;
    vector<P> p(W);
    vector<P> q(H);
    rep(i,W) cin >> p[i].first;
    rep(i,W) p[i].second = i;
    rep(i,H) cin >> q[i].first;
    rep(i,H) q[i].second = i;

    sort(p.begin(),p.end());
    sort(q.begin(),q.end());

    ll ans = 0;
    int pi=0,qi=0;

    while(pi < W && qi < H){
        if(p[pi].first < q[qi].first){
            ans += p[pi].first*(H+1-qi);
            pi++;
        } else {
            ans += q[qi].first*(W+1-pi);
            qi++;
        }
    }
    while(pi < W){
        ans += p[pi].first*(H+1-qi);
        pi++;
    }
    while(qi < H){
        ans += q[qi].first*(W+1-pi);
        qi++;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long j = 1;
		long count = 0;
		while(1 <= H) {
			count+= j;
			H /= 2;
			j *= 2;
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define in insert
#define mp make_pair
using namespace std;
const int N = 1e5+123;
int a[N];
int n,m,k;
string s;
set<int>setik;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n >> m;
	cout << n - m + 1;	
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#include<queue>
#include<functional>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 11234567890123456789
using namespace std;

int main(){
	ll n, k; cin >> n >> k;
	vl l(n); rep(i, n) cin >> l[i];
	sort(l.begin(), l.end());
	ll ans = 0;
	rep(i,k) ans += l[n-1-i];
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,P> cake;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=1000000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll ytox(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}
vector<ll> divisor(ll x){
	vector<ll> div;
	for(int i=1;i*i<=x;i++){
		if(i*i!=x && x%i==0){
			div.pb(i);
			div.pb(x/i);
		}
		else if(x%i==0) div.pb(i);
	}
	return div;
}
vector<ll> vectorprime(ll x){
	vector<bool> is_prime(x+1);
	vector<ll> prime;
	rep(i,x+1) is_prime[i]=true;
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<=x;i++){
		if(is_prime[i]){
			prime.pb(i);
		}
		for(int j=i*2;j<=x;j+=i) is_prime[j]=false;
	}
	return prime;
}

//a,b x
int main(){
	ll N; cin>>N;
	ll mem1,mem2; cin>>mem1>>mem2;
	rep(i,N-1){
		ll tmp1,tmp2; cin>>tmp1>>tmp2;
		ll T=max(ytox(mem1,tmp1),ytox(mem2,tmp2));
		mem1=tmp1*T;
		mem2=tmp2*T;
	}
	cout<<mem1+mem2;
}

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

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

  while (N > 0) {
    if (N % 10 == 7) {
      cout << "Yes" << endl;
      return 0;
    }
    N = N / 10;
  }

  cout << "No" << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;

#define EPS 1e-10

int main(){

	int n;
	while(cin >> n, n){
		vector<int> a(n);
		rep(i, n) cin >> a[i];
		
		ll sum = 0;
		ll ans = -LLINF;
		rep(i, n){
			sum += a[i];
			ans = max(ans, sum);
			if(sum < 0) sum = 0;
		}
		
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> a(n);
    REP(i,n) cin >> a[i];
    sort(ALL(a));
    ll ans = 0;
    int left = 0, right = n-1, i = 0;
    while (right-left>1) {
        ans += abs(a[right]-a[left]);
        if(i%2==0) -- right;
        else ++ left;
        ++ i;
    }
    if(n%2==1) ans += max(abs(a[n-1]-a[right]), abs(a[left]-a[right]));
    else ans += max(abs(a[n-1]-a[left]), abs(a[right]-a[left]));
    ll tmp = 0;
    left = 0, right = n-1, i = 0;
    while (right-left>1) {
        tmp += abs(a[right]-a[left]);
        if(i%2==0) ++ left;
        else -- right;
        ++ i;
    }
    if(n%2==1) tmp += max(abs(a[0]-a[left]), abs(a[left]-a[right]));
    else tmp += max(abs(a[0]-a[right]), abs(a[right]-a[left]));
    chmax(ans,tmp);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
using namespace std;
const int INF = 1000000000;
const int mod = 1000000007;
signed main() {
	int n, x = 0, y = 0; cin >> n;
	if (n == 1000000000000000000) {
		cout << 0 << ' ' << 0 << ' ' << INF << ' ' << 0 << ' ' << 0 << ' ' << INF << endl;
		return 0;
	}
	x = (n / INF + 1) * INF - n; y = (n + x) / INF;
	cout << 0 << ' ' << 0 << ' ' << INF << ' ';
	cout << 1 << ' ' << x << ' ' << y << endl;
	return 0;
}

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

int main() {
	string s;
	int k = 0, u = 0, p = 0, c = 0;

	cin >> s;
	for (int i = 0;i < s.size();i++) {
		if (s[i] == 'K')k++;
		else if (s[i] == 'U')u++;
		else if (s[i] == 'P')p++;
		else if (s[i] == 'C')c++;
	}
	cout << min(min(k,u),min(p,c)) << endl;
	return 0;
}

Measured memory_bytes: 3180