akhauriyash/Code-Regression huggingface dataset:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
c=Counter(a)
an=[]
for b,count in c.items():
    for _ in range(count//2):
        an.append(b)
an.sort(reverse=True)
if len(an)<2:
    print(0)
else:
    print(an[0]*an[1])

Measured memory_bytes: 18600
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;

const int MOD = 1000000007;
ll modpow(ll b, ll e, ll m) {
  ll r = 1;
  while(e) {
    if(e%2) {
      r*=b;
      r%=m;
    }
    b*=b;
    b%=m;
    e/=2;
  }
  return r;
}
ll fact[200000];
ll ifact[200000];

ll choose(int n, int k) {
  assert(k >= 0 && k <= n);
  ll ret = fact[n];
  ret *= ifact[k];
  ret %= MOD;
  ret *= ifact[n-k];
  ret %= MOD;
  return ret;
}

void solve() {
  int n, m;
  cin >> n >> m;
  fact[0] = 1;
  for(int i = 1; i < 200000; i++) {
    fact[i] = i * fact[i-1];
    fact[i] %= MOD;
  }
  ifact[199999] = modpow(fact[199999], MOD-2, MOD);
  for(int i = 199998; i >= 0; i--) {
    ifact[i] = ifact[i+1] * (i+1);
    ifact[i] %= MOD;
  }
  ll ret = 1;
  for(int i = 2; i * i <= m; i++) {
    if(m%i) continue;
    int p = 0;
    while(m%i==0) {
      m /= i;
      p++;
    }
    ret *= choose(n-1+p, n-1);
    ret %= MOD;
  }
  if(m > 1) ret *= choose(n, n-1);
  ret %= MOD;
  cout << ret << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
  solve();
}


Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main() {
	long long K;
	while (~scanf("%lld", &K)) {
		int N = 50;
		vector<ll> ans(N);
		rep(i, N)
			ans[i] = (N - 1) + K / N;
		int m = (int)(K % N);
		rep(i, K % N) {
			ans[i % m] += N - (m - 1);
			rep(j, N) if (j >= m)
				-- ans[j];
		}
		printf("%d\n", N);
		for (int i = 0; i < (int)ans.size(); ++ i) {
			if (i != 0) putchar(' ');
			printf("%lld", ans[i]);
		}
		puts("");
	}
	return 0;
}


Measured memory_bytes: 256
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
INF = 1000000000000

x,n = LI()
p = LI()

val = INF
ret = INF
tmp = 0
for i in range(-100,200):
    flg = False
    for y in p:
        if(i == y):
            flg = True
    if(not flg):
        tmp =  abs(x - i)
        if(val > tmp):
            val = tmp
            ret = i

print(ret)

Measured memory_bytes: 9236
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;

int main() {
	string s;cin>>s;
	int n=s.size();
	ll p[N],a[N],b[N],c[N];

	if(s[0]=='?') p[0]=3;
	else p[0]=1;
	for(int i=1;i<n;i++){
		if(s[i]=='?') p[i]=3*p[i-1];
		else p[i]=p[i-1];
		p[i]%=MOD;
	}

	if(s[0]=='A'||s[0]=='?') a[0]=1;
	else a[0]=0;
	for(int i=1;i<n;i++){
		if(s[i]=='A') a[i]=a[i-1]+p[i-1];
		else if(s[i]=='?') a[i]=3*a[i-1]+p[i-1];
		else a[i]=a[i-1];
		a[i]%=MOD;
	}

	b[0]=0;
	for(int i=1;i<n;i++){
		if(s[i]=='B') b[i]=a[i-1]+b[i-1];
		else if(s[i]=='?') b[i]=a[i-1]+3*b[i-1];
		else b[i]=b[i-1];
		b[i]%=MOD;
	}

	c[1]=0;
	for(int i=2;i<n;i++){
		if(s[i]=='C') c[i]=b[i-1]+c[i-1];
		else if(s[i]=='?') c[i]=b[i-1]+3*c[i-1];
		else c[i]=c[i-1];
		c[i]%=MOD;
	}

	cout<<c[n-1]<<endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl

int main() {
    vector<int> a(3);
    rep(i, 3) cin >> a.at(i);

    int res = 10000;
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            for(int k=0; k<3; k++){
                if(i==j) continue;
                if(j==k) continue;
                if(k==i) continue;

                res = min(res, abs(a.at(i)-a.at(j))+abs(a.at(j)-a.at(k)));
            }
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int N = 1e5 + 5;
using namespace std;

string s;
int n, m, l[N], r[N], sum[N];
int pset[N];

int findset(int i){return ((pset[i] == i) ? i : pset[i] = findset(pset[i]));}

void dsu(int i, int j){
    i = findset(i); j = findset(j);
    if (i == j) return;
    pset[j] = i;
    sum[i] += sum[j];
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> s;
    n = s.size();
    s = '.' + s;
    cin >> m;
    for (int i = 1; i <= m; i++){
        cin >> l[i] >> r[i];
        if (r[i] < n + 1 - r[i]) continue;
        if (l[i] > n + 1 - l[i]){
            l[i] = n + 1 - l[i];
            r[i] = n + 1 - r[i];
            swap(l[i], r[i]);
            continue;
        }
        r[i] = n + 1 - r[i];
        if (l[i] <= r[i]) r[i]--;
        else l[i]--, swap(l[i], r[i]);
    }

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

    for (int i = 1; i <= n; i++) pset[i] = i;
    for (int i = 1; i <= m; i++) dsu(l[i], r[i]+1);

    for (int i = 1; i <= n; i++) {
        if (pset[i] == i && sum[i] % 26 != 0) return cout << "NO", 0;
    }
    cout << "YES";
}


Measured memory_bytes: 1772
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var a     = long.Parse(spl[0]);
        var b     = long.Parse(spl[1]);
        var c     = long.Parse(spl[2]);

        var r = c - a - b;

        return (r>0) && (4*a*b < r*r) ? "Yes" : "No";
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
typedef long long ll;

int main()
{
    char a;
    cin >> a;
    if ((a >= 'a') && (a <= 'z'))
    {
        cout << "a" << endl;
    }
    else
    {
        cout << "A" << endl;
    }
    return 0;
}

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

const int Nmax=200010;

int main() {
	int n,A,B,C,D;
	cin >> n;
  	A = n/1000; n %= 1000;
  	B = n/100; n %= 100;
  	C = n/10; n %= 10;
  	D = n;
	if(A+B+C+D==7){cout <<A<<'+'<<B<<'+'<<C<<'+'<<D<<"=7"<<endl; return 0;}
	if(A+B-C+D==7){cout <<A<<'+'<<B<<'-'<<C<<'+'<<D<<"=7"<<endl; return 0;}
	if(A+B+C-D==7){cout <<A<<'+'<<B<<'+'<<C<<'-'<<D<<"=7"<<endl; return 0;}
	if(A-B+C+D==7){cout <<A<<'-'<<B<<'+'<<C<<'+'<<D<<"=7"<<endl; return 0;}
	if(A-B-C+D==7){cout <<A<<'-'<<B<<'-'<<C<<'+'<<D<<"=7"<<endl; return 0;}
	if(A-B+C-D==7){cout <<A<<'-'<<B<<'+'<<C<<'-'<<D<<"=7"<<endl; return 0;}
	if(A+B-C-D==7){cout <<A<<'+'<<B<<'-'<<C<<'-'<<D<<"=7"<<endl; return 0;}
	if(A-B-C-D==7){cout <<A<<'-'<<B<<'-'<<C<<'-'<<D<<"=7"<<endl; return 0;}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n + 2);
	for (int i = 1; i <= n; i++) cin >> a[i];
	int sum = 0;
	for (int i = 1; i < a.size(); i++) sum += abs(a[i] - a[i - 1]);

	vector<int> diff(n + 2);
	for (int i = 1; i <= n; i++) {
		diff[i] = abs(a[i + 1] - a[i - 1]) - abs(a[i + 1] - a[i]) - abs(a[i] - a[i - 1]);
	}

	for (int i = 1; i <= n; i++) cout << sum + diff[i] << endl;
}


Measured memory_bytes: 2048
n = gets.to_i
str = gets.chomp

w = Array.new(n, 0)
e = Array.new(n, 0)

acc_w = 0
acc_e = 0

1.upto(n - 1) do |i|
  acc_w += 1 if str[i - 1] == "W"
  w[i] = acc_w
  acc_e += 1 if str[n - i] == "E"
  e[n - i - 1] = acc_e
end

puts w.zip(e).map {|w, e| w + e}.min

Measured memory_bytes: 24836
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string[] cin = Console.ReadLine().Split();
    static int h = int.Parse(cin[0]);
    static int w = int.Parse(cin[1]);
    static bool[,] map = new bool[w, h];
    static bool[,] search = new bool[w, h];
    static long black = 0;
    static long white = 0;

    static void Main()
    {
        for (int j = 0; j < h; j++)
        {
            string s = Console.ReadLine();
            for (int i = 0; i < w; i++)
            {
                // blackのときtrue
                if (s[i] == '#') map[i, j] = true;
            }
        }

        var route = new long[w, h];
        long ans = 0;
        for (int i = 0; i < w; i++)
        {
            for (int j = 0; j < h; j++)
            {
                if (!search[i, j])
                {
                    Route(i, j);
                    ans += (black * white);
                    black = 0;
                    white = 0;
                }
            }
        }
        Console.WriteLine(ans);
    }

    static void Route(int i, int j)
    {
        search[i, j] = true;
        if (map[i, j]) black++;
        else white++;
        if (0 < j)
        {
            if (map[i, j] != map[i, j - 1])
            {
                if (!search[i, j - 1]) Route(i, j - 1);
            }
        }
        if (0 < i)
        {
            if (map[i, j] != map[i - 1, j])
            {
                if (!search[i - 1, j]) Route(i - 1, j);
            }
        }
        if (i + 1 < w)
        {
            if (map[i, j] != map[i + 1, j])
            {
                if (!search[i + 1, j]) Route(i + 1, j);
            }
        }
        if (j + 1 < h)
        {
            if (map[i, j] != map[i, j + 1])
            {
                if (!search[i, j + 1]) Route(i, j + 1);
            }
        }
    }
}

Measured memory_bytes: 14412
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	a := scanInt()
	b := scanInt()
	x := scanInts(n)

	ans := 0

	for i := 0; i < n-1; i++ {
		ans += min((x[i+1]-x[i])*a, b)
	}

	fmt.Fprintln(wr, ans)
}


Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;

