akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>
#include <fstream>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i, a, n) for(LL i = (a), i##_max = (n); i < i##_max; ++i)
#define REM(i, a, n) for(LL i = (LL)(n) - 1, i##min = (a); i >= i##min; --i)
#define ALL(arr) (arr).begin(), (arr).end()
#define FLOAT fixed << setprecision(16)
#define SPEEDUP {cin.tie(NULL); ios::sync_with_stdio(false);}
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template<class T>
T Compare(T left, T right) { return left > right ? 1 : (left < right ? -1 : 0); }
istream& Ignore(istream& ist) { string s; ist >> s; return ist; }
bool Inside(int i, int j, int h, int w) { return i >= 0 && i < h && j >= 0 && j < w; }
template <class T>
T Next() { T buf; cin >> buf; return buf; }

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "BinaryMatrix.h"
#include "BIT.h"
#include "Factorization.h"
#include "FlowSolver.h"
#include "Graph.h"
#include "LazySegmentTree.h"
#include "Math.h"
#include "Matrix.h"
#include "MinMax.h"
#include "Position.h"
#include "Range.h"
#include "Rational.h"
#include "SegmentTree.h"
#include "SegmentTree2D.h"
#include "SuffixArray.h"
#include "Tree.h"
#include "UnionFind.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

#if 1234567891
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;
// template <class T>
// auto Is(const T& value) { return [value](const auto& comparand) -> bool { return comparand == value; }; }
#endif

int main() {
	string s;
	cin >> s;
	while (s.size() < 15) {
		s += 'o';
	}

	YESNO(count(s.begin(), s.end(), 'o') >= 8);
	return 0;
}


Measured memory_bytes: 256
L = input()
n = len(L)
mod = 10**9 + 7

dp = [[0]*2 for _ in range(n+1)]
#dp[i][flag]は、i桁目までみたときにflag = 1はストリクトにLより小さい
dp[0][0] = 1

for i in range(n):
    if L[i] == "1":
        dp[i+1][0] = 2*dp[i][0] % mod
        dp[i+1][1] = (3*dp[i][1] % mod + dp[i][0]) % mod
    else:
        dp[i+1][0] = dp[i][0]
        dp[i+1][1] = 3*dp[i][1] % mod
print((dp[n][0]+dp[n][1]) % mod)

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

typedef long long ll;

ll getInversePair(vector<ll>& nums, int start, int end, vector<ll>& copy) {
    if (start >= end) {
        return 0;
    }
    int mid = (end - start) / 2 + start;
    ll leftCnt = getInversePair(nums, start, mid, copy);
    ll rightCnt = getInversePair(nums, mid + 1, end, copy);
    int p = start;
    int q = mid + 1;
    int index = start;
    ll cnt = 0;
    while (p <= mid && q <= end) {
        if (nums[p] <= nums[q]) {
            copy[index++] = nums[p++];
            cnt += end - q + 1;
        } else {
            copy[index++] = nums[q++];
        }
    }
    while (p <= mid) copy[index++] = nums[p++];
    while (q <= end) copy[index++] = nums[q++];
    for (int i = start; i <= end; ++i) {
        nums[i] = copy[i];
    }
    return (leftCnt + rightCnt + cnt);
}

bool check(ll m, ll lim, const vector<ll> &nums, vector<ll> &sums, vector<ll> &copy) {
    sums[0] = 0;
    for (int i = 0; i < nums.size(); ++i) {
        sums[i + 1] = sums[i];
        if (nums[i] >= m) {
            sums[i + 1]++;
        } else {
            sums[i + 1]--;
        }
    }
    ll res = getInversePair(sums, 0, sums.size() - 1, copy);
    return res >= lim;
}

