akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
long long n, m, mod = 1000000007;
 
long long mulmod(long long a, long long b, long long m) {
    long long res = 0;
    while(b > 0) {
       if(b % 2 == 1) res = (res+a)%m;
       a = (a*2)%m;
       b /= 2;
    }
    return res % m;
}
 
long long fac(long long x){
	if(x == 1) return 1;
	return mulmod(fac(x-1), x, mod);
}
 
int main(){
	cin >> n >> m;
	if(abs(n-m) > 1){
		cout << 0;
		return 0;
	}
	if(n == m) cout << mulmod(mulmod(fac(n), fac(m), mod), 2, mod);
	else cout << mulmod(fac(n), fac(m), mod);
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
    int N; cin >> N;
    int mod = 1000000007;

    vector<bool> tmp_table(N+1, true);
    vector<int> prime_table;
    for(int i=2; i<=N; i++){
        if(tmp_table[i]){
            prime_table.push_back(i);
            int j = 2*i;
            while(j <= N){
                tmp_table[j] = false;
                j += i;
            }
        }
    }


    ll ans = 1;
    for(int i=0; i<prime_table.size(); i++){
        int prime = prime_table[i];
        int cnt = 0;
        for(int j=2; j<=N; j++){
            int tmp = j;
            while(tmp%prime == 0){
                cnt++;
                tmp /= prime;
            }
        }
        ans = ans * (cnt+1) % mod;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main() {
    int N, a, b, K = 0;
    cin >> N;
    P edge[N-1];
    vector<int> G[N];
    for (int i = 0; i < N - 1; i++) {
        cin >> a >> b;
        a--; b--;
        edge[i] = P(a, b);
        G[a].push_back(b);
        G[b].push_back(a);
    }

    map<P, int> mp;
    int used_color[N] = {};
    bool used[N] = {};
    queue<int> que;
    que.push(0);
    used[0] = true;
    while (!que.empty()) {
        int v = que.front(); que.pop();
        K = max(K, (int)G[v].size());
        int cur = 1;
        for (int u: G[v]) {
            if (used[u]) continue;
            if (cur == used_color[v]) cur++;
            used_color[u] = mp[P(u, v)] = mp[P(v, u)] = cur++;
            used[u] = true;
            que.push(u);
        }
    }

    cout << K << endl;
    for (auto p: edge) {
        cout << mp[p] << endl;
    }
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1000000007;

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, q, x, K;
string s,t;

// <------------- Implement Functions Here ----------> //

// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n;
	vll a(n),b(n),c(n);

	for(ll i=0;i<n;i++) cin>>a[i];
	for(ll i=0;i<n;i++) cin>>b[i];
	for(ll i=0;i<n;i++) cin>>c[i];

	ll ans = 0;
	sort(all(a));
	sort(all(c));

	for(ll i=0;i<n;i++) {

		ll val = b[i];
		ll prod = 1;
		ll l = -1, r = n-1;
		ll m;

		while(l < r) {
			m = (l+r + 1)/2;

			if(a[m] < val) {
				l = m;
			}
			else {
				r = m-1;
			}
		}

		prod*=(l+1);

		l=0,r= n;

		while(l < r) {
			m = (l+r)/2;

			if(c[m] > val) {
				r = m;
			}
			else {
				l = m+1;
			}
		}

		prod*= (n-l);

		ans+=prod;
	}

	cout<<ans;

}


int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


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

int main() {
	int a, b;
	while(1){
		cin >> a >> b;
		if (a == 0 && b == 0) {
			break;
		}
		for(int y = 0 ; y < a ; y++){
			for (int x = 0 ; x < b ; x++){
				if (x == 0 || x == b-1 || y == 0 || y == a -1){
					cout << "#";
				}else{
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define N 100009
using namespace std;
 
int n,a[N],b[N];
int main()
{
	scanf("%d",&n);
	for (int i=1; i<=n; i++) scanf("%d%d",&a[i],&b[i]);
	n++;
	sort(a+1,a+n+1); sort(b+1,b+n+1);
	long long ans=0;
	for (int i=1; i<=n; i++) ans+=max(0,a[n-i+1]-b[i]);
	printf("%lld\n",ans*2); 
	return 0;
}

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

#define LL long long

LL h, w;

LL coba(LL a, LL ch, LL cw){
	LL nch = (ch+1)/2;
	LL mx = a, mn = a;
	mx = max(mx, nch*cw);
	mn = min(mn, nch*cw);
	nch = ch/2;
	mx = max(mx, nch*cw);
	mn = min(mn, nch*cw);
	return mx-mn;
}

int main(){
	scanf("%lld%lld",&h,&w);
	LL ans = 1000000000000ll;
	for(int i = 0; i <= h; i++ ){
		ans = min(ans,coba(w*i,h-i,w));
		ans = min(ans,coba(w*i,w,h-i));
	}
	for(int i = 0; i <= w; i++ ){
		ans = min(ans,coba(h*i,h,w-i));
		ans = min(ans,coba(h*i,w-i,h));
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   string s;
   cin >> s;
   bool isbad = false;
   rep(i, 0, s.size() - 1) {
      if (s[i] == s[i + 1]) isbad = true;
   }
   if (isbad)
      cout << "Bad" << endl;
   else
      cout << "Good" << endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(auto i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
const ll INF = ~(1<<31);
#define fs first
#define sc second
#define pb push_back

const double EPS = 1e-9;
const double pi = acos(-1);
typedef unsigned long long ull;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
template <class T> T smod(T a, T b) {
    return (a % b + b) % b;
}

string s;
ll d;
ll memo[10'050][2][101];
ll md = 1000000000+7;

ll dp(ll at, ll same, ll sum) {
    if(at >= s.size()) {
        return sum == 0;
    }
    if(memo[at][same][sum] != -1) {
        return memo[at][same][sum];
    }
    ll cnt = 0;
    if(!same) {
        rep(i,0,10) {
            cnt += dp(at+1, 0, (sum+i)%d);
            cnt %= md;
        }
    } else {
        rep(i,0,s[at]-'0'+1) {
            cnt += dp(at+1, i == s[at]-'0', (sum+i)%d);
            cnt %= md;
        }
    }
    return memo[at][same][sum] = cnt;
}

int main() {
    cin.sync_with_stdio(false);
    memset(memo,-1,sizeof(memo));
    cin >> s >> d;
    cout << (dp(0,1,0)-1+md)%md << endl;
    return 0;
}



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

ll modinv(ll a,ll m){
   ll b=m,u=1,v=0;
   while(b){
      ll t=a/b;
      a-=t*b; 
      swap(a,b);
      u-=t*v; 
      swap(u,v);
   }
   u%=m;
   if(u<0) u+=m;
   return u;
}

ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}



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

  int n=s.size();

  if(n<=k) cout<<s;
  else{
     string x=s.substr(0,k);
     cout<<x<<"...";
  }
   return 0;
}



Measured memory_bytes: 3628
import java.util.*;

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

Measured memory_bytes: 25832
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        int nagasa = sc.next().toString().length();
        for (int i = 0; i < nagasa; i++) {
            sb.append("x");
        }
        System.out.println(sb);
    }
}


Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s = scan.next();
        char[] data = s.toCharArray();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i * 2 < data.length; i++) {
            sb.append(data[i*2]);
        }
        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 25940
N = int(input())
l = []
ans = 0
for i in range(2):
    row = list(map(int,input().split()))
    l.append(row)
for q in range(N):
    candy_get = sum(l[0][0:q+1])+sum(l[1][q:])
    ans = max(ans,candy_get)
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    string s[a];
    int i,j;
    for(i=0;i<a;i++)
        cin>>s[i];
    for(i=0;i<b+2;i++)
        cout<<"#";
    cout<<endl;
    for(i=0;i<a;i++)
    {
        cout<<"#"<<s[i]<<"#"<<endl;
    }
     for(i=0;i<b+2;i++)
        cout<<"#";
    cout<<endl;
    return 0;
}


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

int main() {
	int N; cin >> N;
	unsigned long long int H[N];
	unsigned long long int Max;
  
	for (int i = 0; i < N; ++i) {
    	cin >> H[i];
    }
	if (N == 1) {
    	cout << "Yes" << endl;
    	return 0;
    }
	Max = 1;
      
	for (int i = 1; i < N; ++i) {
    	if (H[i-1] > H[i]) {
        	if (H[i-1] - H[i] > 1 || Max - H[i] > 1) {
            	cout << "No" << endl;
            	return 0;
            }
        
        }
    	if (Max < H[i]) {
        	Max = H[i];
        }
    }
	cout << "Yes" << endl;
}

Measured memory_bytes: 1024
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF (int)(1e9+10)
#define LLINF (lint)(1e18+10)

using namespace std;

int main(){
    int h, w;
    cin >> h >> w;
    vector< vector<char> > a(h+2);
    rep(i, h+2){
        a[i].resize(w+2, '.');
    }
    REP(i, 1, h+1){
        REP(j, 1, w+1){
            cin >> a[i][j];
        }
    }
    int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
    queue< pair<int, int> > que;
    que.push(make_pair(1, 1));
    string ans = "Possible";
    while(!que.empty()){
        pair<int, int> tmp = que.front();
        que.pop();
        int cnt = 0;
        rep(i, 2){
            if(a[tmp.first+dy[i]][tmp.second+dx[i]] == '#'){
                que.push(make_pair(tmp.first+dy[i], tmp.second+dx[i]));
                cnt++;
            }
        }
        REP(i, 2, 4){
            if(a[tmp.first+dy[i]][tmp.second+dx[i]] == '#'){
                cnt = 2;
            }
        }
        if(cnt >= 2){
            ans = "Impossible";
            break;
        }
        a[tmp.first][tmp.second] = '.';
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,i,j,k,x[101],y[101];
double r,d[205],P=acos(-1);
main(){
	cin>>n;++m=i=n;
	while(m--)cin>>x[m]>>y[m];
	while(i--){
		j=k=r=0;
		for(;j<n;j++)if(i-j)d[k++]=atan2(y[j]-y[i],x[j]-x[i]);
		sort(d,d+k);
		for(j=0;j<k;j++)d[j+k]=d[j]+2*P;
		for(j=0;j<k;j++)r=max(r,P-d[j+k-1]+d[j]);
		cout<<r/2./P<<'\n';
	}
}

Measured memory_bytes: 640
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto a = readln.chomp;
  auto b = readln.chomp;
  auto s = max(a.length, b.length);
  auto a2 = a.rightJustify(s, '0');
  auto b2 = b.rightJustify(s, '0');

  if (a2 == b2)
    writeln("EQUAL");
  else if (a2 < b2)
    writeln("LESS");
  else
    writeln("GREATER");
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  int vy[4] = {0, -1, 0, 1};
  int vx[4] = {-1, 0, 1, 0};
  int N;
  while(cin >> N, N) {
    int y[N], x[N];
    y[0] = x[0] = 0;
    FOR(i,1,N) {
      int n, d;
      cin >> n >> d;
      y[i] = y[n] + vy[d];
      x[i] = x[n] + vx[d];
    }
    sort(x, x + N);
    sort(y, y + N);
    cout << x[N-1] - x[0] + 1 << " " << y[N-1] - y[0] + 1 << endl;
   }
   return 0;
}

Measured memory_bytes: 3168
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
	double ax,ay,bx,by,cx,cy,dx,dy;
	while(cin >>ax >> ay >> bx >> by >> cx >> cy >> dx >> dy) {
	if ((bx<cx) || (dx<ax) || (by<cy) || (dy<ay)) cout << "NO" << endl; else cout << "YES" << endl;
	}
	return 0;
}

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


int main() 
{ 
    ios_base::sync_with_stdio(0) ;
    cin.tie(0); cout.tie(0) ;
    
    int a, b ;
    cin >> a >> b ;
    int d = 0,p=1 ;
    while( p < b )
    {
    	p--;
    	d++;
		p+=a; 
	}
    cout << d ;
    return 0; 
}  

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();
            var d = cin.nextInt();
            var x = cin.nextInt();
            var a = cin.ArrayInt(n);

            var ans = 0;
            foreach (var item in a)
            {
                ans += (d-1) / (item);
            }

            Console.WriteLine(ans+x+n);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 11092
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    lint A,B,N;
    cin >> A >> B >> N;
    lint rem=N%B;
    lint maxi;
    if(rem==B-1) maxi=N;
    else maxi=N-rem-1;
    if(maxi<0) maxi=N;
    lint ans=floor((double)(A*maxi)/B)-A*floor((double)maxi/B);
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    long a, b, c;
    cin >> a >> b >> c;
    long ab = a*b, bc = b*c, ca = c*a;
    if(a%2 == 1 && b%2 == 1 & c%2 == 1){
        long ans = min(min(ab, bc), ca);
        cout << ans << endl;
    }else{
        cout << "0" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n, q = gets.split.map(&:to_i)
str  = gets.chomp.chars
cnt  = Array.new(n, 0)

(n - 1).times do |i|
  if [str[i], str[i + 1]] == ['A', 'C']
    cnt[i + 1] = cnt[i] + 1
  else
    cnt[i + 1] = cnt[i]
  end
end

q.times do
  l, r = gets.split.map(&:to_i)
  puts cnt[r - 1] - cnt[l - 1]
end


Measured memory_bytes: 10876
#include<stdio.h>
#include <iostream>
#include <string.h>
#include <cstdlib>

using namespace std;

#define BUF_SIZE 1024

struct Node{
	int data;
	Node* prev;
	Node* next;
};

class ConnectedList{
public:
	ConnectedList(){
		motherNode = new Node();
		motherNode->data = -1;
		motherNode->prev = motherNode;	
		motherNode->next = motherNode;
	};
	~ConnectedList(){
		Node* tmpNode = motherNode->next;
		Node* nextNode;
		while(tmpNode != motherNode){
			nextNode = tmpNode->next;
			delete tmpNode;
			tmpNode = nextNode;
		}
		delete motherNode;
	};
	void insertNode(int x){
		Node* tmpNode = motherNode->next;
		motherNode->next = new Node();
		motherNode->next->data = x;
		motherNode->next->next = tmpNode;
		motherNode->next->prev = motherNode;
		tmpNode->prev = motherNode->next;
	};
	void deleteNode(int x){
		Node* tmpNode = motherNode->next;
		while(tmpNode != motherNode && tmpNode->data != x){
			tmpNode = tmpNode->next;
		}
		if(tmpNode != motherNode){	
			tmpNode->prev->next = tmpNode->next;
			tmpNode->next->prev = tmpNode->prev;
			delete tmpNode;
		}
	};

	void deleteFirst(){
		Node* tmpNode = motherNode->next;
		motherNode->next = motherNode->next->next;
		motherNode->next->prev = motherNode;
		delete tmpNode;	
	};

	void deleteLast(){
		Node* tmpNode = motherNode->prev;
		motherNode->prev = motherNode->prev->prev;
		motherNode->prev->next = motherNode;
		delete tmpNode; 
	};

	void showList(){
		Node* tmpNode = motherNode->next;
		printf("%d",tmpNode->data);
		tmpNode = tmpNode->next;
		while(tmpNode != motherNode){
			printf(" %d",tmpNode->data);
			tmpNode = tmpNode->next;
		}
		printf("\n");
	}

private:
	Node* motherNode;
};


int main(){

	char buf[BUF_SIZE];
	int n = atoi(fgets(buf,BUF_SIZE,stdin));

	ConnectedList list;

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

		fgets(buf,BUF_SIZE,stdin);

		if(buf[6] == 'F'){
			list.deleteFirst();
		}else if(buf[6] == 'L'){
			list.deleteLast();
		}else{
			int S = 0;
			
			if(buf[0] == 'i'){	//insert x

				for(int i = 0; buf[i] != '\0';i++){
					if(buf[i] >= '0' && buf[i] <= '9'){
						S = 10*S + (buf[i] - '0');
					}
				}
				list.insertNode(S);
			}else{	
				for(int i = 0;buf[i] != '\0';i++){
					if(buf[i] >= '0' && buf[i] <= '9'){
						S = 10*S + (buf[i] - '0');
					}
				}
				list.deleteNode(S);
			}

		}

	}

	list.showList();

}


Measured memory_bytes: 34344
//
//  main.cpp
//  B - Bite Eating
//
//  Created by Hashizo on 2019/06/22.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>

using namespace std;

#undef INT_MAX
#undef INT_MIN

#define INT_MAX	2147483647
#define INT_MIN	(-INT_MAX  -1)

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define REPLACE(s, f, t) regex_replace(s, regex(f), t)

int main(int argc, const char * argv[]) {
	int n,l;
	cin >> n >> l;

	int taste = 0;
	int min = INT_MAX;
	int tmin = 0;
	
	REP(i,n){
		taste += i + l;
		if(min >= abs(i + l)) {
			min = abs(i + l);
			tmin = i + l;
		}
		
	}
	
	
	
	taste -= tmin;
	cout << taste << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			int a = sc.nextInt();
			String op = sc.next();
			int b = sc.nextInt();

			if (op.equals("+")) {
				System.out.println(a + b);
			} else {
				System.out.println(a - b);
			}

		} finally {
			sc.close();
		}
	}
}

Measured memory_bytes: 22996
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
a,b,c,d=map(int,input().split())
a-=1
bIka=b-b//c-b//d+b//(c*d//gcd(c,d))
aMiman=a-a//c-a//d+a//(c*d//gcd(c,d))
print(bIka-aMiman)

Measured memory_bytes: 3060
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
  
    int n;
    cin>>n;
    
    if(n/1000!=(n%1000)/100 && (n%100)/10!=n%10){
        cout<<"No"<<endl;
        return 0;
    }else{
        if((n%1000)/100==(n%100)/10){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
    
    return 0;
}







Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    class P
    {
        public int index;
        public List<int> ad;
        public Dictionary<int, int> weights;
        public int Weight;
        public P(int index)
        {
            this.index = index;
            ad = new List<int>();
            weights = new Dictionary<int, int>();
        }
    }
    static void Main(string[] args)
    {
        var nmr = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var r = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var ps = new P[nmr[0]];
        for (var i = 0; i < nmr[0]; i++)
            ps[i] = new P(i);
        for(var i = 0; i < nmr[1]; i++)
        {
            var input = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
            for(var j = 0; j < 2; j++)
            {
                ps[input[j] - 1].ad.Add(input[(j + 1) % 2] - 1);
                ps[input[j] - 1].weights[input[(j + 1) % 2] - 1] = input[2];
            }
        }
        var fromto = new int[nmr[0], nmr[0]];
        for(var i = 0; i < nmr[0]; i++)
        {
            Init(ps, i);
            var set = new HashSet<int>();
            while (true)
            {
                var minVal = int.MaxValue;
                var u = new P(-1);
                for(var j = 0; j < nmr[0]; j++)
                {
                    if (!set.Contains(j) && minVal > ps[j].Weight)
                    {
                        minVal = ps[j].Weight;
                        u = ps[j];
                    }
                }

                if (minVal == int.MaxValue) break;
                set.Add(u.index);

                foreach (var ad in u.ad)
                {
                    if (!set.Contains(ad) && ps[ad].Weight > u.Weight + u.weights[ad])
                    {
                        ps[ad].Weight = u.Weight + u.weights[ad];
                    }
                }
            }
            for (var j = 0; j < nmr[0]; j++)
                fromto[i, j] = ps[j].Weight;
        }
        var min = int.MaxValue;
        for (var i = 0; i < r.Length; i++)
            min = Min(min, dfs(fromto, r, new HashSet<int>(), i));
        WriteLine(min);
    }
    private static int dfs(int[,] fromto,int[] rs,HashSet<int> set,int index)
    {
        set.Add(rs[index]);
        if (set.Count == rs.Length)
        {
            set.Remove(rs[index]);
            return 0;
        }
        var min = int.MaxValue;
        for(var i = 0; i < rs.Length; i++)
        {
            if (!set.Contains(rs[i]))
                min = Min(min, dfs(fromto, rs, set, i)+fromto[rs[index]-1,rs[i]-1]);
        }
        set.Remove(rs[index]);
        return min;
    }
    private static void Init(P[] ps,int index)
    {
        for (var i = 0; i < ps.Length; i++)
            ps[i].Weight = int.MaxValue;
        ps[index].Weight = 0;
    }
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

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

  int ans = n % 500;
  cout << (ans - a <= 0 ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
def cc143
    n = gets.chomp.to_i
    s = gets.chomp#.split(/\s/).map{|x| x.to_i}

    cnt = 0
    bc = nil
    s.each_char do |c|
        unless bc == c
            bc = c
            cnt += 1
        end
    end

    puts cnt
end

cc143

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

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

	int start = 0;
	int end = s.size();
	while (end - start >= 10) {
		string x = s.substr(start, 10);
		if (x == "dreamdream" || x == "dreamerase") start += 5;
		else if (x == "dreamerdre" || x == "dreamerera") start += 7;
		else if (x == "erasedream" || x == "eraseerase") start += 5;
		else if (x == "eraserdrea" || x == "erasereras") start += 6;
		else {
			cout << "NO";
			return 0;
		}
	}
	string z = s.substr(start);
	if (z == "dream" || z == "dreamer" || z == "erase" || z == "eraser") cout << "YES";
	else cout << "NO";
	return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

using PDI = pair<double, int32>;

const int64 mod = 1e9+7;

int main(void){
	int64 A, B, C;
	cin >> A >> B >> C;
	int64 k;
	cin >> k;
	cout << A+B+C-max({A, B, C})+(max({A, B, C}) << k) << endl;
}

Measured memory_bytes: 256
import sys
import bisect
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    A = sorted(map(int, input().split()))
    B = sorted(map(int, input().split()))
    C = sorted(map(int, input().split()))

    ans = 0
    for b in B:
        ans += bisect.bisect_left(A, b) * (N - bisect.bisect_right(C, b))
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 22720
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

char s[100];
int main() {
  int n;
  scanf("%d", &n);
  vector<vector<int>> a;
  vector<int> cnt(26);
  for (int i = 0; i < n; ++i) {
    scanf("%s", s);
    fill(cnt.begin(), cnt.end(), 0);
    for (int k = 0; s[k]; ++k) {
      cnt[s[k] - 'a']++;
    }
    a.push_back(cnt);
  }
  sort(a.begin(), a.end());
  int64 ret = 0;
  for (int i = 0, j; i < n; i = j) {
    for (j = i + 1; j < n && a[j] == a[i]; ++j);
    int64 len = j - i;
    ret += len * (len - 1) / 2;
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 14128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            int[] b = new int[n];
            for (int i = 0; i < n; ++i) {
                a[i] = in.nextInt();
            }
            for (int i = 0; i < n; ++i) {
                b[i] = in.nextInt();
            }
            long res = (1L << 52) - 1;
            if (!possible(res, n, a, b)) {
                out.println(-1);
                return;
            }
            for (int k = 51; k >= 0; --k) {
                res ^= 1L << k;
                if (!possible(res, n, a, b)) {
                    res ^= 1L << k;
                }
            }
            out.println(res);
        }

        private boolean possible(long allowed, int n, int[] a, int[] b) {
            boolean[][] can = new boolean[51][51];
            for (int i = 0; i <= 50; ++i) can[i][i] = true;
            for (int k = 1; k <= 51; ++k)
                if ((allowed & (1L << k)) != 0) {
                    boolean[][] ncan = new boolean[51][51];
                    for (int old = 0; old <= 50; ++old) {
                        for (int nxt = 0; nxt <= 50; ++nxt) {
                            ncan[old][nxt] |= can[old][nxt];
                            ncan[old][nxt] |= can[old % k][nxt];
                        }
                    }
                    can = ncan;
                }
            for (int i = 0; i < n; ++i) if (!can[a[i]][b[i]]) return false;
            return true;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 29524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,W; cin >> N >> W;
    vector<int> v(N),w(N);
    rep(i,N) cin >> v[i] >> w[i];
    vector<int> dp(W+1,0);
    rep(i,N) for (int j=W;j>=w[i];--j){
        chmax(dp[j],dp[j-w[i]]+v[i]);
    }
    cout << dp[W] << endl;
}


Measured memory_bytes: 3252
#include <iostream>
#include <deque>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  deque<long long> a(3*n);
  for(auto& x: a){
    cin >> x;
  }
  sort(a.begin(), a.end());
  long long ans = 0;
  for(int i = 0; i < n; i++){
    a.pop_front();
    a.pop_back();
    ans += a.back();
    a.pop_back();
  }
  cout << ans << endl;
}


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

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

    int maxr = -1000000005;
    int minr = r[0];
    for(int i = 1; i < n; i++){
        maxr = max(maxr, r[i] - minr);
        minr = min(minr, r[i]);
    }
    cout << maxr << endl;

    return 0;
}


Measured memory_bytes: 3624
N = gets.strip.to_i
H = gets.strip.split(' ').map(&:to_i)
longest = 0
streak = 0
(0..N-2).each do |i|
  if H[i] >= H[i+1]
    streak += 1
  else
    if longest < streak
      longest = streak
    end
    streak = 0
  end
end
longest = streak if longest < streak
puts longest

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 998244353;
const int maxn = 400;
const int maxa = 300*300 + 400;

int n;
int a[maxn];

ll dp1[maxn][maxa];
ll dp2[maxn][maxa];

void push(ll &x, ll y) {
    x %= mod;
    y %= mod;
    x += y;
    x %= mod;
}

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

    int s = 0;

    cin>>n;
    for (int i=0; i<n; i++) {
	cin>>a[i];
	s += a[i];
    }

    dp1[0][0] = dp2[0][0] = 1;

    ll all = 1;

    for (int i=0; i<n; i++) {
	all *= 3ll; all %= mod;
	for (int j=0; j<=s; j++) {
	    push(dp1[i+1][j], 2ll*dp1[i][j]);
	    push(dp1[i+1][j+a[i]], dp1[i][j]);

	    push(dp2[i+1][j], dp2[i][j]);
	    push(dp2[i+1][j+a[i]], dp2[i][j]);
	}
    }


    ll res = all;
    ll bad = 0;
    for (int j=(s+1)/2; j<=s; j++) {
	bad += dp1[n][j];
	bad %= mod;
    }
    ll dup = (s%2 == 0 ? dp2[n][s/2] : 0);

    // watch(res);
    // watch(bad);
    // watch(dup);

    res -= (3ll*bad%mod);
    res %= mod;
    res += (3ll*dup%mod);
    res %= mod;


    res %= mod;
    res += mod;
    res %= mod;
    cout<<res<<endl;
    
    return 0;
}


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

#define what_is(x)    cerr<<#x<<" is "<<x<<"\n";
#define rep(i,n)      for(int i=0; i < (n); ++i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define sz(x)         (x).size()
#define M             1e9+7;
#define MM            998244353
#define PI            3.14159265358979

typedef long double ld;
typedef pair <int,int> pii;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,ans; string str;

int solve(){
    int a,b; cin>>a>>b;
    a-=2*b;
    if(a<0) cout<<0;
    else cout<<a;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int a[30];

int main(void){
	          int i;

	      	  cin.tie(0);  ios_base::sync_with_stdio(false);

	      	  string s;
	      	  cin >> s;


	      	  if(s=="AKIHABARA") cout << "YES" << endl;

	      	  else if(s=="KIHABARA") cout << "YES" << endl;
	      	 else if(s=="AKIHBARA") cout << "YES" << endl;
	      	 else if(s=="AKIHABRA") cout << "YES" << endl;
	      	 else if(s=="AKIHABAR") cout << "YES" << endl;

	      	 else if(s=="KIHBARA") cout << "YES" << endl;
	      	 else if(s=="KIHABRA") cout << "YES" << endl;
	      	 else if(s=="KIHABAR") cout << "YES" << endl;
	      	 else if(s=="AKIHBRA") cout << "YES" << endl;
	      	 else if(s=="AKIHBAR") cout << "YES" << endl;
	      	 else if(s=="KIHBARA") cout << "YES" << endl;

	      	 else if(s=="AKIHBR") cout << "YES" << endl;
	      	 else if(s=="KIHABR") cout << "YES" << endl;
	      	 else if(s=="KIHBAR") cout << "YES" << endl;
	      	 else if(s=="KIHBRA") cout << "YES" << endl;

	      	 else if(s=="KIHBR") cout << "YES" << endl;


	      	 else cout << "NO" << endl;


	          return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    string s;
    cin >> s;
    string ans = "No";
    sort(whole(s));
    if (s=="abc") ans = "Yes";
    
    cout << ans << endl;
    return 0;
}


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

int N, Q, K;
vector<vector<pair <int, int> > >g(100001, vector<pair<int, int> >());
vector<long long> dist(100001, 0);

void dfs(int now, int pre){
  for(auto e: g[now]){
    if(e.first != pre){
      int nex = e.first;
      int ndi = e.second;
      dist[nex] = dist[now] + (long long)ndi;
      dfs(nex, now);
    }
  }
}

int main(){
  cin >> N;
  for(int i = 0; i < N-1; i++){
    int a, b, c; cin >> a >> b >> c;
    g[a].push_back(make_pair(b,c));
    g[b].push_back(make_pair(a,c));
  }
  
  cin >> Q >> K;
  
  dfs(K, -1);
  
  for(int i = 0; i < Q; i++){
    int x, y; cin >> x >> y;
    cout << dist[x] + dist[y] << endl;
  }
  
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
#include<string.h>
#define ll long long
#define pf printf
#define sf scanf
#define ff first
#define ss second
#define clr clear()
#define sz size()
#define pb push_back
#define mk make_pair
#define pi acos(-1)
#define inf 2000000000000000000
#define mod 1000000007
#define ull unsigned long long int
#define f(i,k,n) for(i=k;i<n;i++)
#define fr(i,n,k) for(i=n;i>=k;i--)
#define ent(a) scanf("%lld",&a)
#define ent2(a,b) scanf("%lld%lld",&a,&b)
#define ent3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define mem(a) memset(a,0,sizeof(a))
#define vec(v,s) vector<ll>v[s]
#define arr(a,s) ll a[s];
/*#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
//knight and king//
int dr[]= {2,2,-2,-2,1,-1,1,-1};
int dc[]= {1,-1,1,-1,2,2,-2,-2};
int dr1[]= {0,0,1,1,1,-1,-1,-1};
int dc1[]= {1,-1,1,0,-1,0,1,-1};
int dr2[]= {0,0,1,-1};
int dc2[]= {1,-1,0,0};
////////////////////////////
using namespace std;
#define ma 2000005
ll fr[ma];

ll bigmod(ll n,ll p)
{
    if(p==0)return 1;
    ll x=bigmod(n,p/2);
    x=(x*x)%mod;
    if(p%2)x=(x*n)%mod;
    return x;
}

ll ncr(ll n,ll r)
{
    ll r1=(fr[n-r]*fr[r])%mod;
    r1=bigmod(r1,mod-2);
    return (fr[n]*r1)%mod;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,i,j,u,v,k,x,m;
    fr[0]=1;
    for(i=1;i<ma;i++)fr[i]=(fr[i-1]*i)%mod;
    while(cin>>n)
    {
       string s;
       cin>>s;
       ll tot=n+s.sz;
       ll len=s.sz;
       ll ans=0;
       for(i=len;i<=tot;i++)
       {
           ll p=ncr(i-1,len-1);
           ll p1=bigmod(25,i-len);
           ll p2=bigmod(26,tot-i);
           p=(p*p1)%mod;
           p=(p*p2)%mod;
           ans+=p;
           ans%=mod;
       }
       cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 19876
n,a,b=map(int,input().split())
p=10**9+7

def cmb(n, r):
  # 分子(n*(n-1)*...*(n-r+1))
  nume = 1
  for i in range(n-r+1, n+1):
    nume = nume * i % p
  # 分母（1*2*...*r）
  deno = 1
  for j in range(1, r+1):
    deno = deno * j % p
    d = pow(deno, p-2, p)
  return nume * d

nca = cmb(n, a)
ncb = cmb(n, b)
res = pow(2, n, p) - nca - ncb - 1
print(res%p)

Measured memory_bytes: 67244
n, m = map(int, input().split())

s1 = 1
f1 = n // 2
s2 = f1 + 1
f2 = n
if (f1 - s1) % 2 == (f2 - s2) % 2:
    f2 -= 1
ans = []
while f1 > s1:
    ans.append(f"{s1} {f1}")
    s1 += 1
    f1 -= 1

while f2 > s2:
    ans.append(f"{s2} {f2}")
    s2 += 1
    f2 -= 1

print("\n".join(ans[:m]))

Measured memory_bytes: 17620
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    string s,t; cin >> s >> t;
    int sl=s.length();
    int tl=t.length();

    vector<vector<int> > num(26);
    rep(i,tl) num[t[i]-'a'].push_back(i);
    rep(i,26){
        if(num[i].size()<=1) continue;
        char f=s[num[i][0]];
        rep(j,num[i].size()-1){
            if(f!=s[num[i][j+1]]){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    vector<vector<int> > num2(26);
    rep(i,sl) num2[s[i]-'a'].push_back(i);
    rep(i,26){
        if(num2[i].size()<=1) continue;
        char f=t[num2[i][0]];
        rep(j,num2[i].size()-1){
            if(f!=t[num2[i][j+1]]){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n;cin >> n;
    vector<double> v(n);
    REP(i, n) { cin >> v[i]; }
    sort(ALL(v));
    REP(i,n-1){
        v[i + 1] = (v[i] + v[i + 1]) / 2.;
    }
    

    cout << v[n-1] <<"\n";

    return 0;
}

Measured memory_bytes: 256
from __future__ import print_function

from functools import reduce
from operator import mul
from collections import Counter
from collections import deque
from itertools import accumulate
from queue import Queue
from queue import PriorityQueue as pq
from heapq import heapreplace
from heapq import heapify
from heapq import heappushpop
from heapq import heappop
from heapq import heappush
import heapq
import time
import random
import bisect
import itertools
import collections
from fractions import Fraction
import fractions
import string
import math
import operator
import functools
import copy
import array
import re
import sys
sys.setrecursionlimit(500000)


input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    #
    def rec(n, j):  # 「nを0にするのに必要な「2での割り算」の回数」を返す再帰関数
        if n == 0:
            return j
        else:
            return rec(n//2, j+1)

    # input
    h = int(input().strip())

    # procedure
    cnt = 0
    for i in range(rec(h, 0)):
        cnt += 2**i

    # output
    print(cnt)


if __name__ == '__main__':
    main()


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

using namespace std;

const int INF = 1001001001;

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int iter = max(x, y) * 2 + 1;
    
    int cost = INF;
    for (int i = 0; i < iter; ++i) {
        cost = min(cost, a * max(0, x - i/2) + b * max(0, y - i/2) + c*i);
    }

    cout << cost << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <stack>
#include <string>
using namespace std;
int main(){
    int N;
    int H,W;
    cin>>H>>W;
    cin>>N;
    int res=300;
    for(int i=0;i<=H;i++){
        for(int j=0;j<=W;j++){
            if(i>=1&&j>=1){
                if(i+j-1<=i*W+j*H-N) res=min(res,i+j);
            }else{
                if(0<=i*W+j*H-N) res=min(res,i+j);
            }
        } 
    }
    cout<<res<<endl;
    
}

Measured memory_bytes: 256