akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_map>
#include<unordered_set>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;
#define mul(a,b) a=a*b%mod;
#define N 100010
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
ll n,m;
vector<P> g[N];
class dijkstra{
    public:
    ll d[N],w[N];
    void init(ll s){
        w[0]=1;
        for(int i=1;i<=n;i++){
            d[i]=1e17,w[i]=0;
        }
        priority_queue<PP,vector<PP>,greater<PP> > Q;
        Q.push(make_pair(0,make_pair(s,0)));
        while(!Q.empty()){
            ll x=Q.top().second.first,p=Q.top().second.second;
            ll cost=Q.top().first;
            Q.pop();
            if(d[x]<cost)continue;
            if(d[x]==cost){
                mad(w[x],w[p]);
                continue;
            }
            d[x]=cost,w[x]=w[p];
            for(auto y:g[x]){
                Q.push(make_pair(cost+y.second,make_pair(y.first,x)));
            }
        }
    }
};
ll s,t;
int main(){
  cin>>n>>m>>s>>t;
  for(int i=0;i<m;i++){
      ll a,b,c; cin>>a>>b>>c;
      g[a].push_back(make_pair(b,c));
      g[b].push_back(make_pair(a,c));
  }
  dijkstra S,T;
  S.init(s);
  T.init(t);
  ll ans=S.w[t]*S.w[t]%mod;
  for(int i=1;i<=n;i++){
      if(S.d[i]==T.d[i]&&S.d[i]+T.d[i]==S.d[t]){
          ll xy=S.w[i]*T.w[i]%mod;
          mad(ans,-xy*xy);
      }
      for(auto e:g[i]){
          int j=e.first,len=e.second;
          if(S.d[i]*2<S.d[t]&&T.d[j]*2<S.d[t]&&S.d[i]+len+T.d[j]==S.d[t]){
              ll xy=S.w[i]*T.w[j]%mod;
              mad(ans,-xy*xy);
          }
      }
  }
  if(ans<0)ans+=mod;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 26992
from sys import stdin
from collections import defaultdict
import sys
sys.setrecursionlimit(10**6)
N = int(stdin.readline().rstrip())
adj = defaultdict(set)

for i in range(N-1):
    a,b,c = [int(x) for x in stdin.readline().rstrip().split()]
    adj[a].add((b,c))
    adj[b].add((a,c))
    
Q,K = [int(x) for x in stdin.readline().rstrip().split()]

visited = [False]*(N+1)
dist = [0]*(N+1)

def dfs(i,j):
    if visited[i]:
        return
    dist[i] = j
    visited[i] = True
    
    for node,d in adj[i]:
        dfs(node,d+j)
        
dfs(K,0)

for i in range(Q):
    x,y = [int(x) for x in stdin.readline().rstrip().split()]
    print(dist[x]+dist[y])

Measured memory_bytes: 150932
#include <iostream>

using namespace std;
int n,day,x;

int main()
{
    while(scanf("%d%d%d",&n,&day,&x)!=EOF)
    {
        int sum=0;
        for(int i=1; i<=n; i++)
        {
            int u;
            scanf("%d",&u);
            int s=1;
            while(s<=day)
            {
                sum++;
                s+=u;
            }
        }
        printf("%d\n",sum+x);
    }
    return 0;
}


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

#define ll long long
#define mod 1000000007
#define mod2 998244353
#define pii pair<ll,ll>
#define pb push_back

#define debug(a) { cout << #a << " = " << a << endl;}

void sep() {
    cout << "-------------BLOCK-----------------\n";
}

template<typename T>
void debugv(vector<T> arr) {
    for (auto t: arr)
        cout << t << " ";
    cout << "\n";
}

template<typename T>
void debugarr(T arr, int n) {
    for (int i=0;i<n;i++) cout << arr[i] << " ";
    cout << "\n";
}

ll __min(ll a, ll b) {
    return a < b ? a : b;
}

ll __max(ll a, ll b) {
    return a > b ? a : b;
}

const int maxn = 1e5+1;
ll arr[maxn], n, m, t, k, q;
unordered_map<ll,ll> u;

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

    ll a,b,x;
    cin>>x>>a>>b;
    ll d1 = abs(x-a);
    ll d2 = abs(x-b);
    if (d1<d2) cout << "A\n";
    else cout << "B\n";
}