int main() {
    ll n;
    cin >> n;
    vector<ll> nums(n);
    vector<ll> copy(n + 1);
    ll l = LONG_LONG_MAX;
    ll r = LONG_LONG_MIN;
    for (int i = 0; i < n; ++i) {
        cin >> nums[i];
        l = min(l, nums[i]);
        r = max(r, nums[i]);
    }
    vector<ll> sums(n + 1);
    ll lim = (n * (n + 1) / 2 + 1) / 2;
    ll m;
    ll ans = 0;
    while (l <= r) {
        m = (r - l) / 2 + l;
        if (check(m, lim, nums, sums, copy)) {
            ans = m;
            l = m + 1;
        } else {
            r = m - 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <map>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <set>
#include <queue>
#include <list>
 
using namespace std;
int main()
{
    int n;
string s;
    cin>>s;
    int len=s.length();
    int a=0,b=len-1;
    for(int i=0;i<len;++i)
    {
        if(s[i]=='A')
        {
            a=i;
            break;
        }
    }
    for(int i=len-1;i>=0;--i)
    {
        if(s[i]=='Z')
        {
            b=i;
            break;
        }
    }
    printf("%d",b-a+1);
    return 0;
}

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

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Scanner sc = new Scanner(System.in);
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    long mod = 1000000000+7;
    public static void main(String[] args) throws IOException {
        Main main = new Main();
        main.solve();
        out.flush();
    }
    void solve() throws IOException {
        int n = sc.nextInt();
        long[] A = new long[n], B = new long[n];
        int zeroA = 0, zeroB = 0, both = 0;
        Map<String, Integer> pos = new HashMap<>(n/2+1), neg = new HashMap<>(n/2+1);
        Map<Long,Map<Long,Integer>> posi = new TreeMap<>(), nega = new TreeMap<>();
        for(int i=0;i<n;i++){
            A[i] = sc.nextLong(); B[i] = sc.nextLong();
            if(A[i]==0&&B[i]==0) both++;
            else if(A[i]==0){
                zeroA++;
            } else if(B[i]==0){
                zeroB++;
            } else{
                long a = Math.abs(A[i]), b = Math.abs(B[i]);
                long g = gcd(a,b);
                a /= g; b /= g;
                Map<Long,Map<Long,Integer>> mapi = nega;
                if((A[i]>0&&B[i]>0)||(A[i]<0&&B[i]<0)) mapi = posi;
                if(!mapi.containsKey(a)){
                    mapi.put(a,new TreeMap<>());
                }
                Map<Long,Integer> map = mapi.get(a);
                Integer val = map.get(b);
                if(val==null) val = 1;
                else val++;
                map.put(b,val);
            }
        }
        long ans = 1;
        ans = ans*(power(2,zeroA)+power(2,zeroB)-1)%mod;
        for(Map.Entry<Long,Map<Long,Integer>> e:posi.entrySet()){
            long a = e.getKey();
            Map<Long,Integer> map = e.getValue();
            for(Map.Entry<Long,Integer> ff:map.entrySet()){
                Long b = ff.getKey();
                int p = ff.getValue();
                int q = 0;
                if(nega.containsKey(b)) {
                    Map<Long,Integer> curmap = nega.get(b);
                    q = curmap.getOrDefault(a,0);
                    curmap.remove(a);
                    if(curmap.size()==0) nega.remove(b);
                }
                ans = ans*(power(2,p)+power(2,q)-1)%mod;
            }
        }
        for(Map.Entry<Long,Map<Long,Integer>> e:nega.entrySet()){
            Map<Long,Integer> map = e.getValue();
            for(Map.Entry<Long,Integer> ff:map.entrySet()){
                int q = ff.getValue();
                ans = ans*power(2,q)%mod;
            }
        }
        ans = (ans+both-1+mod)%mod;
        out.println(ans);
    }
    long gcd(long a, long b){
        if(a==0||b==0) return 1;
        if(a<b){
            long c= a; a = b; b = c;
        }
        while(a%b!=0){
            long c = b; b = a%b; a = c;
        }
        return b;
    }
    long power(long base, long p){
        long ans = 1;
        while(p>0){
            if(p%2==1) ans = ans*base%mod;
            base = base*base%mod;
            p /= 2;
        }
        return ans;
    }
}

Measured memory_bytes: 98444
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    t=input()
    s_lis=[[] for _ in range(32)]
    t_lis=[[] for _ in range(32)]
    for i,ss in enumerate(s):
        s_lis[ord(ss)-ord('a')].append(i)
    for i,tt in enumerate(t):
        t_lis[ord(tt)-ord('a')].append(i)
    ss_lis=[sl for sl in s_lis if len(sl)>0]
    tt_lis=[tl for tl in t_lis if len(tl)>0] 
    ss_lis.sort()
    tt_lis.sort()
    if all([True if x==y else False for x,y in zip(ss_lis,tt_lis)]):
        print("Yes")
    else:
        print("No")

if __name__=='__main__':
    main()

Measured memory_bytes: 54608
// たなこふ先生の input マクロ (´･_･`)
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        t: f64,
        x: f64,
    }

    println!("{}", t/x);
}


Measured memory_bytes: 4352
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int r = sc.nextInt();
      	if(r < 1200){
        	System.out.println("ABC");
        }else if( r < 2800){
        	System.out.println("ARC");
        }else{
        	System.out.println("AGC");
        }
    }
}

Measured memory_bytes: 35684
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      (int)1e9+7
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;

