akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 1005;
const int MMAX = 2005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
// #define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << "(DUMP) " << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> pl;
typedef pair<ll, ll> pll;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int from, to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(int)){
  ll mid;
  while(_end - _begin > 1LL) {
    mid = (_begin + _end) / 2LL;
    if(f(mid)) {
      debug("BSearch: f(%d) == true\n", mid);
      _end = mid;
    }
    else
    {
      debug("BSearch: f(%d) == false\n", mid);
      _begin = mid;
    }
  }
  return _end;
}


ll N,M,K,A,B,C,D;
std::vector<edge> E;
ll d[NMAX];
string S;
vec v;

ll ans = 0;

void solve(){
  // main algorithm
  Fill(d, INFLL);
  d[A] = 0;
  for (int i = 0; i < N; ++i)
  {
    bool update = false;
    for (auto e: E)
    {
      if (d[e.from] != INFLL && d[e.to] > d[e.from] + e.cost)
      {
         d[e.to] = d[e.from] + e.cost;
         debug("d[%d] = d[%d] + %d\n", e.to, e.from, e.cost);
         update = true;
      }
    }
    if(update && i == N - 1){
      cout << "NEGATIVE CYCLE\n";
      return;
    }
    else if(!update){
      for (int i = 0; i < N; ++i)
      {
        if(d[i] != INFLL) printf("%lld\n", d[i]);
        else printf("INF\n");
      }
      break;
    }
  }
}
void debug(){
  // output debug information
  for(auto&& i : E) {
    cout << i.from << " -> " << i.to << " : " << i.cost << endl;
  }
}
void answer(){
  // output answer
  // printf("%lld\n", ans);
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  scanf("%lld%lld%lld", &N,&M, &A);
  for (int i = 0; i < M; ++i)
  {
    int f,t,c;
    cin >> f >> t >> c;
    E.push_back(edge{f, t, c});
  }
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

Measured memory_bytes: 3324
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    int N;
    cin >> N;
    VI A(N);
    VI B(N);
    VI C(N - 1);
    REP(i,N){
        cin >> A[i];
    }
    REP(i,N){
        cin >> B[i];
    }
    REP(i,N-1){
        cin >> C[i];
    }

    int happy = 0;
    REP(i,N){
        int num = A[i] - 1;
        happy = happy + B[num];
        if(i >= 1){
            if(A[i-1]+1 == A[i]){
                happy = happy + C[num-1];
            }
        }
    }

    cout << happy << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[200005];

int main(){
  ll n,x;
  cin>>n>>x;
  if(x==n*2-1 || x==1) cout<<"No"<<endl;
  else{
    cout<<"Yes"<<endl;
    if(x-2<1) {a[3]=x+2;a[0]=x;a[1]=x-1;a[2]=x*2-1;}
    else {a[0]=x-2;a[1]=x;a[2]=x-1;a[3]=x*2-1;}
    
    
    for(int i=1;i<=(n*2-1);i++) a[i] = i;
    swap(a[n],a[x]);
    swap(a[n-1],a[1]);
    swap(a[n+1],a[n*2-1]);
    if(x-2>1) swap(a[n+2],a[x-2]);
    else swap(a[n-2],a[x+2]);
    for(int i=1;i<=(n*2-1);i++) cout<<a[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++) // for簡略表記
#define DUMP(ar) for(int loop=0; loop<(int)ar.size(); loop++) cout << "[" << loop << "]:" << ar[loop] << endl // 配列一覧表示
#define DUMPL(ar) for(int loop=0; loop<(int)ar.size(); loop++) { cout << ar[loop]; if(loop<(int)ar.size()-1) cout << ' '; } cout << endl; // 配列一行一覧表示
#define COUT(x) cout << x << endl // 単要素出力
#define ALL(ar) ar.begin(), ar.end() // コンテナの全要素
#define LOOPD(i) cout << "ループ[" << i << "]回目---------------" << endl // ループ回数デバグ
using namespace std;
// cout << fixed << setprecision(4) で小数点以下4桁の桁そろえ
// cout << setw(5) << ... で表示形式を5桁に設定 5桁未満なら頭に空白がつく 5桁越なら先頭から5桁まで
// cout << setw(5) << setfill('0') << ... で空白部分の埋め文字に5を使う
// getline(cin, [変数]); で空白などを含む入力の受け取り(行ごとの受け取り)
// cin >> ws; でそこまでにストリームに残されたホワイトスペースを取り除く(=以降のgetlineの有効化)

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

    int x, y;
    cin >> x >> y;
    int ans = 0;
    if(x == 1) ans += 300000;
    if(x == 2) ans += 200000;
    if(x == 3) ans += 100000;
    if(y == 1) ans += 300000;
    if(y == 2) ans += 200000;
    if(y == 3) ans += 100000;
    if(x == 1 && y == 1) ans += 400000;

    COUT(ans);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a,b,c,d;
    string liczba;
    cin>>liczba;
    a=int(liczba[0])-48;
    b=int(liczba[1])-48;
    c=int(liczba[2])-48;
    d=int(liczba[3])-48;

    if(a+b+c+d==7)cout<<a<<'+'<<b<<'+'<<c<<'+'<<d<<"=7";
    else if(a+b+c-d==7)cout<<a<<'+'<<b<<'+'<<c<<'-'<<d<<"=7";
    else if(a+b-c+d==7)cout<<a<<'+'<<b<<'-'<<c<<'+'<<d<<"=7";
    else if(a-b+c+d==7)cout<<a<<'-'<<b<<'+'<<c<<'+'<<d<<"=7";
    else if(a+b-c-d==7)cout<<a<<'+'<<b<<'-'<<c<<'-'<<d<<"=7";
    else if(a-b-c+d==7)cout<<a<<'-'<<b<<'-'<<c<<'+'<<d<<"=7";
    else if(a-b+c-d==7)cout<<a<<'-'<<b<<'+'<<c<<'-'<<d<<"=7";
    else cout<<a<<'-'<<b<<'-'<<c<<'-'<<d<<"=7";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  int N;
  cin >> N;
  string W[N];
  int i, j;
  for(i=0; i<N; i++)
    cin >> W[i];

  for(i=1; i<N; i++){
    if(W[i-1][W[i-1].length()-1] == W[i][0]){
      for(j=0; j<i; j++)
	if(W[j] == W[i])
	  goto No_;
    }
    else
      goto No_;
  }
  
  cout << "Yes" << endl; 
  goto Yes_;
  
 No_ :
  cout << "No" << endl;
 Yes_:
  
  return 0;
}


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

int main(){
    int n; cin >> n;
    string s, ans = ""; cin >> s;
    int a = 0, b = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '('){
            a++;
            ans = ans + '(';
        }else{
            b++;
            ans = ans + ')';
            if(b > a){
                ans = '(' + ans;
                a++;
            }
        }
    }
    for(int i = 0; i < max(0, a-b); i++){
        ans = ans + ')';
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(void){
  
  int a, b;
  cin >> a >> b;
  
  int num = 1;
  int ans = 0;
  
  while(num < b){
  num += a-1;
  ans++; 
  }

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	var a = make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}

	answer := 0
	for {
		for i := range a {
			switch {
			case a[i]%2 == 0:
				a[i] /= 2
			default:
				fmt.Println(answer)
				return
			}
		}
		answer++
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
using vi  = vector<int>;
using ii  = pair<int,int>;
using vii = vector<ii>;
using ll  = long long;

typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;

#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) int((x).size())
#define REP(i, a, b) for (auto (i) = (a); (i) <= (b); (i)++)
#define PER(i, a, b) for (auto (i) = (a); (i) >= (b); (i)--)
#define ITR(i, x) for (auto (i) = (x).begin(); (i) != (x).end(); (i)++)

string to_string(string s) { return '\"' + s + '\"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A,B> p)
{ return "(" + to_string(p.F) + ", " + to_string(p.S) + ")"; }
template <typename T> string to_string(T v) {
	int f = 0; string res = "{";
	for (const auto &x: v)
		res += (f++ ? ", " : "") + to_string(x);
	return res + "}";
}
void debug_out() { cerr << "]\n"; }
template <typename T, typename... V>
void debug_out(T a, V... v)
{ cerr << to_string(a); if (sizeof...(v)) cerr << ", "; debug_out(v...); }

#ifdef LOCAL // add -DLOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = [", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif // debug(var1, var2, ...);

const int mxN = 2e5;
int a[mxN + 5];
int b[mxN + 5];

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	REP(i, 0, n-1) cin >> a[i] >> b[i];
	sort(a, a+n);
	sort(b, b+n);
	if (n & 1)
		cout << b[(n-1)/2] - a[(n-1)/2] + 1 << '\n';
	else
	{
		int r = b[n/2-1] + b[n/2];
		int l = a[n/2-1] + a[n/2];
		cout << r-l+1 << '\n';
	}
	return 0;
}

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

int top,S[1000];
void push(int);
int pop();

int main(){
  int a,b;
  top = 0;
  char s[100];

  while( scanf("%s", s) != EOF ){
    
    if ( s[0] == '+' ){
      a = pop();
      b = pop();
      push(a+b);
    }
    
      else if ( s[0] == '-' ){
      b = pop();
      a = pop();
      push(a-b);
    }

     else if ( s[0] == '*' ){
      a = pop();
      b = pop();
      push(a*b);
    }

     else {
       push(atoi(s));
    }
  }

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

  return 0;
}

void push(int x){
  S[++top]=x;
}

int pop(){
  top--;
  return S[top+1];
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a[3];
  rep(i,3){
    cin >> a[i];
  }
  int t = 0;
  int i[3] = {};
  while(1){
    if(i[t] == a[t].size()){
      cout << char('A' + t) << endl;
      return 0;
    }
    int tmp = t;
    t = (a[t][i[t]] - 'a');
    i[tmp]++;
  }
  return 0;
}



Measured memory_bytes: 256
def cmb(n, r, prime):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n % prime

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] = numerator[k - offset] // pivot
                denominator[k] = denominator[k] // pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= numerator[k]
    
    result = result % prime
    return result


x,y = map(int, input().split())

ans = 0

if (x + y) % 3 == 0 and 2*x - y >= 0 and 2*y - x >= 0:
    a = (x + y) // 3
    b = (2*x - y) // 3
    ans = cmb(a,b, pow(10,9) + 7)
    #ans = mod_combination(a,b,pow(10,9) + 7)

print(ans)


Measured memory_bytes: 31476
S = str(input())
l = len(S)
OZ = '10' * int(l/2)
ZO = '01' * int(l/2)
if(l%2!=0):
    OZ += '1'
    ZO += '0'
cntOZ=0
cntZO=0
for i in range(l):
    if(S[i]==OZ[i]):
        cntOZ+=1
    else:
        cntZO+=1
#print(cntOZ)
#print(cntZO)
if(cntOZ <= cntZO):
    print(cntOZ)
else:
    print(cntZO)


Measured memory_bytes: 40944
#include<cstdio>
#include<iostream>
#include<vector>

using namespace std;

int main(void){
	while (1){
		int n;
		scanf("%d", &n);
		if (n == 0)return 0;
		vector<char> code1;
		vector<char> code2;
		for (int i = 0; i < n; i++){
			char a, b;
			scanf(" %c", &a);
			scanf(" %c", &b);
			code1.push_back(a);
			code2.push_back(b);
		}
		int m;
		scanf("%d", &m);
		vector<char> ans;
		for (int i = 0; i < m; i++){
			char a;
			scanf(" %c", &a);
			ans.push_back(a);
			for (int j = 0; j < n; j++){
				if (ans[i] == code1[j]){
					ans[i] = code2[j];
					break;
				}
			}
			printf("%c", ans[i]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 1308
import java.util.*;

public class Main {

    static int[][]hsum;
    static int[][]wsum;
    static int k;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        k=sc.nextInt();
        int[][]input=new int[k*2][k*2];
        hsum=new int[k*2+1][k*2];
        wsum=new int[k*2][k*2+1];
        int white=0;
        int tmpX,tmpY;
        for(int i=0;i<n;i++){
            tmpX=sc.nextInt();
            tmpY=sc.nextInt();
            if(sc.next().equals("B")){
                input[tmpX%(k*2)][tmpY%(k*2)]++;
            }else{
                white++;
                input[tmpX%(k*2)][tmpY%(k*2)]--;
            }
        }
        for(int i=0;i<k*2;i++){
            for(int j=1;j<k*2+1;j++){
                hsum[j][i]=hsum[j-1][i]+input[j-1][i];
                wsum[i][j]=wsum[i][j-1]+input[i][j-1];
            }
        }
        int[] ans=new int[k*2];
        int finalans=0;
        int tmp;
        for(int i=0;i<k;i++){
            ans[0]+=hsum[k][i]-hsum[0][i];
            ans[0]+=hsum[k*2][i+k]-hsum[k][i+k];
        }
        finalans=ans[0];
        int[]movex1={0,-1,-2};
        int[]movey1={0,1,0};
        int[]movex2={0,1,-1};
        int[]movey2={0,1,1};
        int[]movex3={0,-1,-2,0,1,-2};
        int[]movey3={0,-1,0,-2,-1,-2};
        int[]movex4={0,-1,1,-2,-1,1};
        int[]movey4={0,-1,-1,0,1,1};
        
        for(int i=1;i<k*2;i++){
            tmp=0;
            for(int j=0;j<3;j++){
                tmp+=getsum(i+k+k*movex1[j]-1,k*movey1[j],i+k+k*movex1[j]-1,k-1+k*movey1[j]);
            }
            for(int j=0;j<3;j++){
                tmp-=getsum(i-1+k*movex2[j],k*movey2[j],i-1+k*movex2[j],k-1+k*movey2[j]);
            }
            ans[i]=ans[i-1]+tmp;
            finalans=Math.max(finalans,ans[i]);
        }
        for(int i=1;i<k*2;i++){
            for(int j=1;j<k*2;j++){
                tmp=0;
                for(int l=0;l<6;l++){
                    tmp+=getsum(i+k*movex3[l],j+k+k*movey3[l]-1,i+k-1+k*movex3[l],j+k+k*movey3[l]-1);
                }
                for(int l=0;l<6;l++){
                    tmp-=getsum(i+k*movex4[l],j-1+k*movey4[l],i+k-1+k*movex4[l],j-1+k*movey4[l]);
                }
                ans[i]+=tmp;
                finalans=Math.max(finalans,ans[i]);
            }
        }
        System.out.println(white+finalans);
    }
    static int getsum(int x1,int y1,int x2,int y2){
        if(x1==x2&&x1>=0&&x1<k*2){
            y1=Math.max(-1, Math.min(k*2, y1));
            y2=Math.max(-1, Math.min(k*2, y2));
            if(y1==y2)return 0;
            else return wsum[x1][Math.max(Math.min(y2+1,k*2),0)]-wsum[x1][Math.max(Math.min(y1,k*2-1),0)];
        }else if(y1==y2&&y1>=0&&y1<k*2){
            x1=Math.max(-1, Math.min(k*2, x1));
            x2=Math.max(-1, Math.min(k*2, x2));
            if(x1==x2)return 0;
            else return hsum[Math.max(Math.min(x2+1,k*2),0)][y1]-hsum[Math.max(Math.min(x1,k*2-1),0)][y1];
        }else{
            return 0;
        }
    }

}


Measured memory_bytes: 146844
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
//#define int long long
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int)(n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>vec[i];
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int kurai(int x00, int y00) {
	int z00 = (x00 % jousu(10, y00)) / jousu(10, y00 - 1);
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}


int main() {
	int n, c=0, a=0;
	cin >> n;
	vector<int>vec(n);
	vecin(vec);
	rep(i, n-1) {
		if (vec[i] >= vec[i + 1]) {
			c++;
		}
		else {
			a = max(a, c);
			c = 0;
		}
	}
	a = max(a, c);
	cout << a << endl;
}


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

using namespace std;
typedef long long ll;

// https://freestylewiki.xyz/fswiki/wiki.cgi?page=AtCoder+Beginner+Contest+066

ll mod = 1000000007;
ll factorial[100002];
ll mod_factorial[100002];

ll pow(ll factor, ll q) {
  if (q == 1) {
    return factor % mod;
  }
  if (q % 2 == 0) {
    ll sub = pow(factor, q / 2);
    return ((sub % mod) * (sub % mod)) % mod;
  } else {
    return ((factor % mod) * (pow(factor, q - 1) % mod)) % mod;
  }
}
void init() {
  for (ll i = 0; i <= 100001; i++) {
    if (i == 0 || i == 1) {
      factorial[i] = 1;
    } else {
      factorial[i] = ((i % mod) * (factorial[i - 1] % mod)) % mod;
    }
  }
  for (ll i = 0; i <= 100001; i++) {
    if (i == 0 || i == 1) {
      mod_factorial[i] = 1;
    } else {
      mod_factorial[i] = pow(factorial[i], mod -2 ) % mod;
    }
  }
}
ll C(ll n, ll k) {
  if (n < k) {
    return 0;
  }
  ll sub = ((factorial[n] % mod) * (mod_factorial[k] % mod)) % mod;
  return ((sub % mod) * (mod_factorial[n - k] % mod)) % mod;
}

int main() {
  init();
  ll N;
  cin >> N;
  set<ll> box;
  ll second = 0;
  ll first;

  vector<ll> list(N + 1);
  for (ll i = 0; i < N + 1; i++) {
    cin >> list[i];
    if (box.count(list[i])) {
      second = i;
    }
    box.insert(list[i]);
  }

  for (ll i = 0; i < N + 1; i++) {
    if (list[i] == list[second]) {
      first = i;
      break;
    }
  }

  for (ll i = 1; i <= N + 1; i++) {
    if (i == 1) {
      cout << N << endl;
    } else {
      if (i == N + 1) {
        cout << 1 << endl;
      } else {
        ll sub = (C(N + 1, i) % mod + mod - C(first + N - second, i - 1) % mod) % mod;
        cout << sub << endl;
      }
    }
  }
  return 0;
}


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

int N;
vector<long long> a;

void solve() {
    map<int, long long> ma;
    for (int i = 0; i < N; ++i) ma[a[i]]++;
    long long res = 0;
    for (auto it : ma) res += it.second * (it.second - 1) / 2;
    for (int i = 0; i < N; ++i) {
        long long val = ma[a[i]];
        long long before = val * (val - 1) / 2;
        long long after = (val - 1) * (val - 2) / 2;
        cout << res + after - before << endl;
    }
}

int main() {
    cin >> N;
    a.resize(N);
    for (int i = 0; i < N; ++i) cin >> a[i];
    solve();
}

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

int c[2000][2000];

int lcs(string X, string Y){
    int x = X.length();
    int y = Y.length();
    rep(i, x){
        c[i][0] = 0;
    }
    rep(i, y){
        c[0][i] = 0;
    }
    for (int i = 1; i <= x; i++){
        for (int j = 1; j <= y; j++){
            if(X[i-1] == Y[j-1]){
                c[i][j] = c[i-1][j-1] + 1;
            } else if(c[i-1][j] >= c[i][j-1]){
                c[i][j] = c[i-1][j];
            } else {
                c[i][j] = c[i][j-1];
            }
        }
    }
    return c[x][y];
}

int main() {
    int q; cin >> q;
    rep(i, q){
        string X, Y; cin >> X >> Y;
        int ans = lcs(X, Y);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 11000
import re
a = input()
n = len(a)
ans = []
for i in range(1<<(n-1)):
    f = a[0]
    g = int(a[0])
    for j in range(n-1):
        if (i>>j)&1:
            f += '+'
            g += int(a[j+1])
        else:
            f += '-'
            g -= int(a[j+1])
        f += a[j+1]
    if g == 7:
        print(f+'=7')
        break


Measured memory_bytes: 3188
#include<stdio.h>
int main(){

  int n,i,j,y,m,d,count;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    count=0;
    scanf("%d%d%d",&y,&m,&d);
    for(j=0;j<999-y;j++){
      if(j%3==0){
	count+=200;
      }else{
	count+=195;
      }
    }
    for(j=0;j<10-m;j++){
      if(y%3==0){
	count+=20;
      }else{
	if(j%2==0){
	  count+=19;
	}else{
	  count+=20;
	}
      }
    }
    if(y%3==0){
    count+=21-d;
    }else{
      if(m%2==0){
	count+=20-d;
      }else{
	count+=21-d;
      }
    }
    printf("%d\n",count);
  }
return 0;
}

Measured memory_bytes: 596
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

import numpy as np
a = np.array(ri_())
ans = 0
while True:
    if np.any(a % 2 == 1):
        break
    if a[0] == a[1] and a[1] == a[2]:
        ans = -1
        break
    a = (sum(a) - a) // 2
    ans += 1
print(ans)

Measured memory_bytes: 26896
def JudgePrint(X):
  if X == 0:
    print("#", end="")
  elif X == 1:
    print(".", end="")

while True:
  H, W = map(int, input().split())
  
  if H == 0 and W == 0:
    break

  for i in range(H):
    for j in range(W):
      if i % 2 == 0:
        if j % 2 == 0:
          JudgePrint(0)
        else:
          JudgePrint(1)
      else:
        if j % 2 == 0:
          JudgePrint(1)
        else:
          JudgePrint(0)

    print()
  
  print()





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

using ll = long long;
using namespace std;
constexpr ll inf = 1e15;
constexpr ll mod = 1e9+7;

struct Edge {
    int to;
    int cap;
    int cost;
    int rev;
};
vector<Edge> edges[101];

int primalDual(int s, int t, int f) {
    int ret = 0;
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
    vector<int> potential(101, 0);
    vector<ll> dp(101, inf);
    vector<int> prevv(101, -1), preve(101, -1);
    // Dijkstra with potential
    while (f > 0) {
        dp.assign(101, inf);
        dp[s] = 0;
        q.push(make_pair(0, s));
        while (!q.empty()) {
            auto p = q.top();
            q.pop();
            if (dp[p.second] < p.first) continue;
            for (int i = 0; i < edges[p.second].size(); i++) {
                auto&& edge = edges[p.second][i];
                int nextCost = dp[p.second] + edge.cost + potential[p.second] - potential[edge.to];
                if (edge.cap > 0 && dp[edge.to] > nextCost) {
                    dp[edge.to] = nextCost;
                    prevv[edge.to] = p.second;
                    preve[edge.to] = i;
                    q.push(make_pair(nextCost, edge.to));
                }
            }
        }
        if (dp[t] == inf) return -1;
        for (int v = 0; v <= 100; v++) if (dp[v] < inf) potential[v] += dp[v];
        int addFlow = f;
        for (int v = t; v != s; v = prevv[v]) {
            addFlow = min(addFlow, edges[prevv[v]][preve[v]].cap);
        }
        f -= addFlow;
        ret += addFlow * potential[t];
        for (int v = t; v != s; v = prevv[v]) {
            Edge& e = edges[prevv[v]][preve[v]];
            e.cap -= addFlow;
            edges[v][e.rev].cap += addFlow;
        }
    }

    return ret;
}

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

    int V, E, F;
    cin>>V>>E>>F;
    for (int e = 0; e < E; e++) {
        int U, V, C, D;
        cin>>U>>V>>C>>D;
        edges[U].push_back(Edge{V, C, D, (int)edges[V].size()});
        edges[V].push_back(Edge{U, 0, -D, (int)edges[U].size()-1});
    }

    cout<<primalDual(0, V-1, F)<<endl;
    
    return 0;
}


Measured memory_bytes: 3288
#include <stdio.h>
   
int main(){

  int index = 1;
  int val = 0;

  while (1){

    scanf("%d", &val);

    if (val == 0){
      break;
    }

    printf("Case %d: %d\n", index, val);
    index++;
  }

  return 0;

}

Measured memory_bytes: 1028
N,M = list(map(int,input().split()))

if M%2==0:
    for i in range(M//2):
        print(i+1,M-i)
    for i in range(M//2):
        print(M+i+1,2*M-i+1)
else:
    for i in range(M//2):
        print(i+1,M-i)
    for i in range(M//2+1):
        print(M+i+1,2*M-i+1)

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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  ll n;
  int k;
  cin >> n >> k;
  ll cnt = 0;
  while (n != 0) {
    n /= k;
    ++cnt;
  }
  cout << cnt << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


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

using namespace std;


int main() {
 long long int a,b,c=0,d[100010],e[100010];
  string s;
  
  cin >> a ;
  cin >> s;
  
 for(int i=0;i<a;i++){
  
   if(s[i] != s[i+1]){
     c++;
   }
 }
  cout << c << endl;
}
  
   

Measured memory_bytes: 512
//
//  main.cpp
//  A
//
//  Created by Hashizo on 2019/12/01.
//  Copyright © 2019 Hashizo. All rights reserved.
//

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

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int main(int argc, const char * argv[]) {
	ll ans = 0;

	ll m1,d1,m2,d2;
	cin >> m1 >> d1;
	cin >> m2 >> d2;

	if (m1 != m2) {
		ans = 1;
	}
	
	
	cout << ans << endl;
	return 0;
}


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

using namespace std;

void chmax(int&a, int b) {
  if (b > a) a = b;
}

int main() {
  int N;
  cin >> N;
  
  int a[N+1] = {0};
  int b[N+1] = {0};
  int c[N+1] = {0};
  
  for (int i = 0; i < N; i++) {
    cin >> a[i+1] >> b[i+1] >> c[i+1];
  }
  
  
  int dp[N+1][3] = {0}; //N日目まで過ごし，ラストが0, 1, 2(A,B,C)だったときの幸福度の最大値
  
  for (int i = 0; i < N; i++) {
    chmax(dp[i+1][0], max(dp[i][1], dp[i][2]) + a[i+1]);
    chmax(dp[i+1][1], max(dp[i][2], dp[i][0]) + b[i+1]);
    chmax(dp[i+1][2], max(dp[i][0], dp[i][1]) + c[i+1]);
  }
  
  cout << max({dp[N][0], dp[N][1], dp[N][2]}) << endl;


}

Measured memory_bytes: 2560
import java.util.*;
 
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	String[] spi = new String[n];
      	int list = 0;
      	int[] v = new int[n];
      	int[] cost = new int[n];
      	for(int i = 0; i < n ; i ++){
        	v[i] = sc.nextInt();
        }
      	for(int i = 0; i < n ; i ++){
        	cost[i] = sc.nextInt();
        }
      	for(int i = 0; i < n; i ++){
          	spi[i] = v[i] + "_" + cost[i];
          	list += v[i] - cost[i];
        }
      	Arrays.sort(spi);
      	for(String s : spi){
          	int value = Integer.parseInt(s.split("_")[0]);
          	int c = Integer.parseInt(s.split("_")[1]);
        	list = Math.max(list, list - value + c);
        }
      	System.out.print(list);
      	
    }
}

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

int main(){
    int a,b;
    cin >> a >> b;
    int ans;
    ans = 10 * b;
    int temp;
    rep(i,10){
        temp = ans;
        temp += i;
        if((int)(temp * 0.08)== a){
            cout << temp << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
n = int(input())
al = list('abcdefghijklmnopqrstuvwxyz')

amari = []

while n != 0:
  if n%26 == 0:
    n = n//26 - 1
    amari.append(26)
  else:
    amari.append(n%26)
    n = n//26
  
amari.reverse()

ans = ''
for i in amari:
  ans += al[i-1]
  
print(ans)



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,L[2020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>L[i];
	sort(L,L+N);
	ll ret=0;
	FOR(y,N) FOR(x,y) {
		i=lower_bound(L,L+x,L[y]-L[x]+1)-L;
		ret+=x-i;
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

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

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

const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int N;
string s, t;

bool check(string str) {
	REP(i, N) if (str[str.size() - 1 - i] != t[N - 1 - i]) return false;
	return true;
}

int main() {
	cin >> N;
	cin >> s >> t;
	
	int ans = INF;
	
	if (check(s)) ans = N;
	
	REP(i, N) {
		if (check(s + t.substr(N - 1 - i, i + 1)))
			chmin(ans, s.size() + i + 1);
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define N 100

int arrayg[N][N], arrayn[N], arraywid[N];

void Defdep(int a, int k){
    int i;

    arraywid[a] = k;

    for (i = 1; i <= arrayn[a]; i++){
        if (arraywid[arrayg[a][i]] > k){
            Defdep(arrayg[a][i], k + 1);
        }
    }
}

int main(void){
    int i,j;
    int n,l;

    scanf("%d", &n);

    for (i = 1; i <= n; i++){
        arraywid[i] = N * N;
        for (j = 1; j <= n; j++){
            arrayg[i][j] = 0;
        }
    }

    for (i = 1; i <= n; i++){
        scanf("%d", &l);
        scanf("%d", &arrayn[l]);
        for (j = 1; j <= arrayn[l]; j++){
            scanf("%d", &arrayg[l][j]);
        }
    }

    Defdep(1, 0);

    for (i = 1; i <= n; i++){
        if (arraywid[i] == N * N){
            arraywid[i] = -1;
        }
        printf("%d %d\n", i, arraywid[i]);
    }

    return 0;
}




Measured memory_bytes: 2112
#include<iostream>
#include <stdlib.h>
using namespace std;

int main(void) {
	int n;
	int a[200];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int m = 0;
	bool flag = false;
	while (1) {
		for (int i = 0; i < n; i++) {
			if (a[i] % 2 == 1) {
				flag = true;
				break;
			}
			else a[i] /= 2;
		}
		if (flag == true)break;
		else m++;
	}
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
K = [int(i) for i in input().split()]
K.sort()
K.reverse()
A, B = [], []
for i in range(n):
    if i % 2 == 0:
        A.append(K[i])
    else:
        B.append(K[i])
print(sum(A) - sum(B))

Measured memory_bytes: 3064
h,w,a,b=map(int,input().split())
l=[['0']*w for _ in range(h)]
for i in range(b):
    for j in range(a):
        l[i][j]='1'
for i in range(b,h):
    for j in range(a,w):
        l[i][j]='1'
for i in range(h):
    print("".join(map(str,l[i])))

Measured memory_bytes: 50396
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define rev(a,b,c) for(int a=b;a>=c;a--)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define end end()
#define vec vector<ll>
#define se set<ll>
#define mults multiset<ll>
#define F first
#define S second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b
#define get(a) cin>>a
#define nextl cout<<endl
const ll mod = 1000000007;
const ll maxn = 500005;
const ll mm = 1e+18;
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
ll ncr(ll n, ll k)
{
    ll C[k+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, k); j > 0; j--)
            C[j] = (C[j] + C[j-1])%mod;
    }
    return C[k];
}
vector<int>graph[maxn];
int vis[maxn];
int final[maxn];
void bfs(int head){
    queue<int>q;
    q.push(head);
    vis[head]=0;
    while(q.size()){
        int tt=q.front();
        q.pop();
        for(auto x:graph[tt]){
            if(vis[x]){
                vis[x]=0;
                final[x]+=final[tt];
                q.push(x);
            }
        }
    }
}
void solve()
{
    int n,q;
    get(n);
    get(q);
    for(int i=0;i<n+3;i++){
        vis[i]=1;
        final[i]=0;
    }
    int n1=n-1;
    while(n1--){
        int x,y;
        cin>>x>>y;
        graph[x].pb(y);
        graph[y].pb(x);
    }
    while(q--){
        int x,y;
        cin>>x>>y;
        final[x]+=y;
    }
    bfs(1);
    rep1(i,n) pr2(final[i],"");
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nextl;
    }
    return 0;
}


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

int main(){
    int index;
    double mint = 1000000;
    int n, t, a;
    cin >> n >> t >> a;
    
    rep(i,n){
        int x; cin >> x;
        if(abs(a - (t - x * 0.006)) < mint){
            mint = abs(a - (t - x * 0.006));
            index = i + 1;
        }
    }
    cout << index << endl;
}

Measured memory_bytes: 256
n,t=map(int,input().split())
oyu=list(map(int,input().split()))
inl=[]
ans=n*t
for i in range(n-1):
  inl.append(oyu[i+1]-oyu[i])
for i in range(n-1):
  if inl[i]<t:
    ans-=t-inl[i]
print(ans)


Measured memory_bytes: 26708
S = gets.chomp              # 文字列。chompを付けないと改行文字がついてくる

S.freeze
 
wk = S[S.length-1...S.length]
 
if wk == "2" || wk == "4" || wk == "5" || wk == "7" || wk == "9" then
  puts "hon"
elsif wk == "0" || wk == "1" || wk == "6" || wk == "8" then
  puts "pon"
elsif wk == "3" then
  puts "bon"
else
  ##
end

Measured memory_bytes: 14380
import numpy as np
import math
import sys

sys.setrecursionlimit(10000000)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def main():
    N = int(input())
    S = []
    for i in range(N):
        s = input()
        s = sorted(s)
        S.append(s)
        
    S = sorted(S)
    ans = 0
    num = 0
    for i in range(N):
        if i < N - 1 and S[i] == S[i + 1]:
            num += 1
        else:
            if num == 0:
                continue
            else:
                ans += combinations_count(num + 1, 2)
            num = 0
    print(ans)
                

if __name__ == '__main__':
    main()

Measured memory_bytes: 34544
s = int(input())

A = [s]

for i in range(10**6):
    n = A[-1]
    if n % 2 == 0:
        a = n//2
    else:
        a = 3*n + 1
    if a in A:
        print(i+2)
        break
    else:
        A.append(a)


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    ll X, Y;
    cin >> X >> Y;
    int ans = 0;
    while (X <= Y) {
        X <<= 1;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
(def N (read-string (read-line)))
(def S (read-line))
(println (loop [i 0 ans 0] 
  (if (> i (- N 3))
    ans
    (if (= (subs S i (+ i 3)) "ABC")
      (recur (+ i 1) (+ 1 ans))
      (recur (+ i 1) ans)))))  

Measured memory_bytes: 65652
/**
 * author:    Ziel
 * created:   18.04.2020 00:28:28
**/

// ~zaletaet~

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define pb push_back

using namespace std;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const double EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
	ll n, a, b;
	cin >> n >> a >> b;
	
	vector<ll> x(n);
	for (ll& i: x) cin >> i;
	
	ll cur = x[0];
	ll ans = 0;
	for (int i = 1; i < n; i++) {
		ans += min(b, a * (x[i] - x[i - 1]));
	}
	
	cout << ans;
	return 0;
}



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

int main()
{
	int n;
	int b=0,c=0,d=0,e=0;
	cin>>n;
	
	string a;
	
	for(int i=0; i<n; i++)
	{
		cin>>a;
		
		if(a=="AC")
		{
			b++;
		}
		else if(a=="WA")
		{
			c++;
		}
		else if(a=="TLE")
		{
			d++;
		}
		else
		{
			e++;
		}
	}
	
	cout<<"AC x "<<b<<'\n';
	cout<<"WA x "<<c<<'\n';
	cout<<"TLE x "<<d<<'\n';
	cout<<"RE x "<<e;
	
}

Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());

  if (s < t) puts("Yes"); else puts("No");
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i, x, y) for(int i = x, _b = y; i <= _b; i ++)
#define ff(i, x, y) for(int i = x, _b = y; i <  _b; i ++)
#define fd(i, x, y) for(int i = x, _b = y; i >= _b; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
using namespace std;

const int N = 3e5 + 5;

int w, h, n;

struct P {
	int x, y;
} a[N];

int ans;

int d[N], d0;

map<int, int> rd;

void ls() {
	d0 = 0; d[++ d0] = 0; d[++ d0] = w;
	fo(i, 1, n) d[++ d0] = a[i].x;
	sort(d + 1, d + d0 + 1);
	d0 = unique(d + 1, d + d0 + 1) - (d + 1);
	rd.clear(); fo(i, 1, d0) rd[d[i]] = i;
}

P b[N], c[N]; int b0, c0;

int op;

int cmp1(P a, P b) {
	if(a.x == b.x) {
		if(a.y == b.y) return 0;
		return (a.y < b.y) ^ op;
	}
	return a.x < b.x;
}

void gg(P *a, int &a0) {
	sort(a + 1, a + a0 + 1, cmp1);
	int A = a0; a0 = 0;
	fo(i, 1, A) if(i == 1 || a[i].x != a[a0].x)
		a[++ a0] = a[i];
}

int t[N * 4], lz[N * 4], pl, pr, px;
#define i0 i + i
#define i1 i + i + 1

void upd(int i) { t[i] = max(t[i0], t[i1]);}
void jia(int i, int x) { t[i] += x, lz[i] += x;}
void down(int i) { if(lz[i]) jia(i0, lz[i]), jia(i1, lz[i]), lz[i] = 0; }
void bt(int i, int x, int y) {
	lz[i] = 0;
	if(x == y) { t[i] = h - d[x]; return;}
	int m = x + y >> 1;
	bt(i0, x, m); bt(i1, m + 1, y);
	upd(i);
}
void add(int i, int x, int y) {
	if(y < pl || x > pr) return;
	if(x >= pl && y <= pr) { jia(i, px); return;}
	int m = x + y >> 1; down(i);
	add(i0, x, m); add(i1, m + 1, y);
	upd(i);
}
void pla(int x, int y, int z) {
	pl = x, pr = y, px = z;
	add(1, 1, d0);
}
void ft(int i, int x, int y) {
	if(y < pl || x > pr) return;
	if(x >= pl && y <= pr) { px = max(px, t[i]); return;}
	int m = x + y >> 1; down(i);
	ft(i0, x, m); ft(i1, m + 1, y);
}

int z1[N], z2[N];

void ad1(int f) {
	P u = b[z1[z1[0] - 1]], v = b[z1[z1[0]]];
	pla(rd[u.x], rd[v.x] - 1, f * (h - v.y));
}

void ad2(int f) {
	P u = c[z2[z2[0] - 1]], v = c[z2[z2[0]]];
	pla(rd[u.x], rd[v.x] - 1, f * v.y);
}

void work() {
	ls();
	b0 = c0 = 0;
	fo(i, 1, n)	if(a[i].x) {
		if(a[i].y >= h / 2) b[++ b0] = a[i];
		if(a[i].y <= h / 2) c[++ c0] = a[i];
	}
	op = 0; gg(b, b0);
	op = 1; gg(c, c0);
	
	bt(1, 1, d0);
	
	b[0] = c[0] = (P) {0, h / 2};
	z1[0] = z2[0] = 1;
	z1[1] = z2[1] = 0;
	
	int l1 = 1, l2 = 1;
	fo(i, 1, d0) {
		while(l1 <= b0 && b[l1].x < d[i]) {
			while(b[l1].y < b[z1[z1[0]]].y)
				ad1(1), z1[0] --;
			z1[++ z1[0]] = l1; ad1(-1);
			l1 ++;
		}
		while(l2 <= c0 && c[l2].x < d[i]) {
			while(c[l2].y > c[z2[z2[0]]].y)
				ad2(1), z2[0] --;
			z2[++ z2[0]] = l2; ad2(-1);
			l2 ++;
		}
		pl = 1, pr = i - 1; px = -1e9;
		ft(1, 1, d0);
		ans = max(ans, px + d[i]);
	}
	
}

int main() {
	scanf("%d %d %d", &w, &h, &n);
	fo(i, 1, n) scanf("%d %d", &a[i].x, &a[i].y), a[i].x *= 2, a[i].y *= 2;
	w *= 2, h *= 2;
	ans = max(w, h);
	work();
	swap(w, h); fo(i, 1, n) swap(a[i].x, a[i].y);
	work();
	pp("%d\n", ans);
}

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

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

  int x = 0;
  for (char c : s) {
    //cの中は文字なので、文字コードを変換する必要あり。cから0の文字コードを引くと狙った数字がでる
    //この作業をやらないと、意図しない数字を足しこんでしまう。
    x += (c -'0');
  }
  x %= 9;

  if (x == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3700
MAX = 10**5
count = [0]*(MAX+1)
c = 0
N = int(input())
A = list(map(int,input().split()))
for a in A:
    if a > MAX:
        continue
    count[a] += 1
for i in range(1,N+1):
    if count[i] >= i:
        c += i
print(N-c)


Measured memory_bytes: 15460
n = int(input())
freq = [0 for i in range(n+1)]
combo = [0 for i in range(n+1)]
arr = list(map(int, input().split()))
for i in arr:
    freq[i] += 1
for i in range(1, n+1):
    if freq[i] > 1:
        combo[i] = (freq[i] * (freq[i]-1))//2
ans = sum(combo)
for i in range(n):
    ans -= combo[arr[i]]
    freq[arr[i]] -= 1
    if freq[arr[i]] > 1:
        ans += (freq[arr[i]] * (freq[arr[i]]-1))//2
    print(ans)
    ans -= (freq[arr[i]] * (freq[arr[i]]-1))//2
    freq[arr[i]] += 1
    ans += combo[arr[i]]

Measured memory_bytes: 29656
using System;
using System.Linq;
using System.Text;

namespace ALDS1_11_A
{
    class Program
    {
        private static int n;
        private static int[,] neighborList;
        static void Main(string[] args)
        {
            Program.n = int.Parse(Console.ReadLine());
            Program.neighborList = new int[n,n];
            for (int i = 0; i < n; i++)
            {
                int[] tmpLine = Console.ReadLine()
                                       .Split(' ')
                                       .Select(s => int.Parse(s))
                                       .ToArray();
                for (int j = 2; j < tmpLine[1] + 2; j++)
                {
                    Program.neighborList[i, tmpLine[j] - 1] = 1;
                }
            }

            for (int i = 0; i < n; i++)
            {
                Console.Write(Program.neighborList[i, 0]);
                for (int j = 1; j < n; j++)
                {
                    Console.Write(string.Format(" {0}", Program.neighborList[i, j]));
                }
                Console.WriteLine();
            }
        }
    }
}



Measured memory_bytes: 18460
def main():
    a,b,c = map(int,input().split())
    k = int(input())

    i = 0
    while a >= b:
        b *= 2
        i += 1
    while b >= c:
        c *= 2
        i += 1
    print("Yes" if i <= k else "No")

if __name__ == '__main__':
    main()

Measured memory_bytes: 9096
def get_cuts_nr(loglens, ln):
    ans = 0
    for log in loglens:
        ans += (log - 1) // ln
    # print(ans)
    return ans

def solvee():
    n, k = (int(x) for x in input().split())
    loglens = [int(x) for x in input().split()]

    l_op = 0
    r_cl = 10 ** 9 + 5
    while r_cl - l_op > 1:
        m = (l_op + r_cl) // 2
        cuts_nr = get_cuts_nr(loglens, m)
        if cuts_nr > k:
            l_op = m
        else:
            r_cl = m
    # assert r_cl == 292638192
    print(r_cl)


if __name__ == '__main__':
    solvee()

Measured memory_bytes: 31024
#include <bits/stdc++.h>
using namespace std;
//解けなかったので解説写し
int main(){
  long long n,k;
  cin>>n>>k;
  vector<int>a(n);
  vector<int>b(n,-1);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  vector<int>s;
  vector<int>check(n+1,-1);
  int c=1;
  int nagasa=0;
  {
    int v=1;
    while(check[v]==-1){
      check[v]=s.size();
      s.push_back(v);
      v=a[v-1];
    }
    c=s.size()-check[v];
    nagasa=check[v];
  }
  if(k<nagasa){
    cout<<s[k]<<endl;
  }else{
    k-=nagasa;
    k%=c;
    cout<<s[nagasa+k]<<endl;
  }
  return 0;
}

Measured memory_bytes: 6676