akhauriyash/Code-Regression huggingface dataset:
import time as ti


class MyQueue(object):
    """
    My Queue class

    Attributes:
        queue: queue
        head
        tail
    """

    def __init__(self):
        """Constructor
        """
        self.length = 50010
        self.queue = [0] * self.length
        # counter = 0
        # while counter < self.length:
        #     self.queue.append(Process())
        #     counter += 1
        self.head = 0
        self.tail = 0

    # def enqueue(self, name, time):
    def enqueue(self, process):
        """enqueue method

        Args:
            name: enqueued process name
            time: enqueued process time

        Returns:
            None
        """
        self.queue[self.tail] = process
        # self.queue[self.tail].name = name
        # self.queue[self.tail].time = time
        self.tail = (self.tail + 1) % self.length

    def dequeue(self):
        """dequeue method

        Returns:
            None
        """
        # self.queue[self.head].name = ""
        # self.queue[self.head].time = 0
        self.queue[self.head] = 0
        self.head = (self.head + 1) % self.length

    def is_empty(self):
        """check queue is empty or not

        Returns:
            Bool
        """
        if self.head == self.tail:
            return True
        else:
            return False

    def is_full(self):
        """chech whether queue is full or not"""
        if self.tail - self.head >= len(self.queue):
            return True
        else:
            return False


class Process(object):
    """process class
    """

    def __init__(self, name="", time=0):
        """constructor
        Args:
            name: name
            time: time
        """
        self.name = name
        self.time = time

    def forward_time(self, time):
        """time forward method

        Args:
            time: forward time interval

        Returns:
            remain time

        """
        self.time -= time
        return self.time


def time_forward(my_queue, interval, current_time,):
    """

    Args:
        my_queue: queue
        interval: time step interval
        current_time: current time
    """

    value = my_queue.queue[my_queue.head].forward_time(interval)
    if value <= 0:
        current_time += (interval + value)
        print my_queue.queue[my_queue.head].name, current_time
        my_queue.dequeue()

    elif value > 0:
        current_time += interval
        name, time = my_queue.queue[my_queue.head].name, \
                     my_queue.queue[my_queue.head].time
        my_queue.enqueue(my_queue.queue[my_queue.head])
        my_queue.dequeue()

    return current_time


my_queue = MyQueue()
n, q = [int(x) for x in raw_input().split()]
counter = 0
while counter < n:
    name, time = raw_input().split()

    my_queue.enqueue(Process(name, int(time)))
    counter += 1

# end_time_list = []
current_time = 0
while not my_queue.is_empty():
    current_time = time_forward(my_queue, q, current_time)

Measured memory_bytes: 26384
#include<iostream>
using namespace std;
int main() {
  int n;
  cin>>n;
  int j;
  int k;
  for(int i = 10;n % i <= n;i = i * 10){
    if(i == 10){
      j = n % i;
      continue;
    }
    k = n % (i / 10);
    j = (n % i - k) / (i / 10) + j;
    if (n % i == n){
      break;
    }
  }
  if(n % j == 0){
    cout<<"Yes"<<endl;
    return 0;
  }else{
    cout<<"No"<<endl;
    return 0;
  }
  }

Measured memory_bytes: 3040
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = s; i < n; i++)
const int maxn = 305;
int N;
int A[maxn];
double d[maxn][maxn][maxn];

double dp(int a, int b, int c){
	if(d[a][b][c]>=0) return d[a][b][c];
	double n = N;
	double ans = 0;
	if(a>0)ans+=(a/n)*(dp(a-1,b,c)+1);
	if(b>0)ans+=(b/n)*(dp(a+1, b-1,c)+1);
	if(c>0)ans+=(c/n)*(dp(a,b+1, c-1)+1);
	ans = (ans*n+(n-a-b-c))/(double)(a+b+c);
	return d[a][b][c] = ans;
}


int main(){
	cin>>N;
	rep(i,0,N) cin>>A[i];
	int a,b,c; a = b = c = 0;
	rep(i,0,N){
		if(A[i]==1)a++;
		else if(A[i]==2) b++;
		else c++;
	}
	// cout<<a<<b<<c<<endl;
	rep(i,0,maxn) rep(j,0,maxn) rep(k,0,maxn) d[i][j][k] = -1;
	d[0][0][0] = 0;
	cout<<fixed<<setprecision(10)<<dp(a,b,c)<<endl;
}


Measured memory_bytes: 221952
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

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

    vector<string> s(3);
    REP(i, 3) cin >> s[i];
    REP(i, 3) cout << s[i][i];
    cout << "\n";
    return 0;
}

Measured memory_bytes: 256
def main():
    N = input()

    V = [int(x) for x in input().split()]
    C = [int(x) for x in input().split()]

    V_sum = 0
    C_sum = 0
    for i, j in zip(V, C):
        if i - j > 0:
            # print(i, j)
            V_sum += i
            C_sum += j

    print(V_sum-C_sum)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
//https://atcoder.jp/contests/abc110/tasks/abc110_c

