akhauriyash/Code-Regression huggingface dataset:
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
using namespace std;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef double d;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,D;
    cin>>n>>D;
    ll x;
    cin>>x;
    vector<ll> v(n,0);
    for(ll i=0;i<n;i++)
    {
        cin>>v[i];
    }
    ll sum=0;
    for(ll i=0;i<n;i++)
    {
        ll k=0;
        ll day=k*v[i]+1;
        while(day<=D)
        {
            sum++;
            k++;
            day=k*v[i]+1;
        }
    }
    cout<<(sum+x)<<endl;
    return 0;
}



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

int main() {
  string S;
  int K;
  cin >> S >> K;
  int N = S.size();
  vector<int> I(N);
  for (int i = 0; i < N; i++) I[i] = i;
  sort(I.begin(), I.end(), [&S, &N](int i, int j){ return S.substr(i, N-i) < S.substr(j, N-j); });
  set<string> done;
  for (int i : I) {
    int j = 1;
    while (i + j - 1 < N) {
      string ss = S.substr(i, j); j++;
      if (done.count(ss)) continue;
      if (K == 1) {
        cout << ss << endl;
        return 0;
      }
      K--;
      done.insert(ss);
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,a,b;
  cin >> n >> a >> b;
  int count=0;
  for (int i=1; i<=n; i++) {
    int x=i,t=0;
    for (int j=0; j<5; j++) {
      t += x%10;
      x /= 10;
    }
    if (t >= a && t <= b) {
      count += i;
    }
  }
  cout << count << endl;
}

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

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

typedef map<string,int>M;
M spell;
string mat[10];

void Search(int sx,int sy, int a, int h, int w)
{
	bool f[10][20]={};
	string str;
	int x,y;
	for(x=sx, y=sy; ; x=(x+dx[a]+w)%w, y=(y+dy[a]+h)%h)
	{
		if(f[y][x])
			break;
		f[y][x]=true;
		str+=mat[y][x];
		++spell[str];
	}
}

int main()
{
	int h,w;
	while(cin>>h>>w,h)
	{
		for(int i=0; i<h; ++i)
			cin >> mat[i];

		spell.clear();
		for(int x=0; x<w; ++x)
			for(int y=0; y<h; ++y)
				for(int a=0; a<8; ++a)
					Search(x,y,a,h,w);

		string res("");
		for(M::iterator ite=spell.begin(); ite!=spell.end(); ++ite)
		{
			if(ite->second<=1)
				continue;
			if(res.size()<ite->first.size() || res>ite->first)
				res=ite->first;
		}
		if(res.size()<=1)
			res="0";
		cout << res << endl;
	}
}

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

#define MIN       (1)
#define MAX       (100)

typedef enum
{
    ERROR  =-1,
    SUCCESS= 0
} ResultType;

static void initMatrix(int);
static void convertListToMatrix(int);
static void printMatrix(int);
static ResultType checkRangeOfNum(int, int, int);


int adjacentList[MAX][MAX + 1];
int adjacentMatrix[MAX][MAX];

int main(void)
{

    int i, j, n, tmp;
    ResultType eResult;

    /* input line 1 */
    scanf("%d",&n);
    eResult = checkRangeOfNum(n, MIN, MAX);
    if(eResult < SUCCESS)
    {
        printf("Err: %d is out of range.", n);
        return eResult;
    }

    /* input line from 2 to n+1 */
    for(i=0; i<n; i++)
    {
        /* 1st number (vertex) */
        scanf("%d",&tmp);

        /* 2nd number (degree) */
        scanf("%d",&adjacentList[i][0]);
        eResult = checkRangeOfNum(adjacentList[i][0], 0, n);
        if(eResult < SUCCESS)
        {
            printf("Err: %d is out of range.", adjacentList[i][0]);
            return eResult;
        }

        /* after that */
        for(j=1; j<=adjacentList[i][0]; j++)
        {
            scanf("%d",&adjacentList[i][j]);
            eResult = checkRangeOfNum(adjacentList[i][j], MIN, n);
            if(eResult < SUCCESS)
            {
               printf("Err: %d is out of range.", adjacentList[i][0]);
                return eResult;
            }
        }
    }

    /* initialize Matrix */
    initMatrix(n);

    /* convert List to Matrix */
    convertListToMatrix(n);

    /* print Matrix */
    printMatrix(n);

    return SUCCESS;
}

static ResultType checkRangeOfNum(int n, int nMin, int nMax)
{
    if((n < nMin) || (nMax < n))
    {
        return ERROR;
    }
    return SUCCESS;
}

static void initMatrix(int n)
{
    int i, j;
    for(i=0; i<n; i++)
    {
        for(j=0; j<n; j++)
        {
            adjacentMatrix[i][j] = 0;
        }
    }
}

static void convertListToMatrix(int n)
{
    int i, j;
    for(i=0; i<n; i++)
    {
        for(j=1; j<=adjacentList[i][0]; j++)
        {
            adjacentMatrix[i][adjacentList[i][j] - 1] = 1;
        }
    }
}

static void printMatrix(int n)
{
    int i, j;
    for(i=0; i<n; i++)
    {
        for(j=0; j<n-1; j++)
        {
            printf("%d ", adjacentMatrix[i][j]);
        }
        printf("%d\n", adjacentMatrix[i][n-1]);
    }
}



Measured memory_bytes: 2076
object Main extends App {

  val m = 1000000007;

  val sc = new java.util.Scanner(System.in);
  val n = sc.nextInt();
  val as = Array.fill(n)(sc.nextLong());

  val answer = (0 until 60).map { bit =>
    val count = (0 until n).map { i =>
      ((as(i) >> bit) & 1).toInt;
    }.sum;
    val u = (1L << bit) % m;
    u * count % m * (n - count) % m;
  }.sum % m;

  println(answer);
}

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

#define int long long

#define p first
#define t second

const int NUM = 4;
const int NUM2 = 110;
const int INF = (int)1e18;


int ans1, ans2;

void solve(vector<pair<int,int>> &in){
  int n = in.size()-1;
  ans1 = true;
  ans2 = INF;
  vector<vector<vector<int>>> dp(2, vector<vector<int>>(NUM+1,vector<int>(NUM2,INF)));

  dp[1][0][0] = 0;

  // cout<<"n == "<<n<<endl;
  for(int i = 1; i <= n; i++){
    bool flag = false;
    // cout<<"fjslkfjdskfld;lfjdk;l  i =="<<i<<endl;
    for(int j = 0; j < NUM; j++){
      //for(int k = 0; k < NUM2-1; k++){
      //        if(in[i].)
      int k = in[i].first;
      int z = in[i-1].first;
      //  cout<<"<><><> "<<endl;
      //  cout<<i<<" "<<j<<" "<<k<<" "<<z<<endl;
      // cout<<"dp "<<dp[i%2][j][z]<<endl;
      //        cout<<dp[i%2][j][z]<<" "<<abs(z - k)*(j+1) <<" <= "<<abs(in[i].second - in[i-1].second)<<endl;
        if(dp[i%2][j][z] != INF && abs(z - k)*(j+1) <= abs(in[i].second - in[i-1].second)){
          dp[(i+1)%2][j+1][k] = min(dp[i%2][j][z]+abs(z - k), dp[(i+1)%2][j+1][k]);
          if(j <= 2)flag = true;
          //cout<<"F!"<<" "<<dp[(i+1)%2][j+1][k]<<endl;
        }
        //cout<<dp[i%2][j][z]<<" "<< z*(j+1) + in[i].first<<" <= "<<abs(in[i].second - in[i-1].second)<<endl;
        if(dp[i%2][j][z] != INF && z*(j+1) + in[i].first <= abs(in[i].second - in[i-1].second)){
          dp[(i+1)%2][1][k] = min(dp[i%2][j][z] + z + k, dp[(i+1)%2][1][k]);
          flag = true;
          // cout<<"F2"<<" "<<dp[(i+1)%2][1][k]<<" "<<i+1<<" k = "<<k<<endl;
        }
      }
      for(int j = 0; j < NUM; j++){
        for(int k = 0; k < NUM2; k++){
          dp[i%2][j][k] = INF;
          
          //}
      }
    }

      if(flag == false){
      // if()
      ans1 = false;
      ans2 = i;
      return;
    }
  }

  for(int i = 0; i < NUM; i++){
    // cout<<"n = "<<n<<endl;
    // cout<<dp[(n+1)%2][i][in[n].first]<<" dp"<<" "<<(n+1)<<" "<<i<<" "<<in[n].first<<endl;
    ans2 = min(ans2, dp[(n+1)%2][i][in[n].first] + in[n].first);
  }
  
}

signed main(){


  while(true){
    int n;
    vector<pair<int,int>> in;

    cin>>n;

    if(!n) break;

    in.resize(n+1);

    in[0] = {0,0};
    
    for(int j = 1; j <= n; j++){
      //int p, t;

      //cin>>p>>t;

       cin>>in[j].p>>in[j].t;

    }
    
    solve(in);

    cout<<(ans1?"OK":"NG")<<" "<<ans2<<endl;
  }
  
  return 0;
}



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


void solve(long long N, std::vector<long long> A)
{
    auto minus_num_count = count_if(begin(A), end(A), [](ll a) { return a < 0; });
    auto min_abs_num = *min_element(begin(A), end(A), [](ll a, ll b) { return abs(a) < abs(b); });
    auto abs_total = accumulate(begin(A), end(A), 0LL, [](ll acc, ll n) { return acc + abs(n); });
    auto ans = abs_total - (((minus_num_count % 2) == 0) ? 0 : 2 * abs(min_abs_num));
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    cin.tie(nullptr);
    cout.tie(nullptr);
	ios_base::sync_with_stdio(false);
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
 
int main(void)
{
    int n,x,i,j,k,a;
    while(1)
    {
        a=0;
        scanf("%d%d",&n,&x);
        if(n==0 && x == 0)
        {
            break;
        }
        for(i=1;i<=n-2;i++)
        {
            for(j=i+1;j<n;j++)
            {
                for(k=j+1;k<=n;k++)
                {
                    if(i+j+k==x)
                    {
                        a=a+1;
                    }
                }
            }
        }
        printf("%d\n",a);
    }
    return 0;
         
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < b; i++)

const ll INF = 1e18;
int N;
vector<vector<pair<int,int> > > G;
vector<ll> dist;
//vector<bool> used;

bool dfs(int idx, int par){
    bool flag = 0;
    if(par == -1) dist[idx] = 0;
    //cout << idx << endl;
    for(auto& e: G[idx]){
        int to = e.first, weight = e.second;
        if(par == to) continue;
        // 行ったことがあったら
        if(dist[to] != INF){
            if(dist[to] != dist[idx] + weight) return true;
        }else{
            dist[to] = dist[idx] + weight;
            flag |= dfs(to, idx);
        }
        if(flag) return flag;
    }
    return flag;
}

int main(){
    int M; cin >> N >> M;
    G.resize(N);
    dist.assign(N,INF);
    //used.assign(N,0);
    rep(i, 0, M){
        int L, R, D; cin >> L  >> R >> D; L--, R--;
        G[L].push_back({R,D});
        G[R].push_back({L,-D});
    }
    rep(i, 0, N) if(dist[i] == INF){
        if(dfs(i,-1)){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
}

Measured memory_bytes: 13312
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;

int extgcd(int a,int b,int&x,int&y){
	int d=a;
	if(b){
		d=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}
	else{
		x=1,y=0;
	}
	return d;
}

int modinv(int base){
	int x,y;
	extgcd(base,mod,x,y);
	x%=mod;
	return (x<0?x+mod:x);
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>a(n); for(auto&&i:a)cin>>i;
	int base=0;
	for(auto&&i:a)base=(base+i)%mod;
	int ans=0;
	for(auto&&i:a)ans=(ans+1L*i*(mod+base-i)%mod)%mod;
	cout<<1L*ans*modinv(2)%mod<<"\n"s;
}


Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e10+10;

/*----------------------------------------------*/

signed main(){
  string s;
  int k;
  cin>>s>>k;
  int ans;
  int n=s.size();

  int i=0;
  while(s[i]==s[i+1]&&i<s.size()-1) i++;
  
  if(i+1==s.size()){
    ans=s.size()*k/2;
  }else{
    ans=(i+1)/2;
    //
    int ams=0,check=1;
    FOR(j,i+1,i+1+n){
      if(s[j%n]==s[(j+1)%n]) check++;
      else{
        ams+=check/2;
        check=1;
      }
    }
    ans+=ams*(k-1);
    //
    check=1;      
    FOR(j,i+1,n-1){
      if(s[j]==s[j+1]) check++;
      else{
        ans+=check/2;
        check=1;
      }
    }
  }

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

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int j=0;
		int H=sc.nextInt();
		int W=sc.nextInt();
		boolean conte=true;
		boolean[][] c=new boolean[H][W];
		int[][] field=new int[H][W];
		String[] str=new String[H];
		for(int i=0;i<H;i++){
			str[i]=sc.next();
			for(int k=0;k<W;k++){
				 field[i][k]=-1;
				 c[i][k]=false;
			 }
			j=0;
			conte=true;
			 while(conte && j< str[i].length()){
				 if(str[i].indexOf('c',j) == -1){
					 conte=false; 
				 }else{
					 c[i][str[i].indexOf('c',j)]=true;
					 field[i][str[i].indexOf('c',j)]=0;
					 j=str[i].indexOf('c',j);
				 }
				 j++;
			 }
		}
		sc.close();
		for(int i=0;i<H;i++){
			 for(int k=0;k<W-1;k++){
				 if(c[i][k]==true && c[i][k+1]==false){
					 field[i][k+1]=field[i][k]+1;
					 c[i][k+1]=true;
				 }
			 }
			 for (int k=0;k<W-1;k++){
					System.out.printf("%d ", field[i][k]);
				}
					System.out.printf("%d\n",field[i][W-1]);
		}
		
		
		
		
		
	}

}

Measured memory_bytes: 45420
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

int main() {
	std::cin.tie(0); std::cin.sync_with_stdio(false);
	int n, m, l; std::cin >> n >> m >> l;
	std::vector<std::vector<long long int>> min_distance(n, std::vector<long long int>(n, LLONG_MAX));
	for (auto i = 0; i < m; ++i) {
		int a, b, c; std::cin >> a >> b >> c; --a; --b;
		min_distance[a][b] = min_distance[b][a] = c;
	}
	for (auto k = 0; k < n; ++k) for (auto i = 0; i < n; ++i) for (auto j = 0; j < i; ++j) if (min_distance[i][k] != LLONG_MAX && min_distance[k][j] != LLONG_MAX) {
		min_distance[i][j] = min_distance[j][i] = std::min(min_distance[i][j], min_distance[i][k] + min_distance[k][j]);
	}
	std::vector<std::vector<int>> min_supply(n, std::vector<int>(n, INT_MAX));
	for (auto i = 0; i < n; ++i) for (auto j = 0; j < i; ++j) {
		if (min_distance[i][j] <= l) {
			min_supply[i][j] = min_supply[j][i] = 1;
		}
	}
	for (auto k = 0; k < n; ++k) for (auto i = 0; i < n; ++i) for (auto j = 0; j < i; ++j) if (min_supply[i][k] != INT_MAX && min_supply[k][j] != INT_MAX) {
		min_supply[i][j] = min_supply[j][i] = std::min(min_supply[i][j], min_supply[i][k] + min_supply[k][j]);
	}
	int q; std::cin >> q;
	for (auto i = 0; i < q; ++i) {
		int s, t; std::cin >> s >> t; --s; --t;
		if (min_supply[s][t] == INT_MAX) {
			std::cout << -1 << '\n';
		}
		else {
			std::cout << min_supply[s][t] - 1 << '\n';
		}
	}
}

Measured memory_bytes: 1664
def resolve():
    N, K = map(int, input().split())
    C = [0] * N
    for i in range(K):
        input()
        A = list(map(int, input().split()))
        for a in A:
            C[a-1] += 1

    print(C.count(0))

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9180
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int x; cin >> x;
    if(x < 30){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3648
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    for (int i = 0; i <= 100; i++) {
      for (int j = 0; j <= 100; j++) {
        if (4 * i + 7 * j == n) {
          System.out.println("Yes");
          return;
        }
      }
    }
    System.out.println("No");
  }
}

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

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

  int n = a;
  int m = b;
  while (b > 0)
    n *= 10, b /= 10;

  for (int i = 0; i * i <= n + m; i++) {
    if (i * i == n + m) {
      puts("Yes");
      return 0;
    }
  }

  puts("No");
}

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

int main(){
	int a,b;
	cin >> a >> b;
	if(a % 2 == 1 && b % 2 == 1){
		cout << "Odd" << endl;
	}else{
		cout << "Even" << endl;
	}
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 #include <math.h>
 #include <iostream>
 #include <iomanip>
 using namespace std;
 
 int main(){
    double W, H, x, y;
    int center;

    cin >> W >> H >> x >> y;;
    if (x==W/2 && y==H/2)
        center=1;
    else
        center=0;

    cout << fixed << std::setprecision(6) << (W*H)/2 << ' ' << center << endl;
    return 0;
 }
 


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

using namespace std;

typedef long long ll;

int main() {
	int a, b; scanf("%d%d",&a,&b);
	for (int i=0; i<=2000000; i++) {
		if ((i*8)/100>=a && i/10>=b) {
			if ((i*8)/100==a && i/10==b) printf("%d",i);
			else printf("-1");
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
/* -------------------------------- Template -------------------------------- */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }

template<typename T> constexpr T inf = [](){ assert(false); };
// template<> constexpr int inf<int> = 1e9;
// template<> constexpr ll inf<ll> = 1e18;
// template<> constexpr ld inf<ld> = 1e30;

struct yes_no : std::numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve();

int main() {
  std::locale loc(std::locale(), new yes_no);
  std::cout << std::boolalpha << std::setprecision(12) << std::fixed;
  std::cout.imbue(loc);
  solve();
  return 0;
}

using namespace std;

/* -------------------------------- Library -------------------------------- */

class UnionFind {
  vector<int> p;
public:
  UnionFind (int n) : p(n, -1) {}
  int root(int x) {
    return p[x] < 0 ? x : p[x] = root(p[x]);
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (p[y] < p[x]) swap(x, y);
    if (p[x] == p[y]) --p[x];
    p[y] = x;
    return true;
  }
};

/* ---------------------------------- Main ---------------------------------- */

void solve() {
  using T = tuple<int,int,int,bool,int>;
  priority_queue<T, vector<T>, greater<T>> que;
  int N, Q;
  cin >> N >> Q;
  REP(i,Q) {
    int A, B, C;
    cin >> A >> B >> C;
    que.push(make_tuple(C, A, B, true, 0));
  }
  UnionFind uf(N);
  ll res = 0;
  while (!que.empty()) {
    int C, A, B, p;
    bool sw;
    tie(C, A, B, sw, p) = que.top();
    int nA = A, nB = B;
    if (sw) ++nA; else ++nB;
    if (nA == N) nA = 0;
    if (nB == N) nB = 0;
    que.pop();
    if (uf.unite(A, B)) {
      res += C;
      que.push(make_tuple(C+1, nA, nB, !sw, 0));
    }
    else {
      if (p == 5) continue;
      que.push(make_tuple(C+1, nA, nB, !sw, p + 1));
    }
  }
  cout << res << endl;
  return;
}


Measured memory_bytes: 5484
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

	int N,M; cin >> N >> M;
	int p[100000], y[100000]; rep(i,M) cin >> p[i] >> y[i];
	vei unit[100005]; rep(i,M) unit[p[i]].pub(y[i]);

	rep(i,N) sort(all(unit[i+1]));

	rep(i,M) {
		auto it = lower_bound(all(unit[p[i]]), y[i]);
		int index = it - unit[p[i]].begin();
		printf("%06d%06d\n",p[i],index+1);
	}
	return 0;

}

Measured memory_bytes: 7808
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    ls = [0] * n
    for i in range(1, n):
        if i == 1:
            ls[i] = abs(a[i] - a[i-1])
        else:
            ls[i] = min(ls[i-1] + abs(a[i] - a[i-1]), ls[i-2] + abs(a[i] - a[i-2]))
    print(ls[-1])


if __name__ == '__main__':
    slove()


Measured memory_bytes: 52208
#include<stdio.h>
int main(){
	int a,i=0,u=0,e=0,o,yama[1001]={},ka,ki,ku,sa,si,su;
	scanf("%d",&a);
	for(i=0;i<a;i++){
		ka=0;
		scanf("%d %d %d",&u,&e,&o);
		if(ka<u){ka=u;ki=e;ku=o;}
		if(ka<e){ka=e;ki=o;ku=u;}
		if(ka<o){ka=o;ki=e;ku=u;}
		sa=ka*ka;
		si=ki*ki;
		su=ku*ku;
//		if(sa==si+su)yama[i]=1;
			if(sa==si+su){printf("YES\n");}else{printf("NO\n");}
	}
	/*for(i=0;i<a;i++){
				if(yama[i]==1){printf("Yes\n");}else{printf("No\n");
				}
	}*/
	return 0;
	
	
}

Measured memory_bytes: 576
N = int(input())
b = map(int,input().split())
b_ = [int(s) for s in b]
ans = []
for i in range(N):
    for j in range(len(b_),0,-1):
        if j == b_[j-1]:
            del b_[j-1]
            ans.append(j)
            break
if len(ans) == N:
    for i in reversed(ans):
        print(i)
else:
    print(-1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int H,W,A,B; cin>>H>>W>>A>>B;
  rep(i,0,B){
    rep(j,0,A) cout<<0;
    rep(j,A,W) cout<<1;
    cout<<endl;
  }
  rep(i,B,H){
    rep(j,0,A) cout<<1;
    rep(j,A,W) cout<<0;
    cout<<endl;
  }
  }



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

bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first > b.first;
    }
}

const ll tmax = 1000000000;

int main(){
    int n; cin >> n;
    vector<pair<ll, ll>> p;
    for(int i=0; i<n; ++i){
        ll a, b; cin >> a >> b;
        p.push_back({a, b});
    }
    sort(p.begin(), p.end(), compare); 
    
    ll now = 0; bool ok = true;
    for(auto it=p.begin(); it!=p.end(); ++it){
        now += (it->first); 
        if(now>(it->second)){ok = false; break;}
    } 
    if(ok){cout << "Yes" << endl;}
    else{cout << "No" << endl;}
    return 0;
}

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

int main() {
  string str,ans="";
  cin >> str;
  rep(i,str.size()){
    if(str.at(i) == '0'){
      ans.push_back('0');
    }
    if(str.at(i) == '1'){
      ans.push_back('1');
    }
    if(str.at(i) == 'B'){
      if(ans != ""){
        ans.pop_back();
      }      
    }
  }
  cout << ans << endl;
}


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

ll mod = 1e9 + 7;

int main() {
    int k; cin >> k;
    int num = 7;
    int ans = 0;
    for(int i=1; i<1000001; i++) {
        ans++;
        if(num % k == 0) {
            cout << ans << endl;
            return 0;
        }
        num = (num * 10 + 7) % k;
    }
    cout << -1 << endl;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N+1);
    for (int i=0; i<N-1; i++) {
        int a;
        cin >> a;
        A.at(a)++;
    }
    for (int i=1; i<N+1; i++) {
        cout << A.at(i) << endl;
    }
}


Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+1;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s,cs="",ls="";
	cin>>s;
	int ans=0,i,n=s.size();
	for(i=0;i<n;i++)
	{
		cs+=s[i];
		if(ls!=cs)
		{
			ls=cs;
			cs="";
			ans++;
		}
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 1228
S = input()
w_count = [0]*len(S)
if S[0] == 'W':
    w_count[0] = 1

res = 0
for i in range(1,len(S)):
    if S[i] == 'W':
        res += i - w_count[i-1]
        w_count[i] = w_count[i-1] + 1
    else:
        w_count[i] = w_count[i-1]

#print(w_count)
print(res)


Measured memory_bytes: 11240
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#include <map>
using namespace std;
typedef long long LL;

LL n,cnt = 0;
void solve(LL v,LL x){
	while(v % x == 0) v = v / x;
	if(v % x == 1) cnt ++;
}

int main(){
	ios::sync_with_stdio(false);
	cin >> n; cnt ++;
	for(LL i = 2;i * i <= n;i ++){
		if(n % i == 0){
			solve(n,i);
			if(i * i != n) solve(n,n / i);
		}
	}
	n --;
	for(LL i = 2;i * i <= n;i ++){
		if(n % i == 0){
			if(i * i == n) cnt ++;
			else cnt += 2;
		}
	}
	if(n != 1) cnt ++;
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n = II()
    ans = 0
    for i in range(1, n + 1):
        if i % 3 and i % 5:
            ans += i
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 77568
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define pi 3.14159265358979323846264338327950288
#define MOD 1000000007
#define INF -100000000000000
#define ordered_set tree<pair< ll int ,ll  int>, null_type,less<pair<ll int, ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define lld long double
using namespace __gnu_pbds;
int main()
{
    fast;
   // #ifndef ONLINE_JUDGE
   // freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
   // #endif
    ll int n;
    cin>>n;ll int i;string s;
    ll int t=0,w=0,a=0,r=0;
   for(i=1;i<=n;i++)
   {
   	cin>>s;
   	if(s[0]=='W')
   		w++;
   	else if(s[0]=='T')
   		t++;
   	else if(s[0]=='R')
   		r++;
   	else
   		a++;
   }
   cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<w<<endl;
     cout<<"TLE x "<<t<<endl;
      cout<<"RE x "<<r<<endl;
}

Measured memory_bytes: 3656
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

const ll MAX = 1000000;
ll fac[MAX], finv[MAX], inv[MAX];
// nCk初期化
void nCkInit(const ll MOD) {//O(max(n,r)logmax(n,r) mは素数)
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll N;
int main(){
    cin>>N;
    nCkInit(MOD);
    ll ans=0;
    for(ll i=1;i<=N/3;i++){
        ll n=N-i*3;
        ans=(ans+fac[n+i-1]*finv[n]%MOD*finv[i-1]%MOD)%MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 27068
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<climits>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<string.h>
#include<algorithm>
#include<unordered_map>
#pragma GCC optimize "trapv"
using namespace std;

#define ld long double
#define ll long long int
#define pb push_back
#define mp make_pair
#define f(i,a,b) for(int i=a;i<b;i++)
#define pp pair<int,pair<int,int>>
#define ppp pair<pair<int,int>,pair<int,int>>

const ll M=998244353,N=1e5+2;

struct hash_pair{
	template <class T1, class T2>
	size_t operator()(const pair<T1, T2>& p) const{
		auto hash1 = hash<T1>{}(p.first);
		auto hash2 = hash<T2>{}(p.second);
		return hash1 ^ hash2;
	}
};

void sieve(){
	bool prime[N+1];
	memset(prime,true,sizeof(prime));
	for(ll p=2;p*p<=N;p++){
		if(prime[p] == true){
			for(ll i=p*p;i<=N;i+=p)
				prime[i] = false;
		}
	}
}

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;
}

int root(int i,int A[]){
	while(A[i] != i){
		A[i] = A[A[i]];
		i = A[i];
	}
	return i;
}

void unite(int a,int b,int A[],int B[]){
	int c = root(a,A);
	int d = root(b,A);
	if(c == d)
		return;
	if(B[c] < B[d]){
		A[c] = d;
		B[d] += B[c];
	}
	else{
		A[d] = c;
		B[c] += B[d];
	}
}

inline ll in()
{
	ll n=0;
	bool check=0;
	register char c=getchar();
	while(c<'0' || c>'9')
	{
		if(c=='-')
			check=1;
		c=getchar();
	}
	while(c>='0' && c<='9')
	{
		n = (n<<1)+(n<<3)+c-'0';
		c=getchar();
	}
	return n-2*n*check;
}

string ip()
{
    string i="";
    int temp=getchar();
    while(temp<'a'||temp>'z')
        temp=getchar();
    while(temp>='a'&&temp<='z')
    {
        i+=(char)temp;
        temp=getchar();
    }
    return i;
}

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



	ld l;
	cin>>l;
	cout<<setprecision(12)<<pow((l)/3.0,3);

	return 0;
}

Measured memory_bytes: 256
N = int(input()) # 2<=N<=10

yen = 0
btc = 0.0

data = []

for i in range(N):
    data = []
    data = input().split()
    typ  = data[1]

    if typ == 'BTC':
        btc = btc + float(data[0])
    elif typ == 'JPY':
        yen = yen + int(data[0])

#print(yen, btc)

total = float(yen) + btc * 380000.0

print(total)


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

int main()
{
  int h,w;
  cin >> h >> w;
  vector<string> v;
  string s;
  for(int i = 0;i < h;++i){
    cin >> s;
    v.push_back(s);
  }
  
  int p[h][w];
  if(v[h-1][w-1] == '.'){p[h-1][w-1] = 0;}
  else{p[h-1][w-1] = 1;}
  for(int j = w-2; j >= 0; --j){
    if(v[h-1][j] == '#' && v[h-1][j+1] == '.'){p[h-1][j] = p[h-1][j+1]+1;}
    else{p[h-1][j] = p[h-1][j+1];}
  }
  for(int i = h-2 ; i >= 0 ;--i){
    if(v[i][w-1] == '#' && v[i+1][w-1] == '.'){p[i][w-1] = p[i+1][w-1]+1;}
    else{p[i][w-1] = p[i+1][w-1];}
    for(int j = w-2; j >= 0; --j){
      if(v[i][j] == '#' && v[i+1][j] == '.' && v[i][j+1] == '.' ){
        p[i][j] = min(p[i+1][j]+1,p[i][j+1]+1);
      }else if(v[i][j] == '#' && v[i+1][j] == '.' && v[i][j+1] == '#' ){
        p[i][j] = min(p[i+1][j]+1,p[i][j+1]);
      }else if(v[i][j] == '#' && v[i+1][j] == '#' && v[i][j+1] == '.' ){
        p[i][j] = min(p[i+1][j],p[i][j+1]+1);
      }else{p[i][j] = min(p[i+1][j],p[i][j+1]);}
    }
  }
  cout << p[0][0] << endl;
}


Measured memory_bytes: 256
import sys
import math

def input():
    return sys.stdin.readline()[:-1]

def main():
    N, K = map(int,input().split())
    S = "_" + input() + "_"
    if N == 1:
        print(0)
        exit(0)
    LR = 0
    ans = 0
    for k in range(1,N+1):
        if S[k] == S[k+1]:
            ans += 1
        else:
            LR += 1

    print(min(N-1,2*min(K,LR)+ans))

if __name__ == '__main__':
    main()


Measured memory_bytes: 40176
#include<stdio.h>
#include<algorithm>
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable:4996)
long long i, j, n, m, k;

int main() {
	while (scanf("%lld", &k) != EOF) {
		bool flag = false;
		while (k) {
			if (k % 10 == 7) {
				flag = !flag;
				break;
			}
			k /= 10;
		}
		if (flag)printf("Yes\n");
		else printf("No\n");
	}
}

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

int main(){
  ll N; cin >> N;
  vector<ll> e(N);
  for(ll i = 0; i < N; i++){
    cin >> e[i];
  }
  sort(e.begin(), e.end());
  ll ans = 0;
  
  for(ll i = 0; i < N-2; i++){
    for(ll j = i+1; j < N; j++){
      ll a = e[i], c = e[j];
      ll low = i + 1, high = j - 1;
      ll mid = (high - low) / 2 + low;
      while(high > low){
        ll b = e[mid];
        if(a + b < c+1) low = mid + 1;
        else if(a + b > c+1) high = mid;
        else break;
        mid = (high - low) / 2 + low;
      }
      if(a + e[mid] < c + 1) continue;
      
      while(e[mid-1] == e[mid] && mid > i+1)  mid--;
      ans += j - mid;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
program test
implicit none
real::a,b,c
integer::i,k,l,ans
read*,a,b
c=0
ans=100000
do i=1,10000
	k=floor(i*0.08)
    l=floor(i*0.1)
	if(a==k .and. b==l)then 
    	ans=min(ans,i)
   end if
end do  
if(ans==100000)then
ans=-1
end if
print*,ans
end program test

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K, S;
  cin >> K >> S;
  int ans = 0;
  for (int i=0; i<=K; i++) {
      for (int j=0; j<=K; j++) {
          int Z = S - (i + j);
          if (Z >= 0 && Z <= K) ans++;
      }
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pvec(v) for(auto e: v) cout << e << " ";
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i, a, b) for(int i = (a); i<(b); ++i)
#define pb push_back
#define INF 1000000005
#define MOD 1000000007
#define all(v) v.begin(), v.end()

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

ll power(ll x, ll y, ll p = MOD){  
    ll res = 1LL; 
    x = x % p;
    if (x == 0) return 0;
    while (y > 0){
        if (y & 1LL)  
            res = (res*x) % p;
        y = y>>1LL; 
        x = (x*x) % p;  
    }  
    return res;  
}  

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

	s = 'X' + s;

	int cnt = 0;
	for(int i = 1; i<=3; ++i) {
		if(s[i] == 'R' && s[i - 1] == 'R') {
			++cnt;
		}
		else if(s[i] == 'R') {
			cnt = 1;
		}
	}

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3652
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	
		public static void main(String[] args) {
			int a=scan.nextInt();
			List <Integer>list=new ArrayList<Integer>();
			for(int i=0;i<a;i++)list.add(scan.nextInt());
			while(list.size()>1){
				Collections.sort(list);
				int min=list.get(0);
				if(min==1) {
					System.out.println(1);
					return;
				}
				for(int i=1;i<list.size();i++) {
					int soko=list.get(i);
					list.remove(i);
					if(soko%min==0)i--;
					else {list.add(soko%min);}
				}
			}
			System.out.println(list.get(0));
		}
}

Measured memory_bytes: 57540
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define Rep(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
/*typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SMALLPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const int inf=1000000007;
const int mod=1000000007;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}*/
int main(){
  ll n,m;cin>>n>>m;
  priority_queue<ll> v;
  rep(i,n){
    ll a;
    cin>>a;
    v.push(a);
  }
  rep(i,m){
    ll a=v.top();
    a/=2;
    v.pop();
    v.push(a);
  }
  ll ans=0;
  while(!v.empty()){
    ans+=v.top();
    v.pop();
  }
  cout<<ans<<endl;
}


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


ll dp[3001][3001][2]={0};
ll find(vector<ll>&v,ll l,ll r,ll chance){
	if(l>r) return 0;
	ll &ans=dp[l][r][chance];
	if(ans!=-1) return ans;
	if(chance==0){
		ans=max(v[l]+find(v,l+1,r,1-chance),v[r]+find(v,l,r-1,1-chance));
	}
	else{
		ans=min(-v[l]+find(v,l+1,r,1-chance),-v[r]+find(v,l,r-1,1-chance));
	}
	return ans;
}
int  main(){
		ll n;
		cin>>n;
		vector<ll>v(n);
		for(int i=0;i<n;i++){
			cin>>v[i];
		}
		for(int i=0;i<=n;i++){
			for(int j=0;j<=n;j++){
				dp[i][j][0]=-1;
				dp[i][j][1]=-1;
			}
		}
		cout<<find(v,0,n-1,0)<<endl;
}


Measured memory_bytes: 141312
import sys

inf = float('inf')
n, k, c = map(int, sys.stdin.readline().split())
s = sys.stdin.readline().rstrip()

def main():
    dp_l = [[0] * 2 for _ in range(n + 2)]
    for i in range(n):
        dp_l[i+1][0] = max(dp_l[i][0], dp_l[i][1])
        if s[i] == 'o':
            if i + 1 - c < 0:
                dp_l[i+1][1] = 1 
            else:
                dp_l[i+1][1] = dp_l[i+1-c][0] + 1
    dp_r = [[0] * 2 for _ in range(n + 2)]
    for i in range(n, 0, -1):
        dp_r[i][0] = max(dp_r[i+1][0], dp_r[i+1][1])
        if s[i-1] == 'o':
            if i + c > n + 1:
                dp_r[i][1] = 1
            else:
                dp_r[i][1] = dp_r[i+c][0] + 1

    for i in range(1, n + 1):
        if s[i-1] == 'o':
            if dp_l[i][0] + dp_r[i][0] < k:
                print(i)

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 58504
using System;
using System.Linq;
class Program {
  static void Main(string[] args) {
    int[] n = Console.ReadLine().Split(' ')
    .Select(i => int.Parse(i)).ToArray();
    if (n[1]%n[0] == 0) {
      Console.Write(n[0]+n[1]);
    } else {
      Console.Write(n[1]-n[0]);
    }
  }
}

Measured memory_bytes: 13268
n=int(input())

c=[[0]*10 for _ in range(10)]
ans=0
for i in range(1,n+1):
    c[int(str(i)[0])][int(str(i)[-1])] +=1
    
    
for i in range(10):
    for j in range(10):
        ans += c[i][j] * c[j][i]
    
print(ans)

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2097162
#define inf 1e9
#define MOD 1000000007

bool check(char c)
{

    if(c == 'A' || c == 'C' || c == 'G' || c == 'T')
        return true;
    else return false;
}

int main()
{

    ll ans = 0;
    string ss;
    cin >> ss;
    for(ll i = 0; i < ss.size(); i++)
    {



        ll j = i;
        ll cnt = 0;
        while(j < ss.size() && check(ss[j]))
        {

            cnt++, j++;
        }
        i = j;


        ans = max(ans, cnt);
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

#define lint long long
#define INF 1000000000000000
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end

/* source code below */

int main() {
	 
	string S; cin >> S;
	lint n = S.size();

	vector<char> S1(n);
	vector<char> S2(n);
	for (int i = 0; i < n; i++)
	{
		if (i % 2 == 0) {
			S1[i] = '0';
			S2[i] = '1';
		}
		else {
			S2[i] = '0';
			S1[i] = '1';
		}
	}

	int count1 = 0;
	int count2 = 0;
	for (int i = 0; i < n; i++)
	{
		if (S[i] != S1[i]) {
			count1++;
		}
		if (S[i] != S2[i]) {
			count2++;
		}
	}
	//cout << S1 << endl;
	cout << min(count1, count2) << endl;
}
/* Don't forget to delete the header! */

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,a,b,ma,mi;
	cin>>n>>a>>b;
	ma=max(a,b);
	mi=min(a,b);
	if((ma-mi)%2==0){
		cout<<(ma-mi)/2<<endl;
	}else{
		ll cnt1=mi,cnt2=n-ma+1;
		cout<<min({ma-1,n-mi,(ma-mi)/2+cnt1,(ma-mi)/2+cnt2})<<endl;
	}
	return 0;
}


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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

template<typename T>
struct functor_traits:public functor_traits<decltype(&T::operator())>{};
template<typename C,typename Ret,typename... Args>
struct functor_traits<Ret(C::*)(Args...)const>{
	template<size_t I>
	using nth_argument_type=typename tuple_element<I,tuple<Args...>>::type;
	using first_argument_type=nth_argument_type<0>;
};
template<typename Compare,typename T=typename decay<typename functor_traits<Compare>::first_argument_type>::type>
priority_queue<T,vector<T>,Compare> make_priority_queue(Compare comp){
	return priority_queue<T,vector<T>,Compare>(comp);
}

int get_dist(const vi& xs,const vi& ys,int u,int v)
{
	return min(abs(xs[u]-xs[v]),abs(ys[u]-ys[v]));
}

int main()
{
	for(int n;cin>>n&&n;){
		vi xs(n),ys(n);
		rep(i,n) cin>>xs[i]>>ys[i];

		vi xis(n),yis(n);
		iota(all(xis),0); sort(all(xis),[&](int i,int j){return mp(xs[i],i)<mp(xs[j],j);});
		iota(all(yis),0); sort(all(yis),[&](int i,int j){return mp(ys[i],i)<mp(ys[j],j);});

		vi xrs(n),yrs(n);
		rep(i,n){
			xrs[xis[i]]=i;
			yrs[yis[i]]=i;
		}

		auto pq=make_priority_queue(greater<tuple<int,int>>());
		pq.emplace(0,0);
		vi dist(n,-1);
		while(pq.size()){
			int d,u; tie(d,u)=pq.top(); pq.pop();
			if(dist[u]!=-1) continue;
			dist[u]=d;
			for(int i=xrs[u]-1;i<=xrs[u]+1;i+=2) if(0<=i&&i<n){
				int v=xis[i];
				pq.emplace(get_dist(xs,ys,u,v),v);
			}
			for(int i=yrs[u]-1;i<=yrs[u]+1;i+=2) if(0<=i&&i<n){
				int v=yis[i];
				pq.emplace(get_dist(xs,ys,u,v),v);
			}
		}
		cout<<accumulate(all(dist),0ll)<<endl;
	}
}


Measured memory_bytes: 5108
#include <iostream>
#define MAX 100000
#define NIL -1

using namespace std;

typedef struct{
    int parent;
    int left;
    int right;
}Node;

Node T[MAX];
int Depth[MAX];

int setDepth(int u, int d){
    Depth[u] = d;
    if(T[u].right != NIL) setDepth(T[u].right, d);
    if(T[u].left != NIL) setDepth(T[u].left, d + 1);
}

void print(int u){
    cout << "node " << u << ": parent = " << T[u].parent << ", depth = " << Depth[u] << ", ";
    if(T[u].parent == NIL) cout << "root, ";
    else if(T[u].left == NIL) cout << "leaf, ";
    else cout << "internal node, ";
    int c = T[u].left;
    cout << "[";
    for(int i = 0, c = T[u].left; c != NIL; i++, c = T[c].right){
        if(i != 0) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

int main(){
    int n, id, k, c, x, i, j;
    cin >> n;
    for(i = 0; i < n; i++){
        T[i].parent = NIL;
        T[i].left = NIL;
        T[i].right = NIL;
    }
    for(i = 0; i < n ; i++){
        cin >> id >> k;
        for(j = 0; j < k; j++){
            cin >> c;
            if(j == 0) T[id].left = c;
            else T[x].right = c;
            x = c;
            T[c].parent = id;
        }
    }
    for(i = 0; i < n; i++){
        if(T[i].parent == NIL) x = i;
    }
    setDepth(x, 0);

    for(i = 0; i < n; i++) print(i);

    return 0;
}


Measured memory_bytes: 7768
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
A=[[] for _ in range(N)]

for i in range(N):
    A[i]=list(map(int,input().split()))
    
ans=0
for i in range(N):
    sc=C
    for j in range(M):
        sc+=A[i][j]*B[j]
    if sc>0:
        ans+=1
        
print(ans)

Measured memory_bytes: 38256