akhauriyash/Code-Regression huggingface dataset:
N=int(input())
a=list(map(int,input().split()))
d=[[0]*21 for i in[0]*~-N]
d[0][a[0]]=1
for i in range(1,N-1):
 for j in range(21):
  d[i][j]=(21>j+a[i]and d[i-1][j+a[i]])+(0<=j-a[i]and d[i-1][j-a[i]])
print(d[N-2][a[N-1]])


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

int main(){
 int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  int doub;
  if(a+b>=2*c)doub=2*c;
  else doub=a+b;
  if(a>=2*c && x>=y) cout << doub*y+ (x-y)*2*c <<endl;
  else if(b>=2*c && y>=x) cout << doub*x+(y-x)*2*c <<endl;
  else if(x >=y) cout << doub*y+(x-y)*a << endl;
  else cout << doub*x+(y-x)*b << endl;
    
  
}


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

#define PI 3.141592653589
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vv vector
int MOD=1e9+7;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
ll min(ll a,ll b){return (a>b)?b:a;}
ll max(ll a,ll b){return (a>b)?a:b;}
bool prime[1000001];
vi primes;
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, true, sizeof(prime)); 
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for(int p=2;p<1000001;p++)
        if(prime[p])
            primes.pb(p);
}
ll fact[1001];
void factorial(int n){
    fact[0]=1;
    for(int i=1;i<=n;i++)
        fact[i]=fact[i-1]*i,fact[i]%=MOD;
}
ll ncr(ll n,ll r)
{
    if(n<r)
        return -1;
    else{
        ll x=fact[r]*fact[n-r]%MOD;
        return fact[n]*fermat_inv(x)%MOD;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int t=1;
    //cin>>t;
    //SieveOfEratosthenes(1000000);
    //factorial(1000);
    while(t--){
        int n;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++)
            cin>>a[i];
        ll ans=0;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                for(int k=j+1;k<n;k++){
                    if(a[i]==a[j]||a[j]==a[k]||a[k]==a[i])
                        continue;
                    if(a[i]+a[j]>a[k]&&a[j]+a[k]>a[i]&&a[k]+a[i]>a[j])
                        ans++;
                }
            }
        }
        cout<<ans;
    }
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
// #define INF __INT32_MAX__
#define INF 1e9
#define LINF __LONG_LONG_MAX__