int main(){
	int n,k;
	cin>>n>>k;
	
	vi a(n);
	REP(i,n) cin>>a[i];
	
	int cnt=0;
	int cntt=0;
	REP(i,n-1){
		for(int j=i+1;j<n;++j){
			if(a[i]>a[j]) cnt++;
		}
	}
	REP(i,n){
		REP(j,n){
			if(a[i]>a[j]) cntt++;
		}
	}
	//cout<<cnt<<' '<<cntt<<endl;//!!!
	
	llong ans=0;
	ans+=(llong)cnt*k;
	//cout<<ans<<endl;//!!!
	ans%=MOD;
	//cout<<(llong)k*(k-1)%(MOD)<<endl;//!!!
	ans+=(llong)cntt*(((llong)k*(k-1)/2)%(MOD));
	//cout<<ans<<endl;//!!!
	ans%=MOD;
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys

def main():
	N, x = map(int,input().split(" "))
	tmp = input().split(" ")
	candy = [int(s) for s in tmp]
	
	ans = 0
	for i, val in enumerate(candy):
		if i+1 == len(candy): break
		
		tmp = candy[i] + candy[i+1]
		if x < tmp and candy[i+1] >= tmp - x:
			candy[i+1] = candy[i+1] - (tmp - x)
			ans = ans + (tmp - x)
		elif x < tmp:
			candy[i] = candy[i] - ((tmp - x) - candy[i+1])
			candy[i+1] = 0
			ans = ans + (tmp - x)
	
	print(ans)

if __name__ == "__main__":
	main()


Measured memory_bytes: 14544
import sys
L = input()
s1,s2 = raw_input(),raw_input()
l1,l2 = len(s1), len(s2)

if l1 == l2:
  print( min(s1,s2) * (L//l1) )
  sys.exit()

cands = []
n1 = 0
while True:
  if (L - n1*l1) % l2 == 0:
    n2 = (L - n1*l1) // l2
    cands.append(s1*n1 + s2*n2)
    cands.append(s2*n2 + s1*n1)
    break
  n1 += 1

n2 = 0
while True:
  if (L - n2*l2) % l1 == 0:
    n1 = (L - n2*l2) // l1
    cands.append(s1*n1 + s2*n2)
    cands.append(s2*n2 + s1*n1)
    break
  n2 += 1

print(min(cands))

Measured memory_bytes: 4032
#include<stdio.h>
int main(){
  int n,i,c=0,j;
  scanf("%d",&n);
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  j=1;
  for(i=0;i<n;i++){
    if(a[i]==j){
      j++;
    }
  }
    j=j-1;
  if(j==0){
    printf("-1");
    
  }
  else{
    printf("%d",n-j);
  }
  return 0;
  
}

Measured memory_bytes: 2508
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n+2);
  a[0] = 0;
  a[n+1] = 0;
  for(int i = 1; i <= n; ++i){
    cin >> a[i];
  }
  int ptr = a[0];
  ll cost = 0;
  for(int i = 0; i <= n; ++i){
    cost += abs(a[i] - a[i+1]);
  }

  for(int i = 1; i <= n; ++i){
    ll ans = cost;
    ans -= abs(a[i]-a[i-1]) + abs(a[i]-a[i+1]);
    ans += abs(a[i-1] - a[i+1]);
    cout << ans << endl;
  }


  
}


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

int main() {
  int X,N;
  cin >> X >> N;
  vector<int> p(N);
  for(int i=0;i<N;i++){
	cin >> p.at(i);
  }
  int m,M;
  for(int i=0;i<N+1;i++){
    bool b;
    for(int j=0;j<N;j++){
      if(X+i == p.at(j)){
        b =false;
        break;
      }
      if(j==N-1){
        b = true;
      }
    }
    if(N==0){
      M=X;
      break;
    }
    else if(b){
      M=X+i;
      break;
    }
  }
     
  for(int i=0;i<N+1;i++){
    bool b;
    for(int j=0;j<N;j++){
      if(X-i == p.at(j)){
        b =false;
        break;
      }
      if(j==N-1){
        b = true;
      }
    }
    if(b){
      m=X-i;
      break;
    }
  }
  if(M-X<X-m){
    cout << M << endl;
  }
  else
    cout << m << endl;
}





Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int n=s.size();
    if(n<26){
        vector<int>c(26);
        for(int i=0;i<n;i++){
            c[(int)(s[i]-'a')]++;
        }
        int m;
        for(int i=0;i<26;i++){
            if(c[i]==0){m=i;break;}
        }
        cout<<s<<(char)(m+'a')<<endl;
        return 0;
    }
    else{
        int inc=n;
        for(int i=n-1;i>=1;i--){
            if(s[i-1]<s[i]){inc=i-1;break;}
        }
        if(inc==n){cout<<-1;return 0;}
        vector<int>c(26);
        string t=s.substr(0,inc);
        for(int i=0;i<t.size();i++){
            c[(int)(t[i]-'a')]++;
        }
        int m;
        for(int i=0;i<26;i++){
            char C=(int)('a'+i);
            int N=t.size();
            if(c[i]==0&&C>s[N]){m=i;break;}
        }
        cout<<t<<(char)(m+'a')<<endl;return 0;
    }
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;
public class Main {
	


	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		
		int n = sc.nextInt();
		
		int[] ps = new int[n];
		
		for(int i=0;i<n;i++) {
			ps[i] = sc.nextInt();
		}
		
		int ans = 1;
		
		int min = ps[0];
		
		for(int i=1;i<n;i++) {
			if(min >= ps[i]) {
				ans++;
				min = ps[i];
			}
		}
		
		System.out.println(ans);




		
		
		
		
		

		


		
		
	}
	


}

 

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

int main(int argc, char const *argv[])
{
	int n,d,x;
	cin>>n>>d>>x;
	int a;
	for (int i = 0; i < n; ++i)
	{
		cin>>a;
		x+=(d+a-1)/a;
	}
	cout<<x<<endl;
	return 0;
}


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

inline ll read() {
    ll c,v=0;for(;!isdigit(c=getchar()););
    for(v=v*10+c-'0';isdigit(c=getchar());v=v*10+c-'0');
    return v;
}
const int N = 2e5+3;

ll n, ans = 0;
ll q, s[N], t[N], m = 0;

