akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N = int(input())
h = list(map(int, input().split()))
dp = [0] * N
dp[1] = abs(h[0] - h[1])

for i in range(2, N):
    cost1 = abs(h[i] - h[i - 1])
    cost2 = abs(h[i] - h[i - 2])
    dp[i] = min(dp[i - 1] + cost1, dp[i - 2] + cost2)

print(dp[-1])


Measured memory_bytes: 50324
#include <stdio.h>

int main(void){
	int n,y,i,j,comp;

	scanf("%d %d",&n,&y);

	y/=1000;

	int d[n];

	for(i=0;i<=n && i*10<=y;i++){
		for(j=0;i+j<=n && i*10+j*5<=y;j++){
			if(i*10+j*5+(n-(i+j))==y){
				printf("%d %d %d",i,j,n-(i+j));
				return 0;
			}
		}
	}
  
    printf("-1 -1 -1");

	return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#ifdef JLOCAL
#include "stress.h"
#endif
using namespace std;

#define rep(i, z, n) for (int i = (z); i < int(n); ++i)
#define repr(i, n, z) for (int i = int(n) - 1; i >= (z); --i)
#define shl(n) (1 << (n))
#define hbit(n, i) (((n) >> (i)) & 1)

#define STRESS 0
using lint = long long;

string a[55];

void solve(istream& cin, ostream& cout) {
    int n, m;
    cin >> n >> m;
    rep(i, 0, n) {
        cin >> a[i];
    }
    rep(i, 0, n) {
        rep(j, 0, m) {
            if (a[i][j] == '#') {
                cout << '#';
                continue;
            }
            int ans = 0;
            for (int x = i - 1; x <= i + 1; x++) {
                for (int y = j - 1; y <= j + 1; y++) {
                    if (x >= 0 && x < n && y >= 0 && y < m && a[x][y] == '#') {
                        ans++;
                    }
                }
            }
            cout << ans;
        }
        cout << "\n";
    }
}

int main() {
#if !defined(JLOCAL) || !STRESS
#ifdef JLOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve(cin, cout);
#else
    srand();
    for (int ti = 0; ti < 100; ti++) {
        stress::gen();
        stress::stupid();
        ifstream in("input.txt");
        ofstream out("output.txt");
        solve(in, out);
        out.flush();
        stress::check();
    }
    cout << "ok" << endl;
#endif
    return 0;
}


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

main()
{
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>a[i];
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
   for(int i=2;i<n;i++)
    dp[i]=min((dp[i-1]+abs(a[i]-a[i-1])),(dp[i-2]+abs(a[i]-a[i-2])));
   cout<<dp[n-1];
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
    int main(){
        string N;
            cin >> N;
                if(N.at(0) == N.at(1) && N.at(1) == N.at(2)){
                    cout << "Yes" << endl;
                }else if(N.at(1) == N.at(2) && N.at(2) == N.at(3)){
                    cout << "Yes" << endl;
                }else{
                    cout << "No" << endl;
                }
    return 0;}

Measured memory_bytes: 256
//ABC095B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int n, x;
	cin >> n >> x;
	vector<int> m(n);
	for(int i=0;i<n;i++){
		cin >> m.at(i);
		x -= m.at(i);
	}
	sort(m.begin(),m.end());
	int ans = n+x/m.at(0);
	cout << ans << endl;
	return 0;
}

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

int main() {
  int x;
  cin >> x;
  bool is_prime[200000];
  for (int i = 0; i < 200000; i++)
    is_prime[i] = true;
  for (int i = 2; i <= 100000; i++) {
    if (is_prime[i]) {
      for (int j = 2 * i; j < 200000; j += i) {
        is_prime[j] = false;
      }
    }
  }
  for (int i = x; i < 200000; i++) {
    if (is_prime[i]) {
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 384
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
    int H, W;
    cin >> H >> W;

    int a[H][W];
    int sum = 0;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
        cin >> a[i][j];
      }
    }

    int cnt = 0;
    int put[H*W][4];

    for(int i=0;i<H-1;i++){
    	for(int j=0;j<W;j++){
    		if(a[i][j]%2){
    			put[cnt][0] = i+1;
    			put[cnt][1] = j+1;
    			put[cnt][2] = i+2;
    			put[cnt][3] = j+1;
    			cnt++;
    			a[i+1][j]++;
    		}
    	}
    }

    for(int j=0;j<W-1;j++){
    	if(a[H-1][j]%2){
    		put[cnt][0] = H;
			put[cnt][1] = j+1;
			put[cnt][2] = H;
			put[cnt][3] = j+2;
			cnt++;
			a[H-1][j+1]++;
    	}
    }

    cout << cnt <<endl;
    for(int k=0;k<cnt;k++){
    	for(int l=0;l<3;l++) cout << put[k][l] << " ";
    	cout << put[k][3] <<endl;
    }

    
    
  	return 0;
}



Measured memory_bytes: 6784
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	void doIt() {
		int n = sc.nextInt();
		for(int i = 0; i < n; i++) {
			int a = sc.nextInt();
			if(a % 2 != 0) {
				System.out.println("first");
				return;
			}
		}
		System.out.println("second");
	}
	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 47952
#include<iostream>

int main(void)
{
  int A, B;
  std::cin >> A;
  std::cin >> B;
  int ans;
  
  if(A > 12)
    ans = B;
  else if(A > 5)
    ans = B / 2;
  else
    ans = 0;
  std::cout << ans << std::endl;
  
  return 0;
  
}

Measured memory_bytes: 256
using System;
using static System.Console;
using System.Linq;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] tmp = ReadLine().Split(' ').Select(int.Parse).ToArray();
            WriteLine(tmp[0] <= tmp[2] && tmp[0] + tmp[1] >= tmp[2] ? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>

using namespace std;

int main(){
  int t, a=0, b=0;
  for(int i=0;i<4;i++){ cin >> t; a += t; }
  for(int i=0;i<4;i++){ cin >> t; b += t; }
  cout << max(a, b) << endl;
}

Measured memory_bytes: 0
//#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);
  V<int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int x;cin>>x;x--;
  cout<<a[x]<<ENDL;

}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 384
N = gets.chomp.to_i
a = Array.new(N)
str = gets.split
for i in 0...N do
    a[i] = str[i].to_i
