akhauriyash/Code-Regression huggingface dataset:
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() int {
	n := scanInt(sc)
	s := nextIntSlice(sc, n)
	sort.Sort(sort.Reverse(sort.IntSlice(s)))
	a, b := 0, 0
	for i := 0; i < len(s); i++ {
		if i%2 == 0 {
			a += s[i]
		} else {
			b += s[i]
		}
	}
	return a - b
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return int(a)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextIntSlice(sc *bufio.Scanner, n int) (a []int) {

	a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	return a
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <math.h>  
#include <string>
#include <cstdio>
#include <iostream>
#include <algorithm> 

using namespace std;

// typedef signed long long ll;
typedef unsigned long long ull;
typedef vector< pair<int, int> > vec_int_pairs;
typedef vector<int>  vecint;
typedef vector< vector<int> > vecint2;
// typedef vecint2 graph;
typedef vector< vec_int_pairs > graph;
typedef map<int, int> int_int_map;


#define MOD 1000000007


int main() {
	string s, t;
	
	cin >> s;
	cin >> t;
	
	vecint2 d(s.length(), vecint(t.length(), 0));
	
	for (unsigned int i = 0; i < s.length(); ++i) {
		for (unsigned int j = 0; j < t.length(); ++j) {	
			d[i][j] = (i > 0 && j > 0 ? d[i - 1][j - 1] : 0);
			if (s[i] == t[j]) {
				d[i][j] += 1;
			} else {
				d[i][j] = max(
					d[i][j],
					max((i > 0 ? d[i - 1][j] : 0), (j > 0 ? d[i][j - 1] : 0))
				);
			}
			
			// cout << d[i][j] << " ";
		}
		
		// cout << endl;
	}
	
	int l_s = s.length();
	int l_t = t.length();
	
	vector<char> ans;
	
	int i = l_s - 1, j = l_t - 1;
	
	int next = d[l_s - 1][l_t - 1];
	
	int dirs[][2] = {
		{-1, 0},
		{0, -1},
		{-1, -1}
	};
	
	while (next > 0) {
		bool found = true;
		for (auto dir : dirs) {
			int i1 = i + dir[0];
			int j1 = j + dir[1];
			
			if (i1 >= 0 && j1 >= 0 && d[i1][j1] == d[i][j]) {
				found = false;
			}
		}
		
		if (found) {
			ans.push_back(s[i]);
			--i;
			--j;
			--next;
		} else {
			while (i > 0 && d[i - 1][j] == d[i][j]) {
				--i;
			}
			
			while (j > 0 && d[i][j - 1] == d[i][j]) {
				--j;
			}
		}
	}
	
	for (vector<char>::reverse_iterator it = ans.rbegin(); it != ans.rend(); ++it) {
		cout << (*it);
	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 35584
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {


	public static void main(String[] args) throws IOException {
		BufferedReader bf = null;
		bf = new BufferedReader(new InputStreamReader(System.in));
		int ans = 0,n,temp = 0,temph,h;
		String str;
		String[] s;
		str = bf.readLine();
		n = Integer.parseInt(str);
		str = bf.readLine();
		s = str.split(" ");
		h = Integer.parseInt(s[0]);
		for(int i = 1;i < n;++i) {
			temph = Integer.parseInt(s[i]);
			if(h >= temph) {
				temp++;
			} else {
				if(ans < temp) {
					ans = temp;
				}
				temp = 0;
			}
			h = temph;
		}
		if(ans < temp) {
			ans = temp;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 42708
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n) 
#define ALL(s) s.begin(),s.end()
bool dp[5010][10010];
int a[10]={0,2,5,5,4,5,6,3,7,6};
int main(){
	int n,m,x;vector<int>v;
	cin>>n>>m;
	rep(i,m){
		cin>>x;
		v.pb(x);
	}
	sort (ALL(v));
	reverse (ALL(v));
	memset (dp,false,sizeof(dp));
	dp[0][0]=1;
	rep(i,5005) rep(j,n+1){
		if (!dp[i][j]) continue;
		rep(k,m) dp[i+1][j+a[v[k]]]=true;
	}
	int d=0;
	rep(i,5005){
		if (dp[i][n]) d=max(d,i);
	}
	string out="";
	for (int i=d;i>0;i--){
		x=0;
		rep(j,m){
			if (dp[i-1][n-a[v[j]]]) x=max(x,v[j]); 
		}
		out+=('0'+x);
		n-=a[x];
	}
	cout<<out<<endl;
}

Measured memory_bytes: 49280
#include <stdio.h>

typedef struct{
  char name[10];
  int time;
} P;

int main(void){

  int n,q,head,tail,i,t,x;
  P pro[100000];

  scanf("%d %d",&n,&q);

  for(i=0;i<n;i++){
    scanf("%s %d",pro[i].name,&pro[i].time);
  }

  head = 0;
  tail = n;
  t = 0;
  
  while(head != tail){
    x = pro[head].time - q;
    if(x <= 0){
      t += pro[head].time;
      printf("%s %d\n",pro[head].name,t);
      if(head == 99999){
	head = 0;
      }
      else{
        head++;
      }
    }
    else{
      pro[head].time = x;
      pro[tail] = pro[head];
      t += q;
      if(tail == 99999){
	tail = 0;
      }
      else{
	tail++;
      }
      if(head == 99999){
	head = 0;
      }
      else{
	head++;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 2164
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;

int main()
{
  ll M, N;
  ll ans = 0;
  ll total = 0;
  cin >> N >> M;
  vector<ll> A(N);
  rep(i, N)
  {
    cin >> A.at(i);
    total += A.at(i);
  }
  rep(i, N)
  {
    if (4 * M* A.at(i) >= total)
    {
      ans++;
    }
  }
  if (ans >= M)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;

  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N-1);
  for(int i=0; i<N; i++) cin >> A[i];
  for(int i=0; i<N; i++) cin >> B[i];
  for(int i=0; i<N-1; i++) cin >> C[i];
  
  int ans=0;
  for(int i=0; i<N; i++) ans+=B[A[i]-1];
  for(int i=0; i<N-1; i++){
    if (A[i+1]-A[i]==1) ans+=C[A[i]-1];
  }
  cout << ans <<endl;
}

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

using namespace std;

typedef long long ll;

const ll MOD=1000000007;

int main(){
        int N, M;
        cin>>N>>M;
        vector <ll> x, y;
        for(int i=0;i<N;i++){
                ll xx;
                cin>>xx;
                x.push_back(xx);
        }
        for(int i=0;i<M;i++){
                ll yy;
                cin>>yy;
                y.push_back(yy);
        }
        ll xsum=0, ysum=0;
        for(int i=1;i<N;i++){
                xsum+=(x[i]-x[i-1])*i*(N-i);
                xsum%=MOD;
        }
        for(int i=1;i<M;i++){
                ysum+=(y[i]-y[i-1])*i*(M-i);
                ysum%=MOD;
        }
        cout<<xsum*ysum%MOD<<endl;
        return 0;
}


Measured memory_bytes: 2676
unittest
{
	assert( [ "10" ].parse.expand.solve == 5 );
	assert( [ "50" ].parse.expand.solve == 13 );
	assert( [ "10000000019" ].parse.expand.solve == 10000000018 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	return tuple( n );
}

auto solve( long n )
{
	for( auto a = cast( long ) n ^^ 0.5L; 0 < a; a-- )
	{
		if( n % a == 0 ) return ( a + n / a ) - 2;
	}
	assert( false );
}


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,a; cin>>n>>a; cout << n*n-a << endl;
	return 0;
}


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

int main() {

  while(1) {
    int x,y,s;
    cin >> x >> y >>s;
    if(x == 0 && y == 0&&s==0) break;

    int maxab = 0;
    int maxy = 0;
    for(int i=1;i<s;i++){
      int a = i*(100.0+x)/100;
      for(int j=1;j<s;j++){
	int b = j*(100.0+x)/100;
	if(a+b==s && maxab <= a+b) {
	  maxab = a+b;
	  int ya = i*(100.0+y)/100;
	  int yb = j*(100.0+y)/100;
	  if(ya+yb > maxy) maxy = ya+yb;//,cout << i << " "<<j<<endl;
	}
      }
    }
    cout << maxy<<endl;
	
  }
      
  return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int N;
        cin >> N;
        vector<int> L(N);
        rep(i, 0, N) cin >> L[i];

        sort(all(L));
        int large = L.back();
        int sum = accumulate(L.begin(), L.begin() + N - 1, 0);
        if (sum > large) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#define rep(i, n) for(int i=0; i<n; i++)

using namespace std;

int main (void) {
    int n;
    cin >> n;
    long long a[n];
    rep(i, n) cin >> a[i];

    long long minus_count = 0;
    long long total = 0;
    rep(i, n) {
        minus_count += a[i] < 0;
        a[i] = abs(a[i]);
        total += a[i];
    }
    sort(a, &a[n]);
    if (minus_count % 2) {
        total -= a[0] * 2;
    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(){
    int x, y;
    
    while(scanf("%d %d", &x, &y), x > 0 || y > 0){
        if(x > y){
            printf("%d %d\n", y, x);
        }
        
        else {
            printf("%d %d\n", x, y);
        }
    }
    
    return 0;
}


Measured memory_bytes: 2684
#include <stdio.h>
#include <limits.h>

int S[500000];
int L[250001];
int R[250001];
int cnt = 0;

void merge(int A[], int left, int mid, int right) {
	int i, j, k, n1, n2;
	n1 = mid - left;
	n2 = right - mid;

	for (i = 0; i < n1; ++i) {
		L[i] = A[left + i];
	}

	for (i = 0; i < n2; ++i) {
		R[i] = A[mid + i];
	}

	L[n1] = INT_MAX;
	R[n2] = INT_MAX;

	i = j = 0;
	for (k = left; k < right; ++k) {
		++cnt;
		if (L[i] <= R[j]) {
			A[k] = L[i];
			++i;
		} else {
			A[k] = R[j];
			++j;
		}
	}
}

void mergeSort(int A[], int left, int right) {
	int mid;
	if (left + 1 < right) {
		mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}
	
int main(void) {
	int n, i;
	
	scanf("%d", &n);

	for (i = 0; i < n; ++i) {
		scanf(" %d", &S[i]);
	}
	mergeSort(S, 0, n);

	for (i = 0; i < n; ++i) {
		if (i != n - 1) {
			printf("%d ", S[i]);
		} else {
			printf("%d\n", S[i]);
		}
	}
	printf("%d\n", cnt);
	
	return 0;
}

Measured memory_bytes: 4500
/*==============================================*\
ID:          shahidul_brur
 
Name:     Md. Shahidul Islam
Study:      CSE, BRUR
Address:  Rangpur, Bangladesh
 
 mail: shahidul.cse.brur@gmail.com
 FB  : fb.com/shahidul.brur
 Blog: shahidul-brur.blogspot.com(in Bengali),
       shahidul-brur-en.blogspot.com(in English)
\*===============================================*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

const double pi = acos(-1.0);
const double eps = 1e-6;
const int mod = (int)1e9+7;
const int maxn = (int)2e5+5;
const int logn = 20;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int a[55], n; cin>>n;
    f1(i,n) cin>>a[i];
    ll s = 0;
    f1(i,n)
    {
        f2(j,i+1,n) s+=a[i]*a[j];
    }
    cout << s;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <cmath>

using namespace std;

template<class T>
class Input {
public:
    T operator()() const {
        T v;
        cin >> v;
        return v;
    }
};

template<class U>
class Input<vector<U>> {
public:
    vector<U> operator()() const {
        Input<size_t> in{};
        auto n = in();
        return (*this)(n);
    }
    vector<U> operator()(size_t n) const {
        vector<U> v;
        v.reserve(n);
        Input<U> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in();
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class U>
class Input<vector<vector<U>>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        auto m = in();
        return (*this)(n, m);
    }
    auto operator()(size_t n, size_t m) const {
        vector<vector<U>> v;
        v.reserve(n);
        Input<vector<U>> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in(m);
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class T>
T input() {
    Input<T> i{};
    return i();
}

int main() {
    Input<size_t> in{};
    auto a = in();
    auto b = in();
    auto c = in();
    auto x = in();
    auto y = in();
    size_t d = 0;
    if (2 * c < a + b) {
        auto z = min(x, y);
        x -= z;
        y -= z;
        d += 2 * c * z;
    }
    d += min(a * x + b * y, 2 * c * max(x, y));
    cout << d << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 100000000000000009
#define MOD 1000000007
#define int long long
using P = pair<int,int>;
signed main(){
  int n;
  cin >> n;
  int ans = 0;
  int num = 10;
  while(n >= num){
    ans += n / num;
    num *= 5;
  }
  if(n % 2 == 0)  cout << ans << endl;
  else cout << 0 << endl;
}

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

using namespace std;

#include <iostream>
#include <vector>

using namespace std;

long long max(long long a, long long b) {
	if (a > b)return a;
	else return b;
}

long long n, W;
vector<long long> w, v;
vector<vector<long long>> dp;
long long dppp(long long weight, long long i);

int main() {
	cin >> n >> W;
	long long a, b;
	dp.assign(n + 1, vector<long long>(W + 1, -1));
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		w.push_back(a);
		v.push_back(b);
	}
	long long ans = dppp(W, 0);
	cout << ans << endl;
}

long long dppp(long long weight, long long i) {
	if (i == n)return 0;
	else if (dp[i][weight] != -1) {
		return dp[i][weight];
	}
	else if (w[i] > weight) {
		dp[i][weight] = dppp(weight, i + 1);
	}
	else {
		dp[i][weight] = max(dppp(weight, i + 1), dppp(weight - w[i], i + 1) + v[i]);
	}
	return dppp(weight, i);
}

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

int main()
{
    ll n,b,c;
    cin>>n>>b>>c;
    if(b==0)
    {
        cout<<0<<endl;
    }
    else
    {
        if(n>=(b+c))
        {
            //cout<<n<<" "<<b+c<<endl;
            ll temp=n/(b+c);
            ll temp2=n%(b+c);
            temp=temp*b;
            if(temp2>b)
            {
                temp+=b;
            }
            else
            {
                temp+=temp2;
            }
            cout<<temp<<endl;
        }
        else
        {
            if(n>=b)
            {
                cout<<b<<endl;
            }
            else
            {
                cout<<n<<endl;
            }
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()



int main() {
	ll a, b;
	cin >> a >> b;
	cout << (10 <= a + b ? "error" : to_string(a + b)) << endl;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> P;
#define INF 10000000000000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main()
{
	int N;
	vector<string> s;
	string tmp;
	ll ans = 0;

	cin >> N;

	rep(i, N)
	{
		cin >> tmp;
		sort(tmp.begin(), tmp.end());
		s.push_back(tmp);
	}

	sort(s.begin(), s.end());

	int k = 1;
	rep(i, N-1)
	{
		if (s[i] == s[i + 1])
		{
			ans += k;
			k++;
		}
		else
			k = 1;
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 5748
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#define DEBUG_OUT(...)  (printf(__VA_ARGS__))
#else
#define VS_ENDPAUSE()
#define DEBUG_OUT(...)
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
#define int int64

#ifndef INT8_MIN
#define INT8_MIN	(-127)
#endif
#ifndef INT8_MAX
#define INT8_MAX	( 128)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX	( 255)
#endif
#ifndef INT16_MIN
#define INT16_MIN	(-32768)
#endif
#ifndef INT16_MAX
#define INT16_MAX	( 32767)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX	( 65535)
#endif
#ifndef INT32_MIN
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#endif
#ifndef INT32_MAX
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#endif
#ifndef UINT32_MAX
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#endif
#ifndef INT64_MIN
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#endif
#ifndef INT64_MAX
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#ifndef UINT64_MAX
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int32 main(void)
{
    func();
    VS_ENDPAUSE();
    return 0;
}


void func(void)
{
//DEBUG_OUT("----\n");
    int32 K, S;
    cin >> K >> S;

    if(3*K < S){
        cout << 0 << endl;
        return;
    }
    int32 ans = 0;
    for(int32 x=0; x<=K; x++){
        if(x+K+K < S){ continue; }
        int32 end_y = min(S-x, K);
        for(int32 y=0; y<=end_y; y++){
            if(x+y+0 <= S && x+y+K >= S){
                DEBUG_OUT("x=%d  y=%d\n", x, y);
                ans++;
            }
        }
    }

    cout << ans << endl;
    
    return;
}



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

int main() {
	int n; cin >> n; stack<int> st; int temp;
	while (n != -1) {
		if (n == 0) cout << "0" << flush;
		else {
			while (n >= 1) {
				st.push(n % 4); n = n / 4; temp++;
			}
			for (int i = 0; i < temp; i++) {
				cout << st.top() << flush; st.pop();
			}
		}
		cout << endl; cin >> n; temp = 0;
	}
	return 0;
}


Measured memory_bytes: 2976
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int i,j,k,l,n,m;
  cin>>n>>m;
  if((1<=n&&n<=9)&&(1<=m&&m<=9))
     cout<<n*m;
     else
     cout<<"-1";
     return 0;
     }

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n,k;
    int i,j;
    int a[100]={};
    int change,sum;
    
    scanf("%d %d",&n,&k);
    
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<n-1;i++){
        for(j=n-1;j>i;j--){
            if(a[j]>a[j-1]){
                change=a[j];
                a[j]=a[j-1];
                a[j-1]=change;
            }
        }
    }
    sum=0;
    for(i=0;i<k;i++){
        sum = sum + a[i];
    }
    printf("%d\n",sum);
    
    return 0;
}

Measured memory_bytes: 128
// https://atcoder.jp/contests/abc171/tasks/abc171_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N;
  cin >> N;

  ll alphabet_ct = 'Z' - 'A' + 1;

  ll rest = N;
  string res_rev = "";

  while (rest > 0) {
    --rest;
    res_rev.push_back('a' + rest % alphabet_ct);

    rest /= alphabet_ct;
  }

  reverse(all(res_rev));
  cout << res_rev << "\n";
}


Measured memory_bytes: 3588
N,K=map(int,input().split())
x=list(map(int,input().split()))

# min( 左端に到達し右へ, 右端に到達し左へ)
ans=10**9
for i in range(N-K+1):
    l=abs(x[i])+abs(x[i]-x[i+K-1])
    r=abs(x[i+K-1])+abs(x[i]-x[i+K-1])
    ans=min(ans,min(l,r))
print(ans)

Measured memory_bytes: 14224
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a = ri()
b = ri()
c = ri()
x = ri()
cnt = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i*500 + j*100 + k*50 == x:
                cnt += 1
print(cnt)














Measured memory_bytes: 26784
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#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;

int main(int argc, char const *argv[]) {
  string s, t;std::cin >> s >> t;
  ll cnt = 0;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]) cnt++;
  }
  std::cout << cnt << '\n';
  return 0;
}


Measured memory_bytes: 3560
import java.util.Scanner;

public class Main {

    //https://atcoder.jp/contests/abc132/tasks/abc132_a
    public static void main( String[] args ) {

        Scanner scanner = new Scanner(System.in);

        String str = scanner.next();

        int[] arr = new int[26];
        for (int i = 0; i < 4; i++) {
            arr[str.charAt(i) - 'A']++;
        }

        int type = 0;
        for (int i = 0; i < 26; i++) {

            if (arr[i] > 0 && arr[i] == 2) {
                type++;
            }
        }

        System.out.println(type == 2 ? "Yes" : "No");
    }
}


Measured memory_bytes: 21972
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int N, M;
vint S[12],p;
int ans=0;

void calc(string str) {
	for (int i = 0; i < M; i++)
	{
		int tmp[10]={0};
		int kosu=0;
		for (int j = 0; j < str.size(); j++)
		{
			if(str[j]=='1'){
				tmp[j]++;
			}
		}
		for (int j = 0; j < S[i].size(); j++) {
			tmp[S[i][j]]++;
		}
		
		for (int j = 0; j < 10; j++) {
			if(tmp[j]==2)kosu++;
		}
		//cout<<str<<":"<<i<<":"<<kosu<<endl;
		if(kosu%2!=p[i]){
			return;
		}
	}
	ans++;
}

void subBin(string str, int n) {
	if (n == 0) calc(str);
	if (n > 0) {
		subBin(str + "0", n - 1);
		subBin(str + "1", n - 1);
	}
}

signed main() {
	


	cin >> N >> M;
	
	p.resize(M);

	for (int i = 0; i < M; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int tmp;
			cin >> tmp;
			S[i].push_back(tmp-1);
		}
	}

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

	string str = "";
	subBin(str, N);
	
	cout<<ans<<endl;
	
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N), b(N);
  rep(i, 0, N) cin >> a[i];
  rep(i, 0, N) cin >> b[i];
  int ans = 0;
  for (int dig = 29; dig > -1; dig--) {
    int high = 1 << (dig + 1);
    int low = 1 << dig;
    rep(i, 0, N) a[i] %= high;
    rep(i, 0, N) b[i] %= high;
    sort(b.begin(), b.end());
    ll num = 0;
    rep(i, 0, N) {
      int add = 0;
      if (low - a[i] >= 0) {
        add += lower_bound(b.begin(), b.end(), high - a[i]) -
               lower_bound(b.begin(), b.end(), low - a[i]);
      } else {
        add += lower_bound(b.begin(), b.end(), high - a[i]) - b.begin();
        add += lower_bound(b.begin(), b.end(), high) -
               lower_bound(b.begin(), b.end(), high + low - a[i]);
      }
      num += add;
    }
    if (num & 1) ans += low;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define uint unsigned long long
#define ll long long
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-8
#define lb(x) x & -x
#define INF 0x3f3f3f3f
#define sz(x) (x).size()
using namespace std;
inline int read()
{
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
    return x * f;
}
inline ll read1()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
using namespace std;
int n, sum;
int a[100010], b[100010];
int main()
{
	n = read();
	rep(i, 1, n) a[i] = read();
	rep(i, 1, n + 1) b[i] = abs(a[i] - a[i - 1]), sum += b[i];
	rep(i, 1, n)
        cout << sum - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]) << endl;

	return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int c = 0;
    bool y = 0;
    if (s[0] != 'A') y = 1;
    for (int i = 1; i < s.length(); i++) if (isupper(s[i])) {
        c++;
        if (s[i] != 'C') y = 1;
    }
    if (c != 1) y = 1;
    if (s[1] == 'C' || s.back() == 'C') y = 1;
    if (y) cout << "WA";
    else cout << "AC";
}


Measured memory_bytes: 256
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
ans = 0
score = {'r': p, 's': r, 'p': s}
for i in range(k):
    j = i
    while j<n:
        if j>=k and t[j]==t[j-k]:
            if j+k<n:
                ans += score[t[j+k]]
            j += 2*k
        else:
            ans += score[t[j]]
            j += k
print(ans)

Measured memory_bytes: 3444
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n=I()
count=0
anss=[]
for i in range(1,10):
    for j in range(1,10):
        anss.append(i*j)
for ans in anss:
    if ans==n:
        print("Yes")
        sys.exit()
    else:
        count+=1
if count==len(anss):
    print("No")


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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n;
	cin >> n;
	int ans = 0;
	FOR(i, 1, n + 1)
	{
		int t = i, d = 0;
		while(t)
		{
			d++;
			t /= 10;
		}
		
		ans += d & 1;
	}
	cout << ans;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  string s;
  cin >> s;
  cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#B - Counting Roads
N,M = map(int,input().split())
a = []
b = []
for _ in range(M):
    ai,bi = map(int,input().split())
    a.append(ai)
    b.append(bi)
start = a + b
count = [0]*N
for i in range(len(start)):
    count[start[i]-1] += 1
    
for o in range(N):
    print(count[o])

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

int main(){
  int n;
  long sum=0;
  cin >> n;
  vector<int> vec(n*3);
  for(int i=0; i<n*3; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  
  for(int i=1; i<n*2; i += 2){
    sum += vec.at(i);
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;

int main(){
    char a[4];
    REP(i, 4){
        cin >> a[i];
    }
    sort(a, a+4);

    if(a[1] == a[2]){
        cout << "No" << endl;
        return 0;
    }
    if(a[0] == a[1] && a[2] == a[3]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    int cmax0 = -2001001001;
    int cmin0 = 2001001001;
    int cmax1 = -2001001001;
    int cmin1 = 2001001001;
    
    rep(i,n){
        int x,y;
        cin >> x >> y;
        cmax0 = max(x-y, cmax0);
        cmin0 = min(x-y, cmin0);
        cmax1 = max(x+y, cmax1);
        cmin1 = min(x+y, cmin1);
    }

    cout << max(cmax0 - cmin0, cmax1 - cmin1) << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a,long long b){
    long long c;
    while(b != 0){
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}

int main(){
    int N;
    long long X;
    cin >> N;
    vector<long long> x;
    x.resize(N+1);
    for(int i=0;i<N+1;i++){
        cin >> x[i];
    }
    sort(x.begin(),x.end());
    for(int i=0;i< N;i++){
        x[i] = x[i+1] -x[i];
    }
    long d=x[0];
    for(int i=0;i<N;i++){
        d = gcd(d,x[i]);
    }
    cout << d << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;
typedef long long ll;
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define CHMIN(a,b) (a) = min((a),(b))
#define CHMAX(a,b) (a) = max((a),(b))

int main()
{
    long long int n;
    scanf("%lld",&n);
    int ans=0;
    while(n>1)
    {
        n=n/3+(n%3!=0);
        ans++;
    }
    printf("%d\n",ans);
    return 0;
}


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


int main(){

    int n;
    cin>>n;
    string s;
    cin>>s;

    if(n%2==1){

       cout<<"No"<<endl;
       return 0;
    }
    string a,b;
    for(int i=0;i<n;i++){

       if(i<n/2)a+=s[i];
       else b+=s[i];
    }


    if(a==b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
<?php

$n = trim(fgets(STDIN));
$histgram = array(
	'1:' => 0,
	'2:' => 0,
	'3:' => 0,
	'4:' => 0,
	'5:' => 0,
	'6:' => 0,
);
for ($i = 0; $i < $n; $i++) {
	$h = trim(fgets(STDIN));
	if ($h < 165.0) {
		$histgram['1:']++;
	} elseif ($h < 170.0) {
		$histgram['2:']++;
	} elseif ($h < 175.0) {
		$histgram['3:']++;
	} elseif ($h < 180.0) {
		$histgram['4:']++;
	} elseif ($h < 185.0) {
		$histgram['5:']++;
	} else {
		$histgram['6:']++;
	}
}

foreach ($histgram as $k => $v) {
	echo $k;
	for ($i = 0; $i < $v; $i++) {
		echo '*';
	}
	echo "\n";
}

Measured memory_bytes: 6580
# https://betrue12.hateblo.jp/entry/2019/06/06/214607

N = int(input())
AB = (map(int, input().split()) for _ in range(N))

INF = 10 ** 9 + 10
s = 0
last = INF
for a, b in AB:
    if a > b:
        last = min(last, b)
    s += b

if last == INF:
    print(0)
else:
    print(s - last)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;

int tc(ll n) {
  ll c = 0;
  while(n%2 == 0) {
    ++c;
    n /= 2;
  }
  return c;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  rep(i,n) {
    cin >> a[i];
    a[i] /= 2;
  }
  ll ans = a[n-1];
  rep(i,n-1) {
    ans = lcm(ans,a[i]);
  }
  ll t = tc(a[n-1]);
  rep(i,n-1) {
    if (t != tc(a[i])) {
      cout << 0 << '\n';
      return 0;
    }
  }
  cout << m/ans - m/(ans*2)<< '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 4048
#!/usr/bin/ruby
$unit=["","Man","Oku","Cho","Kei","Gai","Jo","Jou","Ko","Kan","Sei","Sai","Gok","Ggs","Asg","Nyt","Fks","Mts"]
def _print(x,d)
	if d<$unit.size
		_print(x/10000,d+1)
		v=x%10000
		$><<'%d%s'%[v,$unit[d]] if v>0
	end
end
while(m,n=gets.split.map(&:to_i))!=[0,0]
	m=m**n
	_print(m,0)
	puts
end

Measured memory_bytes: 6144
#include<cstdio>
const int N=2e5+7;
int in[N],out[N],fa[N],n,h;
bool vis[N];
inline int find(int x){while(x!=fa[x])x=fa[x]=fa[fa[x]];return x;}
int main(){
	scanf("%d%d",&n,&h);
	for(int i=0;i<=2*h;++i)fa[i]=i;
	for(int i=1;i<=n;++i){
		int A,B,C,D;
		scanf("%d%d%d%d",&A,&B,&C,&D);
		int iL=C==0?A:-C,iR=D==0?-B:D;
		++in[iL+=h],++out[iR+=h];
		if(find(iL)!=find(iR))fa[fa[iL]]=fa[iR];
	}
	bool ok=1;
	for(int i=0;i<=2*h&&ok;++i)
	if(in[i]||out[i]){
		if(i<=h&&in[i]>out[i])ok=0;
		if(i>h&&in[i]<out[i])ok=0;
		if(in[i]!=out[i])vis[find(i)]=1;
	}
	for(int i=0;i<=2*h&&ok;++i)
	if(in[i]||out[i])if(!vis[find(i)])ok=0;
	puts(ok?"YES":"NO");
	return 0;
}

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    int A,B,ans;
    cin >> A >> B;
    ans=A-2*B;
    if(ans<=0){
        P(0);
    }else{
        P(ans);
    }
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define MOD ((int)(1e9) + 7)
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define filename "lynext"
#define freop freopen(filename ".cik","w",stdout);freopen(filename ".gir","r",stdin)
const long long int N = ((long long int)1e2) + 5;
const long long int M = ((long long int)1e5) + 5;
const long long int llinf = (long long int)1e18;
const int inf = INT_MAX;
typedef long long int lli;

lli n;
lli W;
lli weight[N];
lli value[N];

lli dp[N][M];

lli f(lli i, lli curw)
{
	if (curw > W)
			return -llinf;
	if (i > n)
		return 0;
	if (dp[i][curw] != -1)
		return dp[i][curw];
	lli t1 = f(i + 1,curw + weight[i]) + value[i];
	lli t2 = f(i + 1,curw);
	return dp[i][curw] = max(t1,t2);
}

int main ()
{
	fast;
	//freop;
	cin >> n >> W;
	memset(dp, -1, sizeof dp);
	for (int i = 1; i <= n; i++)
	{
		lli a,b;
		cin >> a >> b;
		weight[i] = a;
		value[i] = b;
	}
	cout << f(1,0) << "\n";
}


Measured memory_bytes: 82304
#include<bits/stdc++.h>
using namespace std;
int dp[3003][6003],n,t;
pair<int,int>a[3003];
int main(){
	cin>>n>>t;
	for(int i=0;i<n;i++)cin>>a[i].first>>a[i].second;
	sort(a,a+n);
	dp[0][0]=0;dp[0][a[0].first]=a[0].second;
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<t;j++)dp[i][j+a[i].first]=dp[i-1][j]+a[i].second;
		for(int j=0;j<6003;j++)dp[i][j]=max(dp[i][j],dp[i-1][j]);
	}
	int ans=0;
	for(int i=0;i<6003;i++)ans=max(ans,dp[n-1][i]);
	cout<<ans;
}

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

int main() {
    string a,b;
    cin>>a>>b;
    int ans=0;
    for(int i=0;i<int(a.length());i++){
        if(a[i]!=b[i])ans++;
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 3896
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W = MAP()
a = [input() for _ in range(H)]
cnt = defaultdict(int)
for l in a:
	for s in l:
		cnt[s] += 1

l = sorted(list(cnt.values()), reverse=True)
if H%2==0 and W%2==0:
	for v in cnt.values():
		if v%4 != 0:
			print("No")
			break
	else:
		print("Yes")
elif H%2==0 and W%2==1:
	tmp = (W-1)*H//4
	if tmp:
		for i in range(len(l)):
			if l[i] >= 4:
				take = l[i]//4
				if tmp - take > 0:
					l[i] -= 4*take
					tmp -= take
				else:  # 取りきった
					l[i] -= 4*tmp
					tmp = 0
					break	
		else:
			print("No")
			exit()
	for v in l:
		if v%2 != 0:
			print("No")
			break
	else:
		print("Yes")
elif H%2==1 and W%2==0:
	tmp = (H-1)*W//4
	if tmp:
		for i in range(len(l)):
			if l[i] >= 4:
				take = l[i]//4
				if tmp - take > 0:
					l[i] -= 4*take
					tmp -= take
				else:  # 取りきった
					l[i] -= 4*tmp
					tmp = 0
					break	
		else:
			print("No")
			exit()
	for v in l:
		if v%2 != 0:
			print("No")
			break
	else:
		print("Yes")
else:
	tmp = (H-1)*(W-1)//4
	if tmp:
		for i in range(len(l)):
			if l[i] >= 4:
				take = l[i]//4
				if tmp - take > 0:
					l[i] -= 4*take
					tmp -= take
				else:  # 取りきった
					l[i] -= 4*tmp
					tmp = 0
					break	
		else:
			print("No")
			exit()
	odd = 0
	for v in l:
		if v%2 == 1:
			odd += 1
	print("Yes" if odd == 1 else "No")


Measured memory_bytes: 5216
N = int(input())
*h,=map(int,input().split())
dp=[0]*(N)
dp[0] = 0
dp[1] = abs(h[1]-h[0])

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

Measured memory_bytes: 20492
#include <bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)


void solve(long long N, std::vector<long double> v){
  sort(v.begin(),v.end());
  for(int i=N-1;i>0;i--){
    for(int j=0;j<=i;j++){
      v[j]/=2;
    }
  }
  cout<<fixed<<setprecision(14)<<accumulate(v.begin(),v.end(),0.0l)<<endl;
}

int main(){
  long long N; cin>>N;
  std::vector<long double> v(N);
  REP(i,N)cin>>v[i];
  solve(N, std::move(v));
  return 0;
}


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

#define f(i,a,b) for( ll i = a; i <(ll) b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)

// policy-based
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;	


using namespace std;
using namespace atcoder;

typedef long long ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

/*
typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
 
const ll MAX = 2e7 ;
const ll inf = 1e18;
const ll mod = 1e9 + 7;

int main(){
	fastio;	
//	ll n,a,b;
//	cin >> n;
	ll n;
	f(tc,1,2){
		cin >> n;
		ll ans = (n&1?n-1:2*n -1);
		if(n == 1){
			cout << "1\n";
		} 
		else{
		 	n*=2;
	
			for(ll i=1; i*i<=n;i++){
				if(n%i == 0 && __gcd(i,n/i) == 1){
					ii aux;

					aux = crt({0LL,n/i -1},{i,n/i});
					ans = min(ans,aux.ff);
					if(aux.ff == 0) ans = min(ans,aux.ff + aux.ss); 
					else ans = min(ans,aux.ff);	
					if(i == 1) continue;
					aux = crt({0LL,i-1},{n/i,i});
					if(aux.ff == 0) ans = min(ans,aux.ff + aux.ss); 
					else ans = min(ans,aux.ff);		
				
			
				}
			}

			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 3684