akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
//#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>

using namespace std;

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF 1<<30
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

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

template<class T>
inline void outmat(T& a, int y, int x) {
	for(int i=0; i<y; i++) {
		for(int j=0; j<x; j++) cout<<a[i][j]<<" ";
		cout<<endl;
	}
}

template<class T>
inline void init(T& v) {
	for(auto &a__: v) cin>>a__;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a__: v) cin>>a__.first>>a__.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a__: v) cin>>a__;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a__: v) cin>>a__.first>>a__.second;
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll GCD(ll a, ll b) { //最大公約数
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll binpow(ll a, ll ex, ll p) { //繰り返し二乗法
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int N;
int pos[200001];
ll res[200001];

void input() {
	res[0]=1;

	cin>>N;
}

void solve() {
	for(int i=1; i<=N; i++) {
		int clr; cin>>clr;
		int cpos=pos[clr];
		res[i]=res[i-1];
		if(cpos && i-cpos>1) {
			res[i]=(res[i]+res[cpos])%MPRIME;
		}
		pos[clr]=i;
	}
	cout<<res[N]<<endl;
}

int main() {
	while(1) {
		input();
		solve();
		break;
	}
}


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

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define endl "\n"
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << endl;}else{cout << "No" << endl;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << endl;}else{cout << "NO" << endl;}}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

struct UnionFind {
    vector<int> data;
    vector<int> sizes;
    
    UnionFind(int n) : data(n) ,sizes(n, 1){
        for(int i = 0; i < n; i++) data[i] = i;
    }
    
    int root(int x) {
        if (data[x] == x) return x;
        return data[x] = root(data[x]);
    }
    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (y < x) swap(x, y);
        data[y] = x;
        sizes[x] += sizes[y];
    }
    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    int size(int x) {
        return sizes[root(x)];
    }
};