import java.util.Scanner;
import java.util.Arrays;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        String T = sc.nextLine();
        int[] start = new int[26];
        Arrays.fill(start,-1);
        int[] goal = new int[26];
        Arrays.fill(goal,-1);
        int a,b;
        for (int i=0;i<S.length();i++){
            a = S.charAt(i)-'a';
            b = T.charAt(i)-'a';
            if (start[a]!=-1 || goal[b]!=-1){
                if (start[a]!=b || goal[b]!=a){
                    System.out.println("No");
                    return;
                }
            }
            start[a] = b;
            goal[b] = a;
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 28660
#include <bits/stdc++.h>
 
using namespace std;
 
#define f0r(a, b) for (long long a = 0; a < (b); a++)
#define f1r(a, b, c) for (long long a = (b); a < (c); a++)
#define f0rd(a, b) for (long long a = (b); a >= 0; a--)
#define f1rd(a, b, c) for (long long a = (b); a >= (c); a--)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define pb push_back
#define mp make_pair
#define f first
#define s second
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
 
void fio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); 
  cout.tie(0);
}
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 

 
const long double pi = 3.14159265358979323846;
const ll mod = (ll)(1e9 + 7);
 
void solve() {
  ll n, m, k; cin >> n >> m >> k;

  ll r = mod * mod;

  ll cost[n], ad[n][m];

  f0r(i, n) {
    cin >> cost[i];
    f0r(j, m) cin >> ad[i][j];
  }

  f0r(i, (1 << n)) {
    ll val[m];
    f0r(j, m) val[j] = 0;
    f0r(j, n) {
      if (i & (1 << j)) {
        f0r(k, m) val[k] += ad[j][k];
      }
    }

    bool f = 1;
    f0r(j, m) if (val[j] < k) f = 0;
    if (f) {
      ll v = 0;
      f0r(j, n) if (i & (1 << j)) v += cost[j];
      r = min(r, v);
    }
  }

  cout << (r == mod * mod ? -1 : r) << '\n';
}
 
int main() {
  fio();
  
  int T;
  T = 1;
  // cin >> T;
  while (T--) solve();
} 

Measured memory_bytes: 3664
import sys
import numpy as np
from itertools import combinations
from itertools import product

height, width, black = map(int, sys.stdin.readline().split())
mat = np.array([list(input()) for _ in range(height)])
n_black_remove = np.sum(mat == "#") - black
n_black_row = np.array([np.sum(mat[row, :] == "#") for row in range(height)])
n_black_col = np.array([np.sum(mat[:, col] == "#") for col in range(width)])
result = 0

for n_delete_row in range(height+1):
    for n_delete_col in range(width+1):
        for combi_row in combinations(range(height), n_delete_row):
            for combi_col in combinations(range(width), n_delete_col):
                remove = 0
                if combi_row:
                    remove += np.sum(n_black_row[list(combi_row)])
                if combi_col:
                    remove += np.sum(n_black_col[list(combi_col)])
                for r, c in product(combi_row, combi_col):
                    if mat[r][c] == "#":
                        remove -= 1
                if remove == n_black_remove:
                    result += 1
print(result)


Measured memory_bytes: 27176
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
const int maxn=200010;
int n,m,a[maxn],b[maxn],cnt,t;
int main(){
    scanf("%d%d",&n,&m);
    rep(i,1,m) scanf("%d",&a[i]),t+=a[i]&1;
    if(t>=3) return puts("Impossible"),0;
    if(t==0){
        rep(i,1,m) printf("%d ",a[i]);puts("");
        b[cnt=1]=1;
        rep(i,1,m-1) b[++cnt]=a[i];t=a[m]-1;
        rep(i,1,t/4) b[++cnt]=2;b[++cnt]=1;t=t-(t/4)*2-1;
        rep(i,1,t/2) b[++cnt]=2;
        printf("%d\n",cnt);
        rep(i,1,cnt) printf("%d ",b[i]);
        return 0;
    }
    if(t==1){
        rep(i,1,m) if(a[i]&1){swap(a[m],a[i]);break;}
        rep(i,1,m) printf("%d ",a[i]);puts("");
        b[cnt=1]=1;
        rep(i,1,m-1) b[++cnt]=a[i];
        rep(i,1,(a[m]-1)/2) b[++cnt]=2;
        printf("%d\n",cnt);
        rep(i,1,cnt) printf("%d ",b[i]);
        return 0;
    }
    if(t==2){
        rep(i,1,m) if(a[i]&1){swap(a[1],a[i]);break;}
        rep(i,2,m) if(a[i]&1){swap(a[m],a[i]);break;}
        rep(i,1,m) printf("%d ",a[i]);puts("");
        b[cnt=1]=a[1]+1;
        rep(i,2,m-1) b[++cnt]=a[i];
        rep(i,1,(a[m]-1)/2) b[++cnt]=2;
        printf("%d\n",cnt);
        rep(i,1,cnt) printf("%d ",b[i]);
        return 0;
    }
    return 0;
}

Measured memory_bytes: 512
def f1(a, b, c, d):  # 2点の中心を通り垂直な線の傾きと切片
    k = (a - c) / (d - b)
    h = ((b + d) - k * (a + c)) / 2
    return k, h


def f2(a, b, c, d):  # 2直線との交点
    x = (d - b) / (a - c)
    y = a * x + b

    return x, y