int main()
{
    vector<int> x(5);
    for(int i =0; i<5;i++){
        cin >> x[i];
        if(x[i] == 0) cout << i+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define cint(d) scanf("%d", &d)
#define cint2(a, b) scanf("%d %d", &a, &b)
#define cint3(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define cint4(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)

#define clong(d) scanf("%lld", &d)
#define clong2(a, b) scanf("%lld %lld", &a, &b)
#define clong3(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
#define clong4(a, b, c, d) scanf("%lld %lld %lld %lld", &a, &b, &c, &d)

#define foreach(v, c) for(__typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define revforeach(v, c) for(__typeof( (c).rbegin()) v = (c).rbegin();  v != (c).rend(); ++v)
#define ALL(v) (v).begin(), (v).end()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second

typedef long long int slong;
typedef pair<int, int> pii;
typedef pair<slong, slong> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

#ifdef VSP4 
    #include "debug.h"    
#else
    #define debug(args...)                  // Just strip off all debug tokens
#endif

const int MOD = 1000000007;
#define MODSET(d) if ((d) >= MOD) d %= MOD;
#define MODNEGSET(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD;
#define MODADDSET(d) if ((d) >= MOD) d -= MOD;
#define MODADDWHILESET(d) while ((d) >= MOD) d -= MOD;

const int MAXN = 2e5;
const int SQRTN = 550;
const int LOGN = 60;
const int INT_INFINITY = 1001001001;
const int LIMIT = 40000;

const slong LONG_INFINITY = 1001001001001001001ll;
const slong LONG_LIMIT = 200100100100101ll;

int n, m;
set<int> graph[MAXN+5];

int main()
{
	#ifdef VSP4
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	
	cout.tie(0);
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	
	int t, i, j, u, v;
	
	cint2(n, m);
	
	for (i = 1; i <= m; i++)
	{
		cint2(u, v);
		graph[u].insert(v);
		graph[v].insert(u);
	}
	
	for (i = 2; i < n; i++)
	{
		if (graph[i].count(1) && graph[i].count(n))
		{
			cout << "POSSIBLE";
			return 0;
		}
	}
	
	cout << "IMPOSSIBLE";
	
	return 0;
}


Measured memory_bytes: 28416
#include <stdio.h>

int main(void)
{
    int p, q, r;
    int t;

    scanf("%d %d %d", &p, &q, &r);

    if(p+q<q+r)
    {
        t=p+q;
        if(r+p<t)
        {
            t=r+p;
        }
    }
    else
    {
        t=q+r;
        if(r+p<t)
        {
            t=r+p;
        }
    }

    printf("%d\n", t);

    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    int n = 0;
    cin >> n;
    vector<pair<int, int>> red(n);
    for (int i=0; i<n; i++) {
        cin >> red.at(i).second >> red.at(i).first;
    }
    vector<pair<int, int>> blue(n);
    for (int i=0; i<n; i++) {
        cin >> blue.at(i).first >> blue.at(i).second;
    }
    sort(red.begin(), red.end());
    sort(blue.begin(), blue.end());
    reverse(red.begin(), red.end());
    int ans = 0;
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            if (red.at(j).second < blue.at(i).first && red.at(j).first < blue.at(i).second) {
                ans++;
                red.at(j).first = 10000;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//2019.8.10 by ljz
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f
#define unl __int128
#define eps 5.6e-8
#define RG register
#define db double
#define pc(x) __builtin_popcount(x)
typedef pair<int,int> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define gc getchar
//inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
//inline int read() {
//    res s=0,ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
inline int read() {
    res s=0,ch=gc(),w=1;
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s*w;
}
inline LL Read() {
    RG LL s=0;
    res ch=gc();
    while(ch<'0'||ch>'9')ch=gc();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s;
}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline void write(RG unl x){
//    if(x>10)write(x/10);
//    putchar(int(x%10)+'0');
//}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//clock_t start=clock();
//inline void ck(){
//    if(1.0*(clock()-start)/CLOCKS_PER_SEC>0.1)exit(0);
//}
namespace MAIN{
    int A,B;
    inline void MAIN(){
        A=read(),B=read();
        printf("%d\n",max({A+B,A-B,A*B}));
    }
}
int main(){
//    srand(19260817);
//    freopen("signin.in","r",stdin);
//    freopen("signin.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 256
import sys
import heapq
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()

from math import ceil
A,B,C,D = map(int,input().split())

taka_atk_num = ceil(C/B)
aoki_atk_num = ceil(A/D)

if aoki_atk_num < taka_atk_num:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9192
#include <stdio.h>

int main(void) {
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	
	int diff_ab = abs(a-b);
	int diff_bc = abs(b-c);
	int diff_ac =abs(a-c);
	
	if (diff_ab<=d&&diff_bc<=d) printf("Yes");
	else if (diff_ac<=d) printf("Yes");
	     else printf("No");
	
	
	return(0);
}

Measured memory_bytes: 128
def battle_A_B(A,B):
	A_points = 0
	B_points = 0
	for i in range(len(A)):
		A_idx = int(A[i])
		B_idx = int(B[i])
		if A_idx > B_idx:
			A_points += (A_idx+B_idx)
		elif A_idx < B_idx:
			B_points += (A_idx+B_idx)
		else:	
			A_points += A_idx
			B_points += B_idx	
	insert = str(A_points)+" "+str(B_points) #+"\n"
	insert_list.append(insert)


insert_list = []
while(1):
	num = input()
	num = num.rstrip("\n")
	num_list = num.split(" ")
	if len(num_list) == 1:
		if int(num_list[0]) == 0:
			break
		battle_num = int(num_list[0])
		A = []
		B = []
	else:
		A.append(num_list[0])
		B.append(num_list[1])
		if len(A) == battle_num:
			battle_A_B(A,B)	

for i in range(len(insert_list)):
	print(insert_list[i])

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

ulong diff(ulong a, ulong b){
    return __builtin_ctzl(a^b);
}

ulong hd(ulong a, ulong b){
    return __builtin_popcountl(a^b);
}

ulong bit_remove(ulong a, ulong n){
    ulong low  = a & ((1<<n)-1);
    ulong high = (a >> (n+1)) << n;
    return high | low;
}

ulong bit_insert(ulong a, ulong n, ulong b){
    ulong low  = a & ((1<<n)-1);
    ulong high = (a >> n) << (n+1);
    return high | (b<<n) | low;
}

long data[1<<17];

void solve(const long n, const long a, const long b, const size_t sp, const size_t ep){
    if(n==1){
        data[sp+0] = a;
        data[sp+1] = b;
        return;
    }
    ulong d = diff(a, b);
    ulong aa = bit_remove(a, d);
    ulong ab = bit_remove(a, d) ^ 1;
    ulong bb = bit_remove(b, d);
    const size_t mp = (sp+ep)/2;
    solve(n-1, aa, ab, sp, mp);
    solve(n-1, ab, bb, mp, ep);
    for(size_t i=sp; i<mp; i++){
        data[i] = bit_insert(data[i], d, (a&(1<<d)) >> d);
    }
    for(size_t i=mp; i<ep; i++){
        data[i] = bit_insert(data[i], d, (b&(1<<d)) >> d);
    }
}

int main(void){
    long n, a, b;
    std::cin >> n >> a >> b;
    if(__builtin_popcountl(a)%2 == __builtin_popcountl(b)%2){
        std::cout << "NO" << std::endl;
        return 0;
    }
    solve(n, a, b, 0, 1<<n);
    const size_t m = 1<<n;
    std::cout << "YES" << std::endl;
    for(size_t i=0; i<m-1; i++){
        std::cout << data[i] << " ";
    }
    std::cout << data[m-1] << std::endl;
    return 0;
}


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

using namespace std;

#define nfs                      \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);

int main() {
    nfs;

    int n, k;
    cin >> n >> k;
    int h[n];
    int a[n] = {};

    for (auto& x : h) cin >> x;

    for (int i = 1; i < n; ++i) {
        a[i] = a[i - 1] + abs(h[i] - h[i - 1]);
        for (int j = max(0, i - k); j < i - 1; ++j) {
            a[i] = min(a[i], a[j] + abs(h[i] - h[j]));
        }
    }
    cout << a[n - 1] << endl;
}

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

int main() {
	int n; cin >> n;
	vector<string> w(n);
	set<string> set_w;
	for(int i = 0; i < n; i++) {
		cin >> w[i];
		set_w.insert(w[i]);
	}

	if(set_w.size() != n) {
			cout << "No\n";
			return 0;
	}

	for(int i = 1; i < n; i++) {
		int end_loc = w[i-1].length() - 1;
		if(w[i-1][end_loc] != w[i][0]) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
}


Measured memory_bytes: 384
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    h = list(map(int, input().split()))

    cost = [0] * N
    cost[1] = abs(h[1] - h[0])
    for i in range(2, N):
        cost_1 = cost[i - 1] + abs(h[i] - h[i - 1])
        cost_2 = cost[i - 2] + abs(h[i] - h[i - 2])
        cost[i] = min(cost_1, cost_2)

    ans = cost[-1]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 20308
a = list(map(int,input().split()))
a.sort()
if (a[2]-a[1])%2==0 and (a[2]-a[0])%2==0:
    print((a[2]-a[1])//2+(a[2]-a[0])//2)
elif (a[2]-a[1])%2==1 and (a[2]-a[0])%2==1:
    print((a[2]-a[1])//2+(a[2]-a[0])//2+1)
else:
    print((a[2]-a[1])//2+(a[2]-a[0])//2+2)

Measured memory_bytes: 9016
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
// using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;

//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define bug2(v1,v2)               cerr<<#v1<<" = "<<(v1)<< ' ' << #v2<<" = "<<(v2)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const double pi = 3.14159265359;
const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
//const ll mod = 998244353;
const ll mod = 1000000007;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return (((a+mod)%mod)*(b+mod)%mod)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline ll modInverse(ll n, ll p){ return power(n, p-2)%p; }

/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 
void stArt()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}
void eNd()
{
	#ifndef ONLINE_JUDGE
  	cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  	#endif
}

//////////////////// start /////////////////////////////////
 

ll i,j,k,l,m,r,n;
//ll a[MAX],b[MAX];


int main()
{
 
stArt();
fast
//cout << setprecision(15) << fixed;

cin >> n >> m;
char a[n+1][m+1];
fr(i,0,n)
	fr(j,0,m)
		cin >> a[i][j];
ll dp[n+1][m+1];
mem(dp,0);
dp[0][0] = 1;
fr(i,0,n)
{
	fr(j,0,m)
	{
		if(a[i][j] == '#')
			dp[i][j] = 0;
		else
		{
			if(i)
				dp[i][j] = add(dp[i][j],dp[i-1][j]);
			if(j)
				dp[i][j] = add(dp[i][j],dp[i][j-1]);
		}
	}
}
cout << dp[n-1][m-1];


 eNd();
  return 0;
 
}

Measured memory_bytes: 12332
#include<bits/stdc++.h>
using namespace std;
#define maxn 200010
int n,a[maxn],pos[maxn];
main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]),pos[a[i]]=i;
    int mx=0,now=1;
    for(int i=2;i<=n+1;i++)
    {
        if(pos[i]>pos[i-1])now++;
        else
        {
            mx=max(mx,now);
            now=1;
        }
    }
    printf("%d\n",n-mx);
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int uint64;
typedef long long int          int64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

void get_N1234 (int64 *n1, int64 *n2, int64 *n3, int64 *n4)
{
  int cnt;

  if (n2 == NULL) {
    cnt = scanf("%lld", n1);
    return;
  }
  if (n3 == NULL) {
    cnt = scanf("%lld %lld", n1, n2);
    return;
  }
  if (n4 == NULL) {
    cnt = scanf("%lld %lld %lld", n1, n2, n3);
    return;
  }
  cnt = scanf("%lld %lld %lld %lld", n1, n2, n3, n4);
  return;
}

void omit_LF (void)
{
  char c;
  int  cnt;
  
  cnt = scanf("%c", &c);
  return;
}

char *get_S (int64 n)
{
  char *buf;
  int  i;
  int  cnt;

  buf = malloc((size_t)(n * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  return buf;
}

char *get_SN (int64 max, int64 *size)
{
  char *buf;
  int  i;
  int  n;
  int  cnt;

  buf = malloc((size_t)(max * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  n = strlen(buf);

  *size = n;
  
  return buf;
}

int64 *get_NSeq (int64 n)
{
  int64 *buf;
  int64 i;

  buf = malloc((size_t)(n * sizeof(int64)));
  for (i=0; i<n; i++) {
    get_N(&buf[i]);
  }

  return buf;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;


int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}

int main()
{
  int64 N,M;
  int64 *A;
  int64 i;
  int64 t,v;
  double l;
  
  get_N1234(&N, &M, NULL, NULL);
  A = get_NSeq (N);

  t=0;
  for(i=0; i<N; i++) {
    t += A[i];
  }
  l = (t*1.0)/(4*M);
  v = 0;
  for(i=0; i<N; i++) {
    if (A[i] >= l) {
      v++;
    }
  }

  if (v >= M) {
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}



Measured memory_bytes: 128
#include<stdio.h>

int main()
{
	int n, t[105], m, p[105], x[105];
	int text[105],sum;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
		scanf("%d", &t[i]);
	scanf("%d", &m);
	for(int i = 1; i <= m; i++)
		scanf("%d %d", &p[i], &x[i]);
	for(int i = 1; i <= m; i++)
	{
		for(int j = 1; j <= n; j++)
			text[j] = t[j];
		sum = 0;
		text[p[i]] = x[i];
		for(int j = 1; j <= n; j++)
			sum += text[j];
		printf("%d\n", sum);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &t : a) { 
    	cin >> t;
    	t--;
    }
    vector<int> b(n), c(n - 1);
    for (auto &t : b) {
    	cin >> t;
    }
    for (auto &t : c) {
    	cin >> t;
    }
    int pr = -3;
    int ans = 0;
    for (int i = 0; i < n; i++) {
    	ans += b[a[i]];
    	if (pr + 1 == a[i]) {
    		ans += c[pr];
    	}
    	pr = a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
object Main extends App {
  val Array(a, b, c, x) = Iterator.continually(io.StdIn.readLine.toInt)
    .take(4).toArray

  val ans = {
    val A = math.min(a, x/500:Int)
    val B = math.min(b, x/100:Int)
    for {
      i <- 0 to A
      c0 = 500*i
      j <- 0 to B
      c1 = 100*j
      if c0 + c1 <= x
      k <- 0 to c
      if c0 + c1 + 50*k == x
    } yield true
  }.size

  println(ans)
}


Measured memory_bytes: 25840
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> base;
  vector<int> perm;
  vector<int> dig;
  int num;
  for(int i=0; i<n; i++){
    cin >> num;
    base.push_back(i+1);
    perm.push_back(num);
    dig.push_back(0);
  }

  for(int i=0; i<n; i++){
    if(base[i]!=perm[i]) dig[i]=1;
  }
  int suma=0;
  for(int i=0; i<n; i++){
    suma += dig[i];
  }
  if(suma==0 || suma==2)  cout << "YES";
  else cout << "NO";
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = sc.nextInt();
        int[] L = new int[N + 1];
        for (int i = 0; i < N; i++) {
            L[i] = sc.nextInt();
        }
        L[N] = 10000;
        Arrays.sort(L);

        int cnt = 0;
        for (int i=0; i<=N-2; i++){
          for (int j=i+1; j<=N-1; j++){
            int sum = L[i] + L[j];

           for (int k=j+1; k<=N; k++){
             if (sum>L[k]){
               cnt++;
             }else{
               break;
             }
           }
         }
       }
       System.out.println(cnt);
    }
}

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

int main() {
  int A, B, C, K; cin >> A >> B >> C >> K;
  int ans = 0;
  if (K <= A) ans = K;
  else if (K <= A + B) ans = A;
  else ans = A - (K - A - B);
  cout << ans << endl;
}

Measured memory_bytes: 3508
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

string str;
int k;

int main()
{
	cin >> str >> k;
	
	REP(i,str.size())
	{
		if(str[i] != 'a' && 'z' - str[i] + 1 <= k)
		{
			k -= ('z' -str[i] + 1);
			str[i] = 'a';
		}
	}
	
	str[str.size()-1] = 'a' + ((str[str.size()-1] - 'a' + k)%26);
	//cout << str[str.size()-1] << endl;
	k--;

	
	cout << str << endl;
	
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define br break
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace2(a,b) cerr <<"a is " << a << " b is " << b << el;
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

int main()
{
    ios;
    ll n , k , x , y ;
    cin >> n >> k >> x >> y;
    if(k >=n) {cout << n*x << el ;}
    else {
            cout << k*x + (n-k)*y << el ;
    }
    ro ;
}



























Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int w,n,num[31];
    int a,b,i,x;
    scanf("%d %d",&w,&n);
    for(i=1;i<=w;i++) num[i]=i;
    for(i=0;i<n;i++){
        scanf("%d,%d",&a,&b);
        x=num[a];
        num[a]=num[b];
        num[b]=x;
    }
    for(i=1;i<=w;i++) printf("%d\n",num[i]);
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<P> v(n);
    rep(i, n) {
        cin >> v[i].first >> v[i].second;
        v[i].first += v[i].second;
    }
    sort(v.begin(), v.end());
    bool taka = true;
    ll a = 0, b = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (taka) {
            a += v[i].first - v[i].second;
            taka = false;
        } else {
            b += v[i].second;
            taka = true;
        }
    }
    cout << a - b << endl;
    return 0;
}

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

int N;
string S;

int main()
{
    cin >> N >> S;
    ll r = 0;
    ll g = 0;
    ll b = 0;
    for(int i = 0; i < N; i++)
    {
        char s = S[i];
        if(s == 'R') r++;
        else if(s == 'G') g++;
        else b++;
    }

    ll res = r * g * b;

    for(int d = 1; d < N + 1; d++)
    for(int j = 0; j < N; j++)
    {   
        int i = j - d;
        int k = j + d;
        if(i < 0 || k >= N) continue;
        if(S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) res--;
    }

    cout << res << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
using std::pair;
using std::vector;
using std::string;

typedef long long ll;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int oo = 0x3f3f3f3f;
 
template<typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48; 
    return x *= f;
}

const int mo = 1e9 + 7;
const int N = 10000000;

int S;
ll ans;
int f[N + 5];

int fpm(int x, int y) {
    int res = 1;
    for(; y > 0; y >>= 1) {
        if(y & 1)
            res = 1ll * res * x % mo;
        x = 1ll * x * x % mo;
    }
    return res;
}

int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif 

    int l = 1, r = 0, cur = 0;
    ll cnt = 0, sum = 0;

    read(S);
    for(int i = 1; i < N; ++i) sum += (f[i] = f[i/10] + 1);
    for(int i = 1; i < N; ++i) {

        while(cur < S && r < N) cur += f[r ++];

        if(cur == S) ++ ans;
        cur -= f[l ++];
        if(sum - cnt < S && (S - (sum - cnt)) % 8 == 0) ++ ans;

        cnt += f[i];
    }

    for(int i = 1; i <= S/8; ++i) {
        if(S % i == 0) {
            ans = (ans + 9ll * fpm(10, (S/i)-1) % mo - i + 1) % mo;
        } else 
            ++ ans;
    }
    printf("%lld\n", (ans + mo) % mo);

    return 0;
}


Measured memory_bytes: 39424
#include<stdio.h>

int f(int n,int k){
  if(n >= 10){
    return f(n/10,(k+1)%2);
  }
  return k;
}

int main(){
  int n,ans=0;
  scanf("%d",&n);
  for(int i=1;i<=n;i++){
    if(f(i,1)){
      ans++;
    }
  }
  printf("%d",ans);
  
  return 0;
}

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

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

int N;
const int mod = 1000000007;
const int size = 100100;
int fact[size];
int inv[size];

int mod_pow(int i, int i1);

void input();

void pre() {
    fact[0] = 1;
    inv[0] = 1;
    for (int i = 1; i < size; ++i) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = inv[i - 1] * mod_pow(i, mod - 2) % mod;
    }
}

int mod_pow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)res *= a;
        a *= a;
        a %= mod;
        res %= mod;
        b >>= 1;
    }
    return res;
}

int combination(int n, int k) {
    if (k > n)return 0;
    if (k < 0)return 0;
    int res = fact[n] * inv[n - k] % mod * inv[k] % mod;
    return res;
}

int A[size];
int l, r;

void input() {
    cin >> N;
    rep(i, N + 1) {
        int a;
        cin >> a;
        if (!A[a])A[a] = i + 1;
        else {
            l = A[a] - 1;
            r = N - i;
            break;
        }
    }
}

int K(int k) {
    int res = combination(N + 1, k) - combination(l + r, k - 1);
    res += mod;
    res %= mod;
    return res;
}

signed main() {
    pre();
    input();
    rep(k, N + 1) {
        cout << K(k + 1) << endl;
    }
    return 0;
}

Measured memory_bytes: 3584
n=int(input())
h=list(map(int,input().split()))
ans="Yes"
for i in range(n-1,0,-1):
  if h[i-1]<=h[i]:
    continue
  elif h[i-1]==h[i]+1:
    h[i-1]=h[i-1]-1
  else:
    ans="No"
    break
print(ans)

Measured memory_bytes: 14396
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC109_A();
        }

        static void ABC109_A()
        {
            var AB = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            Console.WriteLine((AB[0] * AB[1]) % 2 == 0 ? "No" : "Yes");
        }
    }
}

Measured memory_bytes: 13268
N = int(input())
A = list(map(int, input().split()))

def solve():
    ans = float("inf")
    araiguma = sum(A)
    snuke = 0
    for A_i in A[0:-1]:
        snuke += A_i
        araiguma -= A_i
        score = abs(araiguma - snuke)
        if score < ans:
            ans = score
    print(ans)


solve()

Measured memory_bytes: 24816
import java.util.Arrays;
import java.util.Scanner;

/**
 *
 * @author lenovo
 */
public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();

        int[] array = {a, b, c};
        Arrays.sort(array);
        String s=""+array[0]+" "+array[1]+" "+array[2];

        for (int i = 0; i < array.length; i++) {
       
        }
        System.out.println(s);
    }
}

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

using namespace std;
using namespace atcoder;

#define ll long long

int op(int a, int b) {
	return max(a, b);
}
int e() {
	return -1;
}
int target;
bool f(int v) {
	return v < target;
}

signed main() {
	int N, Q; cin >> N >> Q;
	vector<int>A(N);
	for (int i = 0; i < N; i++)cin >> A[i];
	segtree<int, op, e>seg(A);
	for (int i = 0; i < Q; i++) {
		int T; cin >> T;
		if (T == 1) {
			int X, V; cin >> X >> V; X--;
			seg.set(X, V);
		}
		else if (T == 2) {
			int L, R; cin >> L >> R; L--;
			cout << seg.prod(L, R) << endl;
		}
		else {
			int X; cin >> X >> target; X--;
			cout << seg.max_right<f>(X) + 1 << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 6156
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	string S;
	int ans;

	cin >> S;
	if (S == "SUN") ans = 7;
	else if (S == "MON") ans = 6;
	else if (S == "TUE") ans = 5;
	else if (S == "WED") ans = 4;
	else if (S == "THU") ans = 3;
	else if (S == "FRI") ans = 2;
	else if (S == "SAT") ans = 1;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
/* 
    AABRA KA DABRA.. !! 
*/
#include "bits/stdc++.h"
using namespace std;
typedef long double ld;
#define int long long
#define RAGE ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(i=0; i <n; i++)
#define repv(i,k,n) for(int i=k; i<=n; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define endl '\n'
#define deb(x) cout<<#x<<" = "<<x<<endl
#define gcd __gcd
#define inf LLONG_MAX
#define minf LLONG_MIN 
const int mod = (int)(1e9+7);

int power(int x,int n)
{   
    if(n==0)    return 1;
    if(n==1)    return x%mod;
    if(n%2==0)  {   int y = power(x,n/2)%mod;return (y*y)%mod;}
    if(n&1)     {   int y = power(x,n-1);return (x%mod * y%mod)%mod;}
    return 0;
}
bool is_power_2(int n)  { return log2(n)==floor(log2(n));}
bool is_prime(int n){   for(int i=2; i*i<=n; i++)   if(n%i==0)  return 0;   return 1;}

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

/*                                                                 
    ╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩╦═╩═╦═╩═╦═╩═╦═╩═╦═╩╦═╩═╦═╩═╦═╩═╦═╩═╦═╩╦═╩═╦═╩═╦ 
*/  




void solve()
{   
    int n,i,j,k,m;
    char s;
    cin>>s;
    if(s>='A' && s<='Z')
        cout<<'A';
    else
        cout<<'a';
}   
signed main()
{
    RAGE;
    int t=1;
    //  cin>>t;
    while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef struct {
    int a; int b; int c; int d;
}Data;
vector<Data> ans;
priority_queue< int, std::vector<int>, std::greater<int> >
find_(priority_queue< int, std::vector<int>, std::greater<int> > y, int f) {
    priority_queue< int, std::vector<int>, std::greater<int> > ret;
    bool ok = true;
    while(!y.empty()) {
        int tmp = y.top();
        y.pop();
        if(tmp == f) {
            ok = false;
            continue;
        }
        ret.push(tmp);
    }
    if(ok) ret.push(f);
    return ret;
}
int main() {
    int h, w; cin >> h >> w;
    priority_queue< int, std::vector<int>, std::greater<int> > x[h];
    int a[h][w];
    rep(i, h) rep(j, w) {
        cin >> a[i][j];
        if(a[i][j] % 2) x[i].push(j);
    }
    rep(i, h) {
        while(x[i].size() > 1) {
            int first = x[i].top(); x[i].pop();
            int second = x[i].top(); x[i].pop();
            rep(j, second-first) {
                ans.push_back(Data{i,first+j,i,first+j+1});
            }
        }
        if(x[i].size()==1 && i!=h-1) {
            x[i+1] = find_(x[i+1], x[i].top());
            ans.push_back(Data{i,x[i].top(),i+1,x[i].top()});
        }
    }
    cout << ans.size() << endl;
    rep(i, ans.size()) {
        printf("%d %d %d %d\n",ans[i].a+1,ans[i].b+1,ans[i].c+1,ans[i].d+1);
    }
}          


Measured memory_bytes: 6128
#include<iostream>
#include<string>

int main(void){
    std::string s;
    std::cin >> s;

    long long distance = 0;
    long long ans = 0;

    for(int i = 0; i < s.size(); i++){
        if(s.at(i) == 'B') {
            distance++;
        }
        else {
            ans += distance;
            }
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
#define X first
#define Y second
#define PB push_back
#define eps 1e-9
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i=0; i<(int)(n); ++i)

const int maxn = 1e4+7;

inline int read() {
    int ret=0,c,f=1;
    for(c=getchar(); !(isdigit(c)||c=='-'); c=getchar());
    if(c=='-') f=-1,c=getchar();
    for(; isdigit(c); c=getchar()) ret=ret*10+c-'0';
    if(f<0) ret=-ret;
    return ret;
}
int b[maxn];

int main() {
	
    ios_base::sync_with_stdio(0);
    cin.tie(0);    
    // #ifndef ONLINE_JUDGE
    // freopen("i.txt", "r", stdin);
    // freopen("o.txt", "w", stdout);
    // #endif

    int n,m,c;
    cin>>n>>m>>c;
    rep(i,m) cin>>b[i];
    int ans = 0;
    rep(i,n) {
      int res = c;
      rep(j,m) {
        int t;
        cin>>t;
        res += t*b[j];
      }
      if(res > 0) ++ans;
    }
    cout<<ans;
}

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

namespace abc159
{
    class Program
    {
        static void Main(string[] args)
        {
            //a();
            c();
        }

        public static void a()
        {
            int[] nm = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int n = nm[0], m = nm[1];
            int ans = 0;
            
            Console.WriteLine(ans);
        }

        public static void c()
        {
            double l = double.Parse(Console.ReadLine());
            double x = l / 3.0;
            double ans = x * x * x;
            Console.WriteLine(ans);
        }
        
    }
}


Measured memory_bytes: 13140