akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//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())

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

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

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

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

//main code

int main(int argc, char const* argv[])
{
	string s;
	cin >> s;
	for (int i = 0; i < 3; i++) {
		if (s[i] == s[i+1]) {
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;
	return 0;
}


Measured memory_bytes: 764
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return list(sys.stdin.readline())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007

#A
"""
a, b = LI()
print((a+b+1)//2)
"""

#B
a = S()
a = a[:-1]
b = S()
b = b[:-1]
a.sort()
b.sort(reverse=True)
if a < b:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <sstream>
int main(){
    std::string s,t;
    std::getline(std::cin,s);
    std::stringstream ss(s);
    while(std::getline(ss,t,' ')){
        std::cout<<(char)(t[0]+'A'-'a');
    }
    std::cout<<std::endl;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N, K;
	in >> N >> K;
	std::vector<LL>x(N), y(N);
	rep(i, N) in >> x[i] >> y[i];

	LL ans = 4123456789012345678LL;
	rep(i, N)
	{
		rep(j, N)
		{
			rep(k, N)
			{
				rep(l, N)
				{
					LL minX = std::min(x[i], x[j]), maxX = std::max(x[i], x[j]), minY = std::min(y[k], y[l]), maxY = std::max(y[k], y[l]);
					LL cnt = 0;
					rep(m, N)
					{
						if (minX <= x[m] && x[m] <= maxX && minY <= y[m] && y[m] <= maxY) ++cnt;
					}
					if (cnt >= K) ans = std::min(ans, (maxX - minX) * (maxY - minY));
				}
			}
		}
	}

	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <vector>
#include <list>
using namespace std;
#include <stdio.h>
#include <map> 
#include <algorithm>
#include <functional>
#include <algorithm>
#include <functional>
#include <array>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>



int main()
{
	int N;
	std::vector<int> S;
	cin >> N;

	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		if ((a % 2) == 0) {
			if ((a % 3) == 0) {
				continue;
			}
			if ((a % 5) == 0) {
				continue;
			}
			printf("DENIED");
			return 0;

		}
	}

	printf("APPROVED ");


	return 0;
}




Measured memory_bytes: 256
N = int(input())

C = [[0 for _ in range(10)] for _ in range(10)]


for n in range(1, N+1):
    head = int(str(n)[0])
    tail = int(str(n)[-1])
    C[head][tail] += 1

ans = 0
for i in range(1,10):
    for j in range(1,10):
        ans += C[i][j] * C[j][i]


print(ans)



Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
long long NMAX=1000000000000001;

int main() {
  long long n;
  scanf("%lld", &n);
  int mod[20]={0};
  int i;
  for(i=0;i<20;i++){
    mod[i]=n%26;
    if(mod[i]==0) mod[i]=26;
    //printf("%d\n", mod[i]);
    if((n-1)/26==0){
      break;
    }
    n=(n-1)/26;
  }

  for(;i>=0;i--){
    putchar(mod[i]-1+'a');
  }
  return 0;
}


Measured memory_bytes: 2088
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
typedef long long LL;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << a * b / 2 << endl;
}


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

  
// 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, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main() {
    ll N;
    cin >> N;
    map<ll,ll> mp;
    for(int i=0;i<N;i++){
        ll D;
        cin >> D;
        if(i==0 && D != 0){
            cout << 0 << endl;
            return 0;
        }
        mp[D]++;
    }
    if(mp[0] != 1){
        cout << 0 << endl;
        return 0;
    }
    ll lastNum =1;
    ll lastD =-1;
    mint ans = 1;
    for(auto itr =mp.begin();itr  != mp.end();itr++){
        if(itr->first != lastD +1 ){
            cout << 0 << endl;
            return 0;
        }
        ans *= (mint(lastNum).pow(itr->second));
        // cerr <<"ans =" << ans << endl;
        lastNum = itr->second;
        lastD++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9860
// 参考 -> #7422186
// dp[w+1] になっていてメモリ量が節約されているのでとても頭がいい

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int N = sc.nextInt();
        int W = sc.nextInt();
        int[] w = new int[N];
        long[] v = new long[N];

        for (int i = 0; i < N; i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextLong();
        }

        long[] dp = new long[W+1];

        for (int i = 0; i < N; i++) {
            for (int j = W; j >= 0; j--) {
                if (j - w[i] >= 0) {
                    dp[j] = Math.max(dp[j], dp[j - w[i]] + v[i]);
                }
            }
        }

        long ans = 0;
        for (long i : dp)
            ans = Math.max(ans, i);

        System.out.println(ans);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

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

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

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 21844
import sys
sys.setrecursionlimit(1000000)


def dfs(map, reached, pos):
    global dx, dy
    x, y = pos

    if reached[x][y] == 1 or map[x][y] == '0':
        return 0

    reached[x][y] = 1
    for dxi, dyi in zip(dx, dy):
        if not reached[x + dxi][y + dyi]:
            dfs(map, reached, (x + dxi, y + dyi))

    return int(map[x][y])


def island(map):
    w = len(map)
    h = len(map[0])
    reached = [[0] * h for _ in range(w)]

    ans = 0
    for x in range(w):
        for y in range(h):
            if reached[x][y] == 1 or map[x][y] == '0':
                continue
            ans += dfs(map, reached, (x, y))

    return ans


dx = [1, 0, -1, 0, 1, -1, 1, -1]
dy = [0, 1, 0, -1, 1, -1, -1, 1]

while True:
    w, h = map(int, input().split())

    if (0, 0) == (w, h):
        break

    mapp = ['0' * (w + 2)]
    for _ in range(h):
        mapp.append('0%s0' % input().replace(' ', ''))
    mapp.append('0' * (w + 2))
    print(island(mapp))



Measured memory_bytes: 8684
#include <iostream>
#include<bits/stdc++.h>
#define int long long int
#define e 1000000007
using namespace std;

 
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
 int t=1;
    // cin>>t;
  while(t--){
      int cnt = 0;
   int n,d;
   cin>>n>>d;
   for(int i=0;i<n;i++){
int p,q;
cin>>p>>q;
if(d >= sqrt(p*p + q*q)){
    cnt++;
}
   }
   cout<<cnt;
  }
}

Measured memory_bytes: 3624
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n,k;cin>>k>>n;
  V<ll> v(n);
  rep(i,0,n)cin>>v[i];
  ll ans=v.back()-v[0];
  rep(i,0,n-1){
    chmin(ans,k-abs(v[i]-v[i+1]));
  }

  cout<<ans<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.12lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define mod 1000 * 1000 * 1000 + 7
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;

const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);

