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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {
	var inputArray = retreiveStringArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var S = inputArray[0];

			//後ろから削っていく 後ろからなら複数の条件を同時に満たすことはない
			while (S.Length>0) {

				var length = S.Length;

				var eraser = length>=6 ? S.Substring(length - 6, 6):"";
				var erase = length >= 5 ? S.Substring(length - 5, 5):"";
				var dream = length >= 5 ? S.Substring(length - 5, 5):"";
				var dreamer = length >= 7 ?S.Substring(length - 7, 7):"";


				if (eraser== "eraser") {
					S = S.Substring(0, length - 6);
				}
				else if(erase=="erase") {
					S = S.Substring(0, length - 5);
				}
				else if (dream == "dream") {
					S = S.Substring(0, length - 5);
				}
				else if (dreamer == "dreamer") {
					S = S.Substring(0, length - 7);
				}
				else {
					//どの文字でも処理できない場合はNO
					Console.WriteLine("NO");
					return;
				}
			}
			Console.WriteLine("YES");
			return;
		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 29652
#include <bits/stdc++.h>
#define ll long  long
#define ld long double
#define mod 1000000007
#define max_char 128
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define lbd lower_bound
#define ubd upper_bound
#define PI 3.141592653589793238
#define pf push_front
#define all(x) x.begin(),x.end()
#define FOR(i, a, b)    for(int i=a; i<b; i++)
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define mems(x, y) memset(x, y, sizeof(x))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int main()
{
    fastio
    
    ll n,k;
    cin>>n>>k;
    ll x=n%k;
    ll y=k-n%k;
    
    cout<<min(x,y)<<endl;
	
    return 0 ;
}

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

int N;
int x[100];
int y[100];
long long h[100];

int xx, yy;
long long hh;

int main() {

	cin >> N;
	for( int i = 0; i < N; i++ ) {
		cin >> x[i] >> y[i] >> h[i];
		if( h[i] > 0 ) {
			xx = x[i];
			yy = y[i];
			hh = h[i];
		}
	}

	int acx, acy;
	long long ahh;
	int aexit = 0;
	for( int cx = 0; cx <= 100 && aexit == 0; cx++ ) {
		for( int cy = 0; cy <= 100; cy++ ) {
			long long H = hh + abs(xx - cx) + abs(yy - cy);
			int flag = 0;
			for( int k = 0; k < N; k++ ) {
				if( h[k] != max( H - abs( x[k] - cx ) - abs( y[k] - cy ), 0LL ) ) {
					flag = 1;
				}
			}
			if( flag == 0 ) {
				acx = cx;
				acy = cy;
				ahh = H;
				aexit = 1;
				break;
			}
		}
	}


	cout << acx << " " << acy << " " << ahh << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long x = sc.nextLong();
        long k = sc.nextLong();
        long d = sc.nextLong();

        if(x < 0){
            x = -x;
        }
        long n = x / d;

        if(k > n){
            if((n - k) % 2 == 0){
                System.out.println(x - n * d);
            }
            else{
                System.out.println((n + 1) * d - x);
            }
        }
        else{
            System.out.println(x - k * d);
        }
    }
}

Measured memory_bytes: 35608
h,w = map(int,input().split())
s = []
for i in range(h):
	stemp = list(input())
	s.append(stemp)
check = True
for i in range(h):
	for k in range(w):
		if s[i][k] == '#':
			counter = 0
			if k+1 < w and s[i][k+1] == '#':
				counter += 1
			if 0 <= k-1 and s[i][k-1] == '#':
				counter += 1
			if i+1 < h and s[i+1][k] == '#':
				counter += 1
			if 0 <= i-1 and s[i-1][k] == '#':
				counter += 1
			if counter == 0:
				check = False
if check:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 30;


int main(void){

    string S; cin>>S;
    string ans = "";

    for (int i = 0; i < S.length(); ++i) {
        if(S[i]=='0'){
            ans+='0';
        }else if(S[i]=='1'){
            ans+='1';
        }else if(ans!=""){
            ans.erase(ans.length()-1);
        }
    }

    cout<<ans<<endl;

}


Measured memory_bytes: 256
def main():
    import sys
    from collections import deque
    from operator import itemgetter
    b=sys.stdin.buffer
    n,d,a=map(int,b.readline().split())
    m=map(int,b.read().split())
    q=deque()
    popleft,append=q.popleft,q.append
    s=b=0
    for x,h in sorted(zip(m,m),key=itemgetter(0)):
        while q and q[0][0]<x:b-=popleft()[1]
        if h>b:
            t=(b-h)//a
            s-=t
            t*=a
            b-=t
            append((x+d+d,-t))
    print(s)
main()

Measured memory_bytes: 56264
from math import gcd

def main():
    n = int(input())

    t = 0
    for i in range(1, n+1):
        for j in range(1, n+1):
            for k in range(1, n+1):
                ans = gcd(i, gcd(j, k))
                t += ans

    print(t)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9192
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    for (;;) {
        int n, s[100];

        scanf("%d", &n);
        if (n == 0)
            break;

        for (int i = 0; i < n; ++i)
            scanf("%d", &s[i]);

        sort(s, s + n);

        int sum = 0;
        for (int i = 1; i < n - 1; ++i)
            sum += s[i];

        printf("%d\n", sum / (n - 2));
    }

    return 0;
}

Measured memory_bytes: 1044
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