int main() {
    n = read();
    gor(i, 1, n) q = read(),
        s[i] = s[i-1]+q, t[i] = t[i-1]^q;
    for (ll i = 1, j = 1; i <= n; i++) {
        while (j <= n && (t[j]^t[i-1])==s[j]-s[i-1])
            j++;
        ans+=(j-i);
    }
    printf("%lld", ans);
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n;
    cin >> n;
    vector<i64> a(n);
    for (auto& e : a) cin >> e;

    if (a[0] != 0) {
        cout << -1 << endl;
        return;
    }

    i64 ans = 0;
    for (i64 i = 1; i < n; i++) {
        i64 d = a[i] - a[i - 1];
        if (d > 1) {
            cout << -1 << endl;
            return;
        }
        ans += (d == 1 ? 1 : a[i]);
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

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(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll H, W, h, w;
  IN(H,W,h,w);

  if(H%h==0 && W%w==0){
    OUT("No");
    return 0;
  }

  ll P =   99999999;
  ll N = -100000000;

  vvll ans(H, vll(W, 0));

    for(ll i=0; h*i<H; ++i){
      for(ll j=0; w*j<W;++j){
        ans[h*i][w*j] = P;
      }
    }
    for(ll i=0; h*i+h-1<H; ++i){
      for(ll j=0; w*j+w-1<W; ++j){
        ans[h*i+h-1][w*j+w-1] = N;
      }
    }

  ll s = 0;
  REP(i,H) REP(j,W) s += ans[i][j];

  //debug_print(s);

  if(s<0){
    printf("No\n");
  }else{
    printf("Yes\n");
    REP(i,H){
      REP(j,W){
        printf("%lld ", ans[i][j]);
      }
      printf("\n");
    }
  }


  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> W(N);
  for (int i=0; i<N; i++){
    cin >> W.at(i);
  }
  
  int S, S2, S3;
  S = 0;
  S2 = 0;
  for (int i=0; i<N; i++){
    S += W.at(i);
  }
  for (int i=0; i<N; i++){
    S2 += W.at(i);
    if (S2 > S/2){
      S3 = S2 - W.at(i);
      break;
    }
  }
  if (S2-S/2 <= S/2-S3){
    cout << 2*S2-S << endl;
  }
  else{
    cout << S-2*S3 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
const ll mod=1000000007;
const ll mod2=998244353;
const ll inf=100000000000000000;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
const int MAX_N=(1<<18);
int n;
struct seg{
int dat[MAX_N*2-1];
void init(int n_){
    //簡約化のためにnを２の冪乗に置き換える
    n=1;
    while(n<n_)n*=2;
    //ノードの個数 = n+n/2+n/4+...=2n-1
  for(int i=0;i<n*2-1;i++)dat[i]=INT_MAX;  //INT_MAX=2^32-1
}
void update(int i,int x){
    //葉のノード番号
    i+=n-1;
    dat[i]=x;
    //登りながら更新(n1=(n-1)/2,n2=(n1-1)/2...と計算すると親のノードを調べることができ最終的に根に到達する)
    while(i>0){
        i=(i-1)/2;
        //配置の更新
        dat[i]=min(dat[i*2+1],dat[i*2+2]);
    }
}
//区間[a,b)の最小値、l,rにはノードkに対応づく区間を与える
int query(int a,int b,int k,int l, int r){
    //区間が考察するかどうか、しなければINT_MAX
    if(r<=a||l>=b)return INT_MAX;
    //区間を完全に含んでいるか、含んでいたら節点の値
    if(a<=l&&r<=b)return dat[k];
    else{
        //上記を満たさなければ2分法で探す
        int vl=query(a,b,k*2+1,l,(l+r)/2);
        int vr=query(a,b,k*2+2,(l+r)/2,r);
        return min(vl,vr);
    }
}

};
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    seg T;
    int m,q;
    cin>>m>>q;
    T.init(m);
    while(q--){
          int c,x,y;
          cin>>c>>x>>y;
          if(c==0){
              T.update(x,y);
          }
          else{
              cout<<T.query(x,y+1,0,0,n)<<endl;;
          }
    }
}



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

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int N, M, L;
	cin >> N >> M >> L;
	vector<vector<ll> > d1(N + 1, vector<ll>(N + 1, 1e10)), d2(N + 1, vector<ll>(N + 1, 1e10));
	for (int i = 0; i < M; i++) {
		ll a, b, c; cin >> a >> b >> c;
		d1[a][b] = c, d1[b][a] = c;
	}
 
	for (int k = 1; k <= N; k++) {
		for (int i = 1; i <= N; i++) {
			for (int j = 1; j <= N; j++) {
				d1[i][j] = min(d1[i][j], d1[i][k] + d1[k][j]);
				if (k == N&&d1[i][j]<=L) {
					d2[i][j] = 1;
				}
			}
		}
	}
 
	for (int k = 1; k <= N; k++) {
		for (int i = 1; i <= N; i++) {
			for (int j = 1; j <= N; j++) {
				d2[i][j] = min(d2[i][j], d2[i][k] + d2[k][j]);
			}
		}
	}
 
	int Q; cin >> Q;
	vector<pair<int, int> > qs(Q);
	for (int i = 0; i < Q; i++) {
		cin >> qs[i].first >> qs[i].second;
	}
	for (int i = 0; i < Q; i++) {
		int s = qs[i].first, t = qs[i].second;
		if (d2[s][t] > 1e9)cout << -1 << endl;
		else cout << d2[s][t] - 1 << endl;
	}
 
}
 

Measured memory_bytes: 5300
N, X = list(map(int, input().split(' ')))
xs = [abs(X - c) for c in list(map(int, input().split(' ')))]
def gcd(l, s):
    return s if l % s == 0 else gcd(s, l % s)
    
g = xs[0]
for i in xs:  # 1e5
    g = gcd(i, g)

print(g)

Measured memory_bytes: 14252
import fractions
n , x = map(int,input().split())
X = list(map(int,input().split()))
Y =[]
for i in range(n):
    Y.append(abs(X[i]-x))
ans = Y[0]
for i in range(n):
    ans = fractions.gcd(ans, Y[i])
print(ans)

Measured memory_bytes: 16300
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N, M, X;
	cin >> N >> M >> X;
	int ans = 0;
	int a[M];
	rep(i, M) cin >> a[i];
	while (a[ans] < X) ans++;
	cout << min(ans, M - ans) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
 
class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
 
	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
 
	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
 
	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい]
	}
 
	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}
 
		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);
 
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;
 
		return true;
	}
};
 