end

if N % 3 == 0
    a.sort!
    for i in 1...N/3 do
        if a[i] != a[i-1] || a[i+N/3] != a[i+N/3] || a[i+2*N/3] != a[i+2*N/3]
            puts "No"
            exit
        end
    end
    if a[0] ^ a[N/3] == a[2*N/3]
        puts "Yes"
    else
        puts "No"
    end
else
    for i in 0...N do
        if a[i] != 0
            puts "No"
            exit
        end
    end
    puts "Yes"
end

Measured memory_bytes: 9212
#include <bits/stdc++.h>
#define ll long long

using namespace std;

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

    ll N, W;
    cin >> N >> W;
    vector<ll> dp(W+1, 0);
    // dp[i] = maximum value with weight exactly i
    dp[0]=0;
    for(ll i=0; i<N; i++){
        ll w, v;
        cin >> w >> v;
        for(ll j=W; j>=0; j--){
            if(j>=w)
                dp[j]=max(dp[j], v+dp[j-w]);
        }
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;
	return 0;
}


Measured memory_bytes: 3980
N, *L = map(int, open(0).read().split())
memo = [set() for i in range(N)]
ans = sum(L)
def dfs(i, mi, ma):
    global ans
    if i == N:
        ans = min(ans, ma - mi)
        return
    key = (mi, ma)
    if ma - mi >= ans or key in memo[i]:
        return
    memo[i].add(key)
    s = 0
    for j in range(i, N-(i==0)):
        s += L[j]
        dfs(j+1, min(mi, s), max(ma, s))