int main() {
    int N, Y; cin >> N >> Y;

    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= N; j++) {
            if (i + j > N) continue;

            int k = N - i - j;
            if (k < 0) continue;

            int m = 10000 * i + 5000 * j + 1000 * k;
            if (m == Y) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    ll Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;
    ll ans = (N/2) * min(min(8 * Q, 4 * H), min(2 * S, D)) + (N % 2) * min(min(4 * Q, 2 * H), S);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

int main(void) {
	string s; cin >> s;
	int n = s.size();
	rep(i,n){
		if( (i+1)%2==1 && s[i]=='L' ){
			cout << "No" << endl;
			return 0;
		}
		if( (i+1)%2==0 && s[i]=='R' ){
			cout << "No" << endl;
			return 0;
		}		
	}
	cout << "Yes" << endl;
}




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

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

Measured memory_bytes: 3628
N,K=map(int,input().split())

#S = [[0 for j in range(3)] for i in range(2)]　2行3列の場合
S = [[0 for j in range(2)] for i in range(100010)]

for i in range(N):
    T=list(map(int,input().split()))
    S[T[0]][0]=T[0]
    S[T[0]][1]+=T[1]

#print(S)

for i in range(100010):
    if S[i][0]!=0:
        K-=S[i][1]
        if K<=0:
            print(S[i][0])
            exit()


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

int main(){
 int A;
 cin >> A;
for(int a=1;a<=9;a++){
    for(int b=1;b<=9;b++){
        if(a*b==A){
            cout << "Yes"<<endl;
            return 0;
        }
    }
}
 cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void)
{
    int N;
    scanf("%d", &N);
    int C[20], V[20], Profit[20], result;

    int i;
    for (i=0; i<N; i++) {
        scanf("%d", &V[i]);
    }
    for (i=0; i<N; i++) {
        scanf("%d", &C[i]);
    }

    for (i=0; i<N; i++) {
        Profit[i] = V[i] - C[i];
    }
    for (i=0; i<N; i++) {
        if (Profit[i] > 0) result += Profit[i];
    }
    printf("%d", result);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000009
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N){
    cin >> A.at(i);
  }
  set<ll> S;
  rep(i, N){
    S.insert(A.at(i));
  }
  if(S.size() == N){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 11136
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int s = n.ToString().Select(i => int.Parse(i.ToString())).Sum();

        bool ok = n % s == 0;
        string answer = ok ? "Yes" : "No";

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11348
module Main where

import Control.Applicative
import Control.Monad
import Data.List

f :: Int -> Int
f 0 = 0
f n = iter 0 n
  where
    iter k x = case x `divMod` 2 of
        (q, 0) -> iter (k + 1) q
        (q, r) -> k

main :: IO ()
main = do
    n <- readLn :: IO Int
    let ans = head $ sortBy (\a b -> f b `compare` f a) [1 .. n]
    print ans

Measured memory_bytes: 508
#include <stdio.h>
int main () {
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    int flag=1;
    while (1) {
        if (a<=0) {
            printf("No");
            break;
        }
        if (c<=0) {
            printf("Yes");
            break;
        }
        if (flag==1) {
            c-=b;
            flag=0;
        }
        else if (flag==0) {
            a-=d;
            flag=1;
        }
       
    }

}

Measured memory_bytes: 1724
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string HEX = "0123456789ABCDEF";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

int main(void) {
    int n;
    cin >> n;
    long a = 2;
    long b = 1;
    if (n==1) {
        cout << 1;
        return 0;
    }
    REP(i,n-1){
        long na = b;
        long nb = a + b;
        b = nb;
        a = na;
    }
    cout << b;
    return 0;
}


Measured memory_bytes: 256
def readints():
    return list(map(int, input().split()))


n = int(input())
s = [input() for i in range(n)]
# print(s)
s.sort()
# print(s)
L = []
M = -1
i = 0
while i < n:
    j = i
    while j < n and s[i] == s[j]:
        j += 1
    l = j-i
    L.append(l)
    i = j
for i in L:
    if i > M:
        M = i
#print(M, L)
index = 0
for i in L:
    # print(index)
    if i == M:
        print(s[index])
    index += i


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

int main(){
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  int count=0;
  for(int i=0; i<=a; i++){
  	for(int j=0; j<=b; j++){
    	for(int l=0; l<=c; l++){
        	if(500*i+100*j+50*l==x){
            	count++;
            }
        }
    }
  }
  cout << count << endl;  	  
}

Measured memory_bytes: 3628
S = input()
ans = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
if len(set(S))==26:
    print("None")
else:
    ans = set(ans) ^ set(S)
    print(sorted(ans)[0])

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;

void solve()
{
	ll n;
	map<ll, int> mp;
	cin>>n;
	for(ll x = 1; x<=100; x++)
	{
		for(ll y = 1; y<=100; y++)
		{
			for(ll z = 1; z<=100; z++)
			{
				ll fx = x*x + y*y + z*z + x*y + y*z + z*x;
				mp[fx]++;
			}
		}
	}
//	ll totalCnt = 0;
	for(int i=1; i<=n; i++)
	{
		cout<<mp[i]<<"\n";
//		totalCnt+=mp[i];
	}
}
int main()
{	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 6108
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int N;
int x;
int as[114514];

int main() {
  scanf("%d%d", &N, &x);
  rep(i, N) {
    scanf("%d", &as[i]);
  }
  sort(as, as+N);
  
  int ans = 0;
  rep(i, N) {
    if (x >= as[i]) {
      ans++;
      x -= as[i];
    }
  }

  if (ans == N && x > 0) ans--;

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


Measured memory_bytes: 256
import numpy as np

EPS = 1e-12

class MinEnclosingCircle:
  def __init__(self, pts):
    self.pts = pts
    self.center = None
    self.radius = None

  def fit(self):
    self.center = (self.pts[0] + self.pts[1]) / 2
    self.radius = np.linalg.norm(self.pts[0] - self.pts[1]) / 2 + EPS
    for i in range(2, len(self.pts)):
      distance = np.linalg.norm(self.pts[i] - self.center)
      if distance >= self.radius:
        self.center, self.radius = self.find_second_point(i)

  def find_second_point(self, i):
    center = (self.pts[0] + self.pts[i]) / 2
    radius = np.linalg.norm(self.pts[0] - self.pts[i]) / 2 + EPS
    for j in range(1, i):
      distance = np.linalg.norm(self.pts[j] - center)
      if distance >= radius:
        new_center, new_radius = self.find_third_point(i, j)
        if new_radius > 0:
          center = new_center
          radius = new_radius
    return center, radius

  def find_third_point(self, i, j):
    center = (self.pts[j] + self.pts[i]) / 2
    radius = np.linalg.norm(self.pts[j] - self.pts[i]) / 2 + EPS
    for k in range(j):
      distance = np.linalg.norm(self.pts[k] - center)
      if distance >= radius:
        new_center, new_radius = self.find_circle_3pts(i, j, k)
        if new_radius > 0:
          center = new_center
          radius = new_radius
    return center, radius

  def find_circle_3pts(self, i, j, k):
    v1 = self.pts[j] - self.pts[i]
    v2 = self.pts[k] - self.pts[i]
    mid_point1 = (self.pts[j] + self.pts[i]) / 2
    c1 = np.dot(mid_point1, v1)
    mid_point2 = (self.pts[k] + self.pts[i]) / 2
    c2 = np.dot(mid_point2, v2)
    det = np.cross(v1, v2)
    if abs(det) <= EPS:
      d1 = np.sum(v1 * v1)
      d2 = np.sum(v2 * v2)
      d3 = np.sum((v1 - v2) ** 2)
      radius = np.sqrt(max(d1, d2, d3)) / 2 + EPS
      if d1 >= d2 and d1 >= d3:
        center = (self.pts[i] + self.pts[j]) / 2
      elif d2 >= d1 and d2 >= d3:
        center = (self.pts[i] + self.pts[k]) / 2
      else:
        center = (self.pts[j] + self.pts[k]) / 2
    else:
      center = np.zeros_like(v1)
      center[0] = c1 * v2[1] - c2 * v1[1]
      center[1] = v1[0] * c2 - v2[0] * c1
      center = center / det
      radius = np.linalg.norm(center - self.pts[i]) + EPS
    return center, radius

n = int(input())
point = [np.array(input().split(), dtype=int) for _ in range(n)]
mec = MinEnclosingCircle(point)
mec.fit()

print(mec.radius)

Measured memory_bytes: 12508
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i32 = int32_t;
using i64 = int64_t;
constexpr char newl = '\n';

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define F first
#define S second
#define debug(x) cout << #x << ": " << x << '\n';

#if 1

template<typename T>
constexpr T Abs(T a) {
  return a > 0 ? a : -a;
}

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;

  vector<int> a(N), b(N), c(N);
  F0R(i, N) {
    cin >> a[i] >> b[i] >> c[i];
  }
  /*
  vector<vector<int>> a(3, vector<int>(N));
  F0R(i, N) {
    cin >> a[0][i] >> a[1][i] >> a[2][i];
  }
  */

  vector<int> dpa(N), dpb(N), dpc(N);
  dpa[0] = a[0], dpb[0] = b[0], dpc[0] = c[0];
  FOR(i, 1, N) {
    dpa[i] = max(dpb[i - 1], dpc[i - 1]) + a[i];
    dpb[i] = max(dpa[i - 1], dpc[i - 1]) + b[i];
    dpc[i] = max(dpa[i - 1], dpb[i - 1]) + c[i];
  }
  cout << max(max(dpa[N - 1], dpb[N - 1]), dpc[N - 1]);
}
#endif


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define maxn 100005
#define mod 1000000007
vector<int> e[maxn];
long long dp[maxn][2] = {};
void dfs(int v,int p)
{
	dp[v][0] = dp[v][1] = 1;
	for(int u:e[v])
	{
		if(u==p)continue;
		dfs(u,v);
		dp[v][0] = dp[v][0] * (dp[u][0] + dp[u][1]) % mod;
		dp[v][1] = dp[v][1] * dp[u][0] % mod;
	} 
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1; i<n; i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		e[a].push_back(b);
		e[b].push_back(a);
	}
	dfs(1,0);
	printf("%lld\n",(dp[1][1] + dp[1][0]) % mod);
	return 0;
}

Measured memory_bytes: 14208
W,H=map(int,input().split())
p=[int(input()) for i in range(W)]
q=[int(input()) for i in range(H)]
c=sorted([(i,0) for i in p]+[(j,1) for j in q])
a=W+1
b=H+1
ans=0
for z in c:
    if z[1]==0:
        ans+=z[0]*b
        a-=1
    else:
        ans+=z[0]*a
        b-=1
print(ans)


Measured memory_bytes: 27576
k = int(input())
cnt = 0

lun = [1, 2, 3, 4, 5, 6, 7, 8, 9]
i = 0
while True:
    ans = lun[i]
    a0 = ans % 10
    if a0 == 0:
        lun.append(ans*10+a0)
        lun.append(ans*10+a0+1)
    elif a0 == 9:
        lun.append(ans*10+a0-1)
        lun.append(ans*10+a0)
    else:
        lun.append(ans*10+a0-1)
        lun.append(ans*10+a0)
        lun.append(ans*10+a0+1)
    i += 1
    if i >= k:
        break
print(ans)


Measured memory_bytes: 15744
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b[];
      	int c;
      	b = new int[a];
      	int total=0;
		for(int i=0; i<a; i++){
			b[i] = sc.nextInt();
		}
      	for(int i=0; i<a; i++)
        {
          for(int j=i+1;j<a;j++)
          {            
            c=b[i]*b[j];
            total+=c;
          }
        }
		System.out.println(total);
	}
}