int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main()
{
    int x, a;
    cin >> x >> a;
    cout << (x < a ? "0" : "10") << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String[] in = s.nextLine().split(" ");
        int a = Integer.parseInt(in[0]);
        String opcode = in[1];
        int b = Integer.parseInt(in[2]);
        if(opcode.equals("+")){
            System.out.println(a+b);
        }else{
            System.out.println(a-b);
        }
    }
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		int number = 1;
		int i = 0;
		for(i = 0; i < n; i++) {
			if(number <= k) {
				number = number * 2;
			} else {
				number = number + k;
			}
		}
		System.out.println(number);
	}
}

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

using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i < (n); --i)
#define all(x) (x).begin(), (x).end()
#define gsort(x, n) sort((x), (x + n) greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

int f(int n){
    int a = n % 4;
    if(a == 0) return n;
    else if(a == 1) return 1;
    else if(a == 2) return n+1;
    else return 0;
}

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

    int x,y;
    cin>>x>>y;

    int ans = f(x-1)^f(y);
    cout<<ans<<'\n';
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		
		if((N % K) == 0) {
			System.out.println(0);
		} else {
			System.out.println(1);
		}
		
	}
}


Measured memory_bytes: 23764
#include <stdio.h>
#include <string.h>
    void bubbleSort(char a[][3],int n);
    void selectSort(char a[][3],int n);
 
    void sw(char a[],char b[]);
 
    char A[200][3];
    char B[200][3];
 