int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A(M), B(M);
	for (int i = 0; i < M; i++)
	{
		cin >> A[i] >> B[i];
		A[i]--;
		B[i]--;
	}
 
	vector<long long> ans(M);
	ans[M - 1] = (long long)N * (N - 1) / 2;
 
	UnionFind Uni(N);
 
	for (int i = M - 1; i >= 1; i--)
	{
		ans[i - 1] = ans[i];
 
		//繋がってなかったのが繋がった時
		if (Uni.root(A[i]) != Uni.root(B[i])) {
			ans[i - 1] -= (long long)Uni.size(A[i]) * Uni.size(B[i]);
			Uni.connect(A[i], B[i]);
		}
	}
 
	for (int i = 0; i < M; i++)
	{
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 3328
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 2005;
const int K = 10;
int f[N], invf[N], dp[N][N];
int cnt;
map < pair < int, int >, int > mp;
int binpow(int x, int y){
    if (y == 0) return 1;
    if (y % 2) return x * binpow(x, y - 1) % mod;
    int z = binpow(x, y / 2);
    return z * z % mod;
}
int solve(int n, int a, int b, int c, int d){
    if (n == 0) return 1;
    if (a > b) return 0;
    if (n < 0) return 0;
    if (dp[n][a] != -1) return dp[n][a];
    int res = solve(n, a + 1, b, c, d);
    int x = binpow(invf[a], c - 1);
    for (int i = c; i <= d && n - i * a >= 0; i++){
        x = x * invf[a] % mod;
        cnt++;
        res = (res + f[n] * invf[i] % mod * invf[n - i * a] % mod * x % mod * solve(n - a * i, a + 1, b, c, d)) % mod;
    }
     //   cout << n << " " << a << " " << res << " " << x << " " << c << " " << d << endl;
    return dp[n][a] = res;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    f[0] = 1;
    invf[0] = 1;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % mod;
    for (int i = 1; i <= n; i++) invf[i] = binpow(f[i], mod - 2);
    for (int i = 0; i <= n; i++){
        for (int j = 0; j <= n; j++){
            dp[i][j] = -1;
        }
    }
    cout << solve(n, a, b, c, d) << endl;
}


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

int find_step(int cur, int k)
{
	int res = 0;

	while (cur < k)
	{
		cur *= 2;
		res++;
	}

	return res;
}

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

	int n, k, p, ch = 0;

	cin >> n >> k;

	for (int i = 1; i <= n; i++)
	{
		int cur = find_step(i, k);
		int val = n * (1 << cur);

		if (i == 1)
		{
			p = val;
			ch++;
		}
		else
			ch += p / val;
	}

	cout.precision(20);
	cout << ch / (double)p << endl;

	return 0;
}

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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		Map<Character, Integer> hm = new HashMap<>();
		for (int i = 0; i < n; i++) {
			char[] s = sc.next().toCharArray();

			if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H') {
				if (hm.containsKey(s[0])) {
					hm.put(s[0], hm.get(s[0]) + 1);
				} else {
					hm.put(s[0], 1);
				}
			}
		}

		List<Integer> list = new ArrayList<>(hm.values());

