akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long T = sc.nextLong();
    long[] t = new long[n];
    for(int i = 0; i < n; i++){
      t[i] = sc.nextLong();
    }
    long sum = T * n;
    long tmp = T;
    for(int i = 1; i < n; i++){
      sum -= (tmp > t[i]) ? (tmp - t[i]) : 0;
      tmp = t[i] + T;
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 82272
def main():
    h, w, k = map(int, input().split())

    dp = [[0] * (w + 2) for _ in range(h + 1)]
    dp[0][1] = 1

    c = [1, 1, 2, 3, 5, 8, 13, 21]

    for i in range(1, h + 1):
        for j in range(1, w + 1):
            dp[i][j] = c[j - 1] * c[w - j] * dp[i - 1][j] + c[j - 1] * c[w - j - 1] * dp[i - 1][j + 1] + c[j - 2] * c[w - j] * dp[i - 1][j - 1]

    print(dp[h][k] % (10 ** 9 + 7))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
N = int(input())
A = list(map(int,input().split()))
P = [2**i for i in range(30)]
P = sorted(P,reverse = True)
ans = 100
for i in range(N) :
    for j in range(len(P)) :
        if A[i] % P[j] == 0 :
            ans = min(ans,29-j)
            break
print(ans)


Measured memory_bytes: 3060
import java.util.*;

class Main{
   public static void main(String a[]) throws java.io.IOException{
       Scanner scan =new Scanner (System.in);
       Pair pair= new Pair();
       Queue<Pair> fifo = new LinkedList<Pair>();

       while(true){

           int W =scan.nextInt();
           int H =scan.nextInt();
           if((W|H)==0)break;
           char  [][] map = new char [H][W];
           for(int i=0;i<H;i++){
               String  tmp =scan.next();
               for(int j=0;j<W;j++){
                   map[i][j] = tmp.charAt(j);
                   if(tmp.charAt(j)=='@'){
                       
                       pair.x=j;
                       pair.y=i;
                       fifo.add(pair);
                       map[i][j] = '#';
                   }
               }
           }
          int count =1;
          while(fifo.peek()!=null){  
           pair = fifo.poll();
           int x=pair.x;
           int y=pair.y;
           int[] dx ={0,1,0,-1};
           int[] dy ={1,0,-1,0};
          for(int i=0;i<4;i++){
              int nx =x+dx[i];
              int ny =y+dy[i];
              if(0<=nx&&nx<W&&0<=ny&&ny<H&&map[ny][nx]!='#'){
                  Pair npair =new Pair();
                  npair.x=nx;
                  npair.y=ny;
                  fifo.add(npair);
                  map[ny][nx] = '#';
                  count++;
              }
          } 
          }
          System.out.println(count);

       
       }
}
}

class Pair{
    public int x;
    public int y;
}

Measured memory_bytes: 12000
n, m = gets.chomp.split(" ").map(&:to_i)
c = {}

n.times do
  gets.chomp.split(" ").drop(1).map(&:to_i).each do |f|
    c[f] ||= 0
    c[f] += 1
  end
end

ans = 0
c.each {|_, v| ans += 1 if v == n }

puts ans


Measured memory_bytes: 3836
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	int a,b,ans;
	cin >> a >> b;
	int count=0;
	for(int i=1;i<=b-a;i++){
		count+=i;
	}
	cout << count-b << endl;
/////////////////////////////////////////////
}


Measured memory_bytes: 256
'''
https://beta.atcoder.jp/contests/abc103/submissions/2888942
'''

n, m = map(int, input().split())
M = list(tuple(map(int, input().split())) for _ in range(m))#各クエリの(a,b)タプルのリスト
M_b_asc = sorted(M, key=lambda x: x[1])#Mをb昇順でソート

cnt = 0
c = -1
for a, b in M_b_asc:
    #print(a,b,c)
    if a <= c < b:
        continue
    else:
        cnt += 1
        c = b - 1   

print(cnt)


Measured memory_bytes: 19024
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n, m;
    cin >> n >> m;
    int ans = 0;
    ans += m * (m-1) / 2;
    ans += n * (n-1) / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
thing={}
ans=0
for i in range(n):
  if i-a[i] in thing:
    ans+=thing[i-a[i]]
  if i+a[i] in thing:
    thing[i+a[i]]+=1
  else:
    thing[i+a[i]]=1
print(ans)

Measured memory_bytes: 111628
////*24-AUG-19*///
//Why do we fall?//
// So we can learn to pick ourself up!//
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fr(a,b,c) for(int a=b; a<c; a++)
#define frr(a,b,c) for(int a=b;a>=c;a--)
#define pb push_back
#define pii pair<int,int>
#define R(a) ll a; cin >> a;
#define RA(a, n) ll a[(n) + 1] = {}; fr(i, 1, (n)+1) {cin >> a[i];}
#define RM(a, n, m) int a[n + 1][m + 1] = {}; fr(i, 1, n) {fr(j, 1, m) cin >> a[i][j];}
#define reset(X) memset(X, 0, sizeof(X))
const int inf = 1e18;
const int mod=1e9+7;
unsigned int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
bool isPrime(int n)
{   if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
    }