def f3(a, b, c, d):
    return ((c - a) ** 2 + (d - b) ** 2) ** 0.5


def main():
    N = int(input())
    for i in range(N):
        a, b, c, d, e, f = map(float, input().split())
        T = []
        if not b == d:
            k, h = f1(a, b, c, d)
            T.append((k, h))
        if not d == f:
            k, h = f1(c, d, e, f)
            T.append((k, h))
        if not  f == b:
            k, h = f1(e, f, a, b)
            T.append((k, h))
        x, y = f2(T[0][0], T[0][1], T[1][0], T[1][1])
        r = f3(x, y, a, b)
        print(f'{round(x, 3):.3f} {round(y, 3):.3f} {round(r, 3):.3f}')


if __name__ == '__main__':
    main()



Measured memory_bytes: 5696
#include <iostream>
using namespace std;
 
int main() {
  int A, B, C, X;
  int ans = 0;
  cin >> A >> B >> C >> X;
  
  for (int i = 0; i < A+1; i++)
    for (int k = 0; k < B+1; k++)
      for (int t = 0; t < C+1; t++)
        if (i*500 + k*100 + t*50 == X)
          ans++;
  cout << ans;
}

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;
int  main(){
int N;
cin>>N;
int a=N/2;
vector<int>d(N);
for(int i=0; i<N; i++){
    cin>>d.at(i);
}
sort(d.begin(),d.end());
int s=0;
int answer=0;
for(int i=d.at(a-1)+1; i<=d.at(a); i++){
    if(s!=i){
    answer++;
    s=i;
    }
}
cout<<answer<<endl;
 }


Measured memory_bytes: 640
N,M = [int(i) for i in input().split(" ")]
neighbor_dict={n:set() for n in range(1,N+1)}


for i in range(M):
    a,b = [int(i) for i in input().split(" ")]
    neighbor_dict[a].add(b)
    neighbor_dict[b].add(a)

ans = 0

def crawl(vertex:int,visited_set:set):
    visited_set = visited_set | {vertex}
    if len(visited_set) == N:
        global ans
        ans = ans + 1
        return

    to_visit = set(neighbor_dict[vertex]) - visited_set

    for v in to_visit:
        crawl(v,visited_set)

crawl(1,set())
print(ans)

Measured memory_bytes: 9160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h> //works like magic, but at cost.
using namespace std;
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout<<x<<endl;
#define fo(i, n) for(int i=0; i<n; i++)
#define fk(i, k, n) for(int i=k; i<=n; i++)
#define fn(i, n) for(int i=n-1;i>=0;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lli long long int
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<lli, lli>	pl;
typedef vector<int>		vi;
typedef vector<lli>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;

int main() {
    int a;
    cin>>a;
    int sum = a + a*a + a*a*a;
    cout<<sum;

    
    return 0;
}