Measured memory_bytes: 23124
j=input()
mst_str=input().split()
mst=list(map(int, mst_str))
n=len(mst)

def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)

if n==1:
    print(mst[0])
else:
    HP = gcd(mst[0], mst[1])
    if n==2:print(HP)
    else:
        for i in range(2,n):
            HP=gcd(HP,mst[i])
        print(HP)



Measured memory_bytes: 14252
main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));
function main(N){
  var T = N.trim();
  var a = T.charAt(0);
  var b = T.charAt(2);
  var c = T.charAt(4);
    if((a=="7"&&b=="5"&&c=="5")||(a=="5"&&b=="7"&&c=="5")||(a=="5"&&b=="5"&&c=="7")){
    console.log("YES");
  }else{
  console.log("NO");
  }
}

Measured memory_bytes: 7372
#include <iostream>

using namespace std;

int main(){
  int a,b,c;
  int x;
  int count = 0;
  
  cin >> a >> b >> c >> x;
  
  for(int i = 0 ; i <= a ; i++){
    for(int j = 0 ; j <= b ; j++){
      for(int k = 0 ; k <= c ; k++){
        if((500*i + 100*j + 50*k) == x) count++;
      }
    }
  }
  
  cout << count << endl;
  
  return 0;
}

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }//最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }//最小公倍数