signed main(){start();
    int n,m,ans=0;
    cin>>n>>m;
    Vi p(n),x(m),y(m);
    REP(i,0,n){
        cin>>p[i];
        p[i]--;
    }
    REP(i,0,m){
        cin>>x[i]>>y[i];
        x[i]--;y[i]--;
    }
    
    UnionFind UF(n);
    
    REP(i,0,m) UF.unite(x[i],y[i]);
    REP(i,0,n){
        if(UF.same(i,p[i])) ans++;
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 4224
#include <stdio.h>
int main ()
{
  int a,b,c;
  char s[100];
  
  scanf("%s",&s);
  if(s[0]=='1')
  {
    a++;
  }
  if(s[1]=='1')
  {
    a++;
  }
  if(s[2]=='1')
  {
    a++;
  }
 
  printf("%d",a);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}
#define int long long
const int N = 5555;
int n, A, B, a[N], id[N], dp[N][N];

inline void U(int &x, int y) {
    x = min(x, y);
}

signed main(void) {
    read(n); read(A); read(B);
    swap(A, B);
    rep (i, n) read(a[i]), id[a[i]] = i;
    memset(dp, 38, sizeof dp);
    int tmp = dp[0][0];
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++)
        for (int pre = 0; pre <= n; pre++)
            if (dp[i - 1][pre] != tmp) {
                int np = id[i];
                if (np > pre) {
                    U(dp[i][np], dp[i - 1][pre]);
                    U(dp[i][pre], dp[i - 1][pre] + A);
                } else {
                    U(dp[i][pre], dp[i - 1][pre] + B);
                }
            }
    // rep (i, n) re0 (pre, n + 1) {
    //     if (dp[i][pre] != tmp)
    //         printf("dp[%lld][%lld] = %lld\n", i, pre, dp[i][pre]);
    // }
    int ans = 1e18;
    for (int pre = 0; pre <= n; pre++)
        U(ans, dp[n][pre]);
    cout << ans << "\n";
}


Measured memory_bytes: 241408
#include <stdio.h>
int main(void){
    long long int a,b,k,w;
    scanf("%lld", &a);
    scanf("%lld", &b);
    scanf("%lld", &k);
    w = k - a;
    if(w > 0){
        a = 0;
        b = b - w;
    }
    else{
        a = 0 - w;
    }
    if(b < 0){
        b = 0;
    }
    printf("%lld %lld\n", a, b);
    return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    int L[M], R[M];
    for (int i = 0; i < M; i++) {
        cin >> L[i] >> R[i];
    }

    int MIN = 1000000;
    int MAX = 0;

    for (int i = 0; i < M; i++) {
        MIN = min(MIN, R[i]);
    }

    for (int i = 0; i < M; i++) {
        MAX = max(MAX, L[i]);
    }

    if (MAX > MIN) cout << 0 << endl;
    else {
        int ans = MIN-MAX+1;
        cout << ans << endl;
    } 
    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;
int main(void){
  long long N, D;
  long long count = 0;
  cin >> N >> D;
  for (int i = 0; i < N; i++) {
    long long x_i, y_i;
    cin >> x_i >> y_i;
    if (D >= sqrt(pow(x_i, 2) + pow(y_i, 2))) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3196
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int h,w;cin>>h>>w;
  string str[h];
  int Map[h][w];
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      Map[i][j]=-1;
  for(int i=0;i<h;i++){
    cin>>str[i];
    for(int j=0;j<w;j++)
      if(str[i][j]=='c')
	Map[i][j]=0;
  }
  for(int i=0;i<h;i++){
    for(int j=w-1;j>=0;j--){
      if(Map[i][j]==0){
	int cnt=1;
	for(int k=j+1;k<w;k++){
	  if(Map[i][k]==-1)
	    Map[i][k]=cnt;
	  else
	    break;
	  cnt++;
	}
      }
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cout<<Map[i][j];
      if(j!=w-1)cout<<" ";
    }
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using namespace std;

int main(){
  int n;cin>>n;
  int x[n],y[n];rep(i,n)cin>>x[i],y[i]=x[i];
  sort(x,x+n);
  int l=x[n/2-1],r=x[n/2];
  rep(i,n){
    cout<<(y[i]<r?r:l)<<endl;
  }
}

Measured memory_bytes: 3712
import java.util.*;
public class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int x = sc.nextInt();
      int a = sc.nextInt();
      int b = sc.nextInt();
      int l1 = Math.abs(x-a);
      int l2 = Math.abs(x-b);
      if(l1 < l2) System.out.println("A");
      else System.out.println("B");
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a, int b) { for(;b;swap(a,b))a%=b; return a; }

char A[100055], B[100055];

int N, M, G;

int main() {
	scanf("%d%d %s %s", &N, &M, A+1, B+1);
	G = gcd(N, M);
	for(int i = 0; i < G; i++) {
		int a = N/G*i, b = M/G*i;
		if(A[a+1] != B[b+1]) {
			puts("-1");
			return 0;
		}
	}
	cout << ll(N) / G * M << endl;
	return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPE(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;

int main() {
    int n; cin >> n;
    int h = n / 100;
    int x = h * 100 + h * 10 + h;
    if(x < n){
        h++;
        x = h * 100 + h * 10 + h;
        cout << x << endl;
    }else{
        cout << x << endl;
    }
}


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

using namespace std;

typedef long long LL;

int main() {
  LL N;
  cin >> N;
  LL max = 1;
  for (LL i = 2; i * i <= N; ++i) {
    if (N % i == 0) {
      max = i;
    }
  }
  cout << (int)log10(N / max) + 1 << endl;

  return 0;
}


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

int main() {
    int x;
    cin>>x;
    int m = x/100;
    int y = x - m*100;
    int n = y/10;
    if(y > m * 5 ){
        cout << 0 <<endl;
    }else{
        cout << 1 <<endl;
    }
  
}

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

typedef long long LL;

const int N=10000,M=10;

int n,c[N+9][2],ans;
char s[M+9];

void into(){
  scanf("%d",&n);
  int c0=0,c1=0,flag=1;
  for (int i=1;i<=n;++i){
	scanf("%s",s+1);
	int m=strlen(s+1);
	for (int j=1;j<m;++j)
	  if (s[j]=='A'&&s[j+1]=='B') ++ans;
    c0+=s[1]=='B';c1+=s[m]=='A';
	if (s[1]=='B'^s[m]=='A') flag=0;
  }
  ans+=min(c0,c1);
  if (c0&&c1) ans-=flag;
}

void work(){
}

void outo(){
  printf("%d\n",ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 3784
#include "bits/stdc++.h"
#include<stdio.h>
#include <sstream>
#define pi 3.141592653589793238462
#define limit 100005
#define mo 1000000007;
typedef long long int lli;
typedef unsigned long long int ulli;
const lli mod=9999999999999983;
const lli ninf=-1e18;
lli primes[6]={1125899906842597,1495921043,1005985879,1495921043,1005985879,1495921043};
using namespace std;
vector<lli>adj[2000009];
lli parent[2000009];
lli vis[2000009];
lli level[2000009];
lli dist[2000009];
lli dp[209][200009];
lli arr[2000009];
lli brr[2000009];
lli crr[2000009];
lli hashing[2000009];
lli ar[509][509];
lli br[509][509];
lli cr[509][509];
lli w[200009];
lli v[200009];


lli solve(lli n,lli wei)
{
    if(dp[n][wei]!=0)
        return dp[n][wei];

    if(n<0||wei<0)
        return ninf;

        if(n==0||wei==0)
            return 0;

    lli res=max(solve(n-1,wei),v[n]+solve(n-1,wei-w[n]));

    if(res<0)
        res=0;

    //cout<<"n="<<n<<" "<<"wei="<<wei<<" "<<"val="<<dp[n][wei]<<endl;
    return dp[n][wei]=res;
}


int main()
{
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
    int start_s = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    vector<lli>vect,vt,vct;
    vector<lli>::iterator itt;
    set<lli>st;
    set<lli>::iterator itr;
    map<lli,lli>mp;
    map<lli,lli>::iterator it;
    string str;

    lli i,j,k,wei,n,m,q,t,a,b,c,maxi=INT_MIN,mini=INT_MAX,sum=0,ans=0,res=0,val=0,ans1=0,ans2=0,rem=0,diff=0,cnt=0,l,r,flag=0,e,index,val1=0,val2=0,x,y,z,h=0,u,mid,len,tot,fl=0;

    cin>>n>>wei;


    for(i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
    }

    solve(n,wei);

    cout<<dp[n][wei];
}


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

int main(){
  int n, m;
  int x, y, z, max;
  cin >> n >> m;

  for(int i = 0; i < n; ++i){
    cin >> x >> y;
    
    if(i == 0){
      max = m;
      z = m + x -y;
    }else z = z + x -y;
    if(z < 0){
      max = 0;
    }else if(z > max && max != 0){
      max = z;
    }
  }
  
  cout << max << endl;
    
  return 0;
}



Measured memory_bytes: 3104
/*
 *
 *
 */

#include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for(int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vc> vvc;
typedef vector<vll> vvll;

int number(string s, int &i){
  int n = 0;
  for (; isdigit(s[i]); i++) {
    n = n * 10 + s[i] - '0';
  }
  // LOG("-> %d\n", n);
  return n / 2 + 1;
}

int dfs(string s, int &i){
  vi vote;
  for(; i < s.length(); i++) {
    if (s[i] == '[') {
      i++;
      if (isdigit(s[i])) {
        int n = number(s, i);
        vote.push_back(n);
      }else if (s[i] == '[') {
        vote.push_back(dfs(s, i));
      }
    }else if(s[i] == ']') break;
  }
  SORT(vote);
  int res = 0;
  REP(i, vote.size() / 2 + 1){
    res += vote[i];
    // LOG("====== %d\n", vote[i]);
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  REP(i, n){
    string s;
    cin >> s;
    int idx = 1;
    cout << dfs(s, idx) << endl;
  }
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
int main(){
    string a,b,c;
    cin >>a>>b>>c;
    for(int i=0;i<a.size();i++){
        for(int j=0;j<b.size();j++){
            for(int z=0;z<c.size();z++){
                if(a[a.size()-1]==b[j] && (b[b.size()-1])==c[0]){ cout << "YES"; return 0;}
            }

}
    }
    cout << "NO";}

Measured memory_bytes: 256
#include <stdio.h>

int main () {
	char s[100001];
	int c[26], flag=1;
	for (int i=0; i<26; i++)
		c[i] = 1;
	scanf ("%s", s);
	int idx=0;
	while (s[idx]!='\0') 
		c[(int)(s[idx++]-'a')] = 0;
	
	for (int i=0; i<26; i++) {
		if (c[i]) {
			putchar (i+'a');
			putchar ('\n');
			flag = 0;
			break;
		}
	}
	if (flag)
		printf ("None\n");
	return 0;
}

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

string s;

int main(void){
    
    cin >> s;
    
    if(s[0] == 'A'){
        int cnt = 0, idx = 0;
        for(int i = 2; i < s.size() - 1; ++i) if(s[i] == 'C') ++cnt, idx = i;
        if(cnt == 1){
            bool big = false;
            for(int i = 1; i < s.size(); ++i){
                if(i == idx) continue;
                if(s[i] < 'a' || 'z' < s[i]){ big = true; break; }  
            }
            if(!big){ printf("AC\n"); return 0; }
        }
    }
    printf("WA\n");
    
    return 0;
}

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

#define fr(i,n) for(int i = 0; i<n; i++)
#define sz(v) (int)(v.size())
#define prin(a) cout << #a << " = " << a << endl
#define all(v) (v).begin(),(v).end()

typedef long long ll;

const ll MOD = 998244353;

ll fp(ll base, ll exp){
	if(exp==0) return 1;
	ll mid = fp(base,exp/2);
	if(exp&1) return mid*mid%MOD*base%MOD;
	return mid*mid%MOD;
}

const int N = 2e5;
ll fat[N+10], invfat[N+10];

ll nck(ll n, ll k){
	ll ans = fat[n];
	ans = ans*invfat[k]%MOD;
	ans = ans*invfat[n-k]%MOD;
	return ans;
}

int main(){
	fat[0] = 1;
	invfat[0] = 1;
	for(ll i = 1; i<=N; i++){
		fat[i] = i*fat[i-1]%MOD;
		invfat[i] = fp(fat[i],MOD-2);
	}
	
	ll ans = 0;
	
	ll n, m, k; cin >> n >> m >> k;
	if(m==1){
		if(k==n-1) puts("1");
		else puts("0");
		return 0;
	}
	
	for(ll n_ig = 0; n_ig<=k; n_ig++){
		ll add = m*fp(m-1,n-1-n_ig)%MOD*nck(n-1,n_ig)%MOD;
		ans = (ans+add)%MOD;
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 6760
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ll n, x;
    cin >> n >> x;
    ll ans = n;
    ll a = x, b = n - x;
    while (a != 0) {
        ans += 2LL * a * (b / a);
        b %= a;
        swap(a, b);
    }
    cout << ans - b << '\n';
}

Measured memory_bytes: 256
s=list(input())
cnt=0
for i in range(len(s)//2):
    if s[i]!=s[len(s)-1-i]:
        print("No")
        exit()
    else:
        continue
for i in range((len(s)//2)//2+1):
    if (s[i]!=s[len(s)//2-i-1]) and (s[-(-len(s)//2)+1]!=s[len(s)-1-i]):
        print("No")
        exit()
    else:
        continue
print("Yes")

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

int main() {
    int n; cin >> n;
    int F[50];
    F[0] = F[1] = 1;
    for(int i = 2; i <= n; i++) {
        F[i] = F[i-1] + F[i-2];
    }
    
    cout << F[n] << endl;
    
    return 0;
}


Measured memory_bytes: 3080
def gcd(a, b):
  return gcd(b, a%b) if b else a

n = int(input())
a = list(map(int, input().split()))
l = [0 for i in range(n+1)]
r = [0 for i in range(n+1)]
ans = 0

for i in range(n):
  l[i+1] = gcd(a[i], l[i])
  r[n-i-1] = gcd(a[n-i-1], r[n-i])
for i in range(n):
  ans = max(ans, gcd(l[i], r[i+1]))
print(ans)


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

int main() {
	string s; cin >> s;
	int ans = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if ((s[i] -'0') == 1) ans++;
	}

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        int x =a;
        int y =0;
        
        	while(x<=b){
        		if(c % x ==0){
        			y++;
        		}
        		x++;
        	}
        System.out.println(y);
	}
}

Measured memory_bytes: 17356
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define BRK(x) { (x); break; }
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define FLOOR(x) ((int)floor(((double)x)))
#define CEIL(x) ((int)ceil(((double)x)))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mt make_tuple
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


int N;
int a[110];


int err(int y){
	int sum = 0;
	rep(i, 0, N) sum += (a[i]-y)*(a[i]-y);
	return sum;
}


int solve(){
	int ans = INF;
	repe(i, -100, 100) ans = min(ans, err(i));
	return ans;
}


signed main(){
	cin >> N;
	rep(i, 0, N) cin >> a[i];

	cout << solve() << endl;

	return 0;
}

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

int main(){
  int n;string s;
  cin >> n >> s;
  bool b=1;
  if(n%2==1) b=0;
  else{
    string a=s.substr(0,n/2),c=s.substr(n/2,n/2);
    if(a!=c) b=0;
  }
  if(b) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3616
function Main(input) {
    input = input.split("\n");
  	var N = Number(input[0]),
        B = input[1].split(' ').map(Number);
  	var sum = B[0] + B[N-2];
  	for(var i=0; i<N-2; i++){
    	sum += Math.min(B[i],B[i+1]);
    }
  console.log(sum);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <stdio.h>
#define black 1
#define white 0
#define BIG 2000000000
 
int n,c[100][100], A[100], color[100];
 
void Keiro() {
    int i, min, u, v;
     
    for (i = 0; i < n; ++i) {
        color[i]  = white;
        A[i] = BIG;
    }
     
    A[0] = 0;
     
    while(1) {
        min = BIG;
         
        u = -1;
        for(i = 0; i < n; i++) {
            if (min > A[i] && color[i] != black) {
                u = i;
                min = A[i];
            }
        }
        if (u == -1) break;
         
        color[u] = black;
        for (v = 0; v < n; ++v) {
            if (color[v] != black) {
                if (A[v] > A[u] + c[u][v]) {
                    A[v] = A[u] + c[u][v];
                }
            }
        }
         
    }
     
}
int main() {
    int i, j, k, a, b;
    scanf("%d", &n);
     
    for (i = 0; i < n; ++i){
        for (j = 0; j < n; ++j) {
            c[i][j] = BIG;
 
        }
    }
    for (i = 0; i < n; ++i) {
        scanf("%d %d", &a, &k);
        for (j = 0; j < k; ++j) {
            scanf("%d %d", &a, &b);
            c[i][a] = b;
        }
    }
    Keiro();
     
    for (i = 0; i < n; ++i) {
        printf("%d %d\n", i, A[i]);
    }
 
    return 0;
}

Measured memory_bytes: 1864
#include <bits/stdc++.h>
using namespace std;
 
int main(){

  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  while(a >= 0 or c >= 0){
    c = c - b;
    if(c <= 0){
      cout << "Yes" << endl;
      break;
    }
    a = a - d;
        if(a <= 0){
      cout << "No" << endl;
      break;
    }

}
}


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

using namespace std;

int main(){
	
	int x[3];
	cin >> x[0] >> x[1] >> x[2];
	sort(x, x + 3);
	if (x[0] == 5 && x[1] == 5 && x[2] == 7) { cout << "YES" << endl; }
	else cout << "NO" << endl;
	

	return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int h;
    int res = 0;
    for(int i = 0; i < n; ++i) {
        cin >> h;
        if(h >= k) ++res;
    }
    
    cout << res << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String args[]){
		Scanner i = new Scanner(System.in);
		int a = i.nextInt();
		int b = i.nextInt();
		a &= 1;
		b &= 1;
		if(a == 1 && b == 1){
			System.out.println(new char[]{'O','d','d'});
		}else{
			System.out.println(new char[]{'E','v','e','n'});
		}
	}
}


Measured memory_bytes: 21716
# -*- coding: utf-8 -*-
import sys 
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 998244353
N, S = map(int, readline().split())
A = list(map(int,readline().split()))

U = 3010
f = np.zeros(U,np.int64)
f[0] = 1
for a in A:
    ff = 2*f
    ff[a:] += f[:-a]
    ff%=MOD
    f = ff
ans = f[S]
print(ans%MOD)

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

if N == 0 and A[0] != 1:
  print(-1)
elif N != 0 and A[0] != 0:
  print(-1)
else:
  ans = 1
  nodes = 1
  preF = 0
  sucF = sum(A)
  
  for d in range(1, N+1):
    fol = A[d]
    nodes = min((nodes-preF)*2, sucF)
    
    if nodes < fol:
      print(-1)
      exit()
    
    ans += nodes
    preF = fol
    sucF -= fol
  print(ans)

Measured memory_bytes: 20168
//In the name of Allah the Most Merciful
//Astagfirullahil laji Rabbi Minkulli Jamio Watubi elai
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define MX 10000008
#define cs int t;cin>>t;while(t--)
int i,j,k;
int r,s;
main()
{
 string s;cin>>s;
 int l=s.length();int k=0;
 for(i=0;i<l/2;i++)
 {
     if(s[i]!=s[l-i-1]) k++;
 }
  cout<<k<<endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

Int N, M, V, P;
vector<Int> A;

bool isOK(Int i) {

	Int temp = 0;
	temp += M * (P - 1);

	if (A[i] + M < A[N - P]) {
		return false;
	}
	temp += M * (i + 1);
	for (Int j = i + 1; j <= N - P; j++) {
		temp += A[i] + M - A[j];
	}

	return temp >= V * M;
}

Int binary_search() {
	Int ng = -1;
	Int ok = N-P; 

	while (abs(ok - ng) > 1) {
		Int mid = (ok + ng) / 2;

		if (isOK(mid)) ok = mid;
		else ng = mid;
	}
	return ok;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	
	cin >> N >> M >> V >> P;
	A.resize(N);
	
	for (Int i = 0; i < N; i++) {
		cin >> A[i];
	}

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

	cout << N-binary_search() << "\n";
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX=2500;
const ll lim=1e10+5;
int n,ans,isp[100005],p;
ll a[100005],prime[100005];
map<ll,int> mp;
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=MX;i++) isp[i]=1;
	for(int i=2;i<=MX;i++)
	{
		if(isp[i]) prime[++p]=i;
		for(int j=1;j<=p&&prime[j]*i<=MX;j++)
		{
			isp[i*prime[j]]=0;
			if(i%prime[j]==0) break;
		}
	}
	for(int i=1;i<=p;i++) a[i]=1ll*prime[i]*prime[i]*prime[i];
	for(int i=1;i<=n;i++) 
	{
		ll x;
		scanf("%lld",&x);
		for(int j=1;j<=p&&x>=a[j];j++) while(x%a[j]==0) x/=a[j];
		mp[x]++;
//		printf("x=%lld\n",x);
	}
	for(map<ll,int>::iterator it=mp.begin();it!=mp.end();it++)
	{
		ll x=it->first,y=1,ori=x;
		int cnt=it->second;
		if(!cnt) continue;
		if(x==1)
		{
			ans++;
			continue;
		}
//		printf("x=%lld cnt=%d\n",x,cnt);
		for(int j=1;j<=p&&x>=prime[j];j++)
		{
			if(x%prime[j]==0)
			{
				int tmp=0;
				while(x%prime[j]==0) x/=prime[j],tmp++;
				tmp=3-tmp;
				while(tmp--) y*=prime[j];
			}
		}
		if(y>lim) 
		{
			ans+=cnt;
			continue;
		}
		ll sq=sqrt(x);
		if(sq*sq==x) 
		{
			y*=sq;
			if(y>lim) ans+=cnt;
			else if(cnt>=mp[y]) ans+=cnt,mp[y]=0; 
		}
		else 
		{
			if(y*x<lim) 
			{
				y*=x;
				if(y*x<lim)
				{
					y*=x;
					if(cnt>=mp[y]) ans+=cnt,mp[y]=0;
				}
				else ans+=cnt;
			}
			else ans+=cnt;
		}
//		printf("x=%lld y=%lld ans=%d\n",ori,y,ans);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int a,b;
  cin >>a>>b;
  if(a==b)cout<<"Draw"<<endl;
  else if(a != b && a==1)cout <<"Alice"<<endl;
  else if(a != b && b==1)cout<< "Bob"<<endl;
  else if(a != 1 && b!=1 && a >b)cout <<"Alice"<<endl;
  else if(a != 1 && b!=1 && a < b)cout <<"Bob"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];
    ll ans = 0;
    rep(i, min(n,k)+1) {
        rep(j, min(n,k)-i+1) {
            vector<ll> arr;
            rep(x, i) arr.push_back(v[x]);
            rep(x, j) arr.push_back(v[n-x-1]);
            ll sum = accumulate(ALL(arr), 0);
            sort(ALL(arr));
            rep(x, min(k-i-j, (int)arr.size())) chmax(sum, sum-arr[x]);
            chmax(ans, sum);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define nl '\n'
#define vi vector<long int>
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mod 1000000007
#define int long int
using namespace std;

signed main(){
    ios;
    int n,k;
    cin>>n>>k;
    vi vec(n);
    for(int i=0;i<n;i++) cin>>vec[i];
    vi ans(n);
    ans[n-1]=0;
    ans[n-2]=abs(vec[n-1]-vec[n-2]);
    vi mini;
    mini.push_back(LONG_MAX);
    for(int i=n-3;i>=0;i--){
        mini[0]=LONG_MAX;
        for(int j=i+1;j<n && j<=(i+k);j++){
            mini[0]=min(mini[0], ans[j] + abs(vec[j]-vec[i]));
        }
        ans[i]=mini[0];
    }
    cout<<ans[0]<<nl;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
ll X[100000];
int main() {
	int N;
	ll A, B;
	cin >> N >> A >> B;
	for (int i = 0; i < N; i++) cin >> X[i];
	ll ans = 0;
	for (int i = 1; i < N; i++) {
		ans += min((X[i] - X[i - 1])*A, B);
	}
	cout << ans << endl;
}


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

using namespace std;

//#define FILE_IO

int N, M, Q;
int nd[100005], cl[100005], dst[100005];
int c[100005];
bool f[100005][11];
vector <int> edg[100005];

void color(int nod, int d, int clr)
{
    if(d < 0 || f[nod][d])  return;
    f[nod][d] = 1;
    if(!c[nod]) c[nod] = clr;
    for(auto nxt: edg[nod])
        color(nxt, d - 1, clr);
}

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

    scanf("%d%d", &N, &M);
    for(int i = 1; i <= M; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        edg[x].push_back(y);
        edg[y].push_back(x);
    }

    scanf("%d", &Q);
    for(int i = 1; i <= Q; i++)
    {
        int x, d, c;
        scanf("%d%d%d", &x, &d, &c);
        nd[i] = x;
        dst[i] = d;
        cl[i] = c;
    }

    for(int i = Q; i >= 1; i--)
        color(nd[i], dst[i], cl[i]);

    for(int i = 1; i <= N; i++)
        printf("%d\n", c[i]);

    return 0;
}


Measured memory_bytes: 9080
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;


int main(void){
    int n, k;
    cin >> n >>k;
    int max_diff = 0;
    if(k != 1){
        max_diff = n-k;
        max_diff = (max_diff > 0) ? max_diff:0 ;
    }
    cout << max_diff<< endl;
    return 0;
}

Measured memory_bytes: 256
// 簡易競プロテンプレ
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n; ll a[114514], s[114514];

bool ok(int m){
 if (m<0) return false;
 if (m>=n) return true;
 ll w = s[m+1];
 for(int i=m+1;i<n;i++){
  if (w * 2 < a[i]) return false;
  w += a[i];
 }
 return true;
}
int main(void){
 cin >> n;
 for(int i=0;i<n;i++) cin >> a[i];
 sort(&a[0], &a[n]);
 for(int i=0;i<n;i++) s[i+1] = s[i] + a[i];

 int mini = 0, maxi = n, med;
 while(1){
  med = (mini + maxi + rand()%2)/2;
  if (ok(med-1)) {maxi = med-1;}
  else if (!ok(med)) {mini = med+1;}
  else break;
 }
 cout << n-med << endl;
 return 0;
}

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

void main_()
{
    ll N;
    cin >> N;
    vector<ll> as;
    as.reserve(N);
    copy_n(istream_iterator<ll>(cin), N, back_inserter(as));
    vector<ll> bs;
    bs.reserve(N);
    copy_n(istream_iterator<ll>(cin), N, back_inserter(bs));

    ll minus = 0;
    ll plus = 0;
    for (ll i = 0; i < N; i++) {
        auto abdiff = as[i] - bs[i];
        if (abdiff < 0) {
            minus += -abdiff / 2;
        } else {
            plus += abdiff;
        }
    }
    if (minus >= plus) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
auto ____ = [] () {ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); };
const int MAXN = 333;
const int INF = 0x3f3f3f3f;
#define fi first
#define se second
#define mp make_pair
typedef pair<int,int> pii;
typedef pair<int,pii> pip;
int n,m,l,q;
struct EDGE{
    int to,cost;
    EDGE(){}
    EDGE(int to, int cost){
        this->to = to;
        this-> cost = cost;
    }
};
vector<EDGE> G[MAXN];
int ans[MAXN][MAXN];
int bot[MAXN];
int dist[MAXN][MAXN];
void Dijkstra(int s){
    memset(dist,255,sizeof(dist));
    memset(bot,INF,sizeof(bot));
    priority_queue<pip, vector<pip>, less<pip>> que;
    dist[s][0] = l;
    bot[s] = 0;
    que.push(mp(l,mp(s,0)));
    while(!que.empty()){
        pip now = que.top();
        que.pop();
        int d = now.fi;
        int u = now.se.fi;
        int k = now.se.se;
        if(dist[u][k]!=d||k>=n||bot[u]<k) continue;
        for(EDGE e : G[u]){
            int v = e.to;
            int c = e.cost;
            if(d>=c&&d-c>dist[v][k]&&bot[v]>=k){
                dist[v][k] = d - c;
                bot[v] = k+1;
                que.push(mp(dist[v][k],mp(v,k)));
            }
            if(dist[v][k+1]<l-c&&bot[v]>=k+1){
                dist[v][k+1] = l-c;
                bot[v] = k+1;
                que.push(mp(dist[v][k+1],mp(v,k+1)));
            }
        }
    }
    for(int i = 1; i <= n; i++){
        if(i==s) continue;
        if(ans[s][i]!=-1) continue;
        for(int j = 0; j<= n; j++){
            if(dist[i][j]!=-1){
                ans[s][i] = ans[i][s] = j;
                break;
            }
        }
    }
}
int main(){
    ____();
    memset(ans,255,sizeof(ans));
    cin >> n >> m >> l;
    for(int i = 1; i <= m; i++){
        int u,v,c;
        cin >> u >> v >> c;
        if(c>l) continue;
        G[u].push_back(EDGE(v,c));
        G[v].push_back(EDGE(u,c));
    }
    for(int i = 1; i <= n; i++) Dijkstra(i);
    cin >> q;
    while(q--){
        int s,t;
        cin >> s >> t;
        cout << ans[s][t] << endl;
    }
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Graph = vector<vector<int>>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll 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(ll 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) const { 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; }

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
} c(2000005);

int main() {
  int n, m, k;
  cin >> n >> m >> k;

  mint ans = 0;
  mint col = m;
  for (int x = n - 1; x >= 0; x--) {
    mint now = col;
    now *= c(n - 1, x);
    if (x <= k) ans += now;
    col *= m - 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 34140
#include <stdio.h>
#include <math.h>

int main()
{
    double x1, y1, x2, y2;
    double dis;

    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    printf("%f\n", sqrt(pow(x2-x1, 2) + pow(y2-y1,2)));

    return 0;
}

Measured memory_bytes: 1840
//{{{
#pragma GCC optimize("O3")
#include <cstdio>
#include <cstring>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
//types
typedef long long ll;
typedef pair<int,int> pii;
//input
bool SR(int &_x){return scanf("%d",&_x)==1;}bool SR(ll &_x){return scanf("%lld",&_x)==1;}
bool SR(double &_x){return scanf("%lf",&_x)==1;}bool SR(char *_s){return scanf("%s",_s)==1;}
bool RI(){return true;}
template<typename I,typename... T>bool RI(I &_x,T&... _tail){return SR(_x) && RI(_tail...);}
//output
void SP(const int _x){printf("%d",_x);}void SP(const ll _x){printf("%lld",_x);}
void SP(const double _x){printf("%.16lf",_x);}void SP(const char *s){printf("%s",s);}
void PL(){puts("");}
template<typename I,typename... T>void PL(const I _x,const T... _tail)
{SP(_x);if(sizeof...(_tail)) putchar(' ');PL(_tail...);}
//macro
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<int(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=int(b);i++)
#define pb push_back
#define mkp make_pair
#define F first
#define S second
//}}}
const int MOD=1e9+7;
const int maxn=2e5+5;
const int K=2e3+3;
int C[K][K];
int fac[K<<2],inv[K<<2],ifac[K<<2];
void predo()
{
    REP(i,K) C[i][0]=1;
    REP1(i,1,K-1) REP1(j,1,i)
        C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

    fac[0]=1;
    REP1(i,1,4*K-1) fac[i]=1LL*fac[i-1]*i%MOD;
    inv[1]=1;
    REP1(i,2,4*K-1) inv[i]=1LL*inv[MOD%i]*(MOD-MOD/i)%MOD;
    ifac[0]=1;
    REP1(i,1,4*K-1) ifac[i]=1LL*ifac[i-1]*inv[i]%MOD;
}
int n,a[maxn],b[maxn];
void read()
{
    RI(n);
    vector<pii> v(n);
    REP(i,n) RI(v[i].F,v[i].S);
    sort(ALL(v));
    REP(i,n) a[i]=v[i].F,b[i]=v[i].S;
}
ll _[K*4],*dp=_+K*2;
void build()
{
    for(int k=K-1;k>=0;k--)
    {
        int up=upper_bound(a,a+n,k)-a;
        REP1(i,up,n-1) dp[b[i]-k]+=C[a[i]-1][a[i]-1-k];
        for(int i=K;i>=-K;i--) dp[i]=(dp[i]+dp[i+1])%MOD;
    }
}
void sol()
{
    ll ans=0;
    REP1(i,-K,K) REP1(j,-i,K)
        ans=(ans+1LL*dp[i]*dp[j])%MOD;
    
    REP(i,n)
    {
        ll cur=fac[a[i]+b[i]+a[i]+b[i]];
        cur=cur*ifac[a[i]<<1]%MOD;
        cur=cur*ifac[b[i]<<1]%MOD;
        ans=(ans-cur)%MOD;
    }

    ans=ans*inv[2]%MOD;
    if(ans<0) ans+=MOD;
    PL(ans);
}
int main()
{
    predo();
    read();
    build();    
    sol();
    return 0;
}




































/*End Of File*/




Measured memory_bytes: 17280
#include<bits/stdc++.h>
using namespace std;
const int SZ=100005;
vector<int> graph[SZ];
int vst[SZ];
void dfs(int x){
	vst[x]=1;
	for(int nxt:graph[x]){
		if(vst[nxt]==1) continue;
		dfs(nxt);
	}
}
int main(void){
	int n,m; scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++){
		int a,b,c; scanf("%d %d %d",&a,&b,&c);
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(vst[i]==1) continue;
		dfs(i); ans++;
	}
	printf("%d",ans);
	return 0;
}

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

const int MOD = 1e9+7;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> oks(n+1, true);
    int a;
    for (int i = 0; i < m; i++) {
        cin >> a;
        oks[a] = false;
    }
    vector<long long int> dp(n+1);
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j <= min(n, i+2); j++) {
            if (oks[j]) {
                dp[j] += dp[i];
                dp[j] %= MOD;
            }
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
using P = pair<int, int>;
const ll inf =1e9;
const ll mod = 1e9+7;

struct edge{
    int to;
    int cost;
};
using graph = vector<vector<edge>>;

int main(){
    int n, k; cin >> n >> k;
    vector<int> p(n);
    int sum = 0;
    for(int i=0; i<n; i++){
        cin >> p[i];
        if(i<k){
            sum += p[i];
        }
    }
    int tmp_sum = sum;
    int memo = 0;
    if(k<n){
        for(int i=0; i<n-k; i++){
        tmp_sum = tmp_sum - p[i] + p[i+k];
            if(tmp_sum >= sum){
                sum = tmp_sum;
                memo = i+1;
            }
        }
    }
    double ans = 0;
    for(int i=memo; i<memo+k; i++){
        ans += (double)(p[i]+1)/2.0;
    }
    cout << setprecision(15) << ans << endl;
}

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

int main() {
    ll N;
    ll K;
    cin >> N >> K;
    vector<double> E(N);
    rep(i, N){
        double a;
        cin >> a;
        E[i] = (1.0+a)/2;
    }
    double max = 0.0;
    vector<double> S(N+10);
    S[0] = 0;
    rep(i, N){
        S[i+1] = S[i] + E[i];
    }
    rep(i, N-K+1){
        double a = S[i+K] - S[i]; 
        if(max < a) max = a;
    }
    printf("%.12lf\n",max);
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#define rep(i,N) for(int i=0; i<N;i++)
using namespace std;
class Person{
    public:
        int num;
        vector<int> person;
        vector<int> statement;
        void addPerson(int p){person.push_back(p);}
        void addStatement(int s){statement.push_back(s);}
        int getPerson(int i){return person[i];}
        int getStatement(int i){return statement[i];}
};

int main(){
    int N;
    cin >>N;
    vector<Person> A(N);
    rep(i,N){
        cin>>A[i].num;
        rep(j,A[i].num){
            int p,s;
            cin >> p >>s;
            A[i].addPerson(p);
            A[i].addStatement(s);
        }
 //       cout<<A.at(i).num<<endl;
    }
    int max=0;
    int wanted;
    for (int bit = 0; bit < (1<<N); ++bit) {
        vector<int> S;
        for (int i = 0; i < N; ++i) {
            if (bit & (1<<i)) {
                S.push_back(i+1);
            }
        }
        rep(i,S.size()){
   //     cout << S[i]<<" ";
        }
  //      cout <<"search"<<endl;
        rep(j,S.size()){
            rep(k,A.at(S.at(j)-1).num){
                vector<int>::iterator itr;
                wanted = A.at(S.at(j)-1).getPerson(k);
 //               cout <<S.at(j)<<" "<<wanted <<" "<<A.at(S.at(j)-1).getStatement(k)<<endl;
                itr = find(S.begin(), S.end(), wanted);
                if(A.at(S.at(j)-1).getStatement(k)==1 and itr == S.end()){
                    goto OUT;
                }else if(A.at(S.at(j)-1).getStatement(k)==0 and itr != S.end()){
                    goto OUT;
                }
   //             cout <<"No found.."<<endl;
            }
            
        }
        if(S.size()>max){
            max=S.size();
        }
  //      cout <<"max : "<<max<<endl;
    OUT:
        max=max;
    }

    cout <<max<<endl;


    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
struct tree
{
	int minv[600000],n;
	tree(int size):n(size){memset(minv,0x3f,sizeof minv);}
	void update(int p,int x,int o,int l,int r)
	{
		if(l==r){minv[o]=min(minv[o],x);return;}
		int m=(l+r)>>1;
		if(p<=m)update(p,x,o*2,l,m);
		else update(p,x,o*2+1,m+1,r);
		minv[o]=min(minv[o*2],minv[o*2+1]);
	}
	int query(int x,int y,int o,int l,int r)
	{
		if(x<=l&&r<=y)return minv[o];
		int m=(l+r)>>1,ans=1<<28;
		if(x<=m)ans=min(ans,query(x,y,o*2,l,m));
		if(y>m)ans=min(ans,query(x,y,o*2+1,m+1,r));
		return ans;
	}
	void set(int p,int x){update(p,x,1,0,n);}
	int get(int l,int r){return query(l,r,1,0,n);}
};
vector<int> v[300000];
int f[300000],b[300000],n,q;
int main()
{
	scanf("%d",&n);
	int cnt=0;
	for(int i=1;i<=n;i++)scanf("%d",b+i),cnt+=!b[i],b[i]=b[i]?1:-1;
	scanf("%d",&q);
	for(int i=1;i<=q;i++)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		v[l].push_back(r);
	}
	tree t(n);
	t.set(0,0);
	for(int i=1;i<=n;i++)
	{
		for(int j:v[i])t.set(j,t.get(i-1,j));
		t.set(i,min(t.get(i,i),t.get(i-1,i-1)+b[i]));
	}
	printf("%d\n",cnt+t.get(n,n));
	return 0;
}


Measured memory_bytes: 14720