int main()
{
 
    int n ;
    scanf("%d",&n);
    for(int i= 0;i<n;i++){
        scanf("%s",A[i]);
        strcpy(B[i],A[i]);
    }
 
 
    for(int i= 0;i<n;i++){
        for(int j=n-1;j>i;j--){
            if(A[j][1] < A[j-1][1]){
                sw(A[j],A[j-1]);
            }
        }
    }
 
    for(int i = 0;i<n-1;i++){
        int ss = i;
        for(int j=i+1;j<n;j++){
            if(B[j][1]<B[ss][1]){
                ss = j;
            }
        }
        if(ss != i){
            sw(B[ss],B[i]);
        }
    }
 
 
 
 
        for(int i= 0;i<n;i++){
            printf("%s%s",A[i],(i == n-1)? "\n": " ");
            //if(i == n-1) printf("\n");
        }
        printf("Stable\n");
 
        for(int i= 0;i<n;i++){
            printf("%s%s",B[i],(i == n-1)? "\n": " ");
            //if(i == n-1) printf("\n");
        }
 
        int stable = 1;
        for(int i= 0;i<n;i++){
            if(strcmp(A[i],B[i])){
                stable = 0;
            }
        }
        printf("%s\n",stable?"Stable":"Not stable");
 
    return 0;
}
 
    void sw(char a[],char b[]){
        char tmp[3] = "";
        strcpy(tmp,a);
        strcpy(a,b);
        strcpy(b,tmp);
    }
 
 
    void selectSort(char a[][3],int n){
 
    }


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  string s;
  cin >> s;
  int p=0, q=0;
  rep(i,s.size()) {
    if(i % 2 == 0) {
      if(s.at(i) == '1')
        p++;
      else q++;
    }
    if(i % 2 == 1) {
      if(s.at(i) == '0')
        p++;
      else q++;
    }
  }
  cout << min(p,q);
}


Measured memory_bytes: 512
N=int(input())

A=[]
B=[]
X=0
for i in range(1,20):
    X+=i
    A.append(X)
    B.append(i)
#print(A)
#print(B)
A=A[::-1]
B=B[::-1]
#print(A,B)
D={}
for i in range(2,10**6+1):
    while N%i==0:
        if i not in D:
            D[i]=1
            N//=i
        else:
            D[i]+=1
            N//=i
if N>1:
    D[N]=1

ans=0
for k,v in D.items():
    for j in range(len(A)):
        if A[j]<=v:
            ans+=B[j]
            break
print(ans)

Measured memory_bytes: 63272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;

int main(){
    ll N; 
    string S; cin >> N >> S;
    ll cnt = 0;
    for(int i = 0; i < N; i++) if(S[i] == 'R') cnt++;
    ll cnt2 = 0;
    for(int i = 0; i < cnt; i++) if(S[i] == 'R') cnt2++;
    cout << cnt - cnt2 << endl;
}


Measured memory_bytes: 3668
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a + b >= c) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 35760
#include <iostream>
using namespace std;
int main() {
  int A, B, C, X, Y, r;
  cin >> A >> B >> C >> X >> Y;
  C *= 2;
  if ((A + B) < C) {
    if (X < Y) {
      r = (A + B) * X;
      r += (B < C ? B : C) * (Y - X);
    } else {
      r = (A + B) * Y;
      r += (A < C ? A : C) * (X - Y);
    }
  } else {
    if (X < Y) {
      r = C * X;
      r += (B < C ? B : C) * (Y - X);
    } else {
      r = C * Y;
      r += (A < C ? A : C) * (X - Y);
    }
  }
  cout << r << endl;
  return 0;
}


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