ll calc(ll g){

}

int main(void){
    int n;
    cin >> n;

    ll a[n];
    rep(i, n)
        cin >> a[i];

    ll l[n], r[n];
    l[0] = a[0];
    r[n-1] = a[n-1];

    rep(i, n){
        if(i != 0)
            l[i] = gcd(l[i-1], a[i]);
    }

    for(int i = n-2; i >= 0; i--){
        r[i] = gcd(r[i+1], a[i]);
    }

    ll g, m = 0;
    rep(i, n){
        if(i == 0)
            g = r[i + 1];
        else if(i == n-1)
            g = l[i - 1];
        else
            g = gcd(l[i - 1], r[i + 1]);
        m = max(g, m);
    }

    cout << m << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>
#include <set>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

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

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(void){
	int n,m,c,i,j;
	int a,b[20];
	int sum[20],cnt=0;
	scanf("%d %d %d",&n,&m,&c);
	for(i=0;i<m;i++){
		scanf("%d",&b[i]);
	}
	for(i=0;i<n;i++){
		sum[i]=c;
		for(j=0;j<m;j++){
			scanf("%d",&a);
			sum[i]+=a*b[j];
		}
	}
	for(i=0;i<n;i++){
		if(0<sum[i]){
			cnt++;
		}
	}
	printf("%d",cnt);
	return 0;
}

Measured memory_bytes: 1732
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: i32 = input();
    let a: i32 = input();
    let b: i32 = input();
    println!("{}", std::cmp::min(n * a, b));
}


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


using namespace std;
static const int MAX = 200000;

int main() {
    int R[MAX], n;

    cin >> n;
    for ( int i = 0; i < n; i++ ) cin >> R[i];

    int maxv = R[1] - R[0];
    int minv = R[0];

    for (int i = 1; i < n; i++ ) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;
    
}



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

typedef long long ll;
#define pa pair<int, int> 
#define pal pair<long long, long long>
#define pali pair<long long, int>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair 
#define COUT(v) for(int64_t i=0;i<(v).size();i++){ cout << v.at(i) << endl;}
#define REP(i, n) for(int64_t i=0;i<n;i++)
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pavec;
typedef vector<pali> palivec;
typedef vector<pal>palvec;


typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector< vector<long long> > lmat;

typedef vector<string> svec;
typedef vector< vector<string> > smat;
const ll infll = (1LL << 60) - 1;
const int inf = (1 << 30) - 1;
const int MOD = 1000000007;


ll gcd(ll x, ll y){
    ll r = x%y;
    if(r == 0) return y;
    else return gcd(y, r);
} 

ll lcm(ll x, ll y){
    return x*y/gcd(x,y);
}

lvec mfactor(ll n){
    bvec ip(n, true);
    lvec mf(n, -1);
    ip[0]=false; ip[1]=false; mf[0]=0; mf[1]=1;
    REP(i, n){
        if(ip[i]){
            mf[i] = i;
            for(ll j=i*i; j<n; j+=i){
                ip[j] = false;
                if(mf[j] == -1) mf[j]=i;
            }
        }
    }
    return mf;
}

palivec get_prime(ll n, const lvec &mf){
    palivec plist;
    while(n != 1){
        int cnt=0;
        ll m=mf[n];
        while(mf[n] == m){
            cnt++;
            n/=m;
        }
        plist.pb(pali(m, cnt));
    }
    return plist;
}