Measured memory_bytes: 3600
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int c = scanner.nextInt();

    int _a = 0;
    int _b = 0;
    int _c = 0;

    if (a < b) {
      if (b < c) {
        _a = a; _b = b; _c = c;
      } else {
        if (a < c) {
          _a = a; _b = c; _c = b;
        } else {
          _a = c; _b = a; _c = b;
        }
      }
    } else {
      if (a < c) {
        _a = b; _b = a; _c = c;
      } else {
        if (b < c) {
          _a = b; _b = c; _c = a;
        } else {
          _a = c; _b = b; _c = a;
        }
      }
    }

    System.out.println(_a + " " + _b + " " + _c);
  }
}

Measured memory_bytes: 17352
list1 = input()

yy = int(list1[:4])
mm = int(list1[5:7])
dd = int(list1[8:])

if yy >= 2019:
    if yy == 2019 and mm <= 4:
        print("Heisei")
        exit()
    print("TBD")
    exit()
print("Heisei")

Measured memory_bytes: 38384
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		
		boolean a = result(S,T);
		boolean b = result(T,S);
		
		if(a && b) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		sc.close();
	}

	private static boolean result(String S, String T) {
		int n = S.length();

		Map<Character, Character> map = new HashMap<Character, Character>();

		for (int i = 0; i < n; i++) {
			char p = S.charAt(i);
			char q = T.charAt(i);

			if (map.get(p) == null) {
				map.put(p, q);
			} else if (map.get(p) != q) {
				return false;
			}
		}
		return true;
	}
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll p,q,r;cin>>p>>q>>r;
  cout<<p+q+r-max({p,q,r})<<endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [str(input()) for i in range(n)]
cnt = 0
for i in s:
    if i == "A":
        cnt += 1
    else:
        cnt -= 1
    if cnt < 0:
        print("NO")
        exit()
if cnt != 0:
    print("NO")
else:
    print("YES")