vll a(1000, 0);
void prime_factor(ll n) {
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) n /= i, a[i]++;
  }
  if(n != 1) a[n]++;
}
int main(int argc, char const *argv[]) {
  ll ans = 1, n, P = 1000000007;std::cin >> n;
  for(int i=1;i<=n;i++) prime_factor(i);

  re(i, 1000) ans = (ans * (a[i]+1))%P;
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <string>
#include <utility>
#include <iomanip>
#include <queue>
#include <algorithm>
#include<set>
using namespace std;

int main()
{
    long long int n,k;
    cin >> n >>k;
    vector<long long int> kazu(k+1,0);
    vector<long long int> pow2(k+1,0);
    pow2.at(0)=1;
    long long int maxn=n;
    for(int i=0;i<=k;i++){
        if(k%pow2.at(i)==0){
            kazu.at(i)=k/pow2.at(i);
        }else{
            kazu.at(i)=k/pow2.at(i)+1;
        }
        // cout << i << "," << kazu.at(i) << endl;
        if(kazu.at(i)==1){
            maxn=i;
            break;
        }
        pow2.at(i+1)=2*pow2.at(i);
        
    }
    // vector<long long int> bunshi(maxn+1);
    long long int bunshi=max((long long int)0,n-kazu.at(0)+1)*pow2.at(maxn);
    // cout << bunshi << endl;
    // bunshi.at(0)=;
    for(int i=1;i<=maxn;i++){
        bunshi+= max((long long int)0,min(n-kazu.at(i)+1,kazu.at(i-1)-kazu.at(i)))*pow2.at(maxn-i);
    }
    double ans = 1.0*bunshi/n/pow2.at(maxn);
    // cout << maxn << "," << ans << endl;
    // for(int i=1;i<maxn;i++){
    //     ans += 1.0*max(0,min(n-kazu.at(i)+1,kazu.at(i-1)-kazu.at(i)))/pow2.at(i)/n;
    // }
    cout<< fixed<<  setprecision(15)  << ans << endl;
    return 0;
}


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

using  namespace std;

#define FOR(x,z,y) for(int x = z; x < y; x++)
typedef long long ll;
typedef pair<int,int> iPair;



int DecToBase(int base, int n){
    int num = 0, q = n, rem = 0, i = 0;

    while(q != 0){
        rem = q%base;
        q /= base;
        num = (rem * 10^i) + num;
        i++;
    }
    cout << i;
    return num;
}


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

    int n,k;
    cin >> n >> k;
    DecToBase(k,n);
}

Measured memory_bytes: 256
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    s = input()
    if s[-1] == 's':
        s += 'es'
    else:
        s += 's'
    print(s)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9060
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
int a[1<<18];
int main(){
    int m,i,n,s1,s2,j,ans=0;
    scanf("%d",&n);
    m=1<<n;
    for(i=0;i<m;i++)scanf("%d",&a[i]);
    for(i=1;i<m;i++){
        s1=a[0];s2=0;
        for(j=i;j;j=(j-1)&i){
            if(a[j]>s1)s2=s1,s1=a[j];
            else if(a[j]>s2)s2=a[j];
        }
        ans=max(ans,s1+s2);
        printf("%d\n",ans);
    }
    return 0;
}


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

using namespace std;

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

int main(){
    string str;cin>>str;
    bool res=false;
    REP(i,str.length()){
        if(str[i]=='9'){
            res=true;
            cout<<"Yes"<<endl;
            break;
        }
    }
    if(res==false){
        cout<<"No"<<endl;
    }
    return 0;
}

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

const int MAX_H = 1000;
const int MAX_W = 1000;
const int MAX_N = 10;

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

typedef struct {
	int x, y;
} node;
node makeNode(int x, int y) {
	node n = {x, y};
	return n;
}

int w, h, n;
// 入力されたフィールド (W * H)
char field[MAX_H][MAX_W + 1];
// 各地点までのステップ数，未到達なら -1
int step[MAX_H][MAX_W + 1];

int bfs(int startX, int startY, int goalX, int goalY) {
	queue<node> que;
	que.push(makeNode(startX, startY));
	step[startY][startX] = 0;
	while (!que.empty()) {
		node current = que.front();
		que.pop();
		if (current.x == goalX && current.y == goalY) {
			return step[current.y][current.x];
		}
		for (int i = 0; i < 4; i++) {
			int nextX = current.x + dx[i];
			int nextY = current.y + dy[i];
			if (0 <= nextX && nextX < w
					&& 0 <= nextY && nextY < h
					&& field[nextY][nextX] != 'X'
					&& step[nextY][nextX] == -1) {
				que.push(makeNode(nextX, nextY));
				step[nextY][nextX] = step[current.y][current.x] + 1;
			}
		}
	}
	return -1;
}

int main () {
	int startX[10], startY[10];
	cin >> h >> w >> n;
	// 入力しながら各地点の座標を探す
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> field[i][j];
			if (field[i][j] == 'S') {
				startX[0] = j;
				startY[0] = i;
			}
			else if (isdigit(field[i][j])) {
				startX[field[i][j] - '0'] = j;
				startY[field[i][j] - '0'] = i;
			}
		}
	}
	
	// 工場を順番に回って合計ステップを計算する
	int ans = 0;
	for (int i = 0; i < n; i++) {
		memset(step, -1, sizeof(step));
		ans += bfs(startX[i], startY[i], startX[i + 1], startY[i + 1]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6108
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner stdIn = new Scanner(System.in);
		
		while(true)
		{
			int x = stdIn.nextInt();
			int y = stdIn.nextInt();
			
			if(x ==  0 && y == 0)
			{
				break;
			}
			
			if(x<y)
			{
				System.out.println(x+" "+y);
			}
			else
			{
				System.out.println(y+" "+x);
			}
			
			
		}
		
	}

}