Measured memory_bytes: 3140
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <string>
#include <ctype.h>
using namespace std;
int main(){
    string s;
    int pos;
    cin >> s;
    string ans = "WA";
    int count=0;
    if(s.substr(0,1) == "A"){
        string x = s.substr(2,s.length()-3);
        for(int j=0;j<x.length();j++){
            if(x.substr(j,1)=="C"){
                pos = s.find("C");
                count++;
            }
        }
        if(count == 1){
            for(int i=1;i<s.length();i++){
                if(i!=pos){
                            if ("a" <= s.substr(i,1) && "z" >= s.substr(i,1)){
                                if(i==s.length()-1){
                                ans = "AC";
                            }
                        }else{
                                break;
                            }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using vi  = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
  int N, M;
  cin >> N >> M;
  vector<pii> ab(N);
  vector<pii> cd(M);
  rep(i, N) {
    int a, b;
    cin >> a >> b;
    ab[i].first = a;
    ab[i].second = b;
  }
  rep(i, M) {
    int c, d;
    cin >> c >> d;
    cd[i].first = c;
    cd[i].second = d;
  }

  int curr;
  int ans;
  rep(i, N) {
    int a, b;
    tie(a, b) = ab[i];
    curr = 1000000000;
    rep(j, M) {
      int c, d;
      tie(c, d) = cd[j];
      int dist = abs(c-a)+abs(d-b);
      if (dist < curr) {
        ans = j+1;
        curr = dist;
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int A[10]={0,1,2,3,4,5,6,7,8,9};
	while(true){
		int N=in(),S=in();
		if(!N && !S) break;
		int ans = 0;
		REP(i,1024){
			int num=0,sum=0,digit=0;
			int v=i;
			while(v){
				if(v&1){
					num++;
					sum+=A[digit];
				}
				v>>=1;
				digit++;
			}
			if(num==N && sum==S) ans++;
		}
		out(ans);
	}
	return 0;
}


Measured memory_bytes: 3140
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve();
        }

        public void Solve()
        {
            var cin = new MyInputStream();

            var S = cin.Read();
            for (int i = 0; i < S.Length; ++i)
                if (i % 2 == 0)
                    Console.Write(S[i]);
            Console.WriteLine();
        }
    }

    public class MyInputStream
    {
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(char separator = ' ')
        {
            this.separator = separator;
            inputStream = new Queue<string>();
        }

        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = Console.ReadLine().Trim().Split(separator);
            for (int i = 0; i < tmp.Length; i++)
            {
                inputStream.Enqueue(tmp[i]);
            }
            return inputStream.Dequeue();
        }
        public string ReadLine() => Console.ReadLine();
        public int ReadInt() => int.Parse(Read());
        public long ReadLong() => long.Parse(Read());
        public double ReadDouble() => double.Parse(Read());
        public string r() => Read();
        public int ri() => ReadInt();
        public long rl() => ReadLong();
        public double rd() => ReadDouble();
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

int main(){
    bool np[1000001] = {};
    np[0] = np[1] = true;
    for(int i = 2; i < 1000001; i++){
        if(np[i])   continue;
        for(int j = i+i; j < 1000001; j += i)   np[j] = true;
    }

    int n;
    cin >> n;
    vector<int> q(n);
    for(int i = 0; i < n; i++)  cin >> q[i];

    if(np[q[0]]){
        cout << 0 << endl;
        return 0;
    }
    if(n == 1){
        cout << 1 << endl;
        return 0;
    }

    vector<vector<ll>> dp(2, vector<ll>(n,0));
    dp[1][0] = 1;
    dp[0][1] = 1;
    if(!np[q[1]] && q[1] > q[0])    dp[1][1] = 1;
    for(int i = 2; i < n; i++){
        // 指数の肩ver
        if(!np[q[i-1]]) dp[0][i] = (dp[0][i] + dp[1][i-1]) % mod;
        // 素数ver
        if(!np[q[i]]){
            if(!np[q[i-1]] && q[i] > q[i-1]) dp[1][i] = (dp[1][i] + dp[1][i-1]) % mod;
            if(!np[q[i-2]] && q[i] > q[i-2]) dp[1][i] = (dp[1][i] + dp[1][i-2]) % mod;
        }
    }

    cout << (dp[0][n-1]+dp[1][n-1])%mod << endl;
    return 0;
}


Measured memory_bytes: 6440
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

const ll MOD = (ll)1e9 + 7LL;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	vector<P> v(2*N);
	rep (i, N){
		int a; cin >> a;
		v[i].first = a;
		v[i].second = 1;
	} // end rep
	rep (i, N){
		int b; cin >> b;
		v[i+N].first = b;
		v[i+N].second = -1;
	} // end rep

	sort(ALL(v));

	ll sum = 0LL;
	ll ans = 1LL;
	for (int i = 0; i < v.size(); ++i){
		if ((sum > 0LL && v[i].second < 0) || (sum < 0LL && v[i].second > 0)){
			ans = (ans * abs(sum)) % MOD;
		} // end if
		sum += v[i].second;
	} // end for
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include <stdlib.h>
#include<math.h>

int main(){
  long int n,p;
  long int i,m,k,t;
  scanf("%ld %ld",&n,&p);
  m=1;
  
  t=(long int)pow(p,(double)1/n);
  
  if(pow(2,n)>p)
    
    m=1;
 else if(n==1)
    m=p;
  
  else if(pow(t,n)==p)
    m=t;
          
  
          
  else {
  for(i=2;(long int)pow(i,n)<=p;i++){
    
    if(p%(long int)pow(i,n)==0){
      for(k=2;k<10000;k++){
        if(p%(long int)pow(i,n*k)!=0)
          break;
      }
    
      p=p/(long int)pow(i,n*(k-1));
      m=m*pow(i,(k-1));
    }
  }
  }
  
  printf("%ld",m);
  
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
#define ALL(V) V.begin(), V.end()
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}


int Main(int N)
{
    int d = to_string(N).size();
    if(d == 1) {
        return N;
    }
    else if(d == 2) {
        return 9;
    }
    else if(d == 3) {
        return 9 + N - 99;
    }
    else if(d == 4) {
        return 909;
    }
    else if(d == 5) {
        return 909 + N - 9999;
    }
    else if(d == 6) {
        return 90909;
    }
    else {
        return -1; // can't happen
    }
}

int main(void){
    int N;
    cin >> N;
    cout << Main(N) << endl;
    return 0;
}

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

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

    string s;
    cin >> s;
    int former = stoi(s.substr(0, 2)), latter = stoi(s.substr(2, 2));
    if ((former == 0 or former > 12) and 1 <= latter and latter <= 12) {
        cout << "YYMM" << endl;
    } else if (1 <= former and former <= 12 and (latter == 0 or latter > 12)) {
        cout << "MMYY" << endl;
    } else if (1 <= former and former <= 12 and 1 <= latter and latter <= 12) {
        cout << "AMBIGUOUS" << endl;
    } else {
        cout << "NA" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import Data.List
import Data.Tree
import Data.Array  --変数衝突
import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.ST
import Data.Graph
--import Data.Vector as V　--変数衝突
import Control.Monad
import Control.Monad.State
import Control.Monad.ST
--import Debug.Trace

type DP s = STUArray s (Int,Int) Int

mod0 :: Int -> Int
mod0 n = mod n 1000000007

dp_i :: DP s -> (Int,Int) -> ST s ()
dp_i dparr (1,1) = writeArray dparr (1,1) 1
dp_i dparr (i,j) = do
  aij  <- readArray dparr (i,j)
  if aij == (-1) then return ()
    else do
      ai1j <- readArray dparr (i-1,j)
      aij1 <- readArray dparr (i,j-1)
      case (ai1j,aij1) of
        (-1,-1) -> return ()
        (x,-1)  -> writeArray dparr (i,j) x
        (-1,y)  -> writeArray dparr (i,j) y
        (x,y)   -> writeArray dparr (i,j) (mod0 $ x+y)


solve :: Int -> Int -> [Int] -> ST s Int
solve h w mat = do
  dparr <- newListArray ((0,0),(h,w)) mat
  forM_ [1..h] $ \i ->
    forM_ [1..w] $ \j -> dp_i dparr (i,j)
  ans <- readArray dparr (h,w)
  return ans

main :: IO ()
main = do
  [h,w] <- map read.words <$> getLine
  mat' <- replicateM h $ do
    row <- getLine :: IO [Char]
    return $ 0 : (map (\x -> if x == '.' then 0 else -1) row)
  let mat = concat mat'
  putStrLn $ show $ runST $ solve h w ((take (w+1) $ repeat 0) ++ mat)


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

int main(){
    string s,t;
    cin >> s >> t;
    bool ok=true;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i])ok=false;
    }
    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main(){
  int a,b,n,i,p,ans;
  int cnt[3]={0};
  cin>>n>>a>>b;
  for(i=0;i<n;i++){
    cin>>p;
    if(p<=a){
      cnt[0]++;
    }else if(p<=b){
      cnt[1]++;
    }else{
      cnt[2]++;
    }
  }
  ans=min(cnt[0],cnt[1]);
  ans=min(ans,cnt[2]);
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <iostream>
#include <vector>
#include <iomanip>
#define lsb(x) ((x) & -(x))
using namespace std;

#define mod 1000000007
typedef long long i64;
int n;
i64 form[50][50];
const i64 mod2 = 1LL * mod * mod;

struct Mat {
    int v[50][50];
    Mat() {
        fill(v[0], v[50], 0);
    }
    int * operator[](int a) { return v[a]; }
};

Mat operator* (Mat & a, Mat & b)
{
    Mat ans;
    fill(form[0], form[50], 0);
    for (int i = 0; i < n; i++) {
        for (int k = 0; k < n; k++) {
            for (int j = 0; j < n; j++) {
                form[i][j] += 1LL * a[i][k] * b[k][j];
                if (form[i][j] >= mod2)
                    form[i][j] -= mod2;
            }
        }
    }
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            ans[i][j] = form[i][j] % mod;

    return ans;
}

Mat put(Mat a, i64 p)
{
    Mat ans = a;
    p--;

    while (p) {
        if (p & 1LL)
            ans = ans * a;
        p /= 2;
        if (p)
            a = a * a;
    }

    return ans;
}

int main()
{
    Mat a;
    i64 k;
    scanf("%d%lld", &n, &k);

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

    a = put(a, k);


    int ans = 0;

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            ans = (ans + a[i][j]) % mod;

    printf("%d\n", ans);
    return 0;
}


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

using namespace std;

int main()
{
   int a,b,c,k,sum=0;
   cin>>a>>b>>c>>k;
   while(k&&a){
    sum++;
    a--;
    k--;
   }
   while(k&&b){
    b--;
    k--;
   }
   while(k&&c){
    sum--;
    c--;
    k--;
   }
   cout<<sum<<endl;
}


Measured memory_bytes: 3584
s = input()
count = 0
first_half, second_half = s[:len(s)//2], s[(len(s)+1)//2:]
if first_half == reversed(second_half):
    print(count)
else:
    for x in range(len(first_half)):
        if (first_half[x] != second_half[len(second_half)-x-1]):
            count += 1
    print(count)

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

#define ll long long int

int main()
{
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll a,b,c,k=0;
    cin >> a>>b>>c;
    for(ll i=a;i<=b;i++)
    {
           if(i%c==0)
             k++;
    }
    cout<<k;

}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(a-c)<=d||(abs(b-a)<=d&&abs(c-b)<=d))
     cout<<"Yes";
  else
     cout<<"No";
     
  return 0;
    
}

Measured memory_bytes: 3060
N, MOD = int(input()), 10 ** 9 + 7
memo = [{} for i in range(N+1)]
def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i-1], t[i] = t[i], t[i-1]
        if ''.join(t).count('AGC') >= 1:
            return False
    return True
for i in range(N+1):
    if i == 0:
        memo[0]["****"] = 1
    elif i == 1:
        memo[1]["***A"] = 1
        memo[1]["***C"] = 1
        memo[1]["***G"] = 1
        memo[1]["***T"] = 1
    else:
        #print("aa")
        for c in 'ACGT':
            for j in memo[i-1]:
                #print(j)
                if ok(j[1:] + c):
                    if j[1:] + c not in memo[i]:               
                        memo[i][j[1:] + c] = memo[i-1][j] % MOD
                    else:
                        memo[i][j[1:] + c] += memo[i-1][j] % MOD

s = 0
for i in memo[N].values():
    s += i % MOD
print(s % MOD)

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

int main()
{
	int n;
	cin>>n;
	vector<int>v(n);
	r(i,n)cin>>v[i];
 if(prev_permutation(v.begin(),v.end())){
 r(i,n)
 {
   if(i)
    cout<<' ';
   cout<<v[i];
   }
   cout<<endl;}
next_permutation(v.begin(),v.end());
r(i,n)
 {
   if(i)
    cout<<' ';
   cout<<v[i];
   }
     cout<<endl;
     if(next_permutation(v.begin(),v.end())){
 r(i,n)
 {
   if(i)
    cout<<' ';
   cout<<v[i];
   }
     cout<<endl;}

return 0;
}





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

int main() {
  int N, K;
  cin >> N >> K;
  double ans = 0.0;
  for (int i = 1; i <= N; i++) {
	int score = i;
    double temp = (1.0 / N);
    while (score < K) {
      temp /= 2;
	  score *= 2;      
    }
    ans += temp;
  }
  
  cout << setprecision(10) <<  ans << endl;
}

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

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char> > cc(h,vector<char>(w));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> cc[i][j]; 
        }
    }

    for(int i=0;i<w+2;i++){
        cout << "#";
    }
    cout << endl;
    for(int i=0;i<h;i++){
        cout << "#";
        for(int j=0;j<w;j++){
            cout << cc[i][j]; 
        }
        cout << "#" << endl;
    }
    
    for(int i=0;i<w+2;i++){
        cout << "#";
    }
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
n=int(input())
s=[Counter(input()) for i in range(n)]

A='abcdefghijklmnopqrstuvwxyz'
dic={i:0 for i in A}
for alpha in A:
    cnt=10**9
    for dic2 in s:
        if alpha in dic2:
            cnt=min(cnt,dic2[alpha])
        else:
            cnt=0
            break
    dic[alpha]=cnt

ans=''.join([i*dic[i] for i in A])
print(ans)

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

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

    int p[n], q[m];

    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    for(int i = 0; i < m; i++){
        cin >> q[i];
    }
    sort(p, p+n);
    sort(q, q+m);

    if( a < q[0] && b >= q[0] && p[n - 1] < q[0] && q[0] >= q[0]){
        cout <<"No War";
    }
    else cout <<"War";
    return 0;
}




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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int k;