void COMinit(int m, lvec &fac, lvec &finv){
    lvec inv(m);
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < m; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(int n, int k, const lvec& fac, const lvec &finv){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


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;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, r;
    cin >> n >> r;
    int l = n <= 10 ? r + 100*(10-n): r;
    cout << l << endl;
}


Measured memory_bytes: 256
defmodule Main do
  def main do
    n = IO.gets("")
        |> String.trim()
        |> String.codepoints()
        |> Enum.map(&String.to_integer/1)

    sum_of_digits = List.foldl(n, 0, &Kernel.+/2)

    case rem(sum_of_digits, 9) do
      0 -> IO.puts("Yes")
      _ -> IO.puts("No")
    end
  end
end


Measured memory_bytes: 90540
import sys
def input(): return sys.stdin.readline().strip()

def main():
    S = input()
    cnt = 0
    ans = 0
    for c in S:
        if c == 'R':
            cnt += 1
        else:
            ans = max(ans, cnt)
            cnt = 0
    print(max(ans, cnt))


if __name__ == "__main__":
    main()


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

int main(){
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i = 0; i < N; ++i) cin >> H[i];
    int  sum = 1;
    
    for(int i = 1; i < N; ++i){
        bool flag = true;
        for(int j = 0; j < i; ++j){
            if(H[j] > H[i]) flag = false;
        }
        if(flag) sum += 1;
    }
    cout  << sum << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define RG register
#define il inline
#define iter iterator
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
using namespace std;
typedef long long ll;
const int N=200005;
int n,t[105];char s[N<<1];ll ans=0;
void work()
{
	scanf("%s",s+1);
	ans=1;
	n=strlen(s+1);
	for(int i=1;i<=n;i++){
		ans+=i-t[s[i]-'a']-1;
		t[s[i]-'a']++;
	}
	printf("%lld\n",ans);
}

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


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i,n) for(int i=0;i<n;i++)
#define unsigned long ul
using namespace std;

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int n, k;
    string s;
    //int p[25000];
    vector<int> p;
    cin >> n >> k;
    cin >> s;

    char tmp = s[0];
    int count = 1;
    int pos = 0;
    REP(i, n){
        if(i == 0)continue;
        if(s[i] == tmp){
            count++;
        }else{
            if(tmp=='0'){
                p.push_back(count);// = count;
                tmp='1';
            }else{
                p.push_back(-1 * count);
                tmp = '0';
            }
            count = 1;
            pos++;
        }
    }
    //if(count != 0){
        if(tmp=='0')p.push_back(count); else p.push_back(-1 * count);
    //}else{}
    /*REP(i, pos+1){
        cout << p[i] << endl;
    }*/
    pos++; //pos並ぶ
    if(p[0] > 0){p.insert(p.begin(),0);pos++;}
    if(p[pos-1] > 0){p.push_back(0);pos++;}
    /*REP(i, pos){
        cout << p[i] << endl;
    }*/
    int plus = (pos-1)/2;
    if(plus <+ k){cout << n << endl;return 0;}
    int sum = 0;
    int m = 0;
    REP(i, plus-k+1){
        REP(j, 2*k+1){
            if(j%2==0){//正でないところ
                sum += -1 * p[i*2+j];
            }else{
                sum += p[i*2+j];

            }
        }
        m = max(m, sum);
        sum = 0;

    }
    cout << m << endl;
    /*
    int minus, plus;
    if(pos % 2 == 0){
        minus = pos/2;
        plus = pos/2;
        if(k >= plus){cout << n << endl;return 0;}
        else{
            int max = 0;
            REP(i, plus-k+1){
                REP(j,2*k+1){}//計測フェーズ
            }
        }
    }else{
        if(p[0] < 0){
            minus = (pos+1)/2;
            plus = pos - minus;
        }else{
            plus = (pos+1)/2;
            minus = pos - plus;
        }
    }*/
    
	return 0;
}


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