Measured memory_bytes: 27200
//According to all known laws of aviation, there is no way that a bee should be able to fly.
 //Its wings are too small to get its fat little body off the ground. The bee, of course, flies anyway.
 //Because bees don't care what humans think is impossible.
 #include <bits/stdc++.h>
 #define FAST_IO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 #define mod 1000000007
 #define endl "\n"
 using namespace std ;
 using bigint = long long int ;
 using vi = vector<int> ;
 bigint arr[300011] ;
 int main(){
     bigint A ; string B ; cin >> A >> B ;
     bigint C = ( B[0] - '0' ) * 100 + ( B[2] - '0' ) * 10 + ( B[3] - '0' ) ;
     cout << ( A * C ) / 100 << endl ;
     return 0 ;
 }


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

using namespace std;
//はじめ：L　最後：L+N-1
int main() {
  int N, L;
  cin >> N >> L;

  int sum = (2 * L + N - 1) * N * 0.5;
  
  if( L > 0 ) sum -= L;
  if( L + N - 1 < 0 ) sum -= (L + N - 1);
  
  cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if((a < b) & (b < c)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 26076
#include<bits/stdc++.h>
using namespace std;
#define hackcyborg shresth_walia
#define ll  long long
#define int long long
#define ld  long double
#define pb push_back
#define mod 1000000007
#define M_PI 3.141592653589
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
long long binpow(long long a, long long b, long long m=mod) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
main()
{
    string s;
    ll n;
    cin>>n;
    while(n>0)
    {
        s+=char('a'+((n%26)+25)%26);
        if(n==26)break;
        n=(n-1)/26;
    }
    reverse(s.begin(),s.end());
    cout<<s;

}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
#define all(x) (x).begin(), (x).end()
#define li long long
#define itn int
 
using namespace std;
 
inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

int main(){

	int k = nxt(), n = nxt();
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		a[i] = nxt();
	}

	sort(all(a));
	reverse(all(a));

	if (2 * a[0] <= k + 1) {
		puts("0");
	} else {
		cout << 2 * a[0] - k - 1 << "\n";
	}

	return 0;
}

Measured memory_bytes: 384
using System;

namespace BeginnerContest085
{
    class Program
    {
        static void Main(string[] args)
        {
            bool find_flag = false;
        
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int Y = int.Parse(input[1]);

            for(int i=0; i<=N; i++)
            {
                for(int j=0; j<=N; j++)
                {
                    if((i*10000+j*5000+(N-i-j)*1000 == Y) && (N-i-j >= 0) )
                    {
                        Console.WriteLine("{0} {1} {2}",i, j, N-i-j);
                        find_flag = true;
                    }
                    if(find_flag == true) break;
                }
                if(find_flag == true) break;
            }
            if(find_flag == false) Console.WriteLine("-1 -1 -1");
        }
    }
}


Measured memory_bytes: 13140
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>

int n;
int time_count = 0;
std::vector<std::pair<int, int>> times;
std::vector<std::vector<int>> vec;

void dfs(int id) {
    if (times[id-1].first == -1) {
        times[id-1].first = ++time_count; 
        for (int i = 1; i <= n; i++) {
            if (vec[id][i] == 1 && times[i-1].first == -1) {
                dfs(i);
            }
        }
        times[id-1].second = ++time_count;
    }
}

int main() {
    std::cin >> n;
    vec.assign(n+1, std::vector<int>(n+1, 0));
    for (int i = 0; i < n; i++) {
        times.push_back(std::make_pair(-1, -1));
    }
    for (int i = 0; i < n; i++) {
        int id, num, d;
        std::cin >> id >> num;
        for (int p = 0; p < num; p++) {
            std::cin >> d;
            vec[id][d] = 1;
        }
    }
    for (int i = 1; i <= n; i++) {
        dfs(i);
    }
    
    for (int i = 0; i < n; i++) {
        std::cout << i+1 << " " << times[i].first << " " << times[i].second << std::endl;
    }
}




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

#define     F       first
#define     S       second
typedef pair<int, int>  pi;
typedef long long       ll;

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

    int n;
    cin >> n;
    for (int i=0; i<n; ++i) {
        int a;
        cin >> a;

        if (a%2==0 && (a%5 && a%3)) {
            cout << "DENIED";
            return 0;
        }
    }

    cout << "APPROVED";

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000000+7
using namespace std;
typedef long long ll;

int main(){
  int a, b; cin >> a >> b;
  cout << (b%a==0?a+b:b-a) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define ind(a) scanf("%d", &a)
#define inlld(a) scanf("%lld", &a)
#define ind2(a, b) scanf("%d%d", &a, &b)
#define inlld2(a, b) scanf("%lld%lld", &a, &b)
#define ind3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define inlld3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)

using namespace std;

const int N=55;
const int MOD=1e9+7;

typedef long long ll;
typedef long double ld;

ll n, A, arr[N], dp[N][N*N][N];

ll solve(ll idx, ll sum, ll taken)
{
    if(idx==n+1)
    {
        if(!taken)
            return 0;
        if(sum%taken==0 && sum/taken==A)
            return 1;
        return 0;
    }
    if(dp[idx][sum][taken]!=-1)
        return dp[idx][sum][taken];
    return dp[idx][sum][taken]=solve(idx+1, sum+arr[idx], taken+1)+solve(idx+1, sum, taken);
}

int main() 
{
    inlld2(n, A);
    for(ll a=1; a<=n; a++)
        inlld(arr[a]);
    memset(dp, -1, sizeof(dp));
    printf("%lld\n", solve(1, 0, 0));
    return 0;
}



Measured memory_bytes: 71680
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n, m;
    cin >> n >> m;
    string s; cin >> s;
    int pos = s.size()-1;
    vector<int> ans;

    bool goal = true;
    while(pos != 0 && goal) {

        for(int i = m; i > -1; i--) {
            if (i == 0) {
                goal = false;
                break;
            }
            if (pos-i < 0) continue;
            if (pos-i == 0) {
                ans.push_back(i);
                pos = 0;
                break;
            }
            if (s[pos-i] == '0') {
                ans.push_back(i);
                pos -= i;
                break;
            }
        }
    }
    if (goal) {
        for (auto it = ans.rbegin(); it+1 < ans.rend(); it++) {
            cout << *it << " ";
        }
        cout << ans.front() << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 1096
import java.util.*;

class Main{
  static Scanner sc = new Scanner(System.in);
  public static void main(String[] args){
    int  a = sc.nextInt();
    int b=sc.nextInt();
    int N=0;
    while(1+N*(a-1)<b){
      N++;
    }
    System.out.println(N);
  }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=1e5+10;
int c[maxn],a[maxn],to[maxn],ans[maxn],tmp[maxn],p[maxn],pos[maxn],K,now;
int n,m;
void solve(int y)
{
	for(;y;y>>=1)
	{
		if (y&1)
		{
			for (int i=1;i<=n;++i)p[i]=ans[to[i]];
			for (int i=1;i<=n;++i)ans[i]=p[i];
		}
		for (int i=1;i<=n;++i)p[i]=to[to[i]];
		for (int i=1;i<=n;++i)to[i]=p[i];
	}
	for(int i=1;i<=n;++i)p[i]=c[ans[i]];
	for(int i=1;i<=n;++i)c[i]=p[i];
}

signed main()
{
	cin>>n;
	for (int i=1;i<=n;++i)cin>>pos[i],c[i]=pos[i]-pos[i-1],to[i]=ans[i]=i;
	scanf("%d%lld",&m,&K);
	for(int i=1;i<=m;++i)cin>>a[i];
	for(int i=1;i<=m;++i)
		swap(to[a[i]],to[a[i]+1]);
	solve(K);
	for (int i=1;i<=n;++i)
		c[i]+=c[i-1],cout<<c[i]<<".0 "<<endl;;
}
/*
这个1e18 明示矩阵加速/倍增 
fi表示第i只兔子的期望位置。
扫操作，每次操作还要扫一下上一只和下一只，然后才能转移
这 
pos[i]=pos[i-1]+pos[i+1]-pos[i]

草啊谁tm想得到差分啊？？？？
 */
 

Measured memory_bytes: 8196
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

bool is_prime(int k, int i) {
    if(k == 2) return true;
    if(k <= i) return true;
    else {
        if(k % i == 0) return false;
        else return is_prime(k, i + 1);
    }
}


int main() {
    int n, k;
    cin >> n >> k;
    deque<ll> V(n);
    REP(i, n) {
        cin >> V[i];
    }
    

    ll max_value = 0;
    ll value = 0;
    
    FOR(a, 0, min(n, k) + 1) {
        REP(b, min(n, k) - a + 1) {
            deque<ll> v = V;
            vector<ll> v_plus;
            vector<ll> v_minus;
            value = 0;
            int num_push = k - a - b;
            REP(i, a) {
                ll jewel = v.front();
                v.pop_front();
                if(jewel >= 0) {
                    v_plus.push_back(jewel);
                }
                else {
                    v_minus.push_back(jewel);
                }
            }

            REP(i ,b) {
                ll jewel = v.back();
                v.pop_back(); 
                if(jewel >= 0) {
                    v_plus.push_back(jewel);
                }
                else {
                    v_minus.push_back(jewel);
                }
            }
            
            sort(v_minus.begin(), v_minus.end(), greater<ll>());
            
            REP(i, num_push) {
                if(v_minus.size() > 0) {
                    v_minus.pop_back();
                }
            }
            REP(i, v_plus.size()) {
                value += v_plus[i];
            }
            
            REP(i, v_minus.size()) {
                value += v_minus[i];
            }
            
            if(max_value < value) {
                
                max_value = value;
            }
        }
    }
    
    cout << max_value << endl;
}


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

long long *layer,*pate;
long long eatpate(int n,long long x){
	if(x<=n)return 0;
	if(n==0)return 1;
	if(x<=layer[n-1]+1)return eatpate(n-1,x-1);
	return pate[n-1]+1+eatpate(n-1,x-2-layer[n-1]);
}

int main(void){
	int n;
	long long x;
	cin>>n>>x;
	layer=new long long[n+1];
	pate=new long long[n+1];
	layer[0]=1;
	pate[0]=1;
	for(int i=1;i<=n;i++){
		layer[i]=layer[i-1]*2+3;
		pate[i]=pate[i-1]*2+1;
	}
	cout<<eatpate(n,x)<<endl;
	
	delete[] layer;
	delete[] pate;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	int n; cin >> n;
	std::vector<int> v;
	int sum;
	for (int i = 0; i < n; ++i)
	{
		int a; cin >> a;
		sum += a;
		v.push_back(a);
	}
	sort(v.rbegin(), v.rend());
	if (2*v[0] < sum) cout << "Yes" << endl;
	else cout << "No" << endl;

}


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

char buffer[200001];

int main()
{
  while (scanf("%s", buffer) == 1) {
    int t = 0, s = 0;
    for (int i = 0; buffer[i]; ++ i) {
      if (buffer[i] == 'S') {
        s ++;
      } else if (s) {
        s --;
      } else {
        t ++;
      }
    }
    printf("%d\n", s + t);
  }
}


Measured memory_bytes: 384
lines = $stdin.read
array = lines.split("\n")

# https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q1155016236
# nが偶数のときはr=n/2
# nが奇数のときはr=(n-1)/2,(n+1)/2
# で最大値をとることになります．

N = array[0].to_i
A = array[1].split(" ").map(&:to_i).sort.reverse

n = A.max
A.delete(n)

max_r_idx = A.map.with_index{|e,idx| [(n/2-e).abs,idx]}.min_by{|arr| arr.first}.last
max_r     = A[max_r_idx]

puts "#{n} #{max_r}"

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

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  for (ll i = 0; i < n; i++) cin >> a[i];

  using P = pair<ll, ll>;
  vector<P> vp;
  for (ll i = 0; i < m; i++) {
    ll b, c;
    cin >> b >> c;
    vp.emplace_back(c, b);
  }

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

  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    if (vp.empty() || vp.back().first <= a[i]) {
      ans += a[i];
      continue;
    }
    ans += vp.back().first;
    vp.back().second--;
    if (vp.back().second == 0) vp.pop_back();
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6124
N = int(input())

ans = []
for n in range(1,N+1):
    count = 0
    if n % 2 == 1:
        for i in range(1,n+1):
            if n%i == 0 :
                count += 1
        if count == 8:
            ans.append(n)
print(len(ans))

Measured memory_bytes: 38608
n = int(input())
s_list = dict(AC=0,WA=0,TLE=0,RE=0)

for _ in range(n):
    s = input()
    s_list[s] += 1

print(f"AC x {s_list['AC']}")
print(f"WA x {s_list['WA']}")
print(f"TLE x {s_list['TLE']}")
print(f"RE x {s_list['RE']}")


Measured memory_bytes: 8940
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
#define ull unsigned long long
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ull x;
    cin>>x;
    ull cur=(ull)100;
    for(int i=1;;i++)
    {
        cur=cur+cur/(ull)100;
        if(cur>=x)
        {
            cout<<i<<'\n';
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define pll pair<ll,ll>
#define pb push_back
#define F first
#define S second
#define I insert
#define vll vector<ll>
#define vbl vector<bool>
#define vvll vector<vll>
#define vld vector<ld>
#define vb vector<bool>
#define vc vector<char>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()

template<class T> ostream& operator<<(ostream &os, vector<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T> ostream& operator<<(ostream &os, set<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, map<T , R> V){
	os << "[ ";
	for(auto v  : V) os << "(" << v.first << ":" << v.second << ")";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, pair<T , R> V){
	return os << "(" << V.first << "," << V.second << ")";
}

#define cerr cout
#define TRACE
#ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " : " << arg1<<" | ";
        __f(comma+1, args...);
    }
    clock_t clk=clock();
    #define checktime() cout<<"\nTime Elapsed : "<<float(clock()-clk)/CLOCKS_PER_SEC<<endl
#else
    #define trace(...);
    #define checktime();
#endif

const ll Mod = 1e9 + 7;
// const ll Mod = 998244353;
const ll MAXN = 1e6;

void solve(){
    ll n,a,b;cin>>n>>a>>b;
    ll ans=1ll<<60;
    if((a-b)%2){
        ans=min(n-b,a-1)+1+(b-a-1)/2;

    }else ans=(b-a)/2;

    cout<<ans<<"\n";
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<fixed<<setprecision(25);

    ll t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
main()
{
  int q;scanf("%d",&q);
  for(;q--;)
  {
    long a,b;scanf("%ld%ld",&a,&b);
    if(a>b)a^=b^=a^=b;
    if(a==b||a+1==b)
    {
      printf("%ld\n",2*a-2);
    }
    else
    {
      long f=0,l=1e9;
      while(l-f>1)
      {
        long m=l+f>>1;
        if(m*m<a*b)f=m;
        else l=m;
      }
      if(f*(f+1)>=a*b)
      {
        printf("%ld\n",2*f-2);
      }
      else
      {
        printf("%ld\n",2*f-1);
      }
    }
  }
}

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

class Program
{
    static void Main(string[] args)
    {
        var num = int.Parse(Console.ReadLine());
        var sampleText =Console.ReadLine();
        var b = new List<string>();
        if(sampleText.Length > num)
        {
            for(var i = 0; i < num;i++)
            {
                b.Add(sampleText[i].ToString());
            }
            b.Add("...");
        }
        else{
            b.Add(sampleText);
        }
        var sb = new StringBuilder();
        foreach(var a in b)
        {
            sb.Append(a);
        }
        Console.WriteLine(sb.ToString());

    }
  
}

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

int main(){
  int p,q,r;cin >> p >>q >> r;
  int dest=min(min(p+q, q+r),r+p);



  cout << dest << endl;
  return 0;
}


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


Measured memory_bytes: 2036
n = gets.to_i

count = 0
flag = false

n.times do
  a1,a2 = gets.chomp.split(" ").map(&:to_i)
  if a1 == a2
    count += 1
  else
    count = 0
  end
  if count >= 3
    flag = true
    break
  end
end

if flag
  puts("Yes")
else
  puts("No")
end

Measured memory_bytes: 14396
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

typedef pair<int,int> P;
const int INF =1e+8;

// 2 点間のマンハッタン距離, d = |x1-x2| + |y1-y2|
int dist( P p , P p_ ){
	return abs(p.first-p_.first)+abs(p.second-p_.second);
}

int to_i(string s){
	int n=0;
	for(int i=0 ; i < s.size() ; i++ ){
		n = n*10 + s[i]-'0';
	}
	return n;
}

int main(){
	int w, h;
	while( cin >> w >> h , w || h ){
		string s;
		map<int,vector<P> > f;
		vector< vector<int> > dp;
		int gx, gy, t=0;
		
		for(int y=0 ; y < h ; y++ ){
			for(int x=0 ; x < w ; x++ ){
				cin >> s;
				if( s == "S" ){
					vector<int> v;
					v.push_back( 0 );
					dp.push_back( v );
					f[0].push_back( P(x,y) );
				}else if( s == "G" ){
					gx = x;
					gy = y;
				}else if( s != "." ){
					int n = to_i(s);
					t = max( t , n );
					f[n].push_back( P(x,y) );
				}
			}
		}
		f[t+1].push_back( P(gx,gy) );
		for(int i=1 ; i <= t+1 ; i++ ){
			vector<int> v;
			for(int j=0 ; j < f[i].size() ; j++ ){
				v.push_back( INF );
			}
			dp.push_back( v );
		}
		for(int i=0 ; i <= t ; i++ ){
			for(int j=0 ; j < f[i].size() ; j++ ){
				for(int k=0 ; k < f[i+1].size() ; k++ ){
					int d = dist( f[i+1][k] , f[i][j] );
					dp[i+1][k] = min( dp[i+1][k] , dp[i][j] + d );
				}
			}
		}
		cout << dp[t+1][0] << endl;
	}
}

Measured memory_bytes: 1192
#include <stdio.h>
int main()
{
    char s[3][3];
    int i,j;
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
            scanf("%c",&s[i][j]);
        getchar();
    }
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            if(i==j)
                printf("%c",s[i][j]);
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=200005;

int n,m,a[N*3];
char s[N];

void pri(int tag,int now)
{
	for (int i=0;i<n;i++) putchar('A'+(a[now+i]^tag));
	puts("");
}

int main()
{
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	for (int i=1;i<=n;i++) a[i]=s[i]-'A';
	int tag=0,now=1;
	for (int i=1;m&&i<=n*2;i++,m--)
	{
		if ((a[now]^tag)==0) a[now]^=1;
		else tag^=1,a[now+n]=tag,now++;
	}
	if (n&1)
	{ 
		if (m&&(a[now]^tag)==1) tag^=1,a[now+n]=tag,now++,m--;
		m%=2;
		if (m)
		{
			if (a[now]^tag==0) a[now]^=1;
			else tag^=1,a[now+n]=tag,now++;
		}
	}
	for (int i=0;i<n;i++) putchar('A'+(a[now+i]^tag));
	return 0;
}

Measured memory_bytes: 2560
n = int(input())
a = list(map(int, input().split()))

result = 0
for i in range(1, n):
    hoge = a[i]
    a[i] = a[i]+(a[i-1]-a[i]) if a[i-1] > a[i] else a[i]
    result += a[i] - hoge
    
print(result)

Measured memory_bytes: 32148
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

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

int cnt[100005];

struct UnionFind {
	vector<int> rank;
	vector<P> par;
	int N;

	UnionFind(int n) {
		N = n;
		par.resize(n);
		rank.resize(n);

		rep(i,n) {
			par[i] = P(i, 0);
			rank[i] = 0;
		}
	}

   	P find(int x) {
		if(par[x].first == x) return par[x] = P(x, 0);
		else {
			P p = find(par[x].first);
			p.second += par[x].second;
			return par[x] = p;
		}
	}

	void unite(int x, int y, int c) {
		P px = find(x);
		P py = find(y);

		int X = px.first;
		int Y = py.first;

		if(same(X, Y)) return;

		if(rank[X] < rank[Y]) {
			par[X].first = Y;
			par[X].second = py.second - px.second - c + (cnt[y] - cnt[x]);
		}
		else {
			par[Y].first = X;
			par[Y].second = px.second - py.second + c + (cnt[x] - cnt[y]);
			if(rank[X] == rank[Y]) rank[X]++;
		}
	}

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

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

	memset(cnt, 0, sizeof(cnt));
	UnionFind uf(n+5);

	rep(i,q) {
		string s;
		cin >> s;

		if(s == "COMPARE") {
			int a, b;
			cin >> a >> b;

			a--;
			b--;

			if(uf.same(a, b)) {
				cout << uf.find(b).second - uf.find(a).second + cnt[b] - cnt[a] << endl;
			} else {
				cout << "WARNING" << endl;
			}
		} else {
			int a, b, c;
			cin >> a >> b >> c;

			a--;
			b--;

			cnt[a] += c;
			cnt[b] += c;
			uf.unite(a, b, c);
		}
	}

	return 0;
}

Measured memory_bytes: 2588
#include <iostream>
using namespace std;
int main(){
    int x,y,z;
    cin >> x >> y >> z;
    if(x>=y) swap(x,y);
    if(y>=z) swap(y,z);
    if(x>=y) swap(x,y);
    if(x==5 && y==5 && z==7) cout << "YES" <<endl;
    else cout << "NO" <<endl;
    return 0;
}

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

int main() {
  int n, W;
  cin >> n >> W;
  vector<int> w(n + 1), v(n + 1);
  for (int i = 1; i <= n; i++) cin >> w[i] >> v[i];
  vector<vector<long>> dp(n + 1, vector<long>(110000, 1000000000000L));
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    dp[i + 1] = dp[i];
    for (int j = 0; j + v[i + 1] <= 100000; j++) {
      dp[i + 1][j + v[i + 1]] = min(dp[i][j + v[i + 1]], dp[i][j] + w[i + 1]);
    }
  }
  int ret = 0;
  for (int i = 0; i <= 100000; i++) {
    if (dp[n][i] <= W) ret = i;
  }
  cout << ret;
  return 0;
}

Measured memory_bytes: 87936
import math

def parent(i):
    return math.floor(i / 2)

def left(i):
    return 2 * i

def right(i):
    return 2 * i + 1

def get_largest(A, n, i):
    l = left(i)
    r = right(i)
    largest = None
    if l <= n and A[i] < A[l]:
        largest = l
    else:
        largest = i
    if r <= n and A[largest] < A[r]:
        largest = r
    return largest


def max_heapify(A, n, i):
    largest = get_largest(A, n, i)
    x = i
    while largest is not x:
        tmp = A[x]
        A[x] = A[largest]
        A[largest] = tmp
        x = largest
        largest = get_largest(A, n, x)

def build_max_heap(A, n):
    for i in range(math.floor(n/2), 0, -1):
        max_heapify(A, n, i)

n = int(input())
heap = [None] + list(map(int, input().split()))

build_max_heap(heap, n)

print(' ', end='')
print(*heap[1:])

Measured memory_bytes: 62320
/*input
3 7
1 6 3
*/

#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <iomanip>
#include <utility>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define pb                push_back
#define pp                pop_back
#define nl                cout << "\n"
#define MIN(con)          (*min_element(ALL(con)))
#define MAX(con)          (*max_element(ALL(con)))
#define NX(cont)          next_permutation(ALL(cont))
#define PX(cont)          prev_permutation(ALL(cont))
#define prec(n)           cout << fixed << setprecision(n)
#define PI                3.14159265358979323846264338327951
#define all(c)            c.begin(),c.end()
#define rep(i,a,b)        for(ll i=a;i<b;i++)
#define sp                cout << " "
#define mod               1000000007    //9
#define ifalse            ios_base::sync_with_stdio(false),cin.tie(NULL)

using ll = long long;
using ld = long double;
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > T LCM(T a, T b)            { return (a * b) / GCD(a, b); }
template < typename T > string toString(T a)       { return to_string(a); }  // Convert int to string
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}  // Convert string to int

ll add(ll x, ll y) { x += y; if(x >= mod) x -= mod; return x; }
ll sub(ll x, ll y) { x -= y; if(x < 0) x += mod; return x; }
ll mul(ll x, ll y) { return ((x % mod) * (y % mod)) % mod; }

ll powr(ll a, ll b) {
    ll x = 1LL;
    while(b) {
        if(b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}

ll inv(ll a) { return powr(a, mod - 2); }
const int inv2 = (mod + 1) >> 1;
const ll INF =  1e18;
const int inf = 1e9;

bool check(ll n)
{
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;
    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}

/*********************************************START**************************************************************/
ll dp[60][2];
ll cnt[60][2];
ll k;

ll func(ll n, bool flag)
{
	if(n == -1) return 0;
	if(dp[n][flag] > -1) {
		return dp[n][flag];
	}	
	ll ret = 0;
	if(flag) {
		ret = max(ret, func(n - 1, 1) + (1LL << n) * max(cnt[n][1], cnt[n][0]));
	}
	else {
		int b = (k >> n) & 1;
		if(b) {
			// 0
			ret = max(ret, func(n - 1, 1) + ((1LL << n) * cnt[n][1]));
			// 1
			ret = max(ret, func(n - 1, 0) + ((1LL << n) * cnt[n][0]));
		}
		else {
			// 0
			ret = max(ret, func(n - 1, 0) + ((1LL << n) * cnt[n][1]));
		}
	}
	return dp[n][flag] = ret;
}
int main()
{
    ifalse;
    int n;
    cin >> n >> k;
    rep(i, 0, n) {
    	ll a;
    	cin >> a;
    	rep(j, 0, 50) {
    		int b = ((a >> j) & 1LL);
    		cnt[j][b] ++;
    	}
    }
    memset(dp, -1, sizeof(dp));
    cout << func(50, 0);
    return 0;
}

Measured memory_bytes: 256
N, K = input().split()
N = int(N)
K = int(K)
H = input().split()
H = [int(h) for h in H]
H.sort(reverse = True)
# print(H)
I = K if K <= N else N
for i in range(0, I):
    H[i] = 0
# print(H)
print(sum(H))

Measured memory_bytes: 26356
n = gets.to_i
name_count = [0,0,0,0,0]
head = ["M","A","R","C","H"]
n.times do
  s = gets.chomp
  5.times do |i|
    if s[0] == head[i]
      name_count[i] += 1
    end
  end
end

ans = 0
32.times do |i|
  b,r,t = 1,1,0
  flag = true
  5.times do |j|
    c = b << j
    if i & c != 0
      t += 1
      r *= name_count[4-j]
    end
  end
  #p [i,r,t,flag]
  ans += r if t == 3 && flag
end
puts ans
#p name_count


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

public class Main {
    static final int MOD = 1000000007;
	public static void main (String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		char[] arr = br.readLine().toCharArray();
		int[] counts = new int[26];
		for (char c : arr) {
		    counts[c - 'a']++;
		}
		long ans = 1;
		for (int x : counts) {
		    ans *= x + 1;
		    ans %= MOD;
		}
		ans--;
		ans += MOD;
		ans %= MOD;
		System.out.println(ans);
    }
}



Measured memory_bytes: 23124
#include <iostream>
#include <vector>
using namespace std;
#define nmax 200000
#define time pair<int,int>
#define channel pair<time,int>

int N, C, tmax;

int record[30][nmax];

void solve(){
	int ans=0;
	for(int i=0;i<tmax;i++){
		int count = 0;
		for(int c=0;c<C;c++){
			count += record[c][i];
		}
		//cout << count << endl;
		ans = max(ans,count);
	}

	cout << ans << endl;
}


int main(){
	cin >> N >> C;
	int s,t,c;
	for(int i=0;i<N;i++){
		cin >> s >> t >> c;
		c--;
		tmax = max(tmax, 2*t);
		for(int i=2*s-1;i<2*t;i++){
			record[c][i] = 1;
		}
	}

	solve();

	return 0;
}

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

int main(){

    stack<int> S1;//総面積用
    stack<pair<int,int>> S2;//各面積用
    char ch;
    int sum=0;
    int b;

    for(int i=0;cin>>ch;i++){
        if(ch=='\\'){
            S1.push(i);
        }else if (ch=='/' && S1.size()>0) {
            int j=S1.top(); S1.pop();
            int a=i-j; 
            sum+=a;
            while(S2.size()>0 && S2.top().first>j){
                a+=S2.top().second;S2.pop();
            }
            S2.push(make_pair(j,a));

        }
    }

    vector<int> ans;
    while(S2.size()>0){ans.push_back(S2.top().second);S2.pop();}
    reverse(ans.begin(),ans.end());
    cout<<sum<<endl;
    cout<<ans.size();
    rep(i,ans.size()){
        cout<<" ";
        cout<<ans[i];
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 3240
import sys
input = sys.stdin.buffer.readline

class UnionFind:
    __slots__ = ["data"]
    
    def __init__(self, n=0):
        self.data = [-1]*(n+1)
    
    def root(self, x):
        if self.data[x] < 0:
            return x
        self.data[x] = self.root(self.data[x])
        return self.data[x]
    
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            if self.data[x] < self.data[y]:
                self.data[x] += self.data[y]
                self.data[y] = x
            else:
                self.data[y] += self.data[x]
                self.data[x] = y
    
    def same(self, x, y):
        return self.root(x) == self.root(y)
    
    def size(self, x):
        return -self.data[self.root(x)]
                


def main():
    n, m, k = map(int, input().split())
    friends = [[] for _ in range(n+1)]
    blocks = [[] for _ in range(n+1)]
    uf = UnionFind(n)
    for _ in range(m):
        a, b = map(int, input().split())
        friends[a].append(b)
        friends[b].append(a)
        uf.unite(a, b)
    for _ in range(k):
        c, d = map(int, input().split())
        blocks[c].append(d)
        blocks[d].append(c)
    for i in range(1, n+1):
        nf = len(friends[i])
        nb = sum([uf.same(i, b) for b in blocks[i]])
        ans = uf.size(i) - 1 - nf - nb
        print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 41320
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef unsigned long long ll;

using namespace std;

int main (void) {
    ll N, ans;
    ans = 0;
    scanf("%lld", &N);
    if ( N % 2 == 1 ){
        ans = 0;
    }
    else{
        N /= 2;
        while( N > 0 ){
            N /= 5;
            ans += N;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
// darksta5's template v2.0

#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define popb pop_back
#define del erase
#define sz size
#define ins insert
#define FOR(a,b,c) for(int a = b; a < c; a++)
#define FORS(a,b,c) for(int a = b; a <= c; a++)
#define FORN(a,b) for(int a = 0; a < b; a++)
#define FORD(a,b,c) for (int a = b; a >= c; a--)
#define RES(a,b) memset(a,b,sizeof(a))
#define LL long long
#define PI acos(-1)
#define eps 1e-9
#define MOD 1000000007
using namespace std;

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

  string s;
  cin >> s;

  int cntG = 0, cntP = 0;
  FORN(i, s.sz()) {
    if (s[i] == 'g') {
      cntG++;
    } else {
      cntP++;
    }
  }

  cout << (cntG - cntP) / 2 << endl;
}

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

using namespace std;
using ll = long long;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int N; cin>>N;
    vector<int> L(N);
    for(int i = 0; i < N; i++)
    {
        cin>>L[i];
    }
    sort(all(L));

    int sum=0;
    for(int i = 0; i < N-1; i++)
    {
        sum+=L[i];
    }
    if(sum>L[N-1])puts("Yes");
    else puts("No");
    

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    // スペース区切りの整数の入力
    int N,K;
    cin >> N >> K;
    // 出力
    if(N % K == 0){
         cout << 0 << endl;
    }else{
         cout << 1 << endl;
    }
    return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define PB push_back
#define p(a,b) g.PB(pii(a, b))
#define INF (1<<29)

typedef pair<int, int> pii;
typedef vector<pii> vp;

int main() {
	vp g; //pos to
	REP(i, 9) p(i, i + 1);
	p(9, 10);
	REP(i, 4) p(5 - i, i + 11);
	p(1, 0);
	
	int n;
	cin >> n;
	while (n--) {
		int prev[2][20], miner[2], tmp[2];
		int a, b;
		scanf("%d %d", &a, &b);
		
		tmp[0] = tmp[1] = INF;
		REP(i, g.size()) if (g[i].first == a) {
			if (tmp[0] == INF) tmp[0] = i;
			else tmp[1] = i;
		}
		
		miner[0] = miner[1] = INF;
		REP(i, 2) {
			if (tmp[i] == INF) break;
			
			queue<int> que; //pos
			que.push(tmp[i]);
			
			miner[i] = 0;
			while(true) {
				int pos = g[que.front()].first;
				int to = g[que.front()].second;
				que.pop();
				
				prev[i][miner[i]++] = pos;
				if (pos == b) break;
				
				que.push(to);
			}
		}
		
		int ans = miner[0] < miner[1] ? 0 : 1;
		REP(i, miner[ans]) {
			if (i != 0) printf(" ");
			printf("%d", prev[ans][i]);
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1260