//		pr.println(list);
//		pr.flush();

		if (list.size() < 3) {
			pr.println(0);
		} else if (list.size() == 3) {
			long ans = 0;
			ans += (long)list.get(0) * list.get(1) * list.get(2);

			pr.println(ans);
		} else if (list.size() == 4) {
			long ans = 0;
			ans += (long)list.get(0) * list.get(1) * list.get(2);
			ans += (long)list.get(0) * list.get(1) * list.get(3);
			ans += (long)list.get(0) * list.get(2) * list.get(3);
			ans += (long)list.get(1) * list.get(2) * list.get(3);

			pr.println(ans);
		} else {
			long ans = 0;
			ans += (long)list.get(0) * list.get(1) * list.get(2);
			ans += (long)list.get(0) * list.get(1) * list.get(3);
			ans += (long)list.get(0) * list.get(1) * list.get(4);
			ans += (long)list.get(0) * list.get(2) * list.get(3);
			ans += (long)list.get(0) * list.get(2) * list.get(4);
			ans += (long)list.get(0) * list.get(3) * list.get(4);
			ans += (long)list.get(1) * list.get(2) * list.get(3);
			ans += (long)list.get(1) * list.get(2) * list.get(4);
			ans += (long)list.get(1) * list.get(3) * list.get(4);
			ans += (long)list.get(2) * list.get(3) * list.get(4);

			pr.println(ans);

		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


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

void solve() {
  int n, k, q, ans;
  cin >> n >> k >> q;
  vector<int> a(n);
  rep(i,n) a[i] = k - q;
  rep(i, q) {
    cin >> ans;
    a[ans - 1]++;
  }
  rep(i,n) {
    if (a[i] > 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    a[i]--;
  }
  int now=0;
  for(int i=0;i<n;i++){
    now=a[now];
    if(now==1){
      cout<<i+1;
      return 0;
    }
  }
  cout<<-1;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <math.h>
#include <fstream>
#include <string>
#include <time.h>
#include <ctime>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cstdlib>
using namespace std;

void trace(int A[],int N){
	for(int i=0;i<N;i++){
		if(i>0)cout << ' ';
		cout << A[i];
	}
	cout << endl;
}

void bubbleSort(int A[],int N){
	
	bool flag=1;
	int count=0;
	while(flag){
		flag=0;
		for(int j=N-1;j>0;j--){
			if(A[j]<A[j-1]){
				int tmp;
				tmp = A[j];
				A[j] = A[j-1];
				A[j-1] = tmp;
				flag = 1;
				count++;
			}
		}
	}
	trace(A,N);
	cout << count;
	cout << endl;
}

int main(){

	int N;
	int A[100];

	cin >> N;
	for(int i=0;i<N;i++){
		cin >> A[i];
	}
	bubbleSort(A,N);

	return 0;
}

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

int main() {
  ll n;
  cin>>n;
  ll a[200010];
  for (int i=0; i<n; i++) {
    scanf("%lld",a+i);
  }

  ll sum=0;
  ll b[200010];
  for (int i=0; i<n; i++) {
    sum+=a[i];
    b[i]=sum;
  }
  sort(b,b+n);

  ll ans=0;
  ll cnt=0;
  b[n]=1e18;
  for (int i=0; i<n; i++) {
    if (b[i]==0) {
      ans++;
    }
    cnt++;
    if (b[i]!=b[i+1]) {
      ans+=cnt*(cnt-1)/2;
      cnt=0;
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

const int64_t MOD = 1000000007;

int64_t pow(int64_t b, int64_t n) {
  int64_t result = 1;
  while (n != 0) {
    if (n % 2 == 1) {
      result = result * b % MOD;
    }
    n /= 2;
    b = b * b % MOD;
  }
  return result;
}

int main() {
  int64_t n, k;
  cin >> n >> k;
  int64_t dp[k + 1], result = 0;
  for (int64_t a = k; a >= 1; --a) {
    dp[a] = pow(k / a, n);
    for (int64_t b = 2 * a; b <= k; b += a) {
      dp[a] = (dp[a] - dp[b]) % MOD;
    }
    result = (result + a * dp[a]) % MOD;
  }
  cout << (result + MOD) % MOD;
  return 0;
}

Measured memory_bytes: 3932
#include <iostream>

using namespace std;

int n;

bool tansaku(int tt[])
{
	int max = 0;
	for (int i = 0; i < n; i++) {
		max = max > i + tt[i] ? max : i + tt[i];
		if ( max >= n ) {
			return true;
		} else if ( i + 1 > max ) {
			break;
		}
	}
	return false;
}


int main()
{
	int tt1[300000];
	int tt2[300000];
	cin >> n;

	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;

		tt1[i] = t / 10;
		tt2[n - 1 - i] = t / 10;
	}
	if (tansaku(tt1) && tansaku(tt2) ) {
		cout << "yes" << endl;
	} else {
		cout << "no" << endl;
	}
	return 0;
}



Measured memory_bytes: 5436
#include<stdio.h>                                                                                                                           

int main()
{
   int a, b, c, d;
   int mina, minb;

   scanf("%d",&a);
   scanf("%d",&b);
   scanf("%d",&c);
   scanf("%d",&d);

   if(a<b)
      mina = a;
   else
      mina = b;

   if(c<d)
      minb = c;
   else
      minb = d;

   printf("\n%d\n",mina + minb);

   return 0;
}

Measured memory_bytes: 128
'use strict';
(function(stdin) {
  var param = stdin.split(' ').map(Number);
  var result = (function(a,b) {
     
    if (a < b) {
        return 'a < b';
    } else if (a > b) {
        return 'a > b';
    } else {
        return 'a == b';
    }
 
  }(
    param[0],param[1]
  ));
  console.log(result);
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7380
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<set>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define INF 1000000100
#define rep(i,n) for (int i=0;i<n;i++)

int main(){
    string s,t;
    cin >> s >> t;
    int sum=0;
    rep(i,3){
        if(s[i]==t[i]) sum+=1;
    }
    cout << sum << endl;
    return 0;
}

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

int N;
vector<ll> a;
const int MAX_N = 3010;
ll dp[MAX_N][MAX_N]; //  dp[l][r] := [l, r)で最適に行動した時の先手 - 後手
bool used[MAX_N][MAX_N];

ll rec(int l, int r){
    if(r - l == 1) return dp[l][r] = a[l];
    if(used[l][r]) return dp[l][r];
    
    used[l][r] = true;

    return dp[l][r] = max( a[r-1] - rec(l, r-1), a[l] - rec(l+1, r));

}

int main(){
    cin >> N;
    a.resize(N);
    for(int i = 0 ; i < N; i++) cin >> a[i];

    cout << rec(0, N) << endl;
}

Measured memory_bytes: 78464
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)

ll H,W,L,p;
P dots[100000];
bool grid[4000][4000];
int u[4000][4000],b[4000][4000];
int t[4000][4000];
ll ans=0;
ll U[4000],B[4000];
ll bit[4001];

ll sum(ll i){
	i++;
	ll res=0;
	while(i>0){
		res+=bit[i];
		i-=(i&-i);
	}
	return res;
}

void add(ll i,ll x){
	i++;
	while(i<=4000){
		bit[i]+=x;
		i+=(i&-i);
	}
	return;
}
//U  B
priority_queue<P,vector<P>,greater<P> > q;//(????????§??¨????????????????????????id???)
void calc(ll n){
	memset(bit,0,sizeof(bit));
	//rep(i,n) cout<<U[i]<<" ";
	//cout<<endl;
	//rep(i,n) cout<<B[i]<<" ";
	//cout<<endl;
	while(!q.empty()) q.pop();
	rep(i,n){
		if(i>=L-1){
			if(U[i-L+1]==-1||U[i-L+1]<L-1) goto nex;
			add(0,1);
			add(i-L+1+1,-1);
			q.push(P(i-L+1+U[i-L+1],i-L+1));
		}
		nex: ;
		if(B[i]>=L-1){
			ans+=sum(i-B[i]);
		}
		while(q.size()&&q.top().fr==i){
			P x=q.top();
			q.pop();
			add(0,-1);
			add(x.sc+1,1);
		}
	}
	return;
}

int main()
{
	cin>>H>>W>>L>>p;
	rep(i,p){
		cin>>dots[i].fr>>dots[i].sc;
		dots[i].fr--;
		dots[i].sc--;
		grid[dots[i].fr][dots[i].sc]=1;
	}
	rep(i,H) rrep(j,W){
		if(grid[i][j]) u[i][j]=-1;
		else if(j==W-1) u[i][j]=0;
		else u[i][j]=u[i][j+1]+1;
	}
	rep(j,W) rrep(i,H){
		if(grid[i][j]) t[i][j]=-1;
		else if(i==H-1) t[i][j]=0;
		else t[i][j]=t[i+1][j]+1;
	}
	rep(i,H) rep(j,W){
		u[i][j]=min(t[i][j],u[i][j]);
	}
	
	rep(i,H) rep(j,W){
		if(grid[i][j]) b[i][j]=-1;
		else if(j==0) b[i][j]=0;
		else b[i][j]=b[i][j-1]+1;
	}
	rep(j,W) rep(i,H){
		if(grid[i][j]) t[i][j]=-1;
		else if(i==0) t[i][j]=0;
		else t[i][j]=t[i-1][j]+1;
	}
	rep(i,H) rep(j,W){
		b[i][j]=min(t[i][j],b[i][j]);
	}
	/*cout<<endl;
	rep(i,H){
		rep(j,W){
			cout<<grid[i][j]<<" ";
		}
		cout<<endl;
	}
	cout<<endl;
	
	rep(i,H){
		rep(j,W){
			cout<<u[i][j]<<" ";
		}
		cout<<endl;
	}
	cout<<endl;
	
	rep(i,H){
		rep(j,W){
			cout<<b[i][j]<<" ";
		}
		cout<<endl;
	}
	*/
	rep(j,W){
		for(ll k=0;k<min(H,W-j);k++){
			U[k]=u[k][j+k];
			B[k]=b[k][j+k];
		}
		calc(min(H,W-j));
	}
	rep1(i,H-1){
		for(ll k=0;k<min(W,H-i);k++){
			U[k]=u[i+k][k];
			B[k]=b[i+k][k];
		}
		calc(min(W,H-i));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 206684
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    tree = [[] for _ in range(4)]
    for _ in range(3):
        a, b = map(int, input().split())
        tree[a - 1].append(b - 1)
        tree[b - 1].append(a - 1)

    def dfs(v, p):
        for u in tree[v]:
            if u == p:
                continue
            elif visited[u]:
                return
            else:
                visited[u] = True
                dfs(u, v)
                return

    visited = [False] * 4
    visited[0] = True
    dfs(0, -1)
    print("YES" if visited.count(True) == 4 else "NO")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
H, W, D = map(int, input().split())
M = H * W
A = [list(map(int, input().split())) for i in range(H)]

a_to_ij = {}
for i, aa in enumerate(A):
  for j, a in enumerate(aa):
    a_to_ij[a] = (i, j)

cost = {}
def calc_cost(s):
  global cost
  t = s
  pre_i, pre_j = a_to_ij[s]
  c = cost[s] = 0
  while t + D <= M:
    t += D
    i, j = a_to_ij[t]
    c += abs(i-pre_i) + abs(j-pre_j)
    cost[t] = c
    pre_i, pre_j = i, j

for n in range(1, D+1):
  calc_cost(n)

ans = []
Q = int(input())
for i in range(Q):
  L, R = map(int, input().split())
  ans.append(cost[R] - cost[L])

print(*ans, sep='\n')

Measured memory_bytes: 37516
S = str(input())
T = str(input())

s, t = len(S), len(T)
diff = [0 for i in range(s-t+1)]
for i in range(s-t+1):
  target = S[i:i+t]
  for j in range(t):
    if target[j] != T[j]:
      diff[i] += 1
  j = 0
print(min(diff))

Measured memory_bytes: 8944
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>

template <class Integer>
auto boost_irange(Integer last) { return boost::irange(static_cast<Integer>(0), last); }
template <class Integer>
auto boost_irange(Integer first, Integer last) { return boost::irange(first, last); }

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << '\n'; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << ' ' << val;
            return *this;
        }
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val;
        return {};
    }
};

int main()
{
    input in;
    output out;

    int N = in.read<int>();

    int res = 0;
    for (int d = 1; d <= N; d *= 100) {
        if (N < d * 10) {
            res += N - d + 1;
        } else {
            res += 9 * d;
        }
    }

    out << res;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> h(n);
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    int ans=0;
    int suc=0;
    for(int i=0;i<n-1;i++){
        if(h[i]>=h[i+1]){
            suc++;
        }
        else{
            ans=max(ans,suc);
            suc=0;
        }
    }
    ans=max(ans,suc);
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define P pair<ll, ll>
using namespace std;

ll mod = 1e9 + 7;

int main(){
    vector<vector<ll>> vec(10, vector<ll>(10));
    for(int j=0;j<10;j++) vec[0][j] = 1;
    for(int i=1;i<10;i++){
        for(int j=0;j<10;j++){
            if(j==0) vec[i][j] = vec[i-1][j] + vec[i-1][j+1];
            else if(j==9) vec[i][j] = vec[i-1][j] + vec[i-1][j-1];
            else vec[i][j] = vec[i-1][j-1] + vec[i-1][j] + vec[i-1][j+1];
        }
    }

    /*for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            cout << vec[i][j] << " ";
        }cout<< endl;
    }*/


    int k;
    cin >> k;
    vector<ll>ans;
    ll sum = 0;
    int i, j;
    bool end = false;
    for(i=0;i<10;i++){
        for(j=0;j<10;j++){
            if(i != 0 && j == 0) continue;
            if(sum + vec[i][j] <= k) sum += vec[i][j];
            else{
                end = true;
                break;
            }
        }
        if(end) break;
    }
    ans.push_back(j);
    while(i > 0){
        if(j > 0){  
            if(k < sum + vec[i-1][j-1]){
                j--;
            }else if(k < sum + vec[i-1][j-1] + vec[i-1][j]){
                sum += vec[i-1][j-1];
            }else{
                sum += vec[i-1][j-1] + vec[i-1][j];
                j++;
            }
        }else{
            if(k < sum + vec[i-1][j]){
            }else{
                sum += vec[i-1][j];
                j++;
            }
        }
        i--;
        ans.push_back(j);
    }
    
    for(auto v:ans) cout << v;
    cout << endl;
}

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

ll ksm(ll a,ll b)
{
    ll ans=1;
    for(; b; b>>=1,a=a*a%mod) if(b&1) ans=ans*a%mod;
    return ans%mod;
}
int main()
{
    ll n;cin>>n;
    ll ans=(ksm(10,n)-ksm(9,n)-ksm(9,n)+ksm(8,n))%mod;
    cout<<(ans+mod)%mod;

    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;

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

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  int c = max(a,b);
  int d = min(a,b);
  int g = gcd(c, d);
  int ans;
  int cnt = 0;
  for (int i = g; i >= 1; i--) {
    if (g % i == 0) cnt++;
    if (cnt == k) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;

  // cout << gcd(12, 16) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n,a,i,j;
	long min,max,sum=0;
	scanf("%d",&n);
	if(0<n && n<=10000){
		for(i=0,j=0;i<n;i++){
			scanf("%d",&a);
			if(-1000000 <= a && a<=1000000){
				if(j==0){
					min=max=a;
				}
				if(min>a) min=a;
				if(max<a) max=a;
				sum+=a;
				j++;
			}
		}
		
		printf("%ld %ld %ld\n",min,max,sum);
	}
	return 0;
}

Measured memory_bytes: 600
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int n, m;
  cin >> n >> m;
  ll a[n], b[n], c[m], d[m], x[n];
  for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
  for (int i = 0; i < m; i++) cin >> c[i] >> d[i];
  for (int i = 0; i < n; i++) {
    ll min = 999999999;
    for (int j = 0; j < m; j++) {
      ll distance = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if (distance < min) {
        x[i] = j + 1;
        min = distance;
      }
    }
  }
  for (int i = 0; i < n; i++) cout << x[i] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
 
int main() {
  
  int X,Y,A,B,C;
  cin >> X >> Y >> A >> B >> C;

  vector<long long> p(A),q(B),r(C);
  for(int i = 0;i < A;i++) cin >> p[i];
  for(int i = 0;i < B;i++) cin >> q[i];
  for(int i = 0;i < C;i++) cin >> r[i];

  sort(p.rbegin(),p.rend());
  sort(q.rbegin(),q.rend());
  
  priority_queue<long long> pq;
  for(int i = 0;i < X;i++) pq.push(p[i]);
  for(int i = 0;i < Y;i++) pq.push(q[i]);
  for(int i = 0;i < C;i++) pq.push(r[i]);

  long long sum = 0;
  for(int i = 0;i < X+Y;i++) {
    sum += pq.top();
    pq.pop();
  }

  cout << sum << endl;

  
}


Measured memory_bytes: 8560
n = int(input())
a = list(map(int,input().split()))
cnt1 = {}
cnt2 = {}
for i in range(n):
    x = a[i] + i
    y = i- a[i]
    if x not in cnt1:cnt1[x] = 1
    else:cnt1[x] += 1
    if y not in cnt2:cnt2[y] = 1
    else:cnt2[y] += 1
ans = 0
for num in cnt1:
    if num not in cnt2:continue
    x = cnt2[num]
    ans += x*cnt1[num]
for num in cnt2:
    if num not in cnt1:continue
    x = cnt1[num]
    ans += x*cnt2[num]
ans //= 2
print(ans)

    

Measured memory_bytes: 56768
#include <iostream>
#include <numeric>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
using namespace std;

int main() {
    int N;
    cin >> N;
    int a[N], inc_2[N] = {0};
    REP(i, N) cin >> a[i];

    REP(i, N) {
        while(!(a[i]%2)) {
            inc_2[i]++;
            a[i] /= 2;
        }
    }

    int sum = 0;
    REP(i, N) sum += inc_2[i];

    cout << sum << "\n";

}

Measured memory_bytes: 384