bool visited[MAX_N];
ll dist[MAX_N];

ll ans;

ll solve() {
  fill_n(visited, k + 1, false);
  fill_n(dist, k + 1, INF);

  deque<pair<int, ll>> deq;

  deq.push_front(make_pair(1, 0LL));

  ll ret = 0;

  while (!deq.empty()) {
    auto cur = deq.front();
    deq.pop_front();

    int node = cur.first;
    ll cost = cur.second;

    if (visited[node]) continue;
    visited[node] = true;

    dist[node] = cost;

    if (node == 0) {
      ret = cost;
      break;
    }

    int next_p1 = (node + 1) % k;
    if (dist[next_p1] > cost + 1LL) {
      deq.push_back(make_pair(next_p1, cost + 1LL));
    }

    int next_t10 = (node * 10) % k;
    if (dist[next_t10] > cost) {
      deq.push_front(make_pair(next_t10, cost));
    }
  }

  return ret + 1LL;
}

int main(void) {
  // Here your code !
  scanf("%d", &k);

  ans = solve();

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 2048
package main

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

func main() {
	n := readi()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = readi()
	}
	cp := make([]int, n)
	copy(cp, a)
	sort.Ints(cp)

	for i := 0; i < n; i++ {
		if a[i] != cp[len(cp)-1] {
			fmt.Println(cp[len(cp)-1])
		} else {
			fmt.Println(cp[len(cp)-2])
		}
	}
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

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

func chmin(x *int, y int) bool {
	if *x > y {
		*x = y
		return true
	}
	return false
}

func chmax(x *int, y int) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func comb(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

func permutations(arr []int) [][]int {
	var helper func([]int, int)
	res := [][]int{}

	helper = func(arr []int, n int) {
		if n == 1 {
			tmp := make([]int, len(arr))
			copy(tmp, arr)
			res = append(res, tmp)
		} else {
			for i := 0; i < n; i++ {
				helper(arr, n-1)
				if n%2 == 1 {
					tmp := arr[i]
					arr[i] = arr[n-1]
					arr[n-1] = tmp
				} else {
					tmp := arr[0]
					arr[0] = arr[n-1]
					arr[n-1] = tmp
				}
			}
		}
	}
	helper(arr, len(arr))
	return res
}

func isPrime(n int) bool {
	if n == 1 {
		return false
	}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

func divisor(n int) (res []int) {
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if i*i != n {
				res = append(res, n/i)
			}
		}
	}
	sort.Ints(res)
	return
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7

	COMB_MAX = 510000
)

var (
	readString func() string
)

var (
	fac  = [COMB_MAX]int{}
	finv = [COMB_MAX]int{}
	inv  = [COMB_MAX]int{}
)

func init() {
	readString = newReadString(os.Stdin)
}

func combInit() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for i := 2; i < COMB_MAX; i++ {
		fac[i] = fac[i-1] * i % MOD
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
		finv[i] = finv[i-1] * inv[i] % MOD
	}
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}


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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