int main(){
    int N;
    cin>>N;
    int A[N];
    for(int k=0;k<N;k++){
        cin>>A[k];
    }

    double B[N];
    double x=0;
    for(int i=0;i<N;i++){
        B[i]=(double)1/A[i];
        x+=B[i];
    }
    cout<<1/x<<endl;
    return 0;
}

Measured memory_bytes: 256
while True:
    a=input()
    b=a.split()
    m=int(b[0])
    f=int(b[1])
    c=int(b[0])+int(b[1])
    if m==-1 and f==-1 and int(b[2])==-1:
        break
    elif m==-1 or f==-1:
        print("F")
    elif c>=80:
        print("A")
    elif 80>c>=65:
        print("B")
    elif 65>c>=50 or int(b[2])>=50:
        print("C")
    elif 50>c>=30:
        print("D")
    elif 30>c:
        print("F")
        



Measured memory_bytes: 5592
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a,const void *b){
  return *(int*)a - *(int*)b;
}

int main(void){
  int n,i,j,ans=0,count,pos=0,car;
  scanf("%d",&n);
  int a[n];
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  qsort(a,n,sizeof(a[0]),cmp);
  while(pos<n){
    car = a[pos],count=0;
    while(pos<n && a[pos]==car){
      count++;
      pos++;
    }
    ans += count%2;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <cstring>

#define INF 999999

using namespace std;

int list[100][100];
int ans;
int weigh,high;

void search(int x,int y);

int main(void){
  int n;
  int nx[100],ny[100];

  int i;

  while(cin>>weigh>>high,weigh||high){

    ans=0;
    for(i=0;i<100;i++){
      memset(list[i],0,sizeof(list[i]));
    }

    list[weigh][high]=100;
    cin>>n;
    for(i=0;i<n;i++){
      cin>>nx[i]>>ny[i];
      list[nx[i]][ny[i]]=INF;
    }
    search(1,1);
    cout<<ans<<endl;
  }
  return(0);
}

void search(int x,int y){
  if(list[x][y]==100){
    ans++;
    return;
  }

  if(x<weigh){
    if(list[x+1][y]!=INF){
      search(x+1,y);
    }
  }
  if(y<high){
    if(list[x][y+1]!=INF){
      search(x,y+1);
    }
  }
  return;
}

Measured memory_bytes: 1200
N = int(input())
count = 0

import math  
  
# Method to print the divisors 
def printDivisors(n) : 
	list = []  
	for i in range(1, int(math.sqrt(n) + 1)) : 
		if (n % i == 0) : 
			if (n / i == i) : 
				list.append(i) 
			else : 
				list.append(i) 
				list.append(int(n / i)) 
	return(list)

A = printDivisors(N)

for i in range (1, len(A)):
	if N//(A[i]-1) == N/A[i]:
		count+=(A[i]-1)

print(count)

Measured memory_bytes: 9364
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int N;
long long A[200000];
int main(){
  int i;
  long long res = 1;
  double d = 1;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  for(i=(0);i<(N);i++){
    if(A[i]==0){
      wt_L(0);
      wt_L('\n');
      return 0;
    }
  }
  for(i=(0);i<(N);i++){
    d *= A[i];
    if(d > 2e18){
      wt_L(-1);
      wt_L('\n');
      return 0;
    }
    res *= A[i];
  }
  if(res > 1000000000000000000LL){
    wt_L(-1);
    wt_L('\n');
  }
  else{
    wt_L(res);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20200509-1

// --- original code ---
// int N;
// ll A[2d5];
// {
//   ll res = 1;
//   double d = 1;
//   rd(N,A(N));
//   rep(i,N) if(A[i]==0) wt(0), return 0;
//   rep(i,N){
//     d *= A[i];
//     if(d > 2e18) wt(-1), return 0;
//     res *= A[i];
//   }
//   wt(if[res > 1d18, -1, res]);
// }


Measured memory_bytes: 5408
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500 * i + 100 * j + 50 * k == x:
                ans += 1
print(ans)

Measured memory_bytes: 9120
#include <iostream>
#include <vector>

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

int main() {
    int D;
    cin >> D;

    vector<int> c(26);
    rep(i, 26) {
        cin >> c.at(i);
    }

    vector<vector<int>> s(D, vector<int>(26));
    rep(d, D) {
        rep(i, 26) {
            cin >> s.at(d).at(i);
        }
    }

    vector<int> t(D);
    rep(d, D) {
        cin >> t.at(d);
        t.at(d)--;
    } 

    int score = 0;

    vector<int> last(26);
    rep(i,26) last[i]= -1;

    rep(d, D) { //d:day
        last[t.at(d)] = d;
        //cout << "s: " << s[d][t[d]] << endl;
        score += s[d][t[d]];
        //cout << "score" << d << " " << score << endl; 
        rep(i, 26) { //i:contest
            score -= c[i] * (d - last[i]);
        }
        cout << score << endl;
    }
    
}

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

int P, Q, R;

int main() {
    cin >> P >> Q >> R;

    cout << min({P + Q, Q + R, P + R}) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long int n,ans=1;
    cin>>n;
    int a[n+1];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int j=0;j<n;j++){
        if(n%2==0){
            if(a[j]%2!=1){
                ans=0;
                break;
            }
            else{
            if(j%2==0){
                if(a[j]!=j+1){
                    ans=0;
                    break;
                }
            }
            else{
                if(a[j]!=j){
                    ans=0;
                    break;
                }
            }
            }
        }
        else{
            if(a[j]%2!=0){
                ans=0;
                break;
            }
            else{
            if(j%2==0){
                if(a[j]!=j){
                    ans=0;
                    break;
                }
            }
            else{
                if(a[j]!=j+1){
                    ans=0;
                    break;
                }
            }
            }
        }
    }
    if(ans!=0){
        if(n%2==0){
            for(int l=0;l<(n/2);l++){
                (ans*=2)%=1000000007;
            }
        }
        else{
            for(int k=0;k<((n-1)/2);k++){
                (ans*=2)%=1000000007;
            }
        }
    }
    ans%=1000000007;
    cout<<ans;
    return 0;
}


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

using namespace std;

int main() {

   char char_A = 'A';
   char char_Z = 'Z';
   char char_a = 'a';
   char char_z = 'z';

   bool first = true;

   string inputStr;

   while (cin >> inputStr) {

      if (!first) {
         cout << " ";
      }

      first = false;

      int m = inputStr.length();

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

         char inChar = inputStr[i];

         if (char_A <= inChar && inChar <= char_Z) {
            inChar += char_a - char_A;
         } else if (char_a <= inChar && inChar <= char_z) {
            inChar -= char_a - char_A;
         }

         cout << inChar;

      }

   }

   cout << endl;

   return 0;

}

Measured memory_bytes: 1172
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<vector>
#include<tuple>
#include<stack>
#include<iomanip>
#include<map>
using namespace std;

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

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	int ret=1;
	for(int i=1;i<=a;i++){
		if(ret<=b) ret<<=1;
		else ret+=b;
	}
	printf("%d",ret);
	return 0;
}

Measured memory_bytes: 128
k, n = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
max_dif = 0
for i in list(range(1, n)):
	x = abs(a[i] - a[i-1])
	max_dif = max(max_dif, x)
	ans += x

ans += k-a[-1]+a[0]
max_dif = max(max_dif, k-a[-1]+a[0])
ans -= max_dif
print(ans)


Measured memory_bytes: 26444
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

signed main(){
    string S;
    cin >> S;
    ll ans = 0;
    REP(i, S.length()){
        if(i < (S.length()+ 1) / 2) ans += (S[i] == 'g' ? 0 : -1);
        else ans += (S[i] == 'g' ? 1 : 0);
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 3740
// 秒単位の時間Sが与えられるので、h:m:sの形式へ変換して出力してください。
// ここで、hは時間、mは60未満の分、sは60未満の秒とします。
// 【入力】
// Sが1行に与えられます。
// 【出力】
// h、m、sを :（コロン）区切りで１行に出力してください。
// 数値が１桁の場合、0 を付けて２桁表示をする必要はありません。
// 【制約】
// 0≤S<86400
// 【例】
// 入力：46979、出力：13:2:59
#include <stdio.h>

int main( void) {
  // S秒を60秒で割った余りがs秒
  // S秒を60秒で割った商（整数）がM分
  // M分を60分で割った余りがm分
  // M分を60分で割った商（整数）がh時

  int S,M;

  scanf( "%d", &S);

  int s, m, h;

  s = S % 60;
  M = S / 60;
  m = M % 60;
  h = M / 60;

  printf( "%d:%d:%d\n", h, m, s);

  return 0;
}



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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[N + 2];


void solve()
{

      string str; cin >> str;
      if ( str[0] == '7' or str[1] == '7' or str[2] == '7') cout << "Yes";
      else cout << "No";
}

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

      int test = 1;
      // cin >> test;

      // cout << setprecision(9) << fixed;
      // clock_t z = clock();
      while (test--)solve();
      // cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);
}





Measured memory_bytes: 3656
from collections import defaultdict
import numpy as np
import collections

N = int(input())
As = list(map(int, input().split()))

B = defaultdict(int)

ans = 0

for index, A in enumerate(As):
    ans += B[index-A]
    
    B[index+A] += 1
#    print(B)
#    print(list(B[:20]))

print(ans)


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

int main(){
  int n;cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;++i) cin>>a[i];
  
  vector<int> c(a);
  sort(c.begin(), c.end());
  bool ok = true;
  for(int i=0;i<n;++i) {
    ok &= a[i] == c[i];
  }
  if(ok){
    cout<<"YES"<<endl;
    return 0;
  }

  for(int i=0;i<n;++i){
    for(int j=0;j<i;++j){
      vector<int> b(a);
      swap(b[i],b[j]);		
      bool ok = true;
      for(int k=0;k<n;++k){
       ok &= c[k] == b[k];
      }
      if(ok) {
        cout<<"YES"<<endl;
        return 0;
      }
    }
  }
  cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <set>
// #include <bits/stdc++.h>
using namespace std;

#define size_t int
typedef long long ll;
// #define int long long
typedef vector<int> VI;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define debug(x) cerr << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
#define debug1(i, x) cerr << "(" << (i) <<  ") " << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
#define debug2(i, j, x) cerr << "(" << (i) << ", " << (j) <<  ") " << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
template <typename T> class vec2d : public vector<vector<T>> {
public:
    vec2d(int H, int W): vector<vector<T>> (H, vector<T>(W)) {
    }
};
template <typename T> istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template <typename T> ostream& operator << (ostream& os, vector<T>& vec){
  REP(i, vec.size()) {
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0);
        // cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

signed main(signed argc, char **argv) {
  int N, M;
  cin >> N >> M;
  VI s(M, 1);
  for (size_t i = 0; i < N; i++) {
    int K;
    cin >> K;
    set<int> t;
    for (size_t j = 0; j < K; j++) {
      int tmp;
      cin >> tmp;
      t.insert(tmp - 1);
    }
    for (size_t j = 0; j < M; j++) {
      if (t.find(j) == t.end()) {
        s[j] = false;
      }
    }
  }
  int r = 0;
  for (size_t i = 0; i < M; i++) {
    // debug1(i, s[i]);
    if (s[i]) {
      r++;
    }
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 256
#解説読んだ

import math

N, L = list(map(int, input().split()))
T = [int(input()) for _ in range(N)]

K = N * (N - 1) * (N - 2) / 3 / 2
x, y = 0, 0
for i in range(N - 1):
  for j in range(i + 1, N):
    a = (T[i] + T[j]) / 2
    b = a + L / 2
    t = j - i - 1
    k = N - 2 - t
    x += k * math.cos(2 * math.pi * a / L) / K
    x += t * math.cos(2 * math.pi * b / L) / K
    y += k * math.sin(2 * math.pi * a / L) / K
    y += t * math.sin(2 * math.pi * b / L) / K
print(x, y)

Measured memory_bytes: 45032
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    debug("debug test\n");
    int n,m;cin>>n;
    vll a(n);
    ll x = 0;
    rep(i, n){
        ll t;cin>>t;a[i] = t;
        x += t*(i%2==1?-1:1);
    }
    cout << x;
    rep(i, n-1){
        cout << ' ';
        x = 2*a[i]-x;
        cout << x;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2176
#include <cstdio>
#include <cstdint>
#include <algorithm>

int main() {
  intmax_t A, B, C;
  scanf("%jd %jd %jd", &A, &B, &C);

  intmax_t d = std::min(A, C);
  intmax_t res = d;
  if (C-d <= B) {
    res += C-d+B;
  } else {
    res += B+B+1;
  }
  printf("%jd\n", res);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int a, b, k; cin >> a >> b >> k;
  for(int i = max(a, b); i >= 1; i--){
    if(a%i== 0 && b%i == 0) k--;
    if(k == 0){
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <sstream>
# include <cstdio>
# include <cstdlib>
# include <algorithm>
# include <string>
# include <cstring>
# include <cmath>
# include <stack>
# include <queue>
# include <vector>
# include <list>
# include <map>
# include <set>
# include <deque>
# include <iterator>
# include <functional>
# include <bitset>
# include <climits>
# include <ctime>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define odd(x) (x&1)
typedef long long ll;
typedef long double ld;
const ll oo = /*2 * 1000 * 1000 * 1000*/0x3f3f3f3f;
const int _cnt = 1000 * 1000;
const int _p = 1000 * 1000 * 1000 + 7;
ll o(ll x) { return x%_p; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
//ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b)*b; }
using namespace std;

void file_put() {
	freopen("filename.in", "r", stdin);
	freopen("filename.out", "w", stdout);
}

int a, b, c;

int main() {
	//file_put();

	scanf("%d%d%d", &a, &b, &c);
	if (a <= c && c <= b) printf("Yes\n"); else printf("No\n");

	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(4100000)

n = int(input())
dat =[]
link = []
for i in range(n+1):
    link.append([])
cost = [-1] * (n + 1)

for i in range(n - 1):
    a, b, c = map(int, input().split())
    dat.append((a, b, c))
    link[a].append((b,c))
    link[b].append((a,c))

dat_q = []
q, k = map(int, input().split())

for i in range(q):
    x, y = map(int, input().split())
    dat_q.append((x,y))

#print(link)

def search(curcost, current):
    #print("cost{0}, pos {1}: ".format(curcost, current))
    cost[current] = curcost
    for npos, ncost in link[current]:
        if cost[npos] != -1:
            # 戻らない
            continue
        search(curcost + ncost, npos)

search(0, k)

#print(cost)
for i in range(q):
    x,y = dat_q[i]
    print(cost[x] + cost[y])


Measured memory_bytes: 212812
a, b, c, x, y = map(int, input().split())
minVal = c * 2 * (10 ** 5)
for i in range(10**5):
    total = (c*2) * i + a * max(0, x-i) + b * max(0, y-i)
    minVal = min(total, minVal)
print(minVal)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;

int main(){
    ll x;
    cin >> x;
    ll ans1,ans2;
    bool ok = false;
    for(ll a=0;a*a*a*a*a<=x;a++){
        for(ll b=0;b*b*b*b*b<=x;b++){
            if(a*a*a*a*a + b*b*b*b*b == x){
                ans1 = a,ans2 = -b;
                ok = true;
            }
        }
    }
    ll b = 0;
    if(!ok){
        while(!ok){
            ll a = b*b*b*b*b + x;
            for(ll i=0;i*i*i*i*i<=a;i++){
                if(i*i*i*i*i == a){
                    ans1 = i;
                    ans2 = b;
                    ok = true;
                    break;
                }
            }
            ++b;
        }
    }
    cout << ans1 << " "<< ans2 << endl;
    return 0;
}

Measured memory_bytes: 3632
function Main(input) {
  input=input.split("\n");
  const N=input[0].split(' ')[0]-0;
  const K=input[0].split(' ')[1]-0;
  const Q=input[0].split(' ')[2]-0;
  var seikai=new Array(N+1);
  seikai.fill(0);
  for(var i=1;i<input.length;i++){
    seikai[input[i]-0]++;
  }
  //console.log(seikai);
  for(var i=1;i<=N;i++){
    console.log(seikai[i]>Q-K?'Yes':'No');
  }

}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  
  


Measured memory_bytes: 46448
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n;
	cin >> n;
	int a[n];
	zip(i, 0, n)
	{
		cin >> a[i];
	}
	if (n == 1)
	{
		cout << a[0] << en;
		return 0;
	}
	if (n == 2)
	{
		cout << max(a[0], a[1]) << en;
		return 0;
	}
	if (n == 3)
	{
		cout << max(__gcd(a[0], a[1]), max(__gcd(a[1], a[2]), __gcd(a[0], a[2]))) << en;
		return 0;
	}
	//we will store GCDs in l[i] ans r[i]  where l[i]=gcd upto ith terms
	// and r[i]=gcd from n-1 to i+2th terms

	int l[n + 1];
	//l[0] = 0;
	l[0] = a[0];

	for (int i = 1; i < n; i++)
	{
		l[i] = __gcd(l[i - 1], a[i]);
	}
	int r[n + 1] = {0};
	r[n - 1] = a[n - 1];

	for (int i = n - 2; i >= 0; i--)
	{
		r[i] = __gcd(r[i + 1], a[i]);
	}
	int lar = 0;
	for (int i = 0; i < n - 2; i++)
	{
		lar = max(lar, __gcd(l[i], r[i + 2]));
	}
	int y = max(lar, max(r[1], l[n - 2]));
	cout << y << en;




	return 0;
}




Measured memory_bytes: 2560
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join(chr(i+97) for i in ls)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

class Comb:
    def __init__(self,n,mo=10**9+7):
        self.fac=[0]*(n+1)
        self.inv=[1]*(n+1)
        self.fac[0]=1
        self.fact(n)
        for i in range(1,n+1):
            self.fac[i]=i*self.fac[i-1]%mo
            self.inv[n]*=i
            self.inv[n]%=mo
        self.inv[n]=pow(self.inv[n],mo-2,mo)
        for i in range(1,n):
            self.inv[n-i]=self.inv[n-i+1]*(n-i+1)%mo
        return
    
    def fact(self,n):
        return self.fac[n]
        
    def invf(self,n):
        return self.inv[n]

    def comb(self,x,y):
        if y<0 or y>x:
            return 0
        return self.fac[x]*self.inv[x-y]*self.inv[y]%mo
        
show_flg=False
#show_flg=True

ans=0

h,w,a,b=LI()

cm=Comb(3*10**5,mo)

for i in range(w-b):
    show(i,(h-a+b +i-1,h-a-1),(a-1+w-b-1 -i,a-1))
    show(cm.comb(h-a+b +i-1,h-a-1),cm.comb(a-1+w-b-1 -i,a-1))
    ans+=cm.comb(h-a+b +i-1,h-a-1)*cm.comb(a-1+w-b-1 -i,a-1)
    ans%=mo

print(ans)


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    string a; cin >> a;
    ll answer = a.size()*(a.size()-1)/2 + 1;
    for(int i = 0; i < 26; ++i) {
        char p = 'a' + i;
        ll cnt = 0;
        for(char ch : a) {
            if(ch == p) ++cnt;
        }
        answer -= cnt*(cnt-1) / 2;
    }

    cout << answer << '\n';
}

Measured memory_bytes: 720