Measured memory_bytes: 5604
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (!(b % a)) {
      cout << a + b << '\n';
    } else {
      cout << b - a  << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int N; string A, B, C; cin >> N >> A >> B >> C;

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    set<char> a = {A[i], B[i], C[i]};
    ans += a.size()-1;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int cmp(const int* a, const int* b) {
    return *a - *b;
}
int main(void) {
    int a[300];
    int n, s = 0;
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
        scanf("%d%d", &a[i], &a[i + n]);
    qsort(a, 2 * n, sizeof(int), cmp);
    for(int i = 0; i < 2 * n; i += 2)
        s += a[i];
    printf("%d", s);
    return 0;
}


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

false_flag = 0
'''
if N % 2 == 0:
    count_ = 1
else:
    if A.count(0) != 1:
        false_flag = 1
    count_ = 2
while count_ < N and false_flag == 0:
    if A.count(count_) != 2:
        false_flag = 1
    count_ += 2
'''

count_list = [0 for i in range(N)]
for index in A:
    count_list[index] += 1

if N % 2 == 0:
    count_ = 1
    diff = -1
else:
    if count_list[0] != 1:
        false_flag = 1
    count_ = 2
    diff = -1
while count_ < N and false_flag == 0:
    #print(count_)
    if count_list[count_] != 2 or count_list[count_ + diff] != 0:
        false_flag = 1
    count_ += 2

if false_flag == 0:
    print((2 ** (N // 2) ) % 1000000007)
else:
    print(0)

Measured memory_bytes: 14008
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int N=nextInt();
		int M=nextInt();

		int[] n = new int[N+1];
		Arrays.fill(n, 0);

		for(int i=0;i<M;i++){
			int[] a=nextInts();
			n[a[0]]++;
			n[a[1]]++;
		}
		for(int i=1;i<N+1;i++){
			System.out.println(n[i]);
		}





	}




	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

int main(){
  string s;
  cin>>s;
  map<char,int> mp;
  rep(i,s.size()){
    mp[s[i]]++;
  }
  string ans="YES";
  if(max(mp['a'],max(mp['b'],mp['c']))-min(mp['a'],min(mp['b'],mp['c']))>=2)ans="NO";
  cout<<ans<<endl;
}


Measured memory_bytes: 3704
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I() + 1
A = LI()
D = defaultdict(lambda:-1)
for i in range(n):
    if D[A[i]] != -1:
        l = D[A[i]]
        r = n - i - 1
        break
    else:
        D[A[i]] = i


fac = [1] * (n + 1)
inv = [1] * (n + 1)
i = 1
for j in range(1, n + 1):
    i = i * j % mod
    fac[j] = i
    inv[j] = pow(i, mod - 2, mod)



def comb(n, r):
    if r > n or n < 0 or r < 0:
        return 0
    return fac[n] * inv[n - r] * inv[r] % mod


for j in range(1, n + 1):
    print((comb(n, j) - comb(r + l, j - 1)) % mod)

Measured memory_bytes: 65440
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph=vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;


int main(void)

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

	ll k;
	cin >> k;
	ll num = 0;
	ll ans = 0;

	string s = "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";
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == ',')
		{
			num++;
		}
		if (num > k - 1)
			break;
		else if (k - 1 == num)
		{
			if ('0' <= s[i] && s[i] <= '9')
			{
				ans *= 10;
				ans += s[i] - '0';
			}
		}

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

Measured memory_bytes: 256
N, M = map(int, input().split())
H = [int(i) for i in input().split()]

ans = [True]*N

for i in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    if H[A] == H[B]:
        ans[A] = False
        ans[B] = False
    elif H[A] < H[B]:
        ans[A] = False
    else:
        ans[B] = False

print(sum(ans))


Measured memory_bytes: 19988
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
int inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =1000000000000000000;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define F first
#define S second
#define ac fstream cin("input.txt");ofstream cout("output.txt");
class ArcadeManao
{
    public:
int shortestLadder(vector <string> level, int coinRow, int coinColumn)
{

   }
};
int main()
{
   LL ans=1;
   string a;
   while(cin>>a){
   int cnt[26]={};
   for(int i=0;i<a.sz;i++){
    cnt[a[i]-'a']++;
    ans+=(i+1)-cnt[a[i]-'a'];
   }
    cout<<ans<<endl;
    
    
    
   }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;
template <typename... Args> void dbg(Args &&... args) {
  using expander = int[];
  (void)expander{
      0,
      (static_cast<void>(void(cout << std::forward<Args>(args) << " ")), 0)...};
  cout << endl;
}
void gen() {
  exit(0);
}

string s;

void input() {
  cin >> s;
}

void solve() {
  int n = (int)s.size();
  int best = 0;
  int start = -1;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') {
      if (start == -1) {
        start = i;
      }
    } else {
      if (start != -1) {
        best = max(best, i - start);
        start = -1;
      }
    }
  }
  if (start != -1) {
    best = max(best, n - start);
    start = -1;
  }
  cout << best << "\n";
}

void clean() {
  scanf(" ");
}

int main() {
#ifdef DEBUG
  freopen("input", "r", stdin);
  // freopen("output", "w", stdout);
  // gen();
  while (!feof(stdin)) {
#endif
    input();
    solve();
#ifdef DEBUG
    clean();
  }
#endif
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = []
for _ in range(N):
    A.append(list(map(int, input().split())))

ans = 0

for i in range(N):
    for j in range(N):
        used = True
        for k in range(N):
            if i == k or j == k:
                continue
            tmp = A[i][k] + A[k][j]
            if A[i][j] > tmp:
                print(-1)
                exit()
            if A[i][j] == tmp:
                used = False
        if used:
            ans += A[i][j]
print(ans//2)


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

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

using ll = long long;

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

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

struct UnionFind {
    vector<int> par,rank,large;

    void init(int N){
        rank.assign(N,0);
        large.assign(N,1);
        par.resize(N);
        for(int i= 0; i < N; i++){
            par[i]=i;
        }
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if(rank[rx]<rank[ry]) {
            par[rx]=ry;
            large[ry]+=large[rx];
            large[rx]=0;
        }
        else {
            par[ry]=rx;
            large[rx]+=large[ry];
            large[ry]=0;
            if(rank[rx]==rank[ry])rank[x]++;
        }
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) {
        return large[root(x)];
    }
};

int main() {
  int N,M;
  cin>>N>>M;
  vector<vector<int>> path(M,vector<int>(2));
  for(int i = 0; i < M; i++) {
    int x,y;
    cin>>x>>y;
    path[i][0]=x-1;
    path[i][1]=y-1;
  }
  int ans = 0;
  for(int i = 0; i < M; i++){
    UnionFind tree;
    tree.init(N);
    for(int j = 0; j < M; j++){
      if(i==j)continue;
      tree.unite(path[j][0],path[j][1]);
    }
    if(tree.size(0)!=N) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
/*
   * * * * *       *        * * * * * * * * * * * * * * * * * * * * * * * *     * * * * * * *               * *               * * * * * * * * * *
   * * * * *      * *       * * * * * * * * * * * * * * * * * * * * * *    *    * * * * * * *              * * *             * ** * * * * * * * * *
   * *           * * *            * *     * *     * *      * *          * * *   * * *       *             * * * *           * * * *       * *    * *
   * * * * *    * * * *           * *     * *     * *       * * * * * * *  * *  * * * * * * *            * * * * *         * *  * *       * * * * *
   * * * * *   * * * * *          * *     * *     * *        * * * * ** *   * * * * * * * * *           * * * * * *       * *   * * * *   * * * *
         * *  * * * * * *   * *   * *     * *     * *       * * * * * * *    * ** *     * * *          * * * * * * *     * *    * * * *   * *  * *
         * * * *       * *  * *   * *     * *     * *      * *          *     * * *     * * *         * *       * * *   * *     * *       * *   * *
   * * * * ** *         * * * * * * * * * * * * * * * * * * * * * * * * *      *  * * * * * * * * * ** *         * * * * *      * * * * * * *    * *
   * * * * * *           * ** * * * * * * * * * * * * * * * * * * * * * *       * * * * * * * * * * * *           * * * *       * * * * * * *     * *
*/

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <set>
#define ll long long
#define rep(i, a, b) for (int i = int(a); i <= int(b); i++)
#define sz(a) int((a).size())
using namespace std;
int arr[95];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string S,T;
    int s,t,ans = INT_MAX;;
    cin>>S>>T;
    s=S.size();
    t=T.size();
    for(int i=0;i<=s-t;i++)
    {
        int cnt=0;
        for(int j=0;j<t;j++)
        {
            if(S[i+j]!=T[j])
                cnt++;
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3200
#include<stdio.h>
#define MAX 500001
#define NIL -2000000001
int k[MAX],size;

int Parent(int i){
  return i/2;
}

int Left(int i){
  return i*2;
}

int Right(int i){
  return i*2+1;
}


int maxHeapify(int A[],int i){
  int l,r,largest=NIL,e;
  l=Left(i);
  r=Right(i);
  if(l<=size && A[l]>A[i])
    largest=l;
  else largest=i;
  if(r<=size && A[r]>A[largest])
    largest=r;
  if(largest!=i){
    e=A[i];
  A[i]=A[largest];
  A[largest]=e;
  maxHeapify(A, largest);
  }
    }

int buildMaxHeap(int A[]){
  int i;
  for(i=size/2;i>=1;i--){
    maxHeapify(A,i);
  }    
}

main(){
  
    int i;
  for(i=0;i<MAX;i++)
    k[i]=-(1<<29);


  scanf("%d", &size);
  for(i=1;i<=size;i++)
    scanf("%d", &k[i]);

  buildMaxHeap(k);

  for(i=1;i<=size;i++)
    printf(" %d", k[i] );
  printf("\n");

  return 0;
 
}

Measured memory_bytes: 2552
import math
import copy
from collections import Counter
 
 
 
def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:
 
            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input().split())
    return l
 

a=nCast(input().split())


def func():
    if (max(a)==min(a)):
        return "Yes"
    return "No"
    
 
print(func())


Measured memory_bytes: 3540
#include <bits/stdc++.h>
 
#define int long long
 
#define Vanya Unstoppable
 
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    
    int n;
    cin >> n;
    
    int a[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    
    int cur = 0, ans = 0;
    for (int i = 0; i < n; ++i) {
        int val = cur + a[i];
        ans += val / 2;
        if (a[i] >= cur) {
            cur = val % 2;
        } else {
            cur = 0;
        }
    }
    
    cout << ans;
}


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

int main() {
  int l, r, d;
  scanf("%d %d %d", &l, &r, &d);

  int ans = 0;
  for (int i = l; i <= r; i++)
    ans += (i % d == 0);
  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl


/*--------------------template--------------------*/

int main()
{
	cin >> s;
	REP(i, s.size())
	{
		if (i % 2 == 0) {
			cout << s[i];
		}
	}
	cout << endl;
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline

def main():
    #1:初期化
    N,W = map(int,input().split())
    wv = []
    for _ in range(N):
        wv.append(list(map(int,input().split())))
    dp = [[0]*(W+1) for i in range(N+1)]

    #print(dp)
    #print(dp2)
    #2:初期値(元からゼロなので記述無し)

    #3:dp実行部(貰うDP)
    for i in range(1,N+1):
        for j in range(1,W+1):
            if wv[i-1][0] <= j: #dpの横が重さだが，jが重さ以下ならそもそも入れられない．
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-wv[i-1][0]]+wv[i-1][1])
            else:
                dp[i][j] = dp[i-1][j]
            #print(i,j)
            #print(*dp,sep="\n")

    #4:出力
    print(dp[N][W])

if __name__ == '__main__':
    main()

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

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

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

    int n; cin >> n;
    ll res = 1LL;
    for (int i = 0; i < n; ++i) {
        ll t; cin >> t;
        res = lcm(res, t);
    }

    cout << res << endl;
    return 0;
}

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

int64_t sign(int64_t X){
  int64_t ans= (X > 0) ? 1
              :(X < 0) ? -1
                       : 0;
  return ans;
}

int main(){
  int64_t X0,K,D;
  cin >> X0 >> K >> D;

  int64_t Xgoal= (abs(X0) % D <= D- (abs(X0) % D)) ? sign(X0)* abs(X0) % D
                :(X0 >= 0)                         ? (abs(X0) % D)- D
                                                   : D- (abs(X0) % D);
  int64_t K0= min(K, abs(X0- Xgoal)/ D);
  int64_t Krem= K- K0;

  int64_t ans= (K0==K)     ? abs(X0)- K*D
              :(Krem%2==0) ? abs(Xgoal)
                           : min(abs(Xgoal+ D), abs(Xgoal- D));
  
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {

	int n;
	cin >> n;
	vector <int> num(n);
	rep(i, n) cin >> num.at(i);
	sort(num.begin(), num.end());
	reverse(num.begin(), num.end());
	int score = 0;
	rep(i, n) {
		if (i % 2 == 0) score += num.at(i);
		if (i % 2 != 0) score -= num.at(i);
	}
	cout << score << endl;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define inf 1010000000
#define infll 1010000000000000000ll
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define mpr make_pair
#define fi first
#define se second
#define pq priority_queue<int>
#define pqll priority_queue<ll>
#define up(x,y) (x<(y)?x=(y):0)
#define dn(x,y) (x>(y)?x=(y):0)
#define ad(x,y) (x=(x+(y))%mod)
#define mod 998244353
#define N 100009
using namespace std;

int n,m,dp[N],f[N];
int main(){
	scanf("%d",&n);
	int i,j,x; dp[0]=f[0]=1;
	for (i=1; i<=n; i++){
		scanf("%d",&x); m+=x;
		for (j=m; j>=x; j--){
			dp[j]=((ll)dp[j]*2+dp[j-x])%mod;
			ad(f[j],f[j-x]);
		}
		for (; j>=0; j--) dp[j]=(ll)dp[j]*2%mod;
	}
	int ans=0;
//	for (i=0; i<=m; i++) cerr<<dp[i]<<'\n';
	for (i=m+1>>1; i<=m; i++) ad(ans,(ll)dp[i]*3);
	if (m%2==0) ans=(ans-(ll)f[m/2]*3)%mod;
	//cerr<<ans<<'\n';
	int t=1;
	for (i=1; i<=n; i++) t=t*3ll%mod;
	ans=(t-ans)%mod;
	printf("%d\n",(ans+mod)%mod);
	return 0;
}


Measured memory_bytes: 896
from typing import List
import math

N = int(input())
S = [int(i) for i in input().split()]
q = int(input())
T = [int(i) for i in input().split()]


def binary_search(A: List[int], key: int) -> int:
    left = 0
    right = len(A)
    while left < right:
        mid = math.floor((left + right) / 2)
        if A[mid] == key:
            return mid
        elif key < A[mid]:
            right = mid
        else:
            left = mid + 1
    return -1


count = 0
for t in T:
    if binary_search(S, t) != -1:
        count += 1
print(count)


Measured memory_bytes: 17824
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long f = 1;
        int n=sc.nextInt();
        for (int i = 1; i <=n ; i++) {
            f = 1;
            for (int j = 1; j <= i; j++) {
                f *= j;
            }
        }
        System.out.println( f);
    }
}


Measured memory_bytes: 25748
use proconio::input;

fn main() {
    input! {
        n: usize,
        d: i64,
        xy: [(i64, i64); n],
    };
    let ans = xy
        .iter()
        .filter(|(x_i, y_i)| x_i*x_i + y_i*y_i <= d*d)
        .count();
    println!("{}", ans);
}


Measured memory_bytes: 7752
#include <iostream>
#include <cmath>
#include <stdint.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
using namespace std;
 
#define int long long
#define INF (1e18)+1
 
int nChoosek( int n, int k )
{
    if (k > n) return 0;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;

    int result = n;
    for( int i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i; 
    }
    return result;
}

int choose2(int n){
	
	return n*(n-1)/2;
}

int arr[200001];

int32_t main() {
 
  	int N,K;
  	
  	cin >> N >> K;
  	
  	for(int i=0; i<N; i++){
  	 
  		cin >> arr[i];  	
  		
	}
	
	sort(arr,arr+N);
	
	int l = -INF , r = INF;
	
	while(l+1 < r){
		
		int x = (l+r)/2;
		int cnt = 0;
		for(int i=0; i<N; i++){
			
			if(arr[i] < 0){
				
				int left = i;
				int right =  N;
				
				while(left+1 < right){
					
					int m = (left+right)/2;
					
					if(arr[m] * arr[i]  < x ){
						right = m;
					}
					else{
						left = m;
					}
				}
				cnt += N - right;
			}
			else{
				
				int left = i;
				int right = N;
				
				while(left+1 < right){
					
					int m = (left+right)/2;
					
					if(arr[m] * arr[i] < x)
						left = m;
					else
						right =m;
					
				}
				
				cnt+= left-i;
				
				
			}
			
		//	if(arr[i] * arr[i] < x){
		//		cnt--;
		//	}
			
			
		}
		
		//cnt /= 2;
		
		if(cnt < K){
			l = x;
		}
		else{
			r = x;
		}
		
	}
	
	
	cout << l << endl;
	
	
 
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 29;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

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

  bool f = true;
  rep (i, s.size() - 1) if (s[i] == s[i + 1]) f = false;

  cout << (f ? "Good" : "Bad") << endl;
}


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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0) 

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }
    
    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
	int n = ri();
	int w = ri();
	int a[n], b[n];
	FOR(i,n) a[i] = ri(), b[i] = ri();
	int base = INF;
	FOR(i,n) base = min(base, a[i]);
	vector<int> c[4] = { {} };
	FOR(i,n) c[a[i]-base].push_back(b[i]);
	FOR(i,4) sort(all(c[i]), greater<int>());
	
	s64 res = 0;
	FOR(i,c[0].size()+1) {
		FOR(j,c[1].size()+1) {
			FOR(k,c[2].size()+1) {
				if (((s64)i)*base + ((s64)j)*(base+1) + ((s64)k)*(base+2) > w) continue;
				int l = (w-(((s64)i)*base + ((s64)j)*(base+1) + ((s64)k)*(base+2)))/(base+3);
				l = min(l,(int)c[3].size());
				s64 score = 0;
				score += accumulate(c[0].begin(), c[0].begin()+i, 0);
				score += accumulate(c[1].begin(), c[1].begin()+j, 0);
				score += accumulate(c[2].begin(), c[2].begin()+k, 0);
				score += accumulate(c[3].begin(), c[3].begin()+l, 0);
				res = max(res,score);
			}
		}
	}
	cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>

using namespace std;

void showIntArray(int a[], int n) {
    for (int i=0; i<n; i++) {
        cout << a[i] << ' ';
    } cout << endl;
}

// void showIntArray(vector<int> a[], int n) {
//     for (int i=0; i<n; i++) {
//         cout << a[i] << ' ';
//     } cout << endl;
// }

int main() {
    int X, Y;
    cin >> X >> Y;
    cout << X + Y / 2 << endl;
    return 0;
}

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

int main(){
	double w,h,x,y;
	cin >> w >> h >> x >> y;
	double ans = w*h/2;
	double num = (w == x*2 && h == y*2) ? 1 : 0;
	cout << fixed << setprecision(15) << ans;
	cout << " " << (int)num << endl;
}

// cout << fixed << setprecision(15) <<  << endl;

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repi(i,x,n) for(ll i=x;i<(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);
//ios::sync_with_stdio(false);

ll dp[1000][1000]={};

signed main(){
    ll h,w;cin>>h>>w;
    vector<vector<char>> v(h,vector<char>(w,0));

    rep(i,h)rep(j,w){
        cin>>v[i][j];
    }

    rep(i,h){
        if(v[i][0]=='#'){
            break;
        }
        dp[i][0]=1;
    }
    rep(i,w){
        if(v[0][i]=='#'){
            break;
        }
        dp[0][i]=1;
    }

    for(int i=1;i < h;i++)
    {
        for(int j=1;j<w;j++){
            if(v[i][j]=='#')continue;

            dp[i][j]+=dp[i-1][j];
            dp[i][j]%=mod;

            dp[i][j]+=dp[i][j-1];
            dp[i][j]%=mod;
        }
    }

    cout<<dp[h-1][w-1]<<endl;

}

Measured memory_bytes: 9088
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MAX_V (100005)
#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N;
vector<int> G[MAX_V * 2];
bool visited[MAX_V*2];

void dfs(int v,vector<Int> &cnt) {
    if(visited[v])
        return;
    visited[v] = true;
    cnt[v/MAX_V]++;

    for(auto e:G[v]) {
        dfs(e,cnt);
    }

    return;
}

int main(void) {
    cin>>N;
    int x,y;
    
    for(int i = 0;i < N;i++) {
        cin>>x>>y;
        y+=MAX_V;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    Int ans = 0;

    for(int i = 0;i < MAX_V*2;i++) {
        if(visited[i])
            continue;
        vector<Int> cnt(2);
        dfs(i,cnt);

        ans += cnt[0]*cnt[1];
    }

    cout<<ans-N<<endl;

    return 0;
}


Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
 
int main(int argc, char const *argv[])
{
  int n;
  cin>>n;
  int s= 0;
  int c=n;
  while (c>0) {
    s+=c%10;
    c/=10;
  }
  if (n%s==0)
  {
    printf("Yes");
  }
  else {
    printf("No");
  }
 
  return 0;
}

Measured memory_bytes: 256
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------


//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int a,b,c;cin>>a>>b>>c;
    cout<<a+b+c-mmax(a,mmax(b,c))<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 文字列の入力
        String s = sc.next();
        if (s.equals("Sunny")) {
            System.out.println("Cloudy");
        } else if (s.equals("Cloudy")) {
            System.out.println("Rainy");
        } else {
            System.out.println("Sunny");
        }
    }
}


Measured memory_bytes: 19924
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

total = 0
for i in range(N):
  total += B[A[i]-1]
  if i != 0 and A[i]-A[i-1] == 1:
    total += C[A[i-1]-1]
print(total)

Measured memory_bytes: 9080
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
C = 0
for t in T:
    right = n-1
    left = 0
    mid = 1
    while left <= right:
        mid = (right + left) // 2
        # if t == 11:
        #     print(left)
        #     print(right)
        #     print(mid)
        #     print(S[mid])
        #     print('-----------')
        if t == S[mid]:
            C += 1
            break
        elif t > S[mid]:
            left = mid+1
        else:
            right = mid-1
print(C)


Measured memory_bytes: 16708
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    K = int(rl())
    
    rnrn = [i for i in range(1, 10)]
    
    def calc(a):
        if 3234566667 < int(a):
            return
        
        if a[-1] == '0':
            tmp = a + '0'
            rnrn.append(int(tmp))
            calc(tmp)
            tmp = a + '1'
            rnrn.append(int(tmp))
            calc(tmp)
        elif a[-1] == '9':
            tmp = a + '9'
            rnrn.append(int(tmp))
            calc(tmp)
            tmp = a + '8'
            rnrn.append(int(tmp))
            calc(tmp)
        else:
            tmp = a + str(int(a[-1]) + 1)
            rnrn.append(int(tmp))
            calc(tmp)
            tmp = a + a[-1]
            rnrn.append(int(tmp))
            calc(tmp)
            tmp = a + str(int(a[-1]) - 1)
            rnrn.append(int(tmp))
            calc(tmp)
    
    for i in range(1, 10):
        calc(str(i))
    
    rnrn.sort()
    print(rnrn[K - 1])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 15828
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T> bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
    for (auto &e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k, x;
    cin >> k >> x;
    vector<int> v;
    for (int i = max(-1000000, x - k + 1); i <= min(1000000, x + k - 1); i++) {
        v.push_back(i);
    }
    cout << v;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define mod 1000000007
#define maxn 100009
#define maxr 100009
vector<VL> ad,adlist;
vector<ll> ans,store,visit;

// void dfs2(ll i,VL visit,ll x)
// {
// 	//if(visit[i]==0)
// 	visit[i]=1;
	
// 	//visit[i]=1;
// 	ans[i]+=x;
// 	fr(j,0,SZ(adlist[i]))
// 	{
// 		if(visit[adlist[i][j]]==0)
// 			dfs2(adlist[i][j],visit,x);
// 	}
	
// 	return;
// }
void dfs(ll i)
{
	visit[i]=1;
	fr(j,0,SZ(ad[i]))
	{
		if(visit[ad[i][j]]==0)
		{
			//visit[ad[i][j]]=1;
			store[ad[i][j]]+=store[i];
			dfs(ad[i][j]);
			//adlist[i].PB(ad[i][j]);
		}
	}
	return;
}
void solve()
{
	ll n,q;
	rl2(n,q);
	ad.assign(n,VL());
	//adlist.assign(n,VL());
	ans.assign(n,0);
	fr(i,0,n-1)
	{
		ll a,b;
		rl2(a,b);
		a--,b--;
		ad[a].PB(b);
		ad[b].PB(a);
	}
	 visit.assign(n,0);
	// visit[0]=1;
	// fr(i,0,SZ(ad[0]))
	// {
	// 	if(visit[ad[0][i]]==0)
	// 	{
	// 		visit[ad[0][i]]=1;
	// 		dfs(ad[0][i],visit);
	// 		adlist[0].PB(ad[0][i]);
	// 	}
	// }
	store.assign(n,0);
	fr(i,0,q)
	{
		ll p,x;
		rl2(p,x);
		p--;
		store[p]+=x;
		//visit.assign(n,0);
		//dfs2(p,visit,x);
	}
	dfs(0);
	fr(i,0,n)
		cout<<store[i]<<" ";
	NL;
	// fr(i,0,n)
	// {
	// 	cout<<"adlist : "<<i+1<<" : ";
	// 	fr(j,0,SZ(adlist[i]))
	// 		cout<<adlist[i][j]+1<<" ";
	// 	NL;
	// }
	return;
}
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	solve();
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

const int MAX = 910000;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}

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

void Main() {
    ll X, Y;
    cin >> X >> Y;
    if ((X + Y) % 3 != 0) {
        cout << 0 << '\n';
    } else {
        if (2 * X - Y < 0 || 2 * Y - X < 0) {
            cout << 0 << '\n';
        } else {
            COMinit();
            cout << COM((X + Y) / 3, X - (X + Y) / 3) % MOD<< '\n';
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 21632