int main (){
    string w;
    cin >> w;
    int a[26] = {0};
    rep(i,w.length()){
        a[(int)w[i]-97]++;
    }
    rep(i,26){
        if(a[i] %2 != 0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define pii pair<int,int>
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#define fio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define vll vector<long long int>
#define vpii vector<pair<int,int>>
#define dsc [](int a,int b)->bool {return a>b;}
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define MAX 1000000000000000000
#define test int t; cin>>t;
#define MOD 1000000007LL
#define all(x) (x).begin(),(x).end()

using namespace std;

ll nxt(){
    ll x;
    cin>>x;
    return x;
}

int main()
{
    #ifndef ONLINE_JUDGE
        fio
    #endif
    IOS
    
    string s,t;
    cin>>s>>t;
    int n = s.length();
    int k = t.length();
    int ans = INT_MAX;
    for(int i = 0; i<=n-k; i++){
        int cnt = 0;
        for(int j = 0; j<k; j++){
            if(s[i+j]!=t[j]) cnt++;
        }
        ans = min(cnt,ans);
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3660
n = gets.to_i
h = gets.split.map(&:to_i)

count = 0

if h.any?{|x| 1<=x && x<=399}
  count += 1
end
if h.any?{|x| 400<=x && x<=799}
  count += 1
end
if h.any?{|x| 800<=x && x<=1199}
  count += 1
end
if h.any?{|x| 1200<=x && x<=1599}
  count += 1
end
if h.any?{|x| 1600<=x && x<=1999}
  count += 1
end
if h.any?{|x| 2000<=x && x<=2399}
  count += 1
end
if h.any?{|x| 2400<=x && x<=2799}
  count += 1
end
if h.any?{|x| 2800<=x && x<=3199}
  count += 1
end

count_stop = h.count{|x| x>=3200}

if n > 0
  min = 1
end

if count > 1
  min = count
end

max = count + count_stop

puts min.to_s + " " + max.to_s

Measured memory_bytes: 1788
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
int dp[45][410][410];
main(){
    fill(dp[0][0],dp[45][0],INF);
    dp[0][0][0] = 0;
    int N,MA,MB,A[40],B[40],C[40],mini = INF;
    cin >> N >> MA >> MB;
    for(int i = 0;i < N;i++){
        cin >> A[i] >> B[i] >> C[i];
    }
    for(int i = 0;i < N;i++){
        for(int j = 0;j <= 400;j++){
            for(int k = 0;k <= 400;k++){
                dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j][k]);
                if(j-A[i] < 0 || k-B[i] < 0)continue;
                dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j-A[i]][k-B[i]] + C[i]);
            }
        }
    }
    for(int i = 1;max(MA,MB)*i <= 400;i++){
        mini = min(mini,dp[N][MA*i][MB*i]);
    }
    if(mini == INF)cout << -1 << endl;
    else cout << mini << endl;
}

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

int main(){
		string s;
		while(getline(cin, s) and s != "."){
				s = regex_replace(s, regex("[a-zA-Z \\.]"), "");
				while(s!=""){
						string before = s;
						s = regex_replace(s, regex("\\(\\)|\\[\\]"), "");
						if(s==before) break;
				}
				cout << ((s=="")?"yes":"no") << endl;
		}
}


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

int n;

int main() {
    cin >> n;
    int ans = (n - 1)  / 2;
    cout << ans << endl;
}


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

int main() {
    string s; cin >> s;
    sort(s.begin(), s.end());

    string t = "abcdefghijklmnopqrstuvwxyz";
    int cnt = 0;
    string u; u += s.at(0);
    rep(i, s.size()-1){
        if(s.at(i)==s.at(i+1)) continue;
        else u += s.at(i+1);
    }

   //cout << u << endl;

    if(u==t){
        cout << "None" << endl;
        return 0;
    }

    for(int i=0; i<u.size(); i++){
        if(t.at(i)==u.at(i)) continue;
        else{
            cout << t.at(i) << endl;
            return 0;
        }
    }

    cout << t.at(u.size()) << endl;

}


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
using namespace std;
struct numnode {
	int x,y;
}a[100500];
bool cmp(numnode a,numnode b){
	if (a.x!=b.x) return a.x<b.x;
	return a.y<b.y;
}
int main(){
	int n,m,ans=0;
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++)
	scanf("%d%d",&a[i].x,&a[i].y);
	sort(a+1,a+1+m,cmp);
	int l=0,r=n+1;
	for (int i=1;i<=m;i++){
		if (a[i].x>l) l=a[i].x;
		if (a[i].y<r) r=a[i].y;
		if (l>=r) ans++,l=a[i].x,r=a[i].y;	
	}
	ans++;
	printf("%d",ans);
}

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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    ll a, b, c;
    cin >> a >> b >> c;
    ll d = c - (a - b);
    if (d < 0)
        d = 0;
    cout << d << endl;
    return 0;
}


Measured memory_bytes: 256
first = 0
second = 0
third = 0
for i in range(10):
    height = int(input())
    if first <= height:
        third = second
        second = first
        first = height
    elif second <= height:
        third = second
        second = height
    elif third <= height:
        third = height
print(first)
print(second)
print(third)


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

int main(){
 int W,H;
cin>>W>>H;

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

if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H )
cout<<"Yes"<<endl;

else cout<<"No"<<endl;

return 0;
 }


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

using ull = unsigned long long;
using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;
const int inf = INT_MAX;

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

    int d, t, s;
    cin >> d >> t >> s;

    if (s * t >= d) {
        cout << "Yes\n";
    } else cout << "No\n";
    return 0;
}

Measured memory_bytes: 3664
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;



