akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define ll long long
template <class T>
inline void read(T &x)
{
   x=0; char c=getchar(); int f=1;
   while(!isdigit(c)){if(c=='-')f=-1; c=getchar();}
   while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=2e5+10;
int a[N];
int pos[N],num[N],top,n;
bool che(int b)
{
	top=0;
	for(int i=2;i<=n;i++)
	if(a[i]<=a[i-1])
	{
		int tmp=a[i];
		while(top&&pos[top]>tmp) top--;
		while(top&&tmp&&pos[top]==tmp&&num[top]==b-1) tmp--,top--;
		if(tmp==0) return 0;
		if(pos[top]<tmp){ pos[++top]=tmp,num[top]=1; if(b<2) return 0;}
		else num[top]++;
	}
	return 1;
}
int main()
{
	read(n);
	for(int i=1;i<=n;i++) read(a[i]);
	int l=1,r=n;
	while(l<r)
	{
		int mid=l+r>>1;
		if(che(mid)) r=mid;
		else l=mid+1;
	}
	printf("%d",r);
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

struct node{
  node *next[11];
  int m;
};

node gN[100*1000];
int cnt;

node *myalloc(){
  REP(i,11) gN[cnt].next[i] = NULL;
  gN[cnt].m = 0;
  return &gN[cnt++];
}

void mknode(node *nd, char *c, int m){
  if(*c == '\0'){
    nd->m = m;
    return;
  }
  int nn = (*c == '*' ? 10 : (*c - '0'));
  node *tmp = nd->next[nn];
  if(!tmp) tmp = nd->next[nn] = myalloc();
  mknode(tmp, c+1, m);
}

int check(node *nd, char *c){
  if(!nd) return 0;
  if(*c == '\0')
    return nd->m;
  //printf("check(%c)\n",*c);
  return max(check(nd->next[*c-'0'], c+1), check(nd->next[10], c+1));
  
}

int main(){
  int n,m;
  while(scanf("%d%d ",&n,&m), n+m){
    char buff[20];
    int c;
    node *root = myalloc();
    REP(i,n){
      scanf("%s %d ",buff,&c);
      mknode(root,buff,c);
    }
    int ans = 0;
    REP(i,m){
      scanf("%s",buff);
      //printf("%d (%s)\n",check(root,buff),buff);
      ans += check(root,buff);
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 0
/* author :: eSeF */
using System;
class AC
{
    static void Main()
    {
        var ABC = Csin.Input<int, int, int>();
        if (ABC == (5, 5, 7) || ABC == (5, 7, 5) || ABC == (7, 5, 5))
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }

    }
}
static class Csin
{
    public static string[] StrArray() => Console.ReadLine().Split();
    public static string[] StrArray(char separator) => Console.ReadLine().Split(separator);

    private static T Conv<T>(string value) => (T)Convert.ChangeType(value, typeof(T));
    public static (T, U) ReadTuple<T, U>(string[] input) => (Conv<T>(input[0]), Conv<U>(input[1]));
    public static (T, U, V) ReadTuple<T, U, V>(string[] input) => (Conv<T>(input[0]), Conv<U>(input[1]), Conv<V>(input[2]));
    public static (T, U, V, W) ReadTuple<T, U, V, W>(string[] input) => (Conv<T>(input[0]), Conv<U>(input[1]), Conv<V>(input[2]), Conv<W>(input[3]));
    public static (T, U, V, W, X) ReadTuple<T, U, V, W, X>(string[] input) => (Conv<T>(input[0]), Conv<U>(input[1]), Conv<V>(input[2]), Conv<W>(input[3]), Conv<X>(input[4]));

    public static (T, U) Input<T, U>() => ReadTuple<T, U>(StrArray());
    public static (T, U, V) Input<T, U, V>() => ReadTuple<T, U, V>(StrArray());
    public static (T, U, V, W) Input<T, U, V, W>() => ReadTuple<T, U, V, W>(StrArray());
    public static (T, U, V, W, X) Input<T, U, V, W, X>() => ReadTuple<T, U, V, W, X>(StrArray());
}


Measured memory_bytes: 27512
MOD = 10 ** 9 + 7
N = int(input())
S = iter(input() + " ")
prev = next(S)
count = 0
counts = []
for c in S:
    count += 1
    if prev != c:
        counts.append(count)
        count = 0
    prev = c
counts = iter(counts)
prev = next(counts)
ans = 3 * prev
for count in counts:
    if prev == 1:
        ans *= 2
    elif count == 2:
        ans *= 3
    prev = count
print(ans % MOD)

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

int main()
{
 int k;
  cin>>k;
  
  string s;
  
  cin>>s;
  
  int q=s.size();
  
  if(q<=k)
  {
    cout<<s<<endl;
  }
  else
  {
    for(int i=0;i<k;i++)
    {
cout<<s[i];
    }
    cout<<"..."<<endl;
  }
  
  return 0;}

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

string s;
stack <char> st;

int main() {
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        if (st.size() == 0)
            st.push(s[i]);
        else {
            if (s[i] == '0') {
                if (st.top() == '1')
                    st.pop();
                else
                    st.push('0');
            }
            else {
                if (st.top() == '0')
                    st.pop();
                else
                    st.push('1');
            }
        }
    }
    cout << s.size() - st.size() << '\n';
 	return 0; 
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int H = line[0], W = line[1];

            var array = new char[H][];

            for (var i = 0; i < H; i++)
            {
                array[i] = Console.ReadLine().ToCharArray();
            }

            var hList = new HashSet<int>();
            for (var i = 0; i < H; i++)
            {
                if (!array[i].Any(z => z == '#')) hList.Add(i);
            }

            var wList = new HashSet<int>();
            for (var i = 0; i < W; i++)
            {
                var isTrue = true;
                for (var j = 0; j < H; j++)
                {
                    if (array[j][i] == '#')
                    {
                        isTrue = false;
                        break;
                    }
                }
                if (isTrue) wList.Add(i);
            }

            for (var i = 0; i < H; i++)
            {
                if (hList.Contains(i)) continue;
                for (var j = 0; j < W; j++)
                {
                    if (wList.Contains(j)) continue;
                    Console.Write(array[i][j]);
                }
                Console.WriteLine();
            }
        }
    }
}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

int N;
string a, b, c;

int main() {
	cin >> N >> a >> b >> c;
	int ans = 0;
	rep(i, N) {
		vi cnt(26);
		cnt[a[i]-'a']++;
		cnt[b[i]-'a']++;
		cnt[c[i]-'a']++;
		int maxi = 0;
		rep(j, 26) maxi = max(maxi, cnt[j]);
		ans += 3 - maxi;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ctime>
#include <set>
#include <sstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <cmath>
#define ll long long
using namespace std;

int main() {
    int k;
    cin >> k;
    string s;
    cin >> s;
    if (s.length() > k) {
        s = s.substr(0, k) + "...";
    }
    cout << s;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>
#include <tuple>




typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define FOR(i,a,b) for(int i=(int)(a) ; i < (int) (b) ; ++i )
#define rep(i,n) FOR(i,0,n)
#define sz(x) int(x.size())


template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;




int main(){
    int n;
    cin>>n;
    vector<int> v;
    rep(i,n) {
        int a;
        cin>>a;
        v.push_back(a);
    }
    int pre=-21;
    for (int i=0;i<n;i++){
        if (pre<=v[i]-1) {
            v[i]--;
            pre=v[i];
        } else if (pre <=v[i]){
            pre=v[i];
        } else {
            cout<<"No"<<endl;
            return 0;
        }
    }
    
    cout<<"Yes"<<endl;
    
    return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cassert>
using namespace std;

#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;

int main ()
{
    int N; cin >> N;
    vector < int > x(N);
    REP(i,N) cin >> x[i];
    REP(i,N) x[i] -= 1;

    vector < int > ans(N * N, -1);
    REP(i,N) ans[x[i]] = i + 1;

    vector < pair < int,int > > ord;
    REP(i,N) ord.push_back(make_pair(x[i], i));
    sort(ord.begin(), ord.end());

    int top = 0;
    for (int i = 0; i < N; i++) {
    	int idx = ord[i].second;
    	for (int j = 0; j < idx; j++) {
    		while (ans[top] >= 0) top++;
    		ans[top] = idx + 1;
    	}

    }

    int bottom = N * N - 1;
    for (int i = N - 1; i >= 0; i--) {
    	int idx = ord[i].second;
    	for (int j = 0; j < N - 1 - idx; j++) {
    		while (ans[bottom] >= 0) bottom--;
    		ans[bottom] = idx + 1;
    	}
    }

    vector < int > cnt_pre(N, 0);
    vector < int > cnt_nxt(N, 0);
    REP(i,ans.size()) {
    	if (x[ans[i] - 1] < i) cnt_pre[ans[i] - 1]++;
    	if (x[ans[i] - 1] > i) cnt_nxt[ans[i] - 1]++; 
    }

    REP(i,N) {
    	if (cnt_nxt[i] != i) {
    		cout << "No" << endl;
    		return 0;
    	}
    	if (cnt_pre[i] != N - i - 1) {
    		cout << "No" << endl;
    		return 0;
    	}
    }

    cout << "Yes" << endl;
    REP(i,ans.size()) cout << ans[i] << " ";
    cout << endl;
    
    return 0;
}


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

int N, K, R, S, P;
int cnt_r, cnt_s, cnt_p;
string T;
vector<string> str;

void input_init(void) {
	cin >> N >> K >> R >> S >> P >> T;
	str.resize(K, "");
	for (int i = 0; i < N; ++i)
		str[i % K] += T[i];
	for (int i = 0; i < K; ++i)
		str[i] += '@';
	cnt_r = cnt_s = cnt_p = 0;
}

void cnt_check(void) {
	for (int i = 0; i < K; ++i) {
		if (str[i] == "@")
			break;
		int p = 0;
		while (p < (int)str[i].length() - 1) {
			if (str[i][p] == 'r')
				++cnt_r;
			else if (str[i][p] == 's')
				++cnt_s;
			else
				++cnt_p;
			if (str[i][p] == str[i][p + 1])
				p += 2;
			else
				++p;
		}
	}
}

int main(void) {
	input_init();
	cnt_check();
	int ans = P * cnt_r + R * cnt_s + S * cnt_p;
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 5120
type Helix = "A" | "C" | "G" | "T";
  const HelixCouple: Helix[] = ["A", "T", "C", "G"];
  const HelixRegexp = new RegExp(`[${HelixCouple.join("")}]+`, "g");

  const entryPoint = function(args: string[]) {
    let maximamSize = 0;
    let matched: any[];
    while((matched = HelixRegexp.exec(args[0])) != null) {
      if (matched[0].length > maximamSize) maximamSize = matched[0].length;
    }
    console.log(maximamSize);
  }

  const getStandardInput = function() {
    process.stdin.resume();
    process.stdin.setEncoding('utf8');
    let inputString = '';
    process.stdin.on('data', function(chunk) {
        inputString += chunk;
    });
    process.stdin.on('end', () => entryPoint(inputString.split("\n")));
  }();

Measured memory_bytes: 7500
import itertools
from collections import Counter

N = int(input())
V = [int(x) for x in input().split()]
EV_counter = Counter(V[::2])
OD_counter = Counter(V[1::2])

# 1種類しかないとき対策
EV_counter[-1] = 0
OD_counter[-2] = 0

# 上位2種しか使う必要がない
EV = EV_counter.most_common(2)
OD = OD_counter.most_common(2)

answer = N
for (k1,v1), (k2,v2) in itertools.product(EV,OD):
  if k1 == k2:
    continue
  x = (N - v1 - v2)
  if answer > x:
    answer = x

print(answer)


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

int N,A,B,C;
vector<int> L;

int rec(int i, int a, int b, int c)
{
	if(i==N){
		if(!a || !b || !c) return INF;
		return abs(a-A)+abs(b-B)+abs(c-C);
	}

	int res = rec(i+1, a, b, c);
	res = min(res, rec(i+1, a+L[i], b, c) + (a ? 10 : 0));
	res = min(res, rec(i+1, a, b+L[i], c) + (b ? 10 : 0));
	res = min(res, rec(i+1, a, b, c+L[i]) + (c ? 10 : 0));

	return res;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> N >> A >> B >> C;
	L.resize(N);
	REP(i,N) cin >> L[i];

	cout << rec(0, 0, 0, 0) << '\n';
	return 0;
}



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

namespace Atcoder
{
    class AtCodeeeeeeeeeeeeeeeeeeeer
    {
        static void Main(string[] args)
        {
            int[] s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int A = s[0];
            int B = s[1];
            int K = s[2];
            int ans = 0;
            List<int> ls = Func(A, B);
            ls.Sort();
            ls.Reverse();
            Console.WriteLine(ls[K-1]);

            
        }
        static List<int> Func(int a,int b)
        {
            List<int> ls = new List<int>();
            for (int i = 1; i <= a||i<=b; i++)
            {
                if (b%i==0&&a%i==0)
                {
                    ls.Add(i);
                }
            }
            return ls;
        }
    }
}


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

unsigned long long cnt[10000007];

int main() {
	int n;
	cin >> n;
	
	for(int i=1; i<=n; i++) 
		for(int j=i; j<=n; j+=i)
			cnt[j]++;
			
	unsigned long long ans = 0;
	for(int i=1; i<=n; i++)
		ans += cnt[i] * i;
	cout << ans << endl;
}

Measured memory_bytes: 81744
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;


//auto mod int
//https://github.com/atcoder-live/library/blob/master/mint.cpp

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    int64_t x;
    mint(int64_t x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(int64_t t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    //for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    int n;
    cin >> n;
    map<char, mint> G;
    string S;
    cin >> S;
    rep(i, n) {
        G[S[i]] += 1;
    }

    mint ans=1;
    for(auto i:G) {
        ans *= i.second+1;
    }
    ans -= 1;

    cout << ans << endl;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n,k; scanf("%d%d",&n,&k);

	int ans=0;
	for(;n>0;n/=k) ans++;
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main()
{
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    long long n,count=0;
    //long long a[n];
    cin >> n;
    for (long long i=1; i <= n;i++){
        if(i%3==0||i%5==0){
            
            continue;
        }
        else
            count += i;
    }
    cout << count << endl;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
int aa[10000]={0};
int main()
{
    long long a,b,c;
    cin>>a>>b>>c;
    if(a+b+1>=c){
        cout<<b+c;
    }else{
        cout<<a+2*b+1;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <tuple>
#include <cassert>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

int main ()
{
    string s;
    cin >> s;
    if (s == "SUN") {
        cout << 7 << endl;
    }
    if (s == "MON") {
        cout << 6 << endl;
    }
    if (s == "TUE") {
        cout << 5 << endl;
    }
    if (s == "WED") {
        cout << 4 << endl;
    }
    if (s == "THU") {
        cout << 3 << endl;
    }
    if (s == "FRI") {
        cout << 2 << endl;
    }
    if (s == "SAT") {
        cout << 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int A,B;
    cin >> A >> B;
    if((A==2&&B==3)||(A==3&&B==2))cout << 1 << endl;
    else if((A==1&&B==3)||(A==3&&B==1))cout << 2 << endl;
    else cout << 3 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A, B, ans=0;
    string str;
    cin >> A >> B;
    for(int i = A; i < B+1; i++){
        str = to_string(i);
        if((str[0] == str[4]) && str[1] == str[3]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 256
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_COST_MAX		200000									// 最大コスト数
#define D_COST_ROW		0										// コスト - 行
#define D_COST_COL		1										// コスト - 列

// 内部構造体 - コスト情報
typedef struct Cost {
	int miRC;													// 行・列
	long long mlCost;											// コスト
} Cost;

// 内部変数
static FILE *szpFpI;											// 入力
static int siW, siH;											// 幅・高さ
static Cost sz1Cost[D_COST_MAX];								// コスト
static int siCCnt;												// コスト数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// ソート関数 - コスト昇順
int
fSortFnc(
	const void *pzpVal1			// <I> 値１
	, const void *pzpVal2		// <I> 値２
)
{
	Cost *lzpVal1 = (Cost *)pzpVal1;
	Cost *lzpVal2 = (Cost *)pzpVal2;

	// コスト昇順
	if (lzpVal1->mlCost > lzpVal2->mlCost) {
		return 1;
	}
	else if (lzpVal1->mlCost < lzpVal2->mlCost) {
		return -1;
	}

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// 幅・高さ - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d", &siW, &siH);

	// コスト - 取得
	for (i = 0; i < siW; i++) {
		sz1Cost[siCCnt].miRC = D_COST_COL;
		fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
		sscanf(lc1Buf, "%lld", &sz1Cost[siCCnt].mlCost);
		siCCnt++;
	}
	for (i = 0; i < siH; i++) {
		sz1Cost[siCCnt].miRC = D_COST_ROW;
		fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
		sscanf(lc1Buf, "%lld", &sz1Cost[siCCnt].mlCost);
		siCCnt++;
	}
	qsort(sz1Cost, siCCnt, sizeof(Cost), fSortFnc);

	// 合計 - 取得
	long long llSum = 0;
	int liRCnt = -1;
	int liCCnt = -1;
	for (i = 0; i < siCCnt; i++) {
		if (sz1Cost[i].miRC == D_COST_ROW) {
			llSum += sz1Cost[i].mlCost * (long long)(siW - liCCnt);
			liRCnt++;
		}
		else {
			llSum += sz1Cost[i].mlCost * (long long)(siH - liRCnt);
			liCCnt++;
		}
	}

	// 出力
	sprintf(lc1Buf, "%lld\n", llSum);
	fOutLine(lc1Buf);

	return 0;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// データ - 初期化
	siCCnt = 0;													// コスト数

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 6396
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

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

int gcd(int a,int b){int r,tmp;if(a < b){tmp = a;a = b;b = tmp;}r = a % b;while(r != 0){a = b;b = r;r = a % b;}return b;}

int max(int a,int b){return a > b ? a : b;}

int main()
{
    int n,s,x[100010],i,r;
    scanf("%d %d",&n,&s);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&x[i]);
    }
    x[i] = s;

    qsort(x,n + 1,sizeof(int),asc);
    r = x[1] - x[0];
    for (i = 1; i < n; i++)
    {
        r = gcd(x[i + 1] - x[i],r);
    }
    printf("%d\n",r);
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i = 0; i < N; i++) cin >> d[i];
    sort(d.begin(),d.end());
    int Count = 1;
    for(int i = 1; i < N; i++){
        if(d[i] != d[i-1]) Count++;
    }
    cout << Count << endl;
}


Measured memory_bytes: 256
n,q = map(int,input().split())
s = list(input())

#a[i]:s[0]~s[i]までに何個ACがあったか
a = [0]*n
#end[i]:s[i]がACの'C'か
end = [False]*n
for i in range(1,n):
    if s[i] == 'C' and s[i-1] == 'A':
        a[i] = a[i-1]+1
        end[i] = True
    else:
        a[i] = a[i-1]

for i in range(q):
    L,R = map(int,input().split())
    L,R = L-1,R-1
    if L == 0:
        print(a[R])
    else:
        if end[L]:
            print(a[R]-a[L-1]-1)
        else:
            print(a[R]-a[L-1])

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

int main() {
  int N,K,x;
  int sum = 0;
  cin >> N >> K;
  
  for (int i = 0; i < N; i++) {
    cin >> x;
    if(x < abs(K-x)) {
      sum += 2 * x;
    }
    else {
      sum += 2 * abs(K-x);
    }  
  }
  
  cout << sum << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, h int
	fmt.Scan(&n)
	fmt.Scan(&h)
	values1 := make([]int, n)
	values2 := make([]int, n)
	for i := 0; i < n; i++ {
		var x, y int
		fmt.Scan(&x)
		fmt.Scan(&y)
		values1[i] = x
		values2[i] = y
	}
	sort.Ints(values1)
	sort.Ints(values2)
	ans := (h + values1[n-1] - 1) / values1[n-1]
	sum := 0
	for i := 0; i < n; i++ {
		sum += values2[n-1-i]
		if sum >= h {
			if i+1 < ans {
				ans = i + 1
			}
			break
		}
		num := (h-sum+values1[n-1]-1)/values1[n-1] + i + 1
		if num < ans {
			ans = num
		}
	}
	fmt.Println(ans)
}


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

int main() {
    int n;
    cin >> n;
    vector<string> siri(n);
    string s, t;
    for(int i=0; i<n; i++) cin >> siri.at(i);
    bool flag=true;
    for(int i=0; i<n-1; i++) {
        s=siri.at(i);
        t=siri.at(i+1);
        if(s.at(s.size()-1) != t.at(0)) {
            flag=false;
            break;
        }
    }
    sort(siri.begin(), siri.end());
    for(int i=0; i<n-1; i++) {
        if(siri.at(i)==siri.at(i+1)) {
            flag=false;
            break;
        }
    }
    if(flag) cout << "Yes";
    else cout << "No";
}

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

using namespace std;

#define llint long long int
#define REP(i,s,l) for(llint i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main() {

    int S,head,tail;//hhtt
    string result;
    cin >> S ;

    tail = S%100;
    head = S/100;


    if(head == 0){
        if(tail == 0) result = "NA";
        else if(tail < 13) result = "YYMM";//0012
        else{ result = "NA";}//0013
    }else if(head < 13){
        if(tail == 0) result = "MMYY";//0200
        else if(tail < 13) result = "AMBIGUOUS";//
        else {result = "MMYY";} //0214 
    }else {
        if(tail == 0) result = "NA";//1400
        else if (tail < 13) result = "YYMM";//1412
        else {result = "NA"; } //1414      
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int main() {
  string s;
  cin >> s;
  rep(i, s.length()) cout << "x";
  return 0;
}

Measured memory_bytes: 256
class Dice():

    patterns = {"N":[1,5,2,3,0,4],"S":[4,0,2,3,5,1],"W":[2,1,5,0,4,3],"E":[3,1,0,5,4,2]}

    def __init__(self):
        self.number = [i for i in range(6)]

    #0->上、1->正面、2->右面、3->左面、4->裏面、5->下面
    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5

    def roll(self,command,int):
        for i in command:
            self.number = [self.number[j] for j in self.patterns[i]]
        return self.number[int]


dice = Dice()
nums = list(map(int,input().split()))
dice.setNumber(nums[0],nums[1],nums[2],nums[3],nums[4],nums[5]) #サイコロの初期値
q_num = int(input()) #質問の回数

command1 = ["S","S","S","S","E","E","E"] #topを一致させるための回転
command2 = ["S","E","N","S","E","N","S","E","N","S","E","N"] #frontを一致させるための回転


for i in range(q_num): #質問の数だけ回答を繰り返す
    right = nums[2]
    top,front = map(int,input().split())
    for j in command1:
        if top == dice.roll(j,0):
            for k in command2:
                if front == dice.roll(k,1):
                    right = dice.number[2]
    print(right)



Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
int main(){
	int i,j,len1,len2;
	string a,b;
	cin>>a>>b;
	len1=a.size();
	len2=b.size();
	for(i=0;i<len1+len2;i++){
		if(i%2==0){
			cout<<a[i/2];
		}
		else{
			cout<<b[i/2];
		}
	}
	cout<<endl;
}

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

int main() {
    int N;
    cin >> N;
    int s[N];
    for(int i = 0; i < N; i++) {
        cin >> s[i];
    }
    int num[110] = {0};
    for(int i = 0; i< N; i++) {
        num[s[i]]++;
    }
    int res = 0;
    for(int i = 0; i<110; i++) {
        if(num[i] > 0) res++;
    }
    cout << res << endl;

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program{
	static void Main(){
		string s=Console.ReadLine();
		int ans=s.Length;
		if(s.Length%2==0){
			if(s[s.Length/2-1]!=s[s.Length/2]){ans=s.Length/2;}
			else{
				for(int i=s.Length/2;i<s.Length-1;i++){
					if(s[s.Length-i-1]!=s[s.Length-i-2]||s[i]!=s[i+1]){
						ans=i+1;
						break;
					}
				}
			}
		}
		else if(s.Length!=1){
			if(s[s.Length/2]!=s[s.Length/2-1]||s[s.Length/2]!=s[s.Length/2+1]){ans=s.Length/2+1;}
			else{
				for(int i=s.Length/2+1;i<s.Length-1;i++){
					if(s[s.Length-i-1]!=s[s.Length-i-2]||s[i]!=s[i+1]){
						ans=i+1;
						break;
					}
				}
			}
		}
		Console.WriteLine("{0}",ans);
	}
}

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

#define ll long long
#define pii pair <int, int>

using namespace std;

int n, d, a;
pair <ll, ll> v[200001];
ll poz[200001], val[200001];
ll sum[200001];

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

    cin >> n >> d >> a;
    int x, y;
    for (int i = 1; i <= n; ++i)
        cin >> v[i].first >> v[i].second;
    sort(v + 1, v + n + 1);
    for (int i = 1; i <= n; ++i) {
        poz[i] = v[i].first;
        val[i] = v[i].second;
    }
    ll rez = 0;
    for (int i = 1; i <= n; ++i) {
        sum[i] += sum[i - 1];
        val[i] -= sum[i];
        if (val[i] > 0) {
            ll nr = val[i] / a + (val[i] % a == 0 ? 0 : 1);
            rez += nr;
            sum[i] += nr * a;
            int nxt = upper_bound(poz + 1, poz + n + 1, poz[i] + 2 * d) - poz;
            sum[nxt] -= nr * a;
        }
    }
    return cout << rez, 0;
}


Measured memory_bytes: 8064
import java.util.Scanner;

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

	if(N >= 10){
	    System.out.print(R);
	}else{
	    System.out.print(R + 100*(10-N));
	}
    }
}


Measured memory_bytes: 22228
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sf(n) scanf("%lld",&n)
#define sff(n,m) scanf("%lld %lld",&n,&m)
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PLL pair<ll,ll>
#define mod 1000000007
#define mx 100002
#define FILE freopen("input.txt","r",stdin)

ll a[402];
ll f[402];
ll dp[402][402];

ll F(ll st,ll en)
{
  if(st>=en) return 0;
  if(dp[st][en]!=-1) return dp[st][en];

  ll ret = 1e18;

  for(ll i = st;i<en;i++)
  {
    ret = min(ret,(f[en]-f[st-1])+F(st,i)+F(i+1,en));
  }

  return dp[st][en] = ret;
}

int main()
{
ll n;
sf(n);

for(ll i = 1;i<=n;i++)
{
  sf(a[i]);
}

f[0] = 0;

for(ll i = 1;i<=n;i++)
{
  f[i] = a[i];
  f[i]+=f[i-1];
}

memset(dp,-1,sizeof dp);
cout<<F(1,n)<<endl;

return 0;
}


Measured memory_bytes: 1536
import sys
N,M=map(int,raw_input().split())
a=[raw_input() for _ in range(N)]
b=[raw_input() for _ in range(M)]
#print a
#print b

c=[]

for i in range(N-M+1):
	for j in range(N-M+1):
		tmp_c=[]
		for k in range(M):
			#print a[i+k][j:j+M]
			tmp_c.append(a[i+k][j:j+M])
		c.append(tmp_c)


print "Yes" if b in c else "No"

Measured memory_bytes: 3844
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

string s;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> s;
	if((s[0] == s.back()) ^ (s.length() % 2)) cout << "First\n";
	else cout << "Second\n";
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <set>
#include <string>
using namespace std;

int main()
{
	int32_t N;
	cin >> N;

	set<int32_t> _set;
	for (int32_t i = 0; i < N; i++) {
		int32_t A;
		cin >> A;
		if (_set.find(A) == _set.end()) {
			_set.insert(A);
		} else {
			_set.erase(A);
		}
	}

	cout << _set.size() << endl;
	return 0;
}

Measured memory_bytes: 4864
MOD = int(1e9 + 7)


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    dp = [[0] * (K+1) for _ in range(N+1)]
    dp[0][K] = 1

    for i in range(N):
        cumsum = [0] * (K+2)
        for j in range(K+1):
            cumsum[j+1] = cumsum[j] + dp[i][j]
        for j in range(K+1):
            dp[i+1][j] = (cumsum[min(j+A[i]+1, K+1)] - cumsum[j]) % MOD
    print(dp[N][0])


if __name__ == "__main__":
    main()


Measured memory_bytes: 174876
#include <stdio.h>


int main(void) {
    int a[100], n, i, u, swap_count, t;

    while (scanf("%d", &n) == 1 && n) {
        for (i = 0; i < n; i++) {
            scanf("%d", &(a[i]));
        }
        swap_count = 0;
        for (u = n - 1; u > 0; u--) {
            for (i = 0; i < u; i++) {
                if (a[i] > a[i+1]) {
                    t = a[i];
                    a[i] = a[i+1];
                    a[i+1] = t;
                    swap_count++;
                }
            }
        }
        printf("%d\n", swap_count);
    }
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n, m, k;
llint a[200005], b[200005];
llint s[200005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= m; i++) cin >> b[i], s[i] = s[i-1] + b[i];
	
	llint ans = 0, sum = 0;
	for(int i = 0; i <= n; i++){
		if(sum > k) break;
		llint p = upper_bound(s, s+m+1, k - sum) - s - 1;
		ans = max(ans, i+p);
		sum += a[i+1];
	}
	cout << ans << endl;
	
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b; cin>>a>>b;
    cout<<a*b/__gcd(a,b)<<endl;
    return 0;
}


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

using namespace std;

typedef long long LL;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	LL X, Y;
	
	cin >> X >> Y;
	cout << __lg(Y / X) + 1 << '\n';
	
	return 0;
}//main

Measured memory_bytes: 256
import collections
import sys

n = int(input())
nums = list(map(int, input().split()))

max_nums = max(nums)
cnt_list = collections.Counter(nums)
#print(cnt_list)

ans = 1
if cnt_list[0] == 1 and nums[0] == 0:
	for i in range(1, max_nums + 1):
		if cnt_list[i] == 0:
			print(0)
			sys.exit()
		else:
			ans *= (cnt_list[i - 1] ** cnt_list[i]) % 998244353
			#print(ans)
	print(ans % 998244353)

else:
	print(0)


Measured memory_bytes: 19936
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;


int main()
{
	int n;
	cin >> n;
	cout << n + (111 - n % 111)*(n%111!=0) << endl;
}


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

int main() {
	// your code goes here
	string m,n;
	cin>>m>>n;
    int dp[m.length()+1][n.length()+1];
    for(int i=0;i<=m.length();i++){
        for(int j=0;j<=n.length();j++){
            if(i==0 || j==0){
                dp[i][j]=0;
            }else{
                if(m[i-1]==n[j-1]){
                    dp[i][j]=dp[i-1][j-1]+1;
                }else{
                    dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
                }
            }
        }
    }
    int index=dp[m.length()][n.length()];
    char lcs[index+1];
    lcs[index]='\0';
    int i=m.length(),j=n.length();
    while(i>0 && j>0){
        if(m[i-1] == n[j-1]){
            lcs[index-1]=m[i-1];
            i--;j--;index--;
        }else if(dp[i-1][j]>dp[i][j-1]){
            i--;
        }else{
            j--;
        }
    }
    cout<<lcs;
	return 0;
}


Measured memory_bytes: 35456
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int read() { return readln.chomp.to!int; }
int[] reads() { return readln.split.to!(int[]); }

void main() {
    int n = read();
    int[] a = reads();

    long f(long b) {
        return iota(n)
            .map!(i => abs(a[i] - (b + i+1)))
            .sum;
    }

    enum N = 10^^10 + 1;
    long lb = -N, rb = N;
    while (rb - lb > 2) {
        long m1 = (lb+lb+rb) / 3;
        long m2 = (lb+rb+rb) / 3;
        if (f(m1) >= f(m2))
            lb = m1;
        else
            rb = m2;
    }
    assert(rb - lb == 2);
    debug {
        writeln(lb, " ", rb);
    }
    long mid = lb + (rb - lb) / 2;
    writeln(f(mid));
}

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

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

    long long ans = 3;
    int type = 0; //0: red 1: green 2: blue
    int count[3] = {};
    for (int i = 0; i < n; i++)
    {
        if (i == 0)
        {
            if (a[i] != 0)
            {
                cout << 0 << endl;
                return 0;            
            }
            count[type]++;
        }
        else
        {
            int type1 = (type+1) % 3;
            int type2 = (type+2) % 3;
            int candidate = 0;

            if (a[i] == count[type])
            {
                count[type]++;
                candidate++;
            }
            if (a[i] == count[type1])
            {
                if (candidate == 0)
                {
                    count[type1]++;
                }
                candidate++;                
            }
            if (a[i] == count[type2])
            {
                if (candidate == 0)
                {
                    count[type2]++;
                }
                candidate++;                
            }
            ans *= candidate;
            ans %= 1000000007;
            //cout << i << ":" << ans << "(a,b,c)" << count[type] << "," << count[type1] << "," << count[type2]<< endl;
            if (ans == 0)
            {
                cout << 0 << endl;
                return 0;            
            }
        }
    }
    cout << ans << endl;
    return 0;
}
 


Measured memory_bytes: 640
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 998244353
N, A, B, K = lr()
answer = 0
# A * x + B * y = K
# nCx * nCy

def cmb(n, k):
    if k < 0 or k > n: return 0 
    return fact_N * fact_inv[k] % MOD * fact_inv[n-k] % MOD

def cumprod(arr, MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n-1]; arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n-1, -1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64); x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64); x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv

U = N + 1 # 階乗テーブルの上限
fact, fact_inv = make_fact(U, MOD)
fact_N = fact[N]
comb = fact_N * fact_inv % MOD * fact_inv[::-1] % MOD

for x in range(N+1):
    temp = K-A*x
    if temp%B != 0:
        continue
    y = temp // B
    if y > N:
        continue
    if y < 0:
        break
    answer += comb[x] * comb[y]
    answer %= MOD

print(answer % MOD)


Measured memory_bytes: 26592
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

#define int ll

int a,b,at,bt;

signed main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    
    rep(i,n){
        a+=v[i];
        if(i%2&&a>=0){
            at+=a+1;
            a=-1;
        }
        if(i%2==0&&a<=0){
            at+=1-a;
            a=1;
        }
    }

    rep(i,n){
        b+=v[i];
        if(i%2==0&&b>=0){
            bt+=b+1;
            b=-1;
        }
        if(i%2&&b<=0){
            bt+=1-b;
            b=1;
        }
    }
    cout<<min(at,bt)<<endl;
}

Measured memory_bytes: 1024
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

n = int(input())
p = tuple([int(i) for i in readline().split()])
q = tuple([int(i) for i in readline().split()])

if p == q:
    print(0)
    exit()

from itertools import permutations
L = list(range(1,n+1))
for i,c in enumerate(permutations(L)):
    if c == p:
        a = i
    elif c == q:
        b = i

print(abs(a-b))










Measured memory_bytes: 3064
#include<stdio.h>
int main(){
int n,k,i,mod=1000000007;
long int ans=1;
scanf("%d %d\n",&n,&k);
for(i=0;i<n;i++){
ans=ans*k;
k--;
ans=ans%mod;
}
printf("%ld\n",ans);
return 0;
}


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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

int main()
{
  fastio;
  long x; cin >> x;
  long cur = 100;
  for (int i = 1; ; i++){
    cur += cur / 100;
    if (cur >= x) return cout << i, 0;
  }
  return 0;
}

Measured memory_bytes: 3652
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
#def MXI(): return [LI() for i in range(n)]　
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
ans=[]
if n%2==1:
    for i in range(1,n):
        for j in range(i+1,n+1):
            if i+j==n:
                continue
            ans.append([i,j])
else:
    for i in range(1,n):
        for j in range(i+1,n+1):
            if i+j==n+1:
                continue
            ans.append([i,j])
print(len(ans))
for i in range(len(ans)):
    print(*ans[i])
    
            
    
    

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

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  
  vector<int> xT(N, 0);
  vector<int> yT(M, 0);
  
  for (int i = 0; i < N; i++) cin >> xT.at(i);
  for (int i = 0; i < M; i++) cin >> yT.at(i);
  
  int maxX = *max_element(xT.begin(), xT.end());
  int minY = *min_element(yT.begin(), yT.end());
  
  int Zs = minY - maxX;
  
  if (Zs <= 0) {
    cout << "War" << endl;
    return 0;
  }
  
  for (int i = maxX + 1; i <= minY; i++) {
    if (i > X && i <= Y) {
      cout << "No War" << endl;
      return 0;
    }
  }
  
  cout << "War" << endl;
  return 0;
}

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

#define mp make_pair
#define s second
#define f first
#define ll long long
using namespace std;
vector <int> adj[100003];
int dis[100003], vis[100003], ans;

int dfs (int x, int p) {
	if (vis[x] == 1) return dis[x];
	vis[x] = 1;
	
	
	for (int i=0; i<adj[x].size(); i++) {
		int u = adj[x][i];
		if (u == p) continue;
		dis[x] = max(dis[x], dfs(u, x) + 1);
	}
	
	return dis[x];
}

int main () {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
	
	int n, m;
	cin >> n >> m;
	
	for (int i=0; i<m; i++) {
		int a, b; cin >> a >> b;
		adj[--a].push_back(--b);
	}	
	
	for (int i=0; i<n; i++) {
		if (vis[i] == 0) ans = max(ans, dfs(i, -1));	
	}
	
	cout << ans;
return 0;	
}




Measured memory_bytes: 9216
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        s: chars,
    }
    let mut s = s;
    s.dedup();
    println!("{}", s.len());
}


Measured memory_bytes: 4352