namespace IO {
    #define gc getchar()
    template <typename T>
    inline void read(T& x) {
        x = 0; bool f = 1; char ch;
        for (ch = gc; ch < '0' || '9' < ch; ch = gc) if (ch == '-') f ^= 1;
        for (; '0' <= ch && ch <= '9'; ch = gc) x = (x << 3) + (x << 1) + (ch ^ 48);
        x = f ? x : -x;
    }
    #undef gc
}

const int MAXN = 1e6 + 10;
int k, m;
bool vis[MAXN];
int main() {
    scanf("%d", &k);
    m = 7 % k;
    int tmp = m;
    int ans = 1;
    while (1) {
        if (m == 0) {
            printf("%d\n", ans);
            return 0;
        }
        if (vis[m]) { puts("-1"); return 0; }
        ans++; vis[m] = true;
        m = (1ll * m * 10 + 1ll * tmp) % k;
    }
    return 0;
}

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

int main()
{
    int N, M;
    std::cin >> N >> M;
    std::vector<int> A(N);

    long int sum = 0;

    for (int i = 0; i < N; ++i) {
        std::cin >> A[i];
        sum += A[i];
    }

    int count = 0;
    for (int i = 0; i < N; ++i) {
        if (4 * M * A[i] >= sum) {
            ++count;
        }
    }


    if (count >= M) {
        std::cout << "Yes";
    } else {
        std::cout << "No";
    }

    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);
        String str = "";

        while(sc.hasNext()) {
        	str += sc.nextLine();
        }
        str = str.toLowerCase();

        char[] alphabet = new char[] {'a','b','c','d','e','f','g','h','i','j','k',
        							  'l','m','n','o','p','q','r','s','t','u','v',
        							  'w','x','y','z'};

        int[] ans = new int[alphabet.length];

        for(int i = 0; i < str.length(); ++i) {
        	for(int j = 0; j < alphabet.length; j++) {
        		if(str.charAt(i) == alphabet[j]) {
        			ans[j]++;
        		}
        	}
        }

        for(int i = 0; i < alphabet.length; i++) {
        	System.out.println(String.format("%s : %d", alphabet[i], ans[i]));
        }

    }
}