int MOD=1000000007;
int main(){
    int N,K,x=0,ans=0;
    cin >> N >> K;
    int p[N+10];
    for(int i=0; i<N; i++)
	{
        cin >> p[i];
	}
    for(int i=0; i<K; i++){
        x+=p[i];
	}
    ans=x;
    for(int i=0; i+K<N; i++){
        x+=p[i+K]-p[i];
        ans=max(ans,x);
    }
    printf("%f",double(ans+K)/2);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (int i = a; i < b; i++)
#define VREP(it, v) for (vector<int>::iterator it = v.begin(); it != v.end(); it++)
typedef pair<ll,ll> pi;
typedef vector<ll> vi;

template <typename T>
using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename K, typename V>
using pbds_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;
ll h, w, ch, cw, dh, dw;
char grid[1005][1005];
int visited[1005][1005];
set<ll> adjList[600005];
ll counter = 0;
ll dx[] = {1, -1, 0, 0};
ll dy[] = {0, 0, 1, -1};
ll dist[600005];
priority_queue<pi, vector<pi>, greater<pi> > pq;

void dfs(ll x, ll y){
	visited[x][y] = counter;
	REP(i, 0, 4){
		ll newx = x + dx[i];
		ll newy = y + dy[i];
		if (newx < 0 || newx >= h) continue;
		if (newy < 0 || newy >= w) continue;
		if (visited[newx][newy] != -1) continue;
		if (grid[newx][newy] == '#') continue;
		dfs(newx, newy);
	}
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> h >> w;
	cin >> ch >> cw;
	cin >> dh >> dw;
	ch--;cw--;dh--;dw--;
	REP(i, 0, h){
		REP(j, 0, w){
			cin >> grid[i][j];
		}
	}
	memset(visited, -1, sizeof(visited));
	REP(i, 0, h){
		REP(j, 0, w){
			if (grid[i][j] == '#') continue;
			if (visited[i][j] != -1) continue;
			dfs(i, j);
			counter++;
		}
	}
	//cout << "here" << endl;
	REP(i, 0, h){
		REP(j, 0, w){
			REP(k, -2, 3){
				REP(l, -2, 3){
					if (grid[i][j] == '#') continue;
					ll newx = i + k;
					ll newy = j + l;
					if (newx < 0 || newx >= h) continue;
					if (newy < 0 || newy >= w) continue;
					if (grid[newx][newy] == '#') continue;
					if (visited[newx][newy] == -1) continue;
					if (visited[newx][newy] == visited[i][j]) continue;
					if (adjList[visited[i][j]].find(visited[newx][newy]) != adjList[visited[i][j]].end()) continue;
					adjList[visited[i][j]].insert(visited[newx][newy]);
					adjList[visited[newx][newy]].insert(visited[i][j]);
				}
			}
		}
	}
	//cout << "here" << endl;
	
	memset(dist, -1, sizeof(dist));
	dist[visited[ch][cw]] = 0;
	pq.push(make_pair(0, visited[ch][cw]));
	while (!pq.empty()) {
	    pi cur = pq.top();
	    pq.pop();
	    ll x = cur.second, d = cur.first;
	    if (d > dist[x]) continue;
	    for (set<ll>::iterator it = adjList[x].begin(); it != adjList[x].end(); ++it) {
	        ll nx = *it, nd = d+1;
	        if (dist[nx] != -1 && dist[nx] <= nd) continue;
	        dist[nx] = nd;
	        pq.push(make_pair(nd, nx));
	    }
	}
	cout << dist[visited[dh][dw]] << endl;
}

//cout.flush()
//cout << fixed << setprecision(9) << x << endl;

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define per(i, n) for(int i = (n)-1; i >= 0; --i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}

using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

constexpr char sp = ' ';
constexpr char cmm = ',';
constexpr int MOD = 1e9+7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}

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 (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s<<'[';for(size_t i=0;i<v.size();++i){s << v[i];if(i < v.size()-1) s << ", ";}s<<']';return s;
}
struct __f{
    __f(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    };
};