dfs(0, 10**18, -10**18)
print(ans)



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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    string a, b;
    ll d;
    cin >> a >> b;
    d = stoi(a + b);
    for(ll i = 1;i <= 320;i++) {
        if(i * i == d) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int main()
{
	int mx, my;
	cin >> mx >> my;
	for (int i = 0; i < mx; i++)
	{
		string s;
		cin >> s;
		cout << s << endl << s << endl;
	}
}

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

#define INF INT32_MAX

int main()
{
	int N;
	cin >> N;
	vector<int> B( N - 1 );
	for( int i = 0; i < N - 1; i++ ) {
		cin >> B[i];
	}

	vector<int> A( N, INF );
	for( int i = N - 2; i >= 0; i-- ) {
		A[i + 1] = min( B[i], A[i + 1] );
		A[i] = min( B[i], A[i] );
	}
	long long ans = 0;
	for( int i = 0; i < N; i++ ) {
		ans += A[i];
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 10;

ll s[MAXN];

int main() {
	ios::sync_with_stdio(false);
	ll n, k, q, a;
	while(cin >> n >> k >> q) {
		memset(s, 0, sizeof(s));
		for(int i = 1; i <= q; i++) {
			cin >> a;
			s[a]++;
		}
		for(int i = 1; i <= n; i++) {
			if(s[i] > q - k) {
				cout << "Yes\n";
			} else {
				cout << "No\n";
			}
		}
	}
	return 0;
}

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

int main(){
    int h,w,k;
    cin >> h >> w >> k;
    vector<string> s(h);
    int ans = mod;
    for(int i = 0; i < h; i++) cin >> s[i];
    for(int bit = 0; bit < (1<<(h-1)); bit++){
        vector<int> hdiv;
        hdiv.clear();
        for(int i = 0; i < h-1; i++){
            if(bit & (1<<i)) hdiv.push_back(i);
        }
        map<int,int> box;
        map<int,bool> flag;
        flag.clear();
        bool end = false;
        int can = 0;
        for(int i = 0; i < w; i++){
            for(int j = 0; j < h; j++){
                if(s[j][i] == '1'){
                    auto itr = lower_bound(hdiv.begin(),hdiv.end(),j);
                    if(itr == hdiv.end()){
                        box[h-1]++;
                        if(box[h-1] > k){
                            if(flag[i]){
                                end = true;
                            } else {
                                can++;
                                flag[i] = true;
                                box.clear();
                                i--;
                            }
                            break;
                        }
                    } else {
                        box[*itr]++;
                        if(box[*itr] > k){
                            if(flag[i]){
                                end = true;
                            } else {
                                flag[i] = true;
                                can++;
                                box.clear();
                                i--;
                            }
                            break;
                        }
                    }
                }
            }
            if(end) break;
        }
        if(end) continue;
        //cout << can << endl;
        can += hdiv.size();
        if(ans > can) ans = can;
    } 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3660
#include<cstdio>
#include<map>
#include<queue>
#include<cstring>
using namespace std;
#define re register
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int n,a1,b1,a2,b2,head[1000002],cnt,m,k,mxh,mxw,ans;
map<int,int>h,w,pos[300002];
vector<int>H,W;
int main(){
	n=read(),m=read(),k=read();
	for(re int i=1,x,y;i<=k;++i){
		x=read(),y=read();
		++h[x],++w[y],++pos[x][y];
	}
	for(re int i=1;i<=n;++i)if(h[i]>mxh)mxh=h[i];
	for(re int i=1;i<=m;++i)if(w[i]>mxw)mxw=w[i];
	for(re int i=1;i<=n;++i)if(h[i]==mxh)H.push_back(i);
	for(re int i=1;i<=m;++i)if(w[i]==mxw)W.push_back(i);
	ans=mxh+mxw-1;
	for(re int i=0;i<H.size();++i){
		for(re int j=0;j<W.size();++j){
			if(!pos[H[i]][W[j]]){
				printf("%d",ans+1);
				return 0;
			}
		}
	}
	printf("%d",ans);
}

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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define CIN(v) cin >> v;
#define COUT(v) cout << v << "\n";

ll R, S, P;

ll j(char c) {
  switch (c) {
  case 'r':
    return P;
  case 's':
    return R;
  case 'p':
    return S;
  default:
    return 0;
  }
}

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

  ll N, K;
  string T;

  CIN(N >> K);
  CIN(R >> S >> P);
  CIN(T);

  ll count = 0;
  ll before = 0;
  bool existsBefore = false;
  bool sameBefore = false;

  for (ll i = 0; i < N; i++) {
    before = i - K;
    existsBefore = 0 <= before;
    sameBefore = existsBefore ? T[i] == T[before] : false;

    if (sameBefore) {
      // COUT(T[i] << " loose");
      T[i] = '-';
    } else {
      // 前なかったら問答無用で加算
      // COUT(T[i] << " win");
      count += j(T[i]);
    }
  }

  COUT(count);

  return 0;
}


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

int main() {
int n,q;
int count = 0;
cin >> n;
vector<int> S(n+1);
for (int i = 0; i < n; i++) {
  cin >> S.at(i);
}

cin >> q;
vector<int> T(q);
for (int i = 0; i < q; i++) {
  cin >> T.at(i);
}
for(int j = 0; j < T.size();j++){
  int k = 0;
  S.at(n) = T.at(j);
  while(T.at(j) != S.at(k)){
  k++;
  }
  if(k != n){
    count++;
  }
}
cout << count << endl;
}




Measured memory_bytes: 3112
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD = 1000000007;
#define INF (1e9)
#define print(x) cout << x << endl;

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; }
typedef pair <ll,ll> P;


int main()
{
    ll A, B, C;
    cin >> A >> B >> C;
    if (A+B >= C) {
        print("Yes");
    } else {print("No")}
    return 0;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n, kk = na()
ps = [na() for _ in range(n)]

ans = 99999999999999999999999
for i in range(n):
    for j in range(n):
        for k in range(n):
            for l in range(n):
                if ps[i][0] <= ps[k][0] and ps[j][1] <= ps[l][1] and (ps[k][0]-ps[i][0])*(ps[l][1]-ps[j][1]) < ans:
                    hit = len([_ for _ in ps if ps[i][0] <= _[0] <= ps[k][0] and ps[j][1] <= _[1] <= ps[l][1]])
                    if hit >= kk:
                        ans = (ps[k][0]-ps[i][0])*(ps[l][1]-ps[j][1])
print(ans)

Measured memory_bytes: 59356
def keta(n):
    return len(str(n))

def F(a, b):
    return max(keta(a), keta(b))

N = input()

i = 1
ans = float('inf')
while i * i <= N:
    if N % i == 0:
        ans = min(ans, F(i, N/i))
    i += 1
print ans


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

int main() {
    int N;
    cin >> N;
    int res = 0;

    for(int i = 0; i <= N; i += 4) {
        for(int j = 0; j + i <= N; j += 7 ) {
            if(i + j == N) {
                res = 1;
            }
        }
    }
    if(res) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

double sum(ll n){
    return (n+1)/(double) 2;
}

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

    ll n, k;
    cin >> n >> k;
    vector <ll> arr(n);
    for(ll i = 0; i < n; i++){
        cin >> arr[i];
    }
    ll start = 0, end = start+k-1;
    ll maxsum = INT_MIN, curr_sum = 0, maxstart = 0;
    for(ll i = 0; i < k; i++){
        curr_sum += arr[i];
    }
    while(true){
        if(curr_sum > maxsum){
            maxsum = curr_sum;
            maxstart = start;
        }
        if(end == n-1) break;
        curr_sum -= arr[start];
        curr_sum += arr[end+1];
        end++;
        start++;
    }
    double ret = 0;
    for(ll i = maxstart; i < maxstart+k; i++){
        ret += sum(arr[i]);
    }
    cout << fixed << setprecision(6) << ret << endl;

}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
    int n, m, i, j, po, a, ans = 0;
    scanf("%d %d", &n, &m);
    int aa[m];
    for(i=0; i<m; i++) aa[i] = 0;
    for(i=0; i<n; i++){
        scanf("%d", &po);
        for(j=0; j<po; j++){
            scanf("%d", &a);
            aa[a-1]++;
        }
    }
    for(i=0; i<m; i++) if(aa[i] == n) ans++;
    printf("%d", ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#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++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define llp 1000000007
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;


int32_t main(){
	ios::sync_with_stdio(false);
    int h,w,n;
    cin>>h>>w>>n;
    int sr, sc;
    cin>>sr>>sc;
    string s,t;
    cin>>s;
    cin>>t;
    //up
    int R=sr,C=sc;
    int f=0;
    for(int i=0;i<n;i++){
        if(s[i]=='U'){
            R--;
        }
        if(R<=0){
            f=1;
            break;
        }
        if(t[i]=='D' && R!=h){
            R++;
        }
        
    }
    if(f==1){
        // deb("up");
        cout<<"NO\n";
        return 0;
    }

    //down
     R=sr,C=sc;
    for(int i=0;i<n;i++){
        if(s[i]=='D'){
            R++;
        }
        if(R>h){
            f=1;
            break;
        }
        if(t[i]=='U' && R!=1){
            R--;
        }
        
    }
    if(f==1){
        // deb("down");
        cout<<"NO\n";
        return 0;
    }

    //left
    R=sr,C=sc;
    for(int i=0;i<n;i++){
        if(s[i]=='L'){
            C--;
        }
        if(C<=0){
            f=1;
            break;
        }
        if(t[i]=='R' && C!=w){
            C++;
        }
        
    }
    if(f==1){
        // deb("left");
        cout<<"NO\n";
        return 0;
    }

    //right

    R=sr,C=sc;
    for(int i=0;i<n;i++){
        if(s[i]=='R'){
            C++;
        }
        if(C>w){
            f=1;
            break;
        }
        if(t[i]=='L' && C!=1){
            C--;
        }
        
    }
    if(f==1){
        // deb("right");
        cout<<"NO\n";
        return 0;
    }
    cout<<"YES\n";




	return 0;
}

Measured memory_bytes: 920
N = int(input())
A_i = list(map(int,input().split()))

flag = 0
even = list()

for i in range(N):
    if (A_i[i] % 2 == 0):
        even.append(A_i[i])

for i in even:
    if (i % 3 == 0 or i % 5 == 0):
        flag += 1

if(flag == len(even)):
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3064
#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;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__


const int MOD = 1000000007;

ll modpow(ll a, ll n) {
    ll x = a;
    ll ans = 1;
    while (n > 0) {
        if (n & 1) {
            ans *= x;
            ans %= MOD;
        }

        n = n>>1;
        x *= x;
        x %= MOD;
    }
    return ans;
}

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

    vl A(N);
    rep(i, N) {
        cin >> A[i];
    }

    map<int, int> G;
    rep(i, N) {
        G[A[i]]++;
    }

    ll ans;
    // Nが奇数 => Aiは "N以下の偶数が2つづつ"と0 以外は矛盾
    // 並び順は0以外の各iにつき2通りパターン。片方を固定したら、もう片方が決まるので、2^((N-1)/2)
    if (N % 2 == 1) {
        for (auto x : G) {
            if (x.first == 0) {
                if (x.second != 1) {
                    cout << 0 << endl;
                    return 0;
                }
            } else {
                if (x.second != 2) {
                    cout << 0 << endl;
                    return 0;
                }
            }
        }

        ans = modpow(2, (N - 1) / 2);
    }
    // Nが偶数 => Aiは "N以下の奇数が2つづつ" 以外は矛盾
    // 並び順は各iにつき2通りパターンある。片方を固定したら、もう片方が決まるので、2^(N/2)
    else {
        for (auto x : G) {
            if (x.second != 2) {
                cout << 0 << endl;
                return 0;
            }
        }
        ans = modpow(2, N / 2);
    }

    cout << ans << endl;
}

Measured memory_bytes: 6876
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
print(n*800 - 200*(n//15))

Measured memory_bytes: 10504
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>
#include <set>

const int INT_INF = 1e9;
const long long LONG_INF = 1e18;
const long long MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> s(m + 1, vector<int>(n + 1, 0));
    vector<int> p(m);
    for (int i = 0; i < m; i++)
    {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++)
        {
            cin >> s[i][j];
        }
    }
    for (int i = 0; i < m; i++)
    {
        cin >> p[i];
    }

    int ans = 0;

    bool f = true;
    for (int i = 0; i < 1 << n; i++)
    {
        f = true;
        for (int j = 0; j < m; j++)
        {
            int k = 0;
            int count = 0;

            while (s[j][k] != 0)
            {
                if ((1 & i >> (s[j][k] - 1)) == 1)
                {
                    count++;
                }
                k++;
            }
            if (count % 2 != p[j])
            {
                f = false;
                break;
            }
        }
        if (f)
        {
            ans++;
        }
    }

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

Measured memory_bytes: 256
module Main where

import Control.Applicative
import Control.Monad
import Data.List (sort)

solve :: [Int] -> Int
solve as = iter 0 as
  where
    iter n xs
        | all (== head xs) xs = n
        | length ev == 1      = iter (n + 1) (ev ++ fmap (+ 1) od)
        | length ev == 2      = iter (n + 1) (fmap (+ 1) ev ++ od)
        | otherwise           = iter (n + 1) ((y + 2) : ys)
      where
        (ev, od) = (filter even xs, filter odd xs)
        (y:ys)   = sort xs

main :: IO ()
main = do
    xs <- fmap read . words <$> getLine :: IO [Int]
    print $ solve xs

Measured memory_bytes: 508
#include"bits/stdc++.h"
#include"math.h"
using namespace std;

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
 

using ll = long long int;
using ld = long double;
using pii = pair<int,int>;

#define REP(i,m,n) for(ll i = m; i < (ll)(n);++i)
#define rep(i,n) REP(i,0,n)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
 
using vi=vc<int>;

const ll mod=1e9+7;
const ll INF = 1e18;

int main(){
  ll n;cin >> n;
  ll a[100500],b[100500],c[100500];
  rep(i,n) cin >> a[i] >> b[i] >> c[i];
  ll dp[100050][3];
  rep(i,n){
    dp[i+1][0]=max(dp[i][1]+a[i],dp[i][2]+a[i]);
    dp[i+1][1]=max(dp[i][0]+b[i],dp[i][2]+b[i]);
    dp[i+1][2]=max(dp[i][0]+c[i],dp[i][1]+c[i]);
  }
  ll x=max(dp[n][0],max(dp[n][1],dp[n][2]));
  cout << x << endl;
}
  

Measured memory_bytes: 4992
#include<stdio.h>
int main()
{
    int s,a,b,c;
    scanf("%d", &s);
    if(s>=0&&s<=86400)
    {
    a=s/3600;
    b=(s%3600)/60;
    c=((s%3600)%60);
    printf("%d:%d:%d\n",a,b,c);
    }
    return 0;
}



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

#define ARC(i, a, b) for(int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)

template<class T> T rng(const T &a, const T &b){ return a > b ? a - b : b - a; }
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T &anth(T &a, const T &b){ return a = ant(a, b); }
template<class T> T &onth(T &a, const T &b){ return a = ont(a, b); }

int zero, one;

int main(){
	for(;;) switch(getchar()){
		case '0':
			++zero;
			break;
		case '1':
			++one;
			break;
		case '\n':
			printf("%d", zero + one - rng(zero, one));
			return 0;
	}
}


Measured memory_bytes: 256
import sys
import math


def main():
    args = sys.stdin.readline().split()
    N = int(args[0])

    X = 0
    while True:
        X += 1
        temp = math.pow(2, X)
        if temp > N:
            temp = math.pow(2, X-1)
            break

    print(int(temp))

main()

Measured memory_bytes: 2940
//#define _GLIBCXX_DEBUG
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

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



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

  ll N; cin>>N;
  ll ans=0;
  for(int A=1;A<N;A++){
    ans+=(N-1)/A;
  }
  cout<<ans<<'\n';
  return 0;
}


Measured memory_bytes: 3656
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int a, b;
    cin >> a >> b;
    cout << max(0, a - 2 * b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<ll, ll> mll;
typedef map<string, ll> mstrll;
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define indent() cout << '\n'
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}
ll factorial(ll a){return a < 2 ? 1 : factorial(a - 1) * a;}
ll summation(ll a){return a < 1 ? 0 : (a * a + a) / 2;}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ll N = 200005;
const ll M = 100005;
const string ALPHABETS = "abcdefghijklmnopqrstuvwxyz";
ll dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
//ll dx[] = {-1, 0, 1, -1, 1, -1, 0, 1}, dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};
ll n, m, x, y, z, w, h;
string s, t;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n){
        ll ans = 0, tmp = 0, cnt = 0, mx = -INF, mn = INF;
        ll a[N] = {}, b[N] = {}, c[N] = {};
        vll v;
        v.pb(0);
        rep(i, n){
            cin >> x;
            v.pb(v[v.size()- 1] + x);
        }
        sort(all(v));
        v.pb(-1);
        rep(i, v.size() - 1){
            if(v[i] == v[i + 1]){
                cnt++;
            }else{
                ans += summation(cnt);
                cnt = 0;
            }
        }
        print(ans);
    }
}


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

int main() {
    string s; cin >> s;
    long long k; cin >> k;
    long long n = s.length();
    char ans = '1';
    for(int i = 0; i < min(n,k); i ++) {
        if(s[i]!=ans) {
            ans = s[i];
            break;
        }
    }
    cout << ans << endl;
}

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

int main() {
  int N, a, b, c, d;
  cin >> N;
  
  a = N % 10;
  b = (N - a) % 100 / 10;
  c = (N - a - b * 10) % 1000 / 100;
  d = (N - a - b * 10 - c * 100) % 10000 /1000;
  
  if (b == c && c == d || a == b && b ==c){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
  

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)
input=sys.stdin.readline
def intinput():return map(int,input().split())


n=int(input())
a=list(intinput())
b=list(intinput())
ans=0
for i in range(n):
    if a[i]+a[i+1]<b[i]:
        ans+=a[i]+a[i+1]
        a[i+1]=0
    else:
        ans+=b[i]
        a[i+1]-=0 if a[i]-b[i]>0 else b[i]-a[i]
print(ans)

Measured memory_bytes: 19376
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	if s[0] != 'A' {
		fmt.Println("WA")
		return
	}

	var hasC bool
	for i, c := range s {
		if i > 1 && i <= len(s)-2 && c == 'C' {
			hasC = true
		}
	}
	if !hasC {
		fmt.Println("WA")
		return
	}

	var cnt int
	for _, c := range s {
		if 'A' <= c && c <= 'Z' {
			cnt++
		}
	}

	if cnt > 2 {
		fmt.Println("WA")
		return
	}

	fmt.Println("AC")
}


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const lb PI=3.14159265359;

int main(){

  ll n;cin>>n;
  string s;cin>>s;

  ll ans=0;
  rep(i,0,1000){
    ll c[3]={i/100,(i/10)%10,i%10};
    ll k=0;
    rep(j,0,n){
      if(s[j]==(c[k]+'0'))k++;
      if(k==3)break;
    }
    if(k==3)ans++;
  }
  out(ans);

  return 0;
}


Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try {
			String line = reader.readLine();
			int n = Integer.parseInt(line);
			String ans = "No";

			outer:
				for(int i = 1; i < 10; i++){
					for(int j = 1; j < 10; j++){
						if(n == i*j){
							ans = "Yes";
							break outer;
						}
					}
				}
			System.out.println(ans);
		} catch (IOException e) {
			System.out.println(e);
		} catch (NumberFormatException e) {
			System.out.println(e);	
		}
	}
}

Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	int n,i; cin>>n>>i;
	cout<<(n-i+1);
	return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9 + 10;