//z function -  z[i] is the length of the longest common prefix between s and the suffix of s starting at i
vector<int>z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}
int lis( int arr[], int n )
{
    int lis[n];

    lis[1] = 1;

    /* Compute optimized LIS values in bottom up manner */
    for (int i = 2; i <= n; i++ )
    {
        lis[i] = 1;
        for (int j = 1; j < i; j++ )
            if ( arr[i] >=arr[j] && lis[i] < lis[j] + 1)
                lis[i] = lis[j] + 1;
    }

    // Return maximum value in lis[]
    return *max_element(lis+1, lis+n+1);
}
signed main()
{
  int n;
  cin>>n;
  RA(a,n);
  int mx=1;
  int cnt=1;
  fr(i,2,n+1)
  {
      if(a[i]<=a[i-1])
      {
          cnt+=1;
      }
      else
      {
          mx=max(mx,cnt);
          cnt=1;
      }
  }
  cout<<max(mx,cnt)-1<<endl;
}



Measured memory_bytes: 1024
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int N = 1000000;
const ll mod = 1000000007;
const ll INF = std::numeric_limits<long long>::max();
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define srep(i,s) rep(i,(ll)s.size())
#define vin(n,v) rep(i,n)cin>>v[i]
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define sz size
void YN(bool b) { cout << (b ? "YES" : "NO") << endl; }
void yn(bool b) { cout << (b ? "Yes" : "No") << endl; }
ll n, a, b;
int main(){
	cin >> n >> a >> b;
	cout<<(abs(a-b)%2==0?"Alice":"Borys")<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef  long long   ll;
typedef  long double ld;
#define ceil(n, m) ((n / m) + ( n % m ? 1 : 0))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	//freopen("input.txt", "r", stdin);
	int n;
	cin >> n;
	map<string, int> mp;
	string s;
	while (n-- && cin >> s)
		mp[s]++;
	cout << "AC" << " x " << mp["AC"] << '\n';
	cout << "WA" << " x " << mp["WA"] << '\n';
	cout << "TLE" << " x " << mp["TLE"] << '\n';
	cout << "RE" << " x " << mp["RE"] << '\n';


}


Measured memory_bytes: 3664
#include<queue>
#include<cstdio>
#include<cstring>

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

using namespace std;

typedef pair<int,int> pii;

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