Measured memory_bytes: 26464
# coding: utf-8
# Your code here!
a,b=map(int, input().split())

if a == 1 or b == 1:
    print(1)
elif a % 2 == 0:
    print(a*b//2)
elif a % 2 == 1:
    if b % 2 == 0:
        print(a*b//2)
    elif b % 2 == 1:
        print((a+1)*b//2 -(b//2))

Measured memory_bytes: 3060
// 入力は N 個の変数 にそれぞれ M 個の変数がついている
// これとは別に B_1, ... , B_M の変数がある
// 変数のBとの積の総和を評価してうんぬんする
// 変数は多くない

#include <iostream>
#include <string>
using namespace std;

int main(){
  int N, M, C;
  cin >> N >> M >> C;

  int A[N][M];
  int B[M];

  for (int i=0; i<M; i++){
    cin >> B[i];
  }

  for (int i=0; i<N; i++){
    for (int j=0; j<M; j++){
      cin >> A[i][j];
    }
  }

  int counter = 0;
  for (int i=0; i<N; i++){
    int tmp=0;
    for (int j=0; j<M; j++){
      tmp += A[i][j] * B[j];
    }
    if (tmp + C > 0){
      counter++;
    }
  }

  cout << counter << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import* #defaultdict Counter deque appendleft
import sys
input=sys.stdin.readline
import time
t=time.time()

def main():
    n=int(input())
    d=[[]]+[deque(map(int,input().split()))for i in n*[0]]

    c=0
    while any(d):
        c+=1
        f=0
        skip=set()
        for i in range(1,n+1):
            if i not in skip:
                if d[i]:
                    if d[i][0] in skip:
                        continue
                    elif i==d[d[i][0]][0]:
                        oppo=d[i].popleft()
                        d[oppo].popleft()
                        skip.add(oppo)
                        skip.add(i)
                        f=1

        if not f:
            print(-1)
            exit()
        if abs(time.time()-t)>1:
            print(n*(n-1)//2)
            exit()

    print(c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38100
#include <vector>
#include <iostream>
using namespace std;
int P[100010];

// 最初K points持っていた
// Q回の施行をする
// 0を例にして考える。
// 0にP[0]回入ったとすると、0以外にはQ-p[0]回入る
// つまり、0はK-(Q-p[0])点になる
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N, K, Q; cin >> N >> K >> Q;
  for(int i = 0; i < Q; i++) {
    int A; cin >> A; A--;
    P[A]++;
  }
  for(int i = 0; i < N; i++) {
    if(K - (Q - P[i]) > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}



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

int cp(const void* a, const void* b);//比較関数

int main(void){
    int i, A[3];
    int len=sizeof(A)/sizeof(int);
    for(i=0; i<3; i++) scanf("%d", A+i);
    qsort(A, len, sizeof(int), cp);
    printf("%d\n", A[2]-A[0]);
    return 0;
}

int cp(const void* a, const void* b){
    return *(int*)a - *(int*)b;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pp = pair<ll,ll>;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)

int main(){
	int n;
	while(true){
		cin >> n;
		if(!n)break;
		double t[n],sum = 0.0;
		for(int i = 0; i < n; i++){
			cin >> t[i];
			sum += t[i];
		}
		double ave = sum / n;
		double a = 0.0;
		for(int i = 0; i < n; i++){
			a += (t[i] - ave) * (t[i] - ave);
		}
		cout << fixed << setprecision(20) << sqrt(a / n) << endl;

	}
	return 0;
} 


Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define repd(i, a, b) for (int i = a; i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
template <typename H>
bool chmin(H &v1, const H v2)
{
    if (v1 > v2)
    {
        v1 = v2;
        return true;
    }
    return false;
}
template <typename H>
bool chmax(H &v1, const H v2)
{
    if (v1 < v2)
    {
        v1 = v2;
        return true;
    }
    return false;
}
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

int main()
{
    int x;
    cin >> x;
    if (x == 1)
        cout << 0 << endl;
    else
        cout << 1 << endl;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { cout << p.first << ' ' << p.second; return os; }

void solve() {
  i64 K; cin >> K;
  vi64 a(50, 49);
  rep(i, 50) a[i] += K / 50;
  rep(i, 50 - K % 50) a[49 - i] -= K % 50;
  rep(i, K % 50) a[i] += 51 - K % 50;
  cout << 50 << '\n' << a << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c[7],d;
	for(d=0;d<7;d++){
	scanf("%d %d",&a,&b);
	c[d]=a-b;
	}
	for(d=0;d<7;d++){
		printf("%d\n",c[d]);
	}
	return 0;
}


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

int main()
{
    int n;
    cin >> n;
    float sum = 0;
    for (int i = 0; i < n; ++i)
    {
        float input;
        cin >> input;

        sum += 1 / input;
    }

    cout << fixed << setprecision(10);
    cout << (1 / sum) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq1 = priority_queue<T>;
template<typename T> using pq2 = priority_queue<T,vector<T>,greater<T>>;



int main()
{
    int N;
    cin >> N;
    ll D,A;
    cin >> D >> A;
    ve<pll> B(N);
    rep(i,N){
        cin >> B[i].fi >> B[i].se;
        B[i].se = -B[i].se;
    }
    sort(all(B));
    
    ve<pll> Mons;
    Mons.pb({B[0].fi,-B[0].se});
    reps(i,1,N) if(Mons.back().fi != B[i].fi){
        Mons.pb({B[i].fi,-B[i].se});
    }

    ll mon_num = ll(Mons.size());
    ll s,t;
    ll ans = 0;
    
    ll bom = 0;
    pq2<pll> bom_eff;
    
    for (ll i = 0; i < mon_num; i++) {
        
        s = Mons[i].fi;
        t = s + 2 * D;
        
        while (!bom_eff.empty()) {
            pll a = bom_eff.top();
            if(a.fi < s){
                bom_eff.pop();
                bom -= a.se;
            }else{
                break;
            }
        }
        Mons[i].se -= bom;
        if(Mons[i].se <= 0) continue;
        ll boo = (Mons[i].se+A-1)/A;
        ans += boo;
        bom += A*boo;
        bom_eff.push({t,A*boo});
    
    }
    out(ans);
    
    
    
    

    return 0;
}


Measured memory_bytes: 10220
S = input()
ans = 0

len_S = len(S)
center = int(len_S / 2)

former = S[:center]
if len_S % 2 != 0:
    center += 1
latter = S[center:][::-1]

for f, l in zip(former, latter):
    if f != l:
        ans += 1
print(ans)


Measured memory_bytes: 3060
program abc158b
   implicit none
   integer(8)::A,B,N,x,x1,x2,y

      read *,N,A,B
      x1=N/(A+B)
      x1=A*x1
      y=mod(N,A+B)

      if (y>=A) then
        x2=A
      else
        x2=y
      end if

      x=x1+x2
      print *,x
      stop

   end program abc158b

Measured memory_bytes: 768
s = input()
tmp = [0]
for i in range(len(s)-1):
    if s[i] != s[i+1]:  # RとLが切り替わる時のインデックスを保存
        tmp.append(i+1)
tmp.append(len(s))
ans = [0 for i in range(len(s))]
for i in range(len(tmp)-1):
    if i % 2 == 1:
        ans[tmp[i]] = (tmp[i]-tmp[i-1])//2 + (tmp[i+1]-tmp[i]+1)//2
        ans[tmp[i]-1] = (tmp[i+1]-tmp[i])//2 + (tmp[i]-tmp[i-1]+1)//2
print(*ans)
# RRLLLLRLRRLL

Measured memory_bytes: 49648
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

typedef long long ll;

int main(){
	int n;
	scanf("%d",&n);
	vector<int>h(n);
	for(int i=0;i<n;i++){
		scanf("%d",&h[i]);
	}
	vector<int>dp(n+1);
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(int i=2;i<n;i++){
		dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
	}
	printf("%d\n",dp[n-1]);
}

Measured memory_bytes: 1024