int main(){
    
    string s;
    cin >> s;
    vector<string> d = {"SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};
    ppp(find(d.begin(), d.end(), s)-d.begin()+1);
    
    return 0;
}


Measured memory_bytes: 256
s = str(input())
k = int(input())
i, count = 0, 0
while (i < len(s)):
  if int(s[i]) == 1:
    if (count >= k - 1):
      print('1')
      break
    count += 1
  else:
    print(s[i])
    break
  i += 1

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
void read(int &x){
	char ch=getchar();x=0;
	for (;ch==' '||ch=='\n';ch=getchar());
	for (;ch!=' '&&ch!='\n';x=x*10+ch-'0',ch=getchar());
}
bool vis[100004];
bool dp[100004];
int n,k,a[104];
bool win(int x){
	if (vis[x]) return dp[x];
	vis[x]=1;
	for (int i=1;i<=n;i++) if (x>=a[i])
		dp[x]|=(!win(x-a[i]));
	return dp[x];
}
int main(){
	read(n),read(k);
	for (int i=1;i<=n;i++) read(a[i]);
	if (win(k)) puts("First");
	else puts("Second");
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define all(v) (v).begin(),(v).end()
#define endl "\n"
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>b;i--)
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define SET(A,VAL) memset(A, VAL, sizeof(A))
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
const int MAX = 1e6 + 8;
const int MOD = 1e9 + 7;
const int sz = 1e5 + 5;
void f_io(){
    #ifndef ONLINE_JUDGE
    FRE
    #endif
}


int32_t main(){
    // f_io();
    IOS;
    int tc = 1;
    //cin>>tc;
    while(tc--){
        int n; cin >> n;
        if(!(n & 1) || !(n % 5)) {
            cout << "-1" << endl;
            continue;
        }
        int rem = 7, cnt = 1;
        if(n == 7 || n == 1) {
            cout << "1" << endl;
            continue;
        }
        while(rem && cnt <= 1e9) {
            cnt++;
            rem *= 10;
            rem += 7;
            rem %= n;
        }

        if(rem) cout << "-1" << endl;
        else cout << cnt << endl;
    }
}

Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  ll A[N]; rep(i, N) cin >> A[i] ;

  int s = 0, d = 0;
  ll x = A[0], sum = A[0];
  ll result = 0;
  while(s<N) {
    if (x==sum) { 
      if (d==N-1) { 
        result += d-s+1;
        x = x^A[s]; sum -= A[s];
        s++;
      }
      else {
        d++;
        x = x^A[d]; sum += A[d];
      }
    }
    else { 
      result += d-s; 
      x = x^A[s]; sum -= A[s];
      s++;
      }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n;
    int k;
    cin>>n>>k;
    int ans=0;
    while(n)
    {
        ans++;
        n/=k;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int BinarySearch(int *,int);
int n,q;

int main(){
  int C[100000];
  int T[50000];
  int i,j,a,c=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d ",&C[i]);
  }
  scanf("%d",&q);
  for(j=0;j<q;j++){
    scanf("%d",&T[j]);
  }
     
  for(j=0;j<q;j++){
    a = BinarySearch(&C[0],T[j]);
    c+=a;
  }
 
  printf("%d\n",c);

  return 0;
}
 

int BinarySearch(int * A, int key){
  int left,right,mid; 
 
  left=0;
  right=n;

  while(left<right){
    mid=(left+right)/2;
    if(key==A[mid]) return 1;
    if(key>A[mid]) left=mid+1;
    else  right=mid;
  }
  return 0;
}
  

Measured memory_bytes: 1188
using System;
using System.Collections.Generic;
using System.IO;

class Program
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        string[] Input = Console.ReadLine().Split(' ');
        int[] h = new int[N];

        //DPテーブル
        int[] dp = new int[N];

        for (int i = 0; i < N; i++)
        {
            h[i] = int.Parse(Input[i]);
        }
        //入力完了

        dp[0] = 0;
        dp[1] = Math.Abs(h[1] - h[0]);

        for (int i = 2; i < N; i++)
        {
            if (dp[i - 2] + Math.Abs(h[i] - h[i - 2]) > dp[i - 1] + Math.Abs(h[i] - h[i - 1]) )
            {
                dp[i] = dp[i - 1] + Math.Abs(h[i] - h[i - 1]);
            }
            else
            {
                dp[i] = dp[i - 2] + Math.Abs(h[i] - h[i - 2]);
            }
        }

        Console.WriteLine(dp[N - 1]);
    }
}

Measured memory_bytes: 16864
H,W = map(int,input().split())

table = [[0]*(W+1) for i in range(H+1)]

for row in range(H):
    work = list(map(int,input().split())) #★★直にtableに代入すると、列数が変わってしまう!!!★★★
    for col in range(W):
        table[row][col] = work[col]


for row in range(H):
    for col in range(0,W):
        table[row][W] += table[row][col]


for col in range(0,W+1):
    for row in range(0,H):
        table[H][col] += table[row][col]


for row in range(0,H+1):
    print("%d"%(table[row][0]),end="")
    for col in range(1,W+1):
        print(" %d"%(table[row][col]),end = "")
    print()


Measured memory_bytes: 6208
import bisect

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
C.sort()
s = 0
for i in range(N):
    ii = bisect.bisect_left(A, B[i])
    jj = bisect.bisect_right(C, B[i])
    s += ii * (N - jj)

print(s)

Measured memory_bytes: 23360
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	x := nextInt()
	if x == 3 || x == 5 || x == 7 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

Measured memory_bytes: 640