int main(){
	for(int t,n;scanf("%d%d",&t,&n),t;){
		static bool visited[130][130];
		memset(visited,0,sizeof visited);
		rep(i,n){
			int x,y; scanf("%d%d",&x,&y);
			x+=60, y+=60;
			visited[y][x]=true;
		}
		int x0,y0; scanf("%d%d",&x0,&y0);
		x0+=60, y0+=60;
		visited[y0][x0]=true;

		queue< pair<int,pii> > qu; qu.push(mp(0,mp(y0,x0)));
		while(!qu.empty()){
			pair<int,pii> a=qu.front(); qu.pop();
			int turn=a.first,x=a.second.second,y=a.second.first;
			if(turn>=t) continue;

			rep(i,6){
				int xx=x+dx[i],yy=y+dy[i];
				if(!visited[yy][xx]){
					visited[yy][xx]=true;
					qu.push(mp(turn+1,mp(yy,xx)));
				}
			}
		}

		int ans=-n;
		rep(i,130) rep(j,130) if(visited[i][j]) ans++;
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG

int main(){
    ll n;
    cin>>n;
    string c;
    cin>>c;

    ll numR=0;
    rep(i,n){
        if(c[i]=='R') numR++;
    }

    ll ans;
    if(numR==0) ans=0;
    else{
        ll numW=0;
        rep(i,numR){
            if(c[i]=='W') numW++;
            else continue;
        }
        ans=numW;
    }
    cout<<ans<<endl;
    

}

Measured memory_bytes: 3720
#include <iostream>
#include <numeric>

using namespace std;

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

  string s = to_string(N);
  auto SN = accumulate(begin(s), end(s), 0,
                       [](int a, char c) { return a + c - '0'; });
  cout << (N % SN == 0 ? "Yes" : "No") << endl;
  return 0;
}


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

using namespace std;

int main(void) {
  int x, y, z;
  cin >> x >> y >> z;
  for (int i = 0; i < x; i++) {
    int left = x - (y * i);
    int left2 = left - (z * (i + 1));
    if (left2 < 0) {
      cout << (i - 1 < 0 ? 0 : i - 1) << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<vector<int>> card(4, vector<int>(13, 0));
  int n, b; cin >> n;
  char a;
  
  for (int i = 0; i < n; i++){
    cin >> a >> b;
    if(a == 'S'){
      card.at(0).at(b-1) = 1;
    }
    else if(a == 'H'){
      card.at(1).at(b-1) = 1;
    }
    else if(a == 'C'){
      card.at(2).at(b-1) = 1;
    }
    else{
      card.at(3).at(b-1) = 1;
    }
  }
  
  for(int j = 0; j < 4; j++){
    for(int k = 0; k < 13; k++){
      if(card.at(j).at(k) == 0){
      if(j == 0){
        cout << "S " <<  k+1 << endl;
      }
      else if(j == 1){
        cout << "H " <<  k+1 << endl;
      }
      else if(j == 2){
        cout << "C " <<  k+1 << endl;
      }
      else{
        cout << "D " <<  k+1 << endl;
      }
      }
    }
  }
  
}


Measured memory_bytes: 3156
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define INF 1e9;
//#define mod 1e9+7

//#define max(x,y) (x>y)?x:y
//#define min(x,y) (x<y)?x:y
#define rep(i,j,k) for(int i=j;i<k;i++)
#define repp(i,j,k) for(int i=j;i>=k;i--)
#define mi(n) (int*)malloc(sizeof(int)*n);
#define mc(n) (char*)malloc(sizeof(char)*n);

using namespace std;
int mod=1000000007;

int main(){
   int n;
   long long p=1;
   cin>>n;
   int i;
   rep(i,1,n+1){
       p=(p*=i)%mod;
   }
   
   cout<<p<<endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
const int MOD = 998244353;
const int MX = 10000005;
int n;
ll ans = 1, k;
ll exp(ll b, ll n){
	ll res = 1;
	for(; n; n/=2,(b*=b)%=MOD) if(n%2) (res *= b) %= MOD;
	return res;
}
ll fact[MX] = {1}, invf[MX];
void setcomb(int n){
	for(int i = 1; i <= n; i++) fact[i] = (fact[i-1] * i) % MOD;
	invf[n] =  exp(fact[n] ,MOD-2);
	for(int i = n; i > 0; i--) invf[i-1] = (invf[i] * i) % MOD;
}
inline ll comb(int a, int b){return fact[a] * invf[a-b] % MOD * invf[b] % MOD;}
int main(){
	scanf("%d", &n);
	setcomb(n);
	ans = exp(3,n);
	rep(i,n/2) ans -= comb(n,i) * exp(2,i) * 2 % MOD;
	printf("%lld\n", (ans % MOD + MOD) % MOD);
}

Measured memory_bytes: 156544
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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

int main(void) {
    int K, X;
    cin >> K >> X;

    if (500 * K >= X) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
import copy
s=list(input())
t=copy.deepcopy(s)
s=s[::-1]
a=[]
for i in range((len(s)-1)//2):
 a.append(t[i])
b=[]
for i in range(len(s)-(len(s)+2)//2):
 b.append(t[i])
#print(a,b,s,t)
if s!=t:
 print('No')
 #print(s,t)
else:
 if a!=a[::-1]:
  print('No')
  #print(a,a[::-1])
 else:
  if b!=b[::-1]:
   print('No')
   #print(b,b[::-1])
  else:
   print('Yes')

Measured memory_bytes: 38384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ALDS1_1_B
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int[] line = ReadIntAr();
            Console.WriteLine(Gcd(line[0],line[1]).ToString());
        }

        //●最大公約数
        public static long Gcd(long a, long b)
        {
            if (a < b) return Gcd(b, a);  // 引数を入替えて自分を呼び出す
            if (b == 0) return a; //一方が0の場合は、もう片方の数自身がGCD

            long d = 0;
            do
            {
                d = a % b;
                a = b;
                b = d;
            } while (d != 0);
            return a;
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



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



int main()
{
	int N;
	string S;
	double y;

	// 380000.0

	double sum = 0.0;

	cin >> N;

	for (int i = 0; i < N; i++)
	{
		cin >> y >> S;

		if (S != "JPY")
		{
			sum = sum + ( y * 380000.0 );
		}
		else
		{
			sum += y;
		}

	}

	cout << sum;
}


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

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

  for(int i=0; i<n; i++){
    int y, m, d;
    cin >> y >> m >> d;

    int ans = 0;
    ans -= d-1;
    if(y%3 == 0){
      ans -= 20 * (m-1);
    }else{
      if(m%2 == 0){
        ans -= 20 * (int)((m-1)/2+1);
        ans -= 19 * (int)((m-1)/2);
      }else{
        ans -= 20 * (m-1)/2;
        ans -= 19 * (m-1)/2;
      }
    }
    ans += 10 * 20 * (999/3 - (y-1)/3);
    ans += 5 * 39 * (999 - (y-1) - (999/3 - (y-1)/3));

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

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

using namespace std;

int dp[82][82][81 * 161];
int add = 81 * 81;
int a[82][82], b[82][82];

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) cin >> a[i][j];
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) cin >> b[i][j];
    }
    dp[1][1][a[1][1] - b[1][1] + add] = 1;
    dp[1][1][b[1][1] - a[1][1] + add] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            int c = a[i][j] - b[i][j];
            if (i == 1 && j == 1) continue;
            for (int z = 0; z < 81 * 161; ++z) {
                if (z - c >= 0 && z - c < 81 * 161) dp[i][j][z] = max(dp[i - 1][j][z - c], dp[i][j - 1][z - c]);
                if (z + c >= 0 && z + c < 81 * 161) dp[i][j][z] = max({dp[i][j][z], dp[i - 1][j][z + c], dp[i][j - 1][z + c]});
            }
        }
    }
    //cout << dp[1][2][add] << '\n';
    int ans = 1e9;
    for (int z = 0; z < 81 * 161; ++z) if (dp[n][m][z]) ans = min(ans, abs(z - add));
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 336128
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>

#define max 10

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}

int main()
{
    int n, d;
    
    scanf("%d %d", &n, &d);
    
    printf("%d", (2*d+n)/(2*d+1));
     
    return 0;
}





Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        lower, upper = [], []
        i = 1
        while i * i <= n:
            if n % i == 0:
                lower.append(i)
                if i != n // i:
                    upper.append(n // i)
            i += 1
        return lower + upper[::-1]

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True

    @staticmethod
    def fact(N):
        res = {}
        tmp = N
        for i in range(2, int(N ** 0.5 + 1) + 1):
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            if cnt > 0:
                res[i] = cnt
        if tmp != 1:
            res[tmp] = 1
        if res == {}:
            res[N] = 1
        return res


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    N, M = Scanner.map_int()
    A = Scanner.map_int()
    A = [-a for a in A]
    heapq.heapify(A)
    for _ in range(M):
        x = -heapq.heappop(A)
        x //= 2
        heapq.heappush(A, -x)
    print(-sum(A))


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 21884
# -*- coding: utf-8 -*-
n = int(input())
d = []
for i in range(n):
  d.append(int(input()))

d.sort(reverse=True)
ret = 0
prev = 101
for i in range(len(d)):
  if (d[i] < prev):
    ret += 1
    prev = d[i]

print(ret)


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

int main() {
    int ans = 0;
    vector<int> v(5);
    int last = 0, num = 9;
    for(int i = 0; i < 5; i++) {
        cin >> v[i];
        if (v[i] % 10 != 0 && v[i] % 10 < num) {
            last = i;
            num = v[i] % 10;
        }
    }
    for(int i = 0; i < 5; i++) {
        if(i == last) ans += v[i];
        else ans += v[i] / 10 * 10 + (v[i] % 10 != 0 ? 10 : 0);
    }
    cout << ans << endl;
}

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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

// void arrdump(int *arr, int len) {
//   for (int i = 0; i < len; i++) {
//     eprintf("[%d] = %d\n", i, arr[i]);
//   }
// }

int main(int argc, const char *argv[])
{
  int n, q, l, r;
  scanf("%d%d", &n, &q);
  char s[n + 1];
  scanf("%s", s);
  int cnt[n + 2];
  int cnt_tmp = 0;
  cnt[0] = cnt_tmp;
  for (int i = 1; i < strlen(s); i++) {
    if ( s[i-1] == 'A' && s[i] == 'C' )
      cnt_tmp++;
    cnt[i] = cnt_tmp;
  }
  // arrdump(cnt, n);
  for (int i = 0; i < q; i++) {
    scanf("%d%d", &l, &r);
    // eprintf("[l%d] = %d, [r%d] = %d\n", l, cnt[l - 1], r, cnt[r - 1]);
    printf("%d\n", cnt[r - 1] - cnt[l - 1]);
  }
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = (int)1e5 + 10;

struct UnionFind
{
   vector<int> parent, size;

   void init(int n){
      parent.resize(n+1);
      size.resize(n+1);
         
      for (int i = 1; i <= n; ++i)
      {
         parent[i] = i;
         size[i] = 1;
      }

   }

   int find(int x){

      while(x != parent[x]){
         parent[x] = parent[parent[x]];
         x = parent[x];
      }

      return x;
   }

   bool unite(int x, int y){
      x = find(x);
      y = find(y);
      if(x == y)
         return false;
      parent[y] = x;
      size[x] += size[y];
      return true;
   }

   int getSize(int x){
      x = find(x);
      return size[x];
   }

};

vector<int> X[2*N], Y[2*N];

const int maxn = 1e5;
vector<P> edges;

int n;
int32_t main(){_

   cin>>n;

   for (int i = 0; i < n; ++i)
   {
      int a, b;
      cin >> a >> b;
      b += maxn;
      X[a].push_back(b);
      X[b].push_back(a);
      edges.push_back({a, b});
   }

   UnionFind S;
   S.init(2*N);

   for (int i = 1; i < 2*N; ++i)
   {
      if(X[i].empty())continue;
      int fir = X[i][0];
      for(auto it: X[i]){
         S.unite(fir, it);
      }
   }
   

   int ans = -n;

   set<int> s;

   for(auto it: edges){
      int x = it.first, y = it.second;
      x = S.find(x);
      if(s.count(x) == 0){
         ans += S.getSize(x) * S.getSize(y);
      }
      s.insert(x);
   }

   cout<<ans;

   return 0;
}

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

/* 累乗b^eを正確に計算します. */
template<typename T> T ipow(T b, long long e) {
	if (e == 0) {
		return 1;
	} else if (e % 2 == 0) {
		return ipow(b * b, e / 2);
	} else {
		return ipow(b * b, e / 2) * b;
	}
}

/* 10進数での自然数nの桁数を返します. */
int digit_number_10(long long n) {
	for (int i = 1;; i++) {
		if (n < ipow<long long>(10, i)) {
			return i;
		}
	}
}

long long F(long long A, long long B) {
	return digit_number_10(max(A, B));
}

/* 自然数nの約数を列挙します.返すarrayは昇順にソートされています. */
set<long long> enum_divisors(long long n) {
	set<long long> ans;
	for (long long i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ans.insert(i);
			ans.insert(n / i);
		}
	}
	return ans;
}

int main() {
	long long N;
	long long ans = INT_MAX;
	cin >> N;
	auto A = enum_divisors(N);
	for (auto it = A.begin(); it != A.end(); it++) {
		ans = min(ans, F(*it, N / (*it)));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
//============================================================================
// 
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

//============================================================================
typedef struct{
    char suit;
    int  value;
    int  order;
}TCard;
//============================================================================
int BubbleSort(TCard *ary, int n)
{
    int i,j,k,l, cnt; TCard chg;

    for (k=cnt=0, l=n; k<n-1; k++, l--)
    for (i=0,j=1; j<l; i++, j++){
        if (ary[j].value<ary[i].value)
            chg=ary[i], ary[i]=ary[j], ary[j]=chg, cnt++;
	}
    return cnt;
}
//============================================================================
int SelectionSort(TCard *ary, int n)
{
    int i,j,minj,cnt; TCard chg;

    for (i=cnt=0; i<n; i++){
        for (j=minj=i; j<n; j++){
            if (ary[j].value<ary[minj].value)
                minj=j;
        }
        if (i!=minj)
            chg=ary[i], ary[i]=ary[minj], ary[minj]=chg, cnt++;
    }
    return cnt;
}
//============================================================================
void selectionsort()
{
    int i,cnt, n; TCard *ary;

    scanf("%d", &n);
    ary=malloc(n*sizeof(TCard));
    for (i=0; i<n; i++)
        scanf("%d", &ary[i].value);
    cnt=SelectionSort(ary, n);
    for (i=0; i<n; i++){
        if (i) printf(" ");
        printf("%d", ary[i].value);
    }
    printf("\n%d\n", cnt);
    free(ary);
}
//============================================================================
void cardsort()
{
    int i,cnt,nstb,n; TCard *ary; char sub[10];

    scanf("%d", &n);
    ary=malloc(n*sizeof(TCard));
    for (i=0; i<n; i++){
        scanf("%s", sub);
        //scanf("%c%d", &ary[i].suit, &ary[i].value);
        ary[i].suit=*sub;
        ary[i].value=sub[1]-'0';
        ary[i].order=i;
    }
    cnt=BubbleSort(ary, n);
    for (i=nstb=0; i<n; i++){
        if (i) printf(" ");
        printf("%c%d", ary[i].suit, ary[i].value);
        if (i<n-1)
        if (ary[i].value==ary[i+1].value && ary[i+1].order<ary[i].order)
                nstb++;
    }
    printf("\n%s\n", (nstb)?"Not stable":"Stable");
    cnt=SelectionSort(ary, n);
    for (i=0; i<n; i++){
        if (i) printf(" ");
        printf("%c%d", ary[i].suit, ary[i].value);
        if (i<n-1)
        if (ary[i].value==ary[i+1].value && ary[i+1].order<ary[i].order)
                nstb++;
    }
    printf("\n%s\n", (nstb)?"Not stable":"Stable");
    free(ary);
}
//============================================================================
int main(void)
{
    selectionsort();
    //cardsort();
    return 0;
}
//============================================================================

Measured memory_bytes: 604
import numpy
A1 = numpy.array(list(map(int, input().split())))
A2 = numpy.array(list(map(int, input().split())))
A3 = numpy.array(list(map(int, input().split())))

A = numpy.array([A1, A2, A3])
C = numpy.zeros(A.shape)

N = int(input())
B = []
for _ in range(N):
    b = int(input())
    B.append(b)

    C[A == b] = 1

diag1 = numpy.array([C[0,0], C[1,1], C[2,2]])
diag2 = numpy.array([C[0,2], C[1,1], C[2,0]])

flag = False

if numpy.all(C[0] == 1) or numpy.all(C[1] == 1) or numpy.all(C[2] == 1):
    flag = True

if numpy.all(C.T[0] == 1) or numpy.all(C.T[1] == 1) or numpy.all(C.T[2] == 1):
    flag = True

if numpy.all(diag1 == 1) or numpy.all(diag2 == 1):
    flag = True

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

Measured memory_bytes: 27256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define FOR(i, N) for (long i = 0; i < (N); i++)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X, N, T;
    cin >> N >> X >> T;

    FOR(i, 10000) {
        if (N <= X * i) {
            cout << i * T << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC90_1
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = "";
            for (int i = 0; i < 3; i++)
            {
                a += Console.ReadLine()[i];
            }
            Console.WriteLine(a);

        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
 
#define rp(i, k, n) for (int i = k; i < n; i++)
using ll = long long;
using ld = double;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;

int solve(string s, int k, int i=0, bool flag=false) {
    if(k == 0) return 1;
    int sz = s.size();
    if(i == sz) return 0;
    // もうここからどう選んでもsより小さくなる場合は、flag=true
    // その場合、桁の数字に関係なく好きな数字を選べる
    if(flag) {
        return solve(s, k, i+1, flag) + 9 * solve(s, k-1, i+1, flag);
    }
    // そうでない場合はflag=false
    // この時、その桁の数字を選んだ場合はflag = falseのまま
    else {
        if(s[i] == '0') {
            return solve(s, k, i+1, flag);
        } else {
            return solve(s, k, i+1, true) + (s[i] - '0' - 1) * solve(s, k-1, i+1, true) + solve(s, k-1, i+1, false);
        }
    }

}

int main() {
    string n; cin >> n;
    int k; cin >> k;
    cout << solve(n, k) << endl;
    return 0;
}


Measured memory_bytes: 3580
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <ctime>
#include <cstring>
#define ll long long
#define INF 1000000000
#define For(i,a,b) for(int i=a;i<=b;++i)
#define Rev(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define pq priority_queue
#define PI acos(-1)

namespace IO
{
#define p(x) ('0'<=x&&x<='9')
	char cc; int C;
	template <class T>
	void read( T &x )
	{
		x=0; cc=getchar(); C=1;
		while(!p(cc)) { if(cc=='-') C=-1; cc=getchar(); }
		while(p(cc)) { x=x*10+cc-48; cc=getchar(); }
		x*=C;
	}
#undef p
}

using namespace IO;
using namespace std;

#define N 100005

#define lb(x) (x&-x)
int a[N],b[N],c[N],n;
ll Arr[N<<1],Arr_minor[N<<1],tot,tot_minor,tot_zero;

ll sigema(int pos)
{
	ll ret=0;
	while(pos)
	{
		ret+=Arr[pos];
		pos-=lb(pos);
	}
	return ret;
}

void add(int pos)
{
	++tot;
	while(pos<=N) ++Arr[pos],pos+=lb(pos);
}

ll sigema_minor(int pos)
{
	ll ret=0;
	while(pos)
	{
		ret+=Arr_minor[pos];
		pos-=lb(pos);
	}
	return ret;
}

void add_minor(int pos)
{
	++tot_minor;
	while(pos<=N) ++Arr_minor[pos],pos+=lb(pos);
}

#undef lb

void init()
{
	read(n);
	For(i,1,n) read(a[i]),b[i]=a[i];
	sort(b+1,b+1+n);
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	srand(time(0));
#ifdef LOCAL
	freopen("./tmp/input.txt", "r", stdin);
#endif
	init();
	int L=1,R=n,mid,pre,ans;
	ll sum;
	const ll total=1LL*n*(n+1)/2;
	const ll target=(total/2)+1;
	while(L<R)
	{
		mid=(L+R)>>1;

		memset(Arr,0,sizeof(Arr)); tot=0;
		memset(Arr_minor,0,sizeof(Arr)); tot_minor=0;
		tot_zero=0;

		For(i,1,n) c[i]=(a[i]<=b[mid]?1:-1);
		sum=pre=0;
		++tot_zero;
		For(i,1,n)
		{
			pre+=c[i];
			if(pre<0)
			{
				sum+=tot_minor;
				sum-=sigema_minor(-pre);
				add_minor(-pre);
				continue;
			}
			if(pre==0)
			{
				sum+=tot_minor;
				++tot_zero;
				continue;
			}
			if(pre>0)
			{
				sum+=tot_minor+tot_zero;
				sum+=sigema(pre-1);
				add(pre);
				continue;
			}
		}
		if(sum>=target) R=mid;
		else L=mid+1;
	}

	printf("%d\n",b[L]);

	return 0;
}


Measured memory_bytes: 4608
let () =
  let n = Scanf.scanf "%d\n" (fun x -> x) in
  let lst = Array.to_list (Array.init n (fun _ -> Scanf.scanf "%d " (fun x -> x))) in
  let max_num = List.fold_left max min_int lst in
  let min_num = List.fold_left min max_int lst in
  Printf.printf "%d\n" (abs (max_num - min_num))


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

int gcd(int i,int j,int k){
for(int ii=i;ii>=1;ii--){
    if(i%ii==0&&j%ii==0&&k%ii==0)
        return ii;
}
}

int main(){
    int n;
    cin>>n;
    long long sum=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
        for(int k=1;k<=n;k++){
        sum+=gcd(i,j,k);
    }
    cout<<sum<<endl;
    return 0;


}



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

using namespace std;

int main(void)
{
	int n;
	cin>>n;
	bool flag = false;
	while(n%10 != 7){
		n = n/10;
		if(n == 0){
			cout<<"No"<<endl;
			return 0;
		}
	}
	if(n%10 == 7){
		cout<<"Yes"<<endl;
	}
	return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define debug(x) cout << #x << " =" << (x) << endl;
#define MOD 1000000000000000007
#define EPS (1 >> 30)
#define INF (1 << 30)
//#define INFll (1LL << 60)

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

ll comb(ll n, ll k) // nCr
{
    k = min(k, n - k);
    ll nnn = 1;
    for (ll i = n - k + 1; i <= n; i++)
    {
        nnn *= i;
        nnn %= MOD;
    }
    ll kkk = 1;
    for (ll i = 1; i <= k; i++)
    {
        kkk *= i;
        kkk %= MOD;
    }
    return (nnn * power(kkk, MOD - 2)) % MOD;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int n;
    cin>>n;
    vector<string> s(n);
    rep(i,n){
        cin>>s[i];
        sort(s[i].begin(),s[i].end());
    }
    sort(s.begin(),s.end());
    ll memo=0;
    ll ans=0;
    rep(i,n-1){
        if(s[i]==s[i+1]){
            memo++;
        }
        else{
            ans+=memo*(memo+1)/2;
            memo=0;
        }
    }
    ans+=memo*(memo+1)/2;
    cout<<ans<<endl;


}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) (vec).begin(),(vec).end()
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
long long x,k,d,v1;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>x>>d>>k;
	if(x<0) x=-x;
	v1=(x/k);
	if(d%2==v1%2)
		cout<<x-min(d,(x/k))*k<<endl;
	else if((x/k)+1<=d)
		cout<<k-(x%k)<<endl;
	else
		cout<<x-d*k<<endl;
	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;int p[1024][1<<17],v[1<<19],w[1<<19],q,l,i;int f(int a,int l){if(l<0)return -1e9;if(!a)return 0;if(a>1023)return max(f(a/2,l),f(a/2,l-w[a])+v[a]);if(~p[a][l])return p[a][l];return p[a][l]=max({f(a/2,l),f(a,l-1),f(a/2,l-w[a])+v[a]});};int main(){memset(p,-1,1<<29);cin>>l;for(;i++<l;)cin>>v[i]>>w[i];cin>>q;while(q--){cin>>i>>l;cout<<f(i,l)<<" ";}}

Measured memory_bytes: 537716
H, W = map(int, input().split())
a = []

for i in range(H):
    a.append([int(x) for x in input().split()])

n = 0
ans = []
for y in range(H):
    if y % 2 == 0:
        for x in range(W - 1):
            if a[y][x] & 1:
                a[y][x + 1] += 1
                n += 1
                ans.append("{} {} {} {}".format(y + 1, x + 1, y + 1, x + 2))
        if y != H - 1 and (a[y][W - 1] & 1):
            a[y + 1][W - 1] += 1
            n += 1
            ans.append("{} {} {} {}".format(y + 1, W, y + 2, W))

    else:
        for x in range(W - 1, 0, -1):
            if a[y][x] & 1:
                a[y][x - 1] += 1
                n += 1
                ans.append("{} {} {} {}".format(y + 1, x + 1, y + 1, x))
        if y != H - 1 and (a[y][0] & 1):
            a[y + 1][0] += 1
            n += 1
            ans.append("{} {} {} {}".format(y + 1, 1, y + 2, 1))

print(n)
print("\n".join(ans))

Measured memory_bytes: 23896
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <stdio.h>
using namespace std;
using ll = long long;

#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()

int main() {
  int C,D;
  IN(C);
  IN(D);
  int X_max = C;
  int X_min = 1;
  REP(i,D){
    int Y_min, Y_max;
    cin >> Y_min >> Y_max;
    X_min = MAX(X_min, Y_min);
    X_max = MIN(X_max, Y_max);
  }
  int ans = X_max - X_min +1;
  if(ans < 1) ans =0; 
  OUT(ans);
}	

Measured memory_bytes: 256
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

int a,b;
char s[500][500];

signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

        cin >> a >> b;
        a--;b--;
        cout << 100 << " " << 100 << endl;
        for(int i=1;i<=50;i++){
                for(int j=1;j<=100;j++){
                        s[i][j]='.';
                }
        }
        for(int i=51;i<=100;i++){
                for(int j=1;j<=100;j++){
                        s[i][j]='#';
                }
        }
        for(int i=1;i<=50;i+=2){
                for(int j=1;j<=100;j++){
                        if(b){
                                if( (i+j)%2==0 ){s[i][j]='#';b--;}
                        }
                }
        }
        for(int i=100;i>50;i-=2){
                for(int j=1;j<=100;j++){
                        if(a){
                                if( (i+j)%2==0 ){s[i][j]='.';a--;}
                        }
                }
        }
        for(int i=1;i<=100;i++){for(int j=1;j<=100;j++){cout << s[i][j];}cout << endl;}


return 0;
}
///....


Measured memory_bytes: 384
import itertools

def calc_dist(visit1, visit2):
    return ((xy[visit1][0] - xy[visit2][0])**2 + (xy[visit1][1] - xy[visit2][1])**2)** 0.5

n = int(input())
xy = [[int(_) for _ in input().split()] for _ in range(n)]

dist = 0
count = 0
visit_list = [i for i in range(n)]
for visit_order in itertools.permutations(visit_list):
    for i in range(n-1):
        dist += calc_dist(visit_order[i], visit_order[i+1])
    count += 1

print(dist/count)

Measured memory_bytes: 42348
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ans;

signed main(){
	
	string s,t,r;
	cin>>s;
	int flag=0;
	rep(i,s.size()){
		t+=s[i];
		if(t!=r){
			ans++;
			r=t;
			t="";
		}
	}
	cout<<ans<<endl;
	//DEB(flag)END
}

Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    int N = sc.nextInt();
    final int[] X = new int[N];
    BIT bit = new BIT(N * N);
    int[] order = new int[N];
    for (int i = 0; i < N; i++) {
      X[i] = sc.nextInt();
      order[i] = (X[i] << 10) | i;
      bit.add(X[i], i + 1);
    }
    for (int i = 0; i < N; i++) {
      if (bit.cumulativeSum(X[i]) > X[i]) {
        System.out.println("No");
        return;
      }
    }
    Arrays.sort(order);
    HashMap<Integer, Integer> xs = new HashMap<>();
    for (int i = 0; i < N; i++) {
      order[i] &= 0x3FF;
      xs.put(X[i], i + 1);
    }
    ArrayList<Integer> output = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < order[i]; j++) {
        output.add(order[i] + 1);
      }
    }
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N - 1 - order[i]; j++) {
        output.add(order[i] + 1);
      }
    }
    int[] count = new int[N];
    StringBuilder sb = new StringBuilder();
    for (int i = 0, pos = 0; i < N * N; i++) {
      if (xs.containsKey(i + 1)) {
        int v = xs.get(i + 1);
        if (count[v - 1] != v - 1) {
          System.out.println("No");
          return;
        }
        sb.append(v + " ");
      } else {
        count[output.get(pos) - 1]++;
        sb.append(output.get(pos++) + " ");
      }
    }
    System.out.println("Yes");
    sb.deleteCharAt(sb.length() - 1);
    System.out.println(sb);
  }

  static class BIT {
    long[] v;

    BIT(int size) {
      int len = 1;
      while (len < size) {
        len *= 2;
      }
      this.v = new long[len + 1];
    }

    long cumulativeSum(int index) {
      long ret = 0;
      while (index > 0) {
        ret += v[index];
        index &= index - 1;
      }
      return ret;
    }

    // inclusive, 1-indexed
    long sum(int l, int r) {
      long ret = cumulativeSum(r) - cumulativeSum(l - 1);
      return ret;
    }

    void add(int index, long val) {
      while (index < v.length) {
        v[index] += val;
        index += (index & -index);
      }
    }

    void set(int index, long val) {
      long old = sum(index, index);
      add(index, val - old);
    }
  }
}