const ll MOD = 998244353;

const int MAXV = 1e6 + 5;

ll v[MAXV];
ll sum[MAXV];
vi divs[MAXV];

ll cur_sum[MAXV];

void solve(){
	REP(i, 1, MAXV) {
		for(int j = i; j < MAXV; j += i) {
			divs[j].pb(i);
		}
	}
	int n;
	scanf("%d", &n);
	REPN(i, 1, n) {
		scanf("%lld", &v[i]);
	}
	ll ans = 0ll;
	REPN(i, 1, n) {
		ll val = v[i];
		
		cur_sum[val] = sum[val];
		for(int j = SZ(divs[val]) - 2; j >= 0; j--) {
			cur_sum[divs[val][j]] = -cur_sum[val];
		}
		for(int j = SZ(divs[val]) - 2; j >= 0; j--) {
			int d = divs[val][j];
			cur_sum[d] += sum[d];
			REP(k, 0, SZ(divs[d]) - 1) {
				cur_sum[divs[d][k]] -= cur_sum[d];
			}
		}
		
		REP(j, 0, SZ(divs[val])) {
			int d = divs[val][j];
			ll add = cur_sum[d] / d * v[i];
			ans = (ans + add) % MOD;
			sum[divs[val][j]] += val;
			
			//printf("%d: %lld %d %lld %lld\n", i, val, d, cur_sum[d], add);
		}
	}
	cout << ans << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 132224
<?php

fscanf(STDIN, "%d %d", $A, $B);

$flag = false;
for ($i = 1; $i <= 1000; $i++) {
    if ((intval($i * 0.08) === $A) && (intval($i * 0.1) === $B)) {
        echo $i;
        $flag = true;
        break;
    }
}

if (!$flag) {
    echo -1;
}

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=100000000000000000;

int main() {
    int h,w;
    cin >> h >> w;
    vector<vector<int>> a(w,vector<int>(h));
    int k;
    cin >> k;
    rep(i,h){
        rep(j,w){
            char s;
            cin >> s;
            if (s=='.') a[j][i]=0;
            else a[j][i]=1;
        }
    }
    vector<vector<int>> b(w,vector<int>(h+1,1));
    int u=1;
    bool tt=true,ttt=false;
    for (int i=1;i<=h;i++){
        bool t=true;
        int c=u;
        rep(j,w){
            if (a[j][i-1]==1){
                u++;
                t=false;
                if (tt) {ttt=true;tt=false;}
            }
            b[j][i]=max(c,u-1);
        }
        if (ttt){
            ttt=false;
            rep(k,i){
                rep(j,w) b[j][k]=b[j][i];
            }
        }
        if (t){
            rep(j,w){
                b[j][i]=b[j][i-1];
            }
        }
    }
    for (int i=1;i<h+1;i++){
        rep(j,w) cout << b[j][i] << " ";
        cout << endl;
    }
}


Measured memory_bytes: 1536
"use strict";
    
const main = arg => {
    const N  = parseInt(arg.split("\n")[0]);
    const lr = arg.split("\n").slice(1, N + 1);
    let answer = 0;
    
    for(let i=0; i<N; i++) {
        answer += parseInt(lr[i].split(" ")[1]) - parseInt(lr[i].split(" ")[0]) + 1;
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

typedef vector<vector<int>> graph;

vector<int> bfs(int s, const graph &G) {
	constexpr int INF = (1 << 30);
	const int n = G.size();

	vector<int> dist(n, INF);
	queue<int> que;
	dist[s] = 0;
	que.push(s);

	while(!que.empty()) {
		const int v = que.front();
		que.pop();

		for(const auto &to : G[v]) {
			if(dist[to] > dist[v] + 1) {
				dist[to] = dist[v] + 1;
				que.push(to);
			}
		}
	}
	return dist;
}

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

	int n, m, s, t;
	cin >> n >> m >> s >> t;
	--s; --t;

	graph G(n);
	for(int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		G[a].emplace_back(b);
		G[b].emplace_back(a);
	}

	const auto dist_from_s = bfs(s, G);
	const auto dist_from_t = bfs(t, G);
	const auto dist_st = dist_from_s[t];

	unordered_map<int, int> cnt;
	for(const auto &d : dist_from_t) {
		++cnt[d];
	}

	long long ans = 0;
	for(const auto &e : dist_from_s) {
		ans += cnt[dist_st - e - 2];
	}
	cout << ans << endl;

	return EXIT_SUCCESS;
}

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

using namespace std;

int main() {
  int n,m,t,a; cin >> n >> m >> t;
  vector<int> can(t+1);
  for(int i=0;i<n;++i) {
    cin >> a;
    can[a-m]++;
    can[a+m<t?a+m:t]--;
  }
  int ans=0;
  for(int i=1;i<t+1;++i) can[i]+=can[i-1];
  for(int i=0;i<t;++i)
    if(!can[i]) ans++;
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3140
#include<iostream>

using namespace std;

int main(void)
{
    int N;

    cin>>N;

    if((N / 10) == 9)
    {
        cout << "Yes" << endl;
    }
    else if(N-((N/10) * 10) == 9)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
from sys import stdin, setrecursionlimit
input = stdin.buffer.readline
setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

MOD = 10 ** 9 + 7
INF = 10 ** 18

#N = int(input())
N, M = map(int, input().split())
#A = list(map(int, input().split()))
#A = [int(input()) for _ in range(N)]
#ABC = [list(map(int, input().split())) for _ in range(N)]

print(N * M)

Measured memory_bytes: 65124
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<50
#define fst first
#define snd second
#define pb push_back
#define int long long
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(int itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(int itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define debug(x)  cout << #x << " = " << (x) << endl;
typedef long long ll;
typedef pair<ll,ll> P;

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

  int n;
  cin >> n;

  if(n == 3){
    cout << "2 5 63" << endl;
    return 0;
  }
  
  if(n == 4){
    cout << "2 5 20 63" << endl;
    return 0;
  }
  
  if(n == 5){
    cout << "2 3 4 6 9" << endl;
    return 0;
  }
  
  int cnt = 0;
 // debug(check);
  while(n >= 6 && cnt != 2500){
      REP(i,12){
        if(((i+1)%2 == 0 || (i+1)%3== 0) && (i+1)%6 != 0) cout << (i+1)+cnt*12 << " ";
      }
      n -= 6;
      cnt++;
  }
  
  cnt = 1;
  while(n != 0){
    cout << cnt*6 << " ";
    n--;
    cnt++;
  }
  
  return 0;
}

Measured memory_bytes: 384
import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        String a=sc.next();
        String b=sc.next();
        System.out.println((a.length()<b.length())?"LESS":(a.length()>b.length())?"GREATER":    (a.compareTo(b)<0)?"LESS":(a.compareTo(b)==0)?"EQUAL":"GREATER");
    }
}

Measured memory_bytes: 23636
n = gets.to_i
l = gets.split.map(&:to_i)

cmb = l.combination(3).map(&:uniq).select{|i|i.count == 3}
count = 0
cmb.each do |i|
    if (i[0] + i[1] > i[2]) && (i[0] + i[2] > i[1]) && (i[1] + i[2] > i[0])
        count += 1
    end
end
puts count

Measured memory_bytes: 30216
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,ans;
signed main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(true){
		c-=b;
		if(c<=0){
			cout<<"Yes"<<endl;
			return 0;
		}
		a-=d;
		if(a<=0){
			cout<<"No"<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3616
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

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

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

    long long dp[n];

    dp[0] = 0;
    dp[1] = abs(height[1] - height[0]);

    for (int i = 2; i < n; i++) dp[i] = min(dp[i - 1] + abs(height[i] - height[i - 1]), dp[i - 2] + abs(height[i] - height[i - 2]));

    cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int h, n;
vector< int > a, b, dp;
int f(int x){
    if(x <= 0) return 0;
    if(dp[x] != -1) return dp[x];
    int res = 1e9;
    for(int i=0;i<n;i++){
        int t = f(x-a[i]) + b[i];
        if(t < res) res = t;
    }
    return dp[x] = res;
}

int main(void){
    cin >> h >> n;
    a.assign(n, 0);
    b.assign(n, 0);
    for(int i=0;i<n;i++) cin >> a[i] >> b[i];
    dp.assign(h+1, -1);
    int ans = f(h);
    cout << ans << endl;
}


Measured memory_bytes: 768
function Main(input) {
    input = input.split("\n");
    var arr = input[1].split(" ");
    var flag = false;
    arr.forEach(function(val){
        if(val == "Y") flag = true;
    });
    console.log(flag?"Four":"Three");
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 21192
if __name__ == "__main__":
  n,k = map(int, input().split())
  ll = []
  for i in range(k):
    d = int(input())
    ll.append(list(map(int, input().split())))

  ans = set()
  for item in ll:
    ans = ans | set(item)

  count = 0
  for i in range(1, n+1):
    if i not in ans:
      count += 1
  print(count)


Measured memory_bytes: 9196
n, m, x = map(int, input().split())
a = list(map(int, input().split()))

point = []
for i in range(n):
    if i + 1 in a:
        point.append(1)
    else:
        point.append(0)
res1 = sum(point[: x ])
res2 = sum(point[x:])
res = min(res1, res2)
print(res)



Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cmath>
#define eps 1e-6
using namespace std;

int main(){
	string s,t;
	cin>>s>>t;
	s+=t;
	int num=0;
	for(int i=s.size()-1;i>=0;i--){
		num+=(int)(s[i]-'0')*pow(10,s.size()-1-i);
	}
	double a=sqrt(num);
	int b=(int)a;
	cout<<(abs(a-b)<eps?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<limits.h>
int main(){
   int i;
   int a[10000]={0};
   int max=INT_MIN;
   int min=INT_MAX;
   long int sum=0;

   scanf("%d", &i);

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

   for(int j=0; j<i; j++){
      if(max<=a[j]){
      max =a[j];
      }
      if(min>=a[j]){
         min = a[j];
      }
      sum = sum + a[j];
   }

   printf("%d %d %ld\n", min, max, sum);
   return 0;

}


Measured memory_bytes: 2140