akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MAX 105


int main(){
    int n;
    cin >> n;
    int A[MAX];
    REP(i,n) cin >> A[i];
    llong ans = 4000000;
    FOR(i,-100,101){
        llong tmp;
        tmp = 0;
        REP(j,n) tmp += (i -A[j]) * (i - A[j]);
        if( tmp < ans) ans =  tmp; 
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll qGCD(ll a,ll b) {while(b^=a^=b^=a%=b);return a;}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll n;
	cin>>n;
	ll ans=0;
	ll i,j,k;
	for( i=1;i<=n;i++){
		for( j=1;j<=n;j++){
			for( k=1;k<=n;k++){
				ll d=qGCD(i,j);
				ans+=(qGCD(d,k));
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3640
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmax(S &a, T b){
  if(a<b){
    a=b;
  }
  return a;
}
int N;
int H[100000];
int main(){
  int i, res=0, tmp;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(N);Lj4PdHRW++){
      rd(H[Lj4PdHRW]);
    }
  }
  for(i=N-1;i>=0;i--){
    if(i == N-1 || H[i] < H[i+1]){
      tmp = 0;
    }
    chmax(res, tmp);
    tmp++;
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190830-1

// --- original code ---
// int N, H[1d5];
// {
//   int i, tmp, res = 0;
//   rd(N,H(N));
//   for(i=N-1;i>=0;i--){
//     if(i == N-1 || H[i] < H[i+1]) tmp = 0;
//     res >?= tmp;
//     tmp++;
//   }
//   wt(res);
// }


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

using namespace std;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}



int main(){

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

    int a, b, c;
    cin >> a >> b >> c;

    ppp(min(b/a, c));





    return 0;
}


Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(n=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(n+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, n+1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## const ##
MOD=10**9+7
## libs ##
import itertools as it
import functools as ft
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#
def main():
    import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(n=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(n+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, n+1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## const ##
MOD=10**9+7
## libs ##
import itertools as it
import functools as ft
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#
def main():
    n = II()
    aa = MII()
    minc = 10**9
    for i in range(-100, 101):
        minc = min(minc, (sum((a-i)**2 for a in aa)))
    print(minc)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3700
// CppPractice.cpp : アプリケーションのエントリ ポイントを定義します。
//

//#include "stdafx.h"
#include <iostream>

using namespace std;

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

	cout << s / 3600 << ":";
	s = s % 3600;
	cout << s / 60 << ":";
	s = s % 60;
	cout << s << endl;
    return 0;
}




Measured memory_bytes: 3092
package main

import "fmt"

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)

	if b-a+1 <= k*2 {
		for i := a; i <= b; i++ {
			fmt.Println(i)
		}
	} else {
		for i := a; i < a+k; i++ {
			fmt.Println(i)
		}
		for i := b - k + 1; i <= b; i++ {
			fmt.Println(i)
		}
	}
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=1;i<=n;i++)
int main() {
	int h, w;
	while (cin >> h >> w, h, w) {
		char map[114][514];
		bool b[114][514] = {};
		rep(i, h)rep(j, w)cin >> map[i][j];
		int x = 1, y = 1;
		rep(i, 10010) {
			if (b[x][y]) { cout << "LOOP\n"; goto end; }
			b[x][y] = true;
			if (map[x][y] == '>')y++;
			else if (map[x][y] == '<')y--;
			else if (map[x][y] == '^')x--;
			else if (map[x][y] == 'v')x++;
			else {
				cout << --y << ' ' << --x << endl;
				goto end;
			}
		}
	end:;
	}
}

Measured memory_bytes: 3116
#include <iostream>
#include <map>
#include <vector>
#include <cmath>

using ConditonType = std::map<int, int>;

int ExtractDigit(int value, int targetDigit)
{
    if (targetDigit == 1)
    {
        return value % 10;
    }

    return ExtractDigit(value / 10, targetDigit - 1);
}

bool IsMatchCondition(int value, const ConditonType& condition)
{
    for (const auto& current : condition)
    {
        if (ExtractDigit(value, current.first) != current.second)
        {
            return false;
        }
    }

    return true;
}

int main()
{
    int answerDigit = 0;
    std::cin >> answerDigit;

    int conditionCount = 0;
    std::cin >> conditionCount;

    ConditonType condition;
    for (auto count = 0; count < conditionCount; ++count)
    {
        int inputDigit = 0;
        std::cin >> inputDigit;
        // 計算上右からの桁数が扱いやすいので置き換える
        const auto digit = answerDigit + 1 - inputDigit;

        int value = 0;
        std::cin >> value;

        auto prev = condition.find(digit);
        if (prev != condition.end())
        {
            if (prev->second != value)
            {
                std::cout << -1;
                return 0;
            }
        }
        else
        {
            condition.insert(std::make_pair(digit, value));
        }
    }

    const auto startAnswer = (answerDigit == 1 ? 0 : static_cast<int>(std::pow(10, answerDigit - 1)));
    const auto maxAnswer = static_cast<int>(std::pow(10, answerDigit));
    for (auto answer = startAnswer; answer < maxAnswer; ++answer)
    {
        if (IsMatchCondition(answer, condition))
        {
            std::cout << answer;
            return 0;
        }
    }

    std::cout << -1;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string O,E;cin>>O>>E;
  int o=O.size(),e=E.size();
  for(int i=0;i<e;i++)cout<<O.at(i)<<E.at(i);
  if(o>e)cout<<O.at(o-1)<<endl;
  else cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define inf 2147483647
#define infll LLONG_MAX
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int i = 0;
    while(1){
        if(i%2 == 0){
            //takahasi
            c -= b;
            if(c <= 0){
                cout << "Yes" << endl;
                return 0;
            }
            i++;
        }
        else{
            //teki
            a -= d;
            if(a <= 0){
                cout << "No" << endl;
                return 0;
            }
            i++;
        }
    }
}

Measured memory_bytes: 3652
#include<stdio.h>


int n;
int a[100000];


enum
{
	DIR_READY,
	DIR_NONE,
	DIR_ASCEND,
	DIR_DESCEND,
};


int main(void)
{
	int i, result, dir;

	while(scanf("%d", &n)==1)
	{
		dir=DIR_READY;
		result=1;
		for(i=0;i<n;i++)
		{
			scanf("%d", &a[i]);
			switch(dir)
			{
				case DIR_READY:
					dir=DIR_NONE;
					break;
				case DIR_NONE:
					if(a[i]>a[i-1])
					{
						dir=DIR_ASCEND;
					}
					else if(a[i]<a[i-1])
					{
						dir=DIR_DESCEND;
					}
					break;
				case DIR_ASCEND:
					if(a[i]<a[i-1])
					{
						dir=DIR_NONE;
						result++;
					}
					break;
				case DIR_DESCEND:
					if(a[i]>a[i-1])
					{
						dir=DIR_NONE;
						result++;
					}
					break;
			}
		}
		printf("%d\n", result);
	}

	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	string k=s;
	reverse(s.begin(),s.end());
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='p')
		{
			s[i]='q';
			continue;
		}
		if(s[i]=='q')
		{
			s[i]='p';
			continue;
		}
		if(s[i]=='b')
		{
			s[i]='d';
			continue;
		}
		if(s[i]=='d')
		{
			s[i]='b';
			continue;
		}
	}
	if(s==k)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 512
<?php

function chmax(&$a, $b) {
    if ($a < $b) {
        $a = $b;
    }
}

fscanf(STDIN, "%d", $n);
$inputs = [];
for ($i = 0; $i < $n; ++$i) {
    fscanf(STDIN, "%d %d %d", $a, $b, $c);
    $inputs[] = [$a, $b, $c];
}


$dp = [];
for ($i = 0; $i < $n; ++$i) {
    $dp[$i] = array_fill(0, 3, PHP_INT_MIN);
}
$dp[0] = $inputs[0];

for ($i = 1; $i < $n; ++$i) {

    // 前日
    for ($j = 0; $j < 3; ++$j) {
        // 今日
        for ($k = 0; $k < 3; ++$k) {
            if ($j === $k) {
                continue;
            }

            chmax($dp[$i][$k], $dp[$i - 1][$j] + $inputs[$i][$k]);
        }
    }
}

echo max($dp[$n - 1]);


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W;


void solve() {
	int i,j,k,l,r,x,y; string s;
	cin>>H>>W;
	FOR(y,H) FOR(x,W) {
		cin>>s;
		if(s=="snuke") {
			_P("%c%d\n",'A'+x,1+y);
			return;
		}
		
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 764
#include<cstdio>
using namespace std;

int n,k,m,r,t;
bool s[10000];

int main(){
  while(scanf("%d%d%d",&n,&k,&m), n||k||m){
    for(int i=0;i<n;i++)s[i] = true;
    r = n-1; s[--m] = false;
    while(r>1){
      while(!s[m]){
        m++;
        if(m==n)m=0;
      }
      t = (k-1)%r;
      while(t){
        m++;
        if(m==n)m=0;
        if(s[m])t--;
      }
      s[m] = false; r--;
    }
    for(int i=0;i<n;i++)
      if(s[i])printf("%d\n",i+1);
  }
}

Measured memory_bytes: 768
#include <stdio.h>
void calc(int a,int b, char op){
	int ans;
	switch (op) {
	case '+':ans = a + b;
		break;
	case '-':ans = a - b;
		break; 
	case '*':ans = a * b;
		break; 
	case '/':ans = a / b;
		break;
	}
	printf("%d\n", ans);
}
int main(void){
	int a, b, ans;
	char op;
	while (1){
		scanf("%d %c %d", &a, &op, &b);
		if (op == '?')break;
		calc(a, b, op);
	}
	return 0;
}

Measured memory_bytes: 600
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;

    if(n%2==1) cout << "No";
    else {
        if(s.substr(0,n/2)==s.substr(n/2,n/2)){
            cout << "Yes";
        }
        else cout << "No";
    }


    return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <stdlib.h>

int main(void){
  int n;
  scanf("%d", &n);
  int *arr = calloc(n, sizeof(int));
  for(int i = 0; i < n;i++){
    scanf("%d", &arr[i]);
  }
  
  for (int i = 1;i < n;i++){
    if(arr[i] == arr[i-1]){
      continue;		 
    } else if (arr[i-1] < arr[i]){
      arr[i]--;
    } else {
      printf("No");
      return 0;
    }
  }
  printf("Yes");
  return 0;
}


Measured memory_bytes: 512
i_data = input().split()
n = int(i_data[0])
m = int(i_data[1])

def kekka_hantei(i_n):
  if i_n<=1:
    return 0
  else:
    r  = 0
    for i in range(1,i_n):
      r +=i
  return r

print(kekka_hantei(n) + kekka_hantei(m))

Measured memory_bytes: 2940
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
  int n,x,t,m;
  cin>>n>>x>>t;
  m=(n/x);
  if (n % x > 0) {
    m++;
  }
  m=m*t;
  cout<<m<<endl;
  return 0;
}
  
  


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll h,w;cin>>h>>w;
  char s[h][w];rep(i,0,h)rep(j,0,w)cin>>s[i][j];

  ll ans[h][w];
  rep(i,0,h)rep(j,0,w)ans[i][j]=m;
  if(s[0][0]=='#')ans[0][0]=1;
  else ans[0][0]=0;

  rep(i,1,h){
    if(s[i-1][0]=='.'&&s[i][0]=='#')ans[i][0]=ans[i-1][0]+1;
    else ans[i][0]=ans[i-1][0];
  }
  rep(j,1,w){
    if(s[0][j-1]=='.'&&s[0][j]=='#')ans[0][j]=ans[0][j-1]+1;
    else ans[0][j]=ans[0][j-1];
  }

  rep(i,1,h){
    rep(j,1,w){
      ll a=ans[i-1][j],b=ans[i][j-1];

      if(s[i-1][j]=='.'){
        if(s[i][j]=='.')chmin(ans[i][j],ans[i-1][j]);
        else chmin(ans[i][j],ans[i-1][j]+1);
      }
      else chmin(ans[i][j],ans[i-1][j]);

      if(s[i][j-1]=='.'){
        if(s[i][j]=='.')chmin(ans[i][j],ans[i][j-1]);
        else chmin(ans[i][j],ans[i][j-1]+1);
      }
      else chmin(ans[i][j],ans[i][j-1]);

    }
  }

  out(ans[h-1][w-1]);


  // rep(i,0,h){
  //   rep(j,0,w)cout<<ans[i][j];
  //   cout<<endl;
  // }




  return 0;
}


Measured memory_bytes: 384
// A.

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	string n;
	cin >> n;
	int ans = 0;
	for (char c : n) {
		ans = ans * 10 + (c == '1' ? 9 : 1);
	}
	cout << ans << endl;
	return 0;
}


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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define m_p make_pair

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n,d,ans=0;
  cin >> n >> d;
  for(ll i=0;i<n;i+=2*d+1) ans++;
  cout << ans << endl;
  return 0;
}

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

using namespace std;
int N;
#define MAX_N 100001
#define MAX_M 100001
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<edge>> ;


const int MAXN =  100000;
int color[MAXN];

void col(Graph &G, int current_node){
    for(edge i : G[current_node]){
        if(!color[i.to]){
            if(i.weight%2==0)color[i.to] = color[current_node];
            else color[i.to] = -color[current_node];
            col(G, i.to);
        }
    }
}

int main(){
    int N;cin >> N;
    memset(color, 0, N*sizeof(int));
    Graph G(N+1);
    rep(i,N-1){
        int a,b,c;
        cin >> a>> b >> c;
        G[a].push_back(edge(b,c));
        G[b].push_back(edge(a,c));
    }
    color[1] = 1;
    Rep(i,N)col(G,i);

    Rep(i,N){
        if(color[i]==1)cout << 0 << " ";
        else cout << 1 << " ";
        // cout << color[i] << " ";
    }
    cout << endl;




    return 0;
}


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

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

signed main() {
	string s, t;
	cin >> s >> t;
	int ans = 0, now = -1;
	vector<int>vec[27];
	rep(i, s.size()) {
		vec[s[i] - 'a'].push_back(i);
	}
	rep(i, t.size()) {
		if (vec[t[i] - 'a'].size() == 0) {
			cout << -1 << endl;
			return 0;
		}
		if (upper_bound(vec[t[i] - 'a'].begin(), vec[t[i] - 'a'].end(), now) == vec[t[i] - 'a'].end()) {
			ans += s.size() - 1 - now;
			now = vec[t[i] - 'a'][0];
			ans += now + 1;
		}
		else {
			ans += *upper_bound(vec[t[i] - 'a'].begin(), vec[t[i] - 'a'].end(), now) - now;
			now = *upper_bound(vec[t[i] - 'a'].begin(), vec[t[i] - 'a'].end(), now);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1724
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n, k;
    long long a[100005]={0};
    cin>>n>>k;
    for(int i = 0 ; i < n; i++){
        cin>>a[i];
    }
    sort(a, a+n);
    long long minn = 99999999999999;
    for(int i = 0; i <= n-k; i++){
        minn = min((a[i+k-1]-a[i]), minn);
    }

    cout<<minn;

    return 0;
}


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

using namespace std;

int main()
{
  int n;
  cin>>n;
  vector<char> list;
  vector<char> list2;
  char a=a;
  for(int i=0;i<n;i++)
  {
    cin>>a;
    list.push_back(a);
    list2.push_back(a);
  }
  sort(list2.begin(),list2.end());
  int ans=0;
  for(int i=0;i<n;i++)
  {
    if(list2.at(i)=='W')
    {
      break;
    }
    if(list.at(i)!=list2.at(i))
    {
      ans++;
    }
    
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int mod = 1e9+7;
//int p1[100002], p2[100002], p3[100002];

bool mycomp(int m, int n){
	return m>n;
}
//
//LL solve(int i, int j, int k){
////	base case
//	if(i>=a && j>=b && k>=c) return 0;
//	if(green <= 0 && red <= 0) return 0;
//	if(dp[a][b][b]!=-1) return dp[a][b][c];
//	dp[i+1][j][k] = (i<a && red > 0) ? p1[i] + solve(i+1,j,k,red-1, green) : 0;
////	LL r = (i<a && red > 0) ? p1[i] + solve(i+1,j,k,red-1, green) : 0;
//	dp[i][j+1][k] = 
//	LL g = (j<b && green > 0) ? p2[j] + solve(i,j+1,k,red, green-1) : 0;
//	LL kr = (k<c && red > 0) ? p3[k] + solve(i,j,k+1,red-1, green) : 0;
//	LL kg = (k<c && green > 0) ? p3[k] + solve(i,j,k+1,red, green-1) : 0;
//	LL nn = solve(i+1, j+1, k+1, red, green);	
//	return max({r, g, kr, kg, nn});
//}

int main(){
	int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	int p1[a], p2[b], p3[c];
	for(int i=0;i<a;i++) cin>>p1[i];
	for(int i=0;i<b;i++) cin>>p2[i];
	for(int i=0;i<c;i++) cin>>p3[i];
	sort(p1,p1+a, mycomp);
	sort(p2,p2+b, mycomp);
	sort(p3,p3+c, mycomp);
	vector<int> sum;
	for(int i=0;i<x;i++) sum.push_back(p1[i]);
	for(int i=0;i<y;i++) sum.push_back(p2[i]);
	for(int i=0;i<c && i<x+y;i++) sum.push_back(p3[i]);
	sort(sum.begin(), sum.end(), mycomp);
	LL res = 0;
	for(int i=0;i<x+y;i++) res+=sum[i];
//	res = 0;
	cout<<res;
	return 0;
}

Measured memory_bytes: 3572
s = input()
arr = list()

i = 0
buf = ''
while i < len(s):
    if s[i] == 'A':
        if buf:
            arr.append(buf)
            buf = ''
        arr.append('A')
        i += 1
    elif s[i: i + 2] == 'BC':
        if buf:
            arr.append(buf)
            buf = ''
        arr.append('BC')
        i += 2
    else:
        buf += s[i]
        i += 1
if buf:
    arr.append(buf)

cnt = 0
stack = 0
for e in reversed(arr):
    if e == 'BC':
        stack += 1
    elif e == 'A':
        cnt += stack
    else:
        stack = 0
print(cnt)

Measured memory_bytes: 5904
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
xx=[]
for i in range(len(x)-1):
  if len(x)==1:
    xx.append(x[0])
    break
  s=x[i+1]-x[i]
  xx.append(s)
  
xx.sort(reverse=True)
ans=sum(xx[n-1:])
print(ans)


Measured memory_bytes: 20416
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int n,a,sum,ma,mi;
  while(scanf("%d",&n),n){
    sum = 0;
    ma = 0;
    mi = 1001;
    for(int i=0;i<n;i++){
      scanf("%d",&a);
      sum += a;
      ma = max(ma,a);
      mi = min(mi,a);
    }
    sum -= ma+mi;
    printf("%d\n",sum/(n-2));
  }
  return (0);
}

Measured memory_bytes: 2576
def prime_factorize(n):
    result = []
    if n % 2 == 0:
        t = 0
        while n % 2 == 0:
            n //= 2
            t += 1
        result.append((2, t))
    for i in range(3, int(n ** 0.5) + 1, 2):
        if n % i != 0:
            continue
        t = 0
        while n % i == 0:
            n //= i
            t += 1
        result.append((i, t))
        if n == 1:
            break
    if n != 1:
        result.append((n, 1))
    return result


N = int(input())

result = 0
for p, e in prime_factorize(N):
    i = 1
    while e >= i:
        result += 1
        e -= i
        i += 1
print(result)


Measured memory_bytes: 9472
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n); for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
typedef pair<int, int> P;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}


//cout<<""<<endl;
int main(){
  ll A,B,C,K;cin>>A>>B>>C>>K;
  if(K<=A)cout<<K<<endl;
  else if(K>A&&K-A<=B)cout<<A<<endl;
  else if(K>A&&K-A>B)cout<<A-(K-A-B)<<endl;
}


Measured memory_bytes: 3684
while True:
  N,A,B,C,X = map(int, raw_input().split())
  if N==A==B==C==X==0: break
  y = map(int, raw_input().split())
  it = 0
  counter = 0
  x = X
  while True:
    if x == y[it]: it += 1
    if it == N or counter > 10000: break
    x = (A*x+B)%C
    counter += 1
  if counter > 10000:
    print "-1"
  else:
    print counter

Measured memory_bytes: 6240
program probB
  implicit none
  integer a,b,c,x,n
  integer i,j,k

  read(*,*) a
  read(*,*) b
  read(*,*) c
  read(*,*) x

  n=0
  do i=0,a
     do j=0,b
        do k=0,c
           if(500*i+100*j+50*k==x) n=n+1
        end do
     end do
  end do

  write(*,*) n
  
end program probB


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int l;
int main(){
	scanf("%d",&l);
	int n=0,ll=l;
	while (ll){
		ll>>=1;
		n++;
	}
	int y=__builtin_popcount(l)-1;
	printf("%d %d\n",n,(n-1)*2+y);
	for (int i=1;i<n;++i){
		printf("%d %d %d\n",i,i+1,1<<(i-1));
		printf("%d %d %d\n",i,i+1,0);
	}
	int c=1<<(n-1);
	for (int i=n-1;i;--i){
		if ((1<<(i-1))&l) printf("%d %d %d\n",i,n,c),c+=(1<<(i-1));
	}
}

Measured memory_bytes: 3760
from bisect import bisect_left as bisect
from itertools import accumulate

N = int(input())

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

T = A+B+C
T.sort()

A = [bisect(T,v) for v in A]
B = [bisect(T,v) for v in B]
C = [bisect(T,v) for v in C]

T = len(T)+1

dp = [1]*T

for X in (A,B,C):
  ndp = [0]*T
  for x in X:
    ndp[x+1] += dp[x]
  dp = list(accumulate(ndp))

print(dp[-1])

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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  rep(i, n) cin >> vec.at(i);
  int sum = 0;
  rep(i, n) {
    rep(j, n) {
      if(i != j) sum += vec.at(i)*vec.at(j);
    }
  }
  cout << sum/2 << endl;
}


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

int main(void){

  int a, b, c, tmp;

  cin >> a;
  cin >> b;
  cin >> c;

  if(a <= b && b <= c)
    cout << a << " " << b << " " << c << endl;

  else if(a <= c && c <= b)
    cout << a << " " << c << " " << b << endl;

  else if(b <= a && a <= c)
    cout << b << " " << a << " " << c << endl;

  else if( b <= c && c <= a)
    cout << b << " " << c << " " << a << endl;

  else if(c <= a && a <= b)
    cout << c << " " << a << " " << b << endl;

  else if(c <= b && b <= a)
    cout << c << " " << b << " " << a << endl;
  return 0;
}

Measured memory_bytes: 1164
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

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

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	k, _ := strconv.Atoi(input())
	n, _ := strconv.Atoi(input())
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(input())
	}

	maxDiff := k - a[n-1] + a[0]
	for i := 1; i < n; i++ {
		maxDiff = max(maxDiff, a[i]-a[i-1])
	}
	fmt.Println(k - maxDiff)
}


Measured memory_bytes: 3840
#include <stdio.h>
#include <string.h>

int main(void)
{
	int i,len;
	char s[20];

	scanf("%s",s);
	len=strlen(s);
	for(i=len-1;i>=0;i--) {
		printf("%c",s[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 520
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

N, M = map(int, input().split())
v = [[] for _ in range(N)]
for _ in range(M) :
    A, B = map(int, input().split())
    v[A-1].append(B-1)
    v[B-1].append(A-1)

visited = [False] * N
visited[0] = True
path = [[], []]

def dfs(cur, mode) :
    flag = True
    for nex in v[cur] :
        if visited[nex] :
            continue
            
        flag = False
        visited[nex] = True
        f = dfs(nex, mode)
        visited[nex] = False
        if f :
            path[mode].append(cur + 1)
            return True
        
    if flag :
        if mode == 0 :
            dfs(0, 1)
        path[mode].append(cur + 1)
        return True
    
    
    return False
        
dfs(0, 0)
ret = path[0][:-1] + path[1][::-1]
print(len(ret))
print(*ret)

Measured memory_bytes: 130336
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    A, B, H, M = map(int, input().split())

    #output
    #角速度をw/hとする。
    #Aに関して、w_A * 12 = 2*pi
    #Bに関して、w_B * 1 = 2*pi
    #H時M分の時、長針の位置は(H + M/60) * w_A
    # = (H + M/60)*(pi/6)
    #短針の位置は、(M/60) * w_B
    # = (M/60)*(2*pi)
    #余弦定理より
    #answer **2 = A**2 + B**2 -2*A*B*cos(abs(delta))

    import math
    delta = (H + M/60)*math.pi/6 - (M/30)*math.pi
    C = pow(A, 2) + pow(B, 2) - 2*A*B*math.cos(delta)
    print(math.sqrt(C))  

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

Measured memory_bytes: 9336
use bigint;
($A,$B)=split/ /,<>;
if ($A==$B){
    print $A;
    exit;
}
$A-- if($A>0);
$A=&f($A);
$B=&f($B);
$B^=$A if $A!=0;
print $B;
sub f{
    return $_[0] if($_[0]%4==0);
    return 1 if($_[0]%4==1);
    return $_[0]+1 if($_[0]%4==2);
    return 0 if($_[0]%4==3);
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
typedef pair<ll, ll> pll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define PI 3.14159265358979323846264338327950288419716939937510
#define mp make_pair
#define vvl vector<vector<ll>>
#define vll vector<ll>
#define vpll vector<pll>
ll inf = 1e18;
ll p = 1e9 + 7;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll pwr(ll x, ll y)
{
    ll res = 1;
    x = x ;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) ;
        y = y >> 1;
        x = (x * x) ;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i, j, y, x,  z, w, g, key,  k, n, m, a, b, t;
    ll t2, t3, t4, t1, t5, t6;
    string s;
    //t=1;
    cin >> x;
    if (x)
        cout << "0";
    else
        cout << "1";


    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
struct E{
	int t,a,b;
	bool operator<(E a)
	{
		return t<a.t;
	}
};
int n,m;
main()
{
	while(cin>>n>>m,n)
	{
		bool C[22222]={};
		E a[22222];
		C[1]=1;
		for(int i=0;i<m;i++)
		{
			int t,x,y;cin>>t>>x>>y;
			a[i].t=t,a[i].a=x,a[i].b=y;
		}
		sort(a,a+m);
		int cnt=1;
		for(int i=0;i<m;i++)
		{
			if(!C[a[i].a])continue;
			cnt+=!C[a[i].b];
			C[a[i].b]=1;
		}
		cout<<cnt<<endl;
	}
}



Measured memory_bytes: 3352
#include<stdio.h>
int main(){
	double a,b,c,d,e,f,A,x,y,X,Y,Z;
	//while(scanf_s("%f",&a)!=EOF){
	while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){
	Y=a*e-b*d,Z=f*a-c*d;
    y=Z/Y;
 
    x=(c-b*y)/a;
	printf("%.3lf %.3lf\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 652
n = int(input())
h = list(map(int,input().split()))

dp = [0] * n

dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2,n):
    dp[i] = min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2])

print(dp[n-1])

Measured memory_bytes: 13900
#include <bits/stdc++.h> 
using namespace std; 
int main() 
{ 
	
	long x;
	cin>>x;
	long y = -1;
	while(true)
	{
	    
	    if(abs(pow(y,5))>x)
	        break;
	    y--;
	}
	y++;
	
	for(int i =y ;;i++)
	{
	    long p = x+pow(i,5);
	    float ans = pow(p,0.2);
	    long a =ans;
	    
        if(ans - a == 0)
        {
	        cout<<ans<<" "<<i<<endl;
	        break;
        }
	
	    
	}

	return 0; 
}

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

signed main(void)
{
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int n, m, l, cnt, ans;
	n = min(x, y);
	l = max(x, y);
	m = min(c * 2, a + b);
	ans = l * m;
	cnt = n * m;
	x -= n; y -= n;
	cnt += x * a + y * b;
	ans = min(ans, cnt);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
s = input()
x,y = map(int,input().split())
wayx = []
wayy = []
pad = 15000
can_reachx = [False for i in range(pad*2+1)]
can_reachy = [False for i in range(pad*2+1)]


state = True
seq = 0
for c in s:
    if c == "T":
        if state:
            wayx.append(seq)
            seq = 0
            state = False
        else:
            wayy.append(seq)
            seq = 0
            state = True
    else:
        seq += 1


if state:
    wayx.append(seq)
    seq = 0
    state = False
else:
    wayy.append(seq)
    seq = 0
    state = True

can_reachx[pad+wayx[0]] = True
can_reachy[pad] = True

for i in range(1,len(wayx)):
    w = wayx[i]
    b = []
    for j in range(len(can_reachx)):
        if can_reachx[j]:
            if j+w <= pad*2:
                b.append(j+w)
            if j-w >= 0:
                b.append(j-w)
            can_reachx[j] = False
    for t in b:
        can_reachx[t] = True

for w in wayy:
    b = []
    for i in range(len(can_reachy)):
        if can_reachy[i]:
            if i+w <= pad*2:
                b.append(i+w)
            if i-w >= 0:
                b.append(i-w)
            can_reachy[i] = False
    for t in b:
        can_reachy[t] = True

if can_reachx[x+pad] and can_reachy[y+pad]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 51804
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define REP(i,p,n) for(int i=p;i<n;++i)
#define rep(i,n) REP(i,0,n)

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

int W, H, N;
int X, Y;

string A;
string B;

bool isStableX()
{
    int lhs = 0, rhs = W - 1;

    rep (i, N)
    {
        const auto a = A[N - i - 1];
        const auto b = B[N - i - 1];

        if (b == 'L') { rhs = min(rhs + 1, W - 1); }
        if (b == 'R') { lhs = max(lhs - 1, 0); }

        if (a == 'L') { lhs += 1; }
        if (a == 'R') { rhs -= 1; }

        if (lhs > rhs) { return false; }
    }

    return lhs <= X && X <= rhs;
}

bool isStableY()
{
    int lhs = 0, rhs = H - 1;

    rep (i, N)
    {
        const auto a = A[N - i - 1];
        const auto b = B[N - i - 1];

        if (b == 'U') { rhs = min(rhs + 1, H - 1); }
        if (b == 'D') { lhs = max(lhs - 1, 0); }

        if (a == 'U') { lhs += 1; }
        if (a == 'D') { rhs -= 1; }

        if (lhs > rhs) { return false; }
    }

    return lhs <= Y && Y <= rhs;
}

int main()
{
    cin >> H >> W >> N;
    cin >> Y >> X;
    cin >> A >> B;

    --X;
    --Y;

    if (isStableX() && isStableY())
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    string n;
    cin >> n;
    for(int i=0;i<n.size();i++){
        if(n[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

#define ms(s,n) memset(s,n,sizeof(s))
#define all(a) a.begin(),a.end()
#define present(t, x) (t.find(x) != t.end())
#define sz(a) int((a).size())
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;

const int MOD = (int) 1e9+7;
const int INF = (int) 1e9+1;
inline ll gcd(ll a,ll b){ll r;while(b){r=a%b;a=b;b=r;}return a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int n,k,a[1000];

void inp(){
	cin>>n>>k;
	FOR(i,0,n)
		cin>>a[i];
	sort(a,a+n);
	int sum=accumulate(a,a+k,0);
	cout<<sum<<endl;
}

int main(){
	inp();
	return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i < n; i++)
#define reps(i, n) for(ll i=1; i <= n; i++)
#define INF 1e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;
using P=pair<int,int>;
using Pl=pair<ll,ll>;

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


int main() {
  int n;cin >> n;
  int v[n],c[n],dp[n];
  rep(i,n)dp[i]=0;
  rep(i,n)cin >> v[i];
  rep(i,n)cin >> c[i];
  dp[0]=max(v[0]-c[0],0);
  reps(i,n-1){
    dp[i]=dp[i-1]+max(v[i]-c[i],0);
  }
  cout << dp[n-1];
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
using namespace std;
using ll = long long;
constexpr int mod = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i < 10; i++)
    {
        for (int j = i; j < 10; j++)
        {
            if (i * j == n)
            {
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
typedef pair<int,int>P;
main(){
  int n,c[999],s[999],f[999];
  cin>>n;
  r(i,n-1)cin>>c[i]>>s[i]>>f[i];
  r(i,n){
    int t=0;
    for(int j=i;j<n-1;j++){
      if(t<s[j])t=s[j];
      else if(t%f[j]==0);
      else t=t+(f[j]-t%f[j]);
      t+=c[j];
    }
    cout<<t<<endl;
  }
}

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

int main() {
    int N, A , B;
    cin>> N >> A >> B ;

    int ans=0;

    for(int i=1;i<=N;i++){

        if(i==10000){
            int wa = 1;
            if(wa>=A && wa<=B){
                ans += i;
            }
        }


        else if(i>=1000&&i<10000){
            int wa = i%10 + i/10%10 + i/100%10 + i/1000%10;
            if(wa>=A&&wa<=B){
                ans+=i;
            }
        }

        else if(i>=100&&i<1000){
            int wa = i%10 + (i/10)%10 + (i/100)%10;
            if(wa>=A && wa<=B){
                ans += i;
            }
        }

        else if(i<100&&i>=10){
            int wa = i%10 + (i/10)%10;
            if(wa>=A && wa<=B){
                ans += i;
            }
        }

        else if(i<10){
            if(i>=A && i<=B){
                ans += i;
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int a=0x3f3f3f3f,b,tmp,n;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&tmp);
		if(tmp<a)a=tmp;
		if(tmp>b)b=tmp;
	}
	printf("%d\n",b-a);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, A[111111], B[111111];

  std::cin >> N;

  for (int i = 0; i < N + 1; i ++)
    std::cin >> A[i];
  
  for (int i = 0; i < N; i ++)
    std::cin >> B[i];

  long long s = 0;

  for (int i = 0; i < N; i ++) {
    int x = std::min(A[i], B[i]);

    A[i] -= x;
    B[i] -= x;

    s += x;

    x = std::min(A[i + 1], B[i]);

    A[i + 1] -= x;
    B[i    ] -= x;

    s += x;
  }

  std::cout << s << std::endl;
  
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int countjoi(vector<vector<char> >& flag, vector<vector<char> >& joi, int i, int j) {
    int res=0;
    if(i>=0 && i<flag.size()-1 && j>=0 && j<flag[0].size()-1
       && flag[i][j]==joi[0][0] && flag[i][j+1]==joi[0][1] && flag[i+1][j]==joi[1][0] && flag[i+1][j+1]==joi[1][1]) res=1;
    return res;
}

int countjoi4(vector<vector<char> >& flag, vector<vector<char> >& joi, int i, int j) {
    int res=0;
    int di[4]={-1,-1,0,0};
    int dj[4]={-1,0,-1,0};

    for(int k=0; k<4; ++k) {
        res+=countjoi(flag,joi,i+di[k],j+dj[k]);
    }
    return res;
}

int main()
{
    int M,N;

    cin >> M >> N;

    vector<vector<char> > flag(M);
    vector<vector<char> > joi(2);

    for(int i=0; i<M; ++i) {
        string instr;
        cin >> instr;
        for(int j=0; j<N; ++j) {
            flag[i].push_back(instr[j]);
        }
    }

    string instr;
    cin >> instr;
    joi[0].push_back(instr[0]); joi[0].push_back(instr[1]);
    cin >> instr;
    joi[1].push_back(instr[0]); joi[1].push_back(instr[1]);

    int cnt=0,ans=0;

    for(int i=0; i<M-1; ++i) {
        for(int j=0; j<N-1; ++j) {
            cnt+=countjoi(flag,joi,i,j);
        }
    }
    ans=cnt;
    for(int i=0; i<M; ++i) {
        for(int j=0; j<N; ++j) {
            char org=flag[i][j],new1,new2;
            int orgc=0,newc=0;
            orgc=countjoi4(flag,joi,i,j);
            switch(org) {
            case 'J' :
                new1='O'; new2='I'; break;
            case 'O' :
                new1='J'; new2='I'; break;
            case 'I' :
                new1='J'; new2='O'; break;
            }
            flag[i][j]=new1;
            newc=countjoi4(flag,joi,i,j);
            ans=max(ans,cnt+(newc-orgc));
            flag[i][j]=new2;
            newc=countjoi4(flag,joi,i,j);
            ans=max(ans,cnt+(newc-orgc));
            flag[i][j]=org;
        }
    }


    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3936
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<vector>
#include<string> 
#include<queue>
#include<algorithm>
using namespace std;
int main()
{
	int n,x,ans,sum=0,MIN=1e9,i,a[1000];
	cin>>n>>x;
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		MIN=min(MIN,a[i]);
		sum+=a[i];
	}
	ans=n+(x-sum)/MIN;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b;
int main(){
	cin>>a>>b;
	if (b==100) b++;
	if (a==0) cout<<b;
	if (a==1) cout<<b*100;
	if (a==2) cout<<b*10000;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  using boost::multiprecision::int1024_t;
  int N; cin >> N;
  vector<int1024_t> A(N);
  for(auto& i : A) cin >> i;

  int1024_t ans{};
  for (int i = 0; i < 64; ++i) {
    int1024_t cnt0{}, cnt1{};
    for (const auto& a : A) {
      if ((int1024_t)(a >> i) & 0x01) {
        ++cnt1;
      }
      else {
        ++cnt0;
      }
    }
    ans += cnt0 * cnt1 * (int1024_t(1) << i);
    ans %= INF;
  }
  cout << ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 42496