Measured memory_bytes: 53728
#include<stdio.h>
#include<vector>
#include<algorithm>
std::vector<int>a,b;
int F(int bi)
{
	int ai=0,r=0;
	for(;ai<a.size()&&bi<b.size();++ai,++bi)
	{
		while(a[ai]-b[bi])
			if(++ai>=a.size())
				return r;
		++r;
	}
	return r;
}
int main()
{
	int A,B,i,x,r=0;
	scanf("%d%d",&A,&B);
	while(A--)scanf("%d",&x),a.push_back(x);
	while(B--)scanf("%d",&x),b.push_back(x);
	for(i=0;i<b.size();++i)r=std::max(r,F(i));
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 844
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline void read(rel &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  x=f?x:-x;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
 
int main(){
int a[3]={read(),read(),read()},k=read();
sort(a,a+3);
for (;k--;) a[2]*=2;
write(a[2]+a[0]+a[1]); 
}

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

int main(){
  long long n, i, k, s;
  cin >> n;
  for (i = 1; i <=sqrt(n); i++)if( n % i == 0) k = n / i;
  for ( s = 0; k > 0; s++)k /= 10;
  cout << s;
}

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

/*
c[i][j]:iをjに変えるのに必要な魔力
c[i][j]を、iをkに変えてからjに変えるのに必要な魔力の最小値として再計算
kは0~9全ての値で良い
10回繰り返す
*/

void solve(){
    int h,w;
    cin >> h >> w;
    int c[11][11];
    rep(i,10){
        rep(j,10){
            cin >> c[i][j];
        }
    }
    int a[h+10][w+10];
    vector<int> x;
    rep(i,h){
        rep(j,w){
            cin >> a[i][j];
            x.emplace_back(a[i][j]);
        }
    }
    rep(notused, 10){
    rep(i,10){
        rep(j,10){
            rep(k,10){
                c[i][j]=min(c[i][j], c[i][k]+c[k][j]);
            }
        }
    }
    }

    int sum=0;
    rep(i,x.size()){
        if(x[i]!=-1) sum += c[x[i]][1];
    }
    cout << sum << endl;

}

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



Measured memory_bytes: 768
N = int(input())
A = list(map(int, input().split()))
col = [0] * 9
for i in A:
  r = i//400
  if r > 8:
    r = 8
  col[r] += 1

ans = 0
for i in col[:8]:
  if i > 0:
    ans += 1

if ans == 0:
  print(1, col[-1])
else:
  print(ans, ans + col[-1])

Measured memory_bytes: 3064
#include <stdio.h>

int A[200000];

int main(void)
{
	int q, com, x, it = 0;
	scanf("%d", &q);
	while (q--) {
		scanf("%d", &com);
		if (com == 0) {
			scanf("%d", &x);
			A[it++] = x;
		}
		else if (com == 1) {
			scanf("%d", &x);
			printf("%d\n", A[x]);
		}
		else {
			--it;
		}
	}
	return 0;
}




Measured memory_bytes: 2464
from bisect import bisect_right as br
from collections import Counter
n = int(input())
cnt = Counter(list(map(int, input().split())))
keys = sorted(cnt.keys(), reverse=True)
bs = [2 ** i for i in range(32)]
ans = 0
for k in keys:
  if k in bs:
    while cnt[k] >= 2:
      cnt[k] -= 2
      ans += 1
    continue
  to = bs[br(bs, k)] - k
  while cnt[k] > 0:
    if to in cnt and cnt[to]:
      ans += 1
      cnt[to] -= 1
      cnt[k] -= 1
    else:
      break
print(ans)



Measured memory_bytes: 111956