akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
    #include<string>
    #include<vector>
    #include<math.h>
    #include<cmath>
    #include<stack>
    #include <algorithm>
    #include <functional>
    //#include<stdlib.h>
    using namespace std;
    int main() {
    	int n, m;
    	cin >> n >> m;
    	vector<vector<bool>>a(2, vector<bool>(m,false));
    	for (int i = 0; i < m; i++)
    	{
    		a[0][i] = true;
    	}
    	for (int i = 0; i < n; i++)
    	{
    		int k,t;
    		cin >> k;
    		for (int j = 0; j < k; j++)
    		{
    			cin >> t;
    			a[1][t-1] = true;
    		}
    		for (int j = 0; j < m; j++)
    		{
    			if (!a[1][j]) { a[0][j] = false; }
    			a[1][j] = false;
    		}
    	}
    	n = 0;
    	for (int j = 0; j < m; j++)
    	{
    		if (a[0][j]) { n++; }
    	}
    	cout << n;
    	return 0;
    }

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<cmath>
#include<cstdio>
#include<cassert>

using namespace std;

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double INF = 0x3f3f3f3f;
const double INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
const double mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int N, K;
int H[100010];
int dp[100010];

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    cin >> N >> K;
    rep(i,N) cin >> H[i];
    rep(i,N) dp[i] = INF;
    dp[0] = 0;
    REP(i,1,N){
        REP(k,1,K+1){
            if(i-k >= 0) dp[i] = min(dp[i], dp[i-k]+abs(H[i]-H[i-k]));
        }
    }
    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#define LEN 100005


typedef struct pp{

	char name[100];

	int t;

}	P;


P Q[LEN];

int head, tail, n;


void enqueue( P x){

	Q[tail] = x;

	tail = ( tail + 1) % LEN;

}

P dequeue(){

	P x = Q[head];

	head = ( head + 1) % LEN;

	return x;

}


int min( int a, int b){ return a < b ? a: b; }


int main(){

	int elaps = 0, c;

	int i, q;

	P u;

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

	for( i = 1; i <= n; i++){

		scanf( "%s", Q[i].name);

		scanf( "%d", &Q[i].t);

	}

	head = 1; tail = n + 1;


	while( head != tail){

		u = dequeue();

		c = min( q, u.t); 

		u.t -= c;

		elaps += c;

		if ( u.t > 0) enqueue(u);

		else{

			printf( "%s %d\n", u.name, elaps);

		}

	}

	return 0;

}

Measured memory_bytes: 11184
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
signed main() {
    int X,N;
    cin >> X >> N;
    vector<int>p(N);
    for(int i = 0; i < N; i++) {
        cin >> p[i];
    }
    for(int i = 0; i < 120; i++) {
        int X2 = X-i;
        int Y = X+i;
        bool ok1 = true;
        bool ok2 = true;
        for(int i = 0; i < N; i++) {
            if(X2 == p[i]) {
                ok1 = false;
            }
            if(Y == p[i]) {
                ok2 = false;
            }
        }
        if(ok1) {
            cout << X2 << endl;
            return 0;
        }
        if(ok2) {
            cout << Y << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3628
import java.util.*;

public class Main {
    private static int MAX_WEIGHT = 1000000000;

    private static long solve(int N, int W, int[] w, int[] v) {
        HashMap<Integer, Long> maxValue = new HashMap<>();
        HashMap<Integer, Long> candidateMaxValue = new HashMap<>();

        long max = 0;

        for (int k = 0; k < N; k++) {
            if (w[k] > W) continue;

            candidateMaxValue.clear();
            candidateMaxValue.put(w[k], (long)v[k]);

            for (Map.Entry<Integer, Long> entry: maxValue.entrySet()) {
                int newWeight = entry.getKey() + w[k];
                if (newWeight > W) continue;

                candidateMaxValue.put(newWeight, entry.getValue() + v[k]);
            }

            for (Map.Entry<Integer, Long> entry: candidateMaxValue.entrySet()) {
                int weight = entry.getKey();
                long value = entry.getValue();

                Long currentValue = maxValue.get(weight);
                if (currentValue == null || value > currentValue) {
                    maxValue.put(weight, value);
                    max = Math.max(max, value);
                }
            }
        }

        return max;
    }

    public static void main(String[] args) {
        int N, W;
        int[] w;
        int[] v;
        try (Scanner scanner = new Scanner(System.in)) {
            N = scanner.nextInt();
            W = scanner.nextInt();

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

        long result = solve(N, W, w, v);
        System.out.println(result);

//        test();
    }

    private static void test() {
        testCase(3, 8, new int[] {3, 4, 5}, new int[] {30, 50, 60}, 90);
        testCase(1, 1000000000, new int[] { 1000000000 }, new int[] { 10 }, 10);
        testCase(5, 5, new int[] { 1, 1, 1, 1, 1}, new int[] {1000000000,1000000000,1000000000,1000000000,1000000000}, 5000000000L);
        testCase(6, 15, new int[] {6,5,6,6,3,7}, new int[] {5,6,4,6,5,2}, 17);

        timingTest(100);

        System.out.println("DONE");
    }

    private static void timingTest(int size) {
        int[] w = new int[size];
        int[] v = new int[size];
        for (int i=0; i < size; i++) {
            w[i] = Math.min(i*i, MAX_WEIGHT);
            v[i] = i;
        }

        long start = System.currentTimeMillis();
        solve(size, Math.min(100*size*size, MAX_WEIGHT), w, v);
        long elapsed = System.currentTimeMillis() - start;
        System.out.println("timing size=" + size + " elapsed=" + elapsed);
    }

    private static void testCase(int N, int W, int[] w, int[] v, long expected) {
        long result = solve(N, W, w, v);
        if (result != expected) {
            System.out.println("FAILED N=" + N + " W=" + W + " w=" + Arrays.toString(w) + " v=" + Arrays.toString(v)
                    + ", was " + result + " expected " + expected);
        }
    }
}


Measured memory_bytes: 301800
n, m = map(int, input().split())
h = list(map(int, input().split()))

good = [1]*n

for _ in range(m):
    i, j = map(int, input().split())
    if h[i-1] == h[j-1]:
        good[i-1] = 0
        good[j-1] = 0
    elif h[i-1] > h[j-1]:
        good[j-1] = 0
    elif h[i-1] < h[j-1]:
        good[i-1] = 0
print(sum(good))

Measured memory_bytes: 20124
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

using namespace std;
using ll = long long;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI = acos(-1.0);

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

int main() {
    int A, B; cin >> A >> B;

    int ans = 0;

    if (A > B) {
        ans = 2 * A - 1;
    } else if (A < B) {
        ans = 2 * B - 1;
    } else {
        ans = A + B;
    }

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


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

int a,b;

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

int main(){
	while(scanf("%d%d",&a,&b)!=EOF){
		if(a>b)swap(a,b);
		int ans=GCD(a,b);
		printf("%d %d\n",ans,b/ans*a);
	}
}


Measured memory_bytes: 2692
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=1;i<=n;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define foreach(i,c) for(__typeof(c.begin())i=c.begin();i!=(c).end();i++)
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
using namespace std;
int cnt[100010];
vector<int> gr[100010];
int L[100010];
int n;
int P[100010];
void dfs(int v){
	cnt[v]=1;
	REP(i,gr[v].size()){
		int u=gr[v][i];
		if(P[v]==u)continue;
		L[u]=L[v]+1;
		P[u]=v;
		dfs(gr[v][i]);
		cnt[v]+=cnt[u];
	}
}
int a[100010],b[100010];
int main(){
	cin>>n;
	REP(i,n-1){
		cin>>a[i]>>b[i];
		gr[a[i]].push_back(b[i]);
		gr[b[i]].push_back(a[i]);
	}
	dfs(1);
	int up=(L[n]-1)/2;
	int v=n;
	while(up--)v=P[v];
	if(cnt[v]>=n-cnt[v])cout<<"Snuke"<<endl;
	else cout<<"Fennec"<<endl;
	return 0;
}

Measured memory_bytes: 13952
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>pii;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7; constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;

void y(bool c) {
	if (c)print("Yes");
	else print("No");
}
void solve() {
	int X, Y, Z;
	cin >> X >> Y >> Z;
	pe(Z); pe(X); print(Y);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}




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

int main() {
	int N, X;
	for (int a = 0; ; a++) {
		cin >> N >> X;
		if (N == 0 && X == 0) break;
		int count = 0;
		for (int i = 1; i <= N; i++) {
			for (int j = i + 1; j <= N; j++) {
				int k = X - i - j;
				if (j < k && k <= N) count++;
			}
		}
		cout << count << endl;
	}
}


Measured memory_bytes: 3116
H, W = map(int, input().split())
S = [list(input()) for i in range(H)]

board = [[0] * W for i in range(H)]

if S[0][0] == '#':
    board[0][0] = 1

for i in range(1, W):
    if S[0][i - 1] == '.' and S[0][i] == '#':
        board[0][i] = board[0][i - 1] + 1
    else:
        board[0][i] = board[0][i - 1]

for i in range(1, H):
    if S[i - 1][0] == '.' and S[i][0] == '#':
        board[i][0] = board[i - 1][0] + 1
    else:
        board[i][0] = board[i - 1][0]

for i in range(1, H):
    for j in range(1, W):
        if S[i][j] == '.':
            board[i][j] = min(board[i - 1][j], board[i][j - 1])
        else:
            if S[i - 1][j] == '.':
                up = 1
            else:
                up = 0
            if S[i][j - 1] == '.':
                left = 1
            else:
                left = 0
            board[i][j] = min(board[i - 1][j] + up, board[i][j - 1] + left)

print(board[H - 1][W - 1])


Measured memory_bytes: 3316
import java.util.Scanner

object Main {
	def main(args: Array[String]): Unit = {
	  val sc = new Scanner(System.in)
	  var list  = new Array[Int](31);
	  for(i <- 1 to 28){
	    list(sc.nextInt) = 1
	  }
	  for(i <- 1 to 30){
	    if( list(i) == 0){
	      println(i);
	    }
	  }
	}

}

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

using namespace std;

char a[100000];
int b[100000];
int n;

int main() {
  cin>>n;
  cin>>a;
  int s=strlen(a);
  for(int i=0;i<s;i++)
      b[i]=a[i];
  for(int i=0;i<s;i++)
  {    b[i]=b[i]+n;
      if(b[i]>90)
          b[i]=b[i]%90+64;
  }
  for(int i=0;i<s;i++)
  {    a[i]=b[i];
     cout<<a[i];
  }

    return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left
q = int(input())
for _ in [0]*q:
    s1, s2 = input(), input()
    l1, l2 = len(s1), len(s2)

    p = []
    for i, c in enumerate(s1):
        s = 0
        while True:
            j = s2[s:].find(c)
            if j == -1:
                break
            p.append((i, s+j))
            s += j+1

    lis = []
    for _, y in sorted(p, key=lambda x: (x[0], -x[1])):
        i = bisect_left(lis, y)
        if len(lis) <= i:
            lis.append(y)
        else:
            lis[i] = y
    print(len(lis))


Measured memory_bytes: 216100
# なるべく根本に近いところで枝分かれさせたい。
# 根から葉に向かって考えると「ここで枝分かれするべきか?」の答えがその先（つまりもっと葉側）を読まなければいけないので厄介
# だが実はそれは「その先の葉の個数の合計」だけ見れば良い。できそう。
# 葉から根に向かって考えると「ここで枝を統合するべきか?」の答えがその先（つまりもっと根側）を読まなければいけないので厄介
# これは根本近くのどの位置に数字があるかに依存して変わるから難しい。
# 根から考えるのが良さそう。

n = int(input())
nums = list(map(int, input().split()))

# コーナーケース先に潰しておこう
if n == 0:
    if nums[0] == 1:
        print(1)
    else:
        print(-1)
    exit()
if n > 0 and nums[0] >= 1:
    print(-1)
    exit()

# 根から葉に向かう

rest = sum(nums)

n_node = 1
ans = 1
for i in range(1, n+1):
    # なるべく根本に近いところで枝分かれさせたい。
    # 「ここで枝分かれするべきか?」→基本的にはそう。しかしその先の葉の合計を超えてはいけない。
    n_node = min(n_node * 2, rest)
    ans += n_node

    # 葉を引く
    n_node -= nums[i]
    rest -= nums[i]

    # 負ならダメ 0 0 5とか
    if n_node < 0:
        print(-1)
        exit()
    # 最後ではないのに0になったらダメ 0 0 4 1とか
    if n_node == 0 and i < n:
        print(-1)
        exit()

print(ans)


Measured memory_bytes: 20136
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let n: usize = read();
    let s: Vec<char> = read::<String>().chars().collect();

    let mut R = vec![];
    let mut G = vec![];
    let mut B = vec![];

    for i in 0..n {
      if s[i] == 'R' {
        R.push(i);
      } else if s[i] == 'G' {
        G.push(i);
      } else {
        B.push(i);
      }
    }
    let v = vec![R, G, B];
    let mut ans: usize = 0;
    // (R, G, B)

    let patern = vec![(0, 1, 2), (0, 2, 1), (1, 0, 2), (1, 2, 0), (2, 0, 1), (2, 1, 0)];
    // for i in 0..3 {
    //   println!("{:?}", v[i]);
    // }
    for (a, b, c) in patern {
      for i in &v[a] {
        for k in &v[b] {
          if i >= k {
            continue;
          }

          let lb = match v[c].binary_search(&i) {
              Ok(x) => x,
              Err(x) => x,
          };
          let ub = match v[c].binary_search(&k) {
              Ok(y) => y,
              Err(y) => y,
          };
          ans += ub - lb;
          let x = i+k;
           match v[c].binary_search_by(|probe| (2 * probe).cmp(&x)) {
              Ok(num) => ans -= 1,
              Err(num)  => ans += 0,
          }
        }
      }
    }


    println!("{}", ans);
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define all(v) (v).begin(),(v).end()
#define mod 1e9+7

using namespace std;
using vi = vector<int>;
using vl = vector<long>;
using P = pair<int,int>;

main()
{
        vi v(3);
        rep(i,3)cin>>v[i];
        sort(all(v));
        cout<<v[0]+v[1]<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	static class FastReader{
		BufferedReader br ;
		StringTokenizer st;
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {
			while(st==null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch(IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}
	public static void main(String[] args) {
		FastReader ob = new FastReader();
		int h = ob.nextInt();
		int w = ob.nextInt();
		int n = ob.nextInt();
		int sum=0;
		int count=0;
		while(sum<n) {
			sum+=Math.max(h, w);
			count++;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 23124
n,k=map(int,input().split())
ans=0
for b in range(k+1,n+1):
  res=(n-k)%b
  quo=(n-k)//b
  if b-k-1>res:
    #ans+=(res+1)*(quo+1)+(b-k-res-1)*quo
    ans+=(b-k)*quo+res+1
  else:
    ans+=(b-k)*(quo+1)
  ans-=(k==0)
    
print(ans)

#n-k-j>=b*r  j=0,...,b-k-1

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

int main(){
  set<string> p;
  int n;
  cin >> n;
  for (int i=0;i<n;++i){
    string s;
    cin >> s;
    p.insert(s);
  }
  cout << p.size() << endl;
}


Measured memory_bytes: 19224
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
fac = [-1] * (10**7+1)
inv = [-1] * (10**7+1)
finv = [-1] * (10**7+1)

fac[0] = fac[1] = 1
inv[1] = 1
finv[0] = finv[1] = 1

def initNCMMod(limit):
    for i in range(2, limit):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod // i) % mod
        finv[i] = finv[i-1] * inv[i] % mod

def NCMMod(n, k):
    if n < k:
        return 0
    if (n < 0 or k < 0):
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod
initNCMMod(1000)
def main():
    N, M = LI()
    print(NCMMod(N, 2) + NCMMod(M, 2))


main()



Measured memory_bytes: 282880
N=gets.to_i;v=$<.map{|e|Complex(*e.split.map(&:to_i))};h={};r=2**N+~N;[*0...N].combination(2){|i,j|h[x=[i,j]]||((j+1...N).map{|k|((v[j]-v[k]).conj*(v[i]-v[k])).imag.abs<1e-9&&x<<k};r-=2**(l=x.size)+~l;x.combination(2){|e|h[e]=1})};p r%998244353

Measured memory_bytes: 7036
A, B, H, M = gets.split.map(&:to_i)
PI = Math::PI

H_angle = H / 12.0 + (M / 60.0) / 12.0
M_angle = M / 60.0
Angle = ((M_angle - H_angle).abs) * PI * 2

puts Math.sqrt((A ** 2 + B ** 2) - (2 * A * B) * Math.cos(Angle))

Measured memory_bytes: 14632
#include<cstdio>
int main() {
   int a,b,c,d,e;
   d = 0, e = 0;
   scanf("%d %d %d",&a,&b,&c);
   for(int i = 1;i <= c;i++){
       if(c % i == 0 && i >= a){
           for(int d = a;d <= b;d++){
               if(d % i == 0){
                   e = e + 1;
                   break;
               }
           }
       }
   }
   printf("%d\n",e);

return 0;
}


Measured memory_bytes: 2740
#include<stdio.h>
#define MAX 5000000
int size, A[MAX+1];
void maxHeapify(int i){
  int l, r, larg, t;
  l = 2*i;
  r = 2*i+1;
  if(l<=size && A[l] > A[i]) larg=l;
  else                     larg=i;
  if(r<=size && A[r]> A [larg])    larg=r;
  if(larg!=i){
    t = A[i];
    A[i] = A[larg];
    A[larg]=t;
    maxHeapify(larg);
  }
}

int main(){
  scanf("%d", &size);
  int i;
  for(i=1; i<=size; i++)    scanf("%d",&A[i]);
  for(i=size/2; i>=1; i--)  maxHeapify(i);
  for(i=1; i<=size; i++){
    printf(" %d", A[i]);
  }
  printf("\n");
}



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

typedef long long ll;
ll n, m, a, b;
ll M = 1e9 + 7;
int main()
{
	ll i, t1, t2;
	cin >> n >> m;
	n--, m--;
	cin >> t2;
	for (i = 1; n; i++, n--) {
		scanf("%lld", &t1);
		a = (a + i * n * (t1 - t2) % M) % M;
		t2 = t1;
	}
	cin >> t2;
	for (i = 1; m; i++, m--) {
		scanf("%lld", &t1);
		b = (b + i * m * (t1 - t2) % M) % M;
		t2 = t1;
	}
    cout << a * b % M << endl;
    return 0;
}

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

ll a(ll n) {
  // even
  if(n % 2 == 1) {
    return n * 2;
  }
  return n;
}

int main() {
  ll n;
  cin >> n;
  cout << a(n);
}

Measured memory_bytes: 3592
o[1<<17];e[1<<17];i;f;s;g;t;main(a,b){for(;~scanf("%d",&a);)i++?i%2?b=++e[a],b>e[f]?s=f,f=a:b>e[s]&&f-a?s=a:0:(b=++o[a],b>o[g]?t=g,g=a:b>o[t]&&g-a?t=a:0):0;printf("%.f",i-1-(f-g?e[f]+o[g]:fmax(e[f]+o[t],e[s]+o[g])));}

Measured memory_bytes: 896
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
  
int main()
{
	int n;
	scanf("%d", &n);
	int a[100];
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
	}
	vector<int> v;
	int i1=0, i2=1;
	for(int i=0; i<n-1; i++){
		if(a[i]!=a[i+1]){
			v.push_back(i2-i1);
			i1=i2;
			i2++;
		}else{
			i2++;
		}
	}
	v.push_back(i2-i1);
	int ans=0;
	for(int i=0; i<v.size(); i++){
		ans+=(v[i]/2);
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1e5+100;
typedef pair<int,int>PII;
int vis[maxn],cnt[maxn];
int fa[maxn],sz[maxn],deg[maxn];
int get(int x)
{
    return x==fa[x]?x:fa[x] =get(fa[x]);
}
void Union(int x,int y)
{
    int xx = get(x);
    int yy = get(y);
    if(xx==yy) return ;
    fa[yy]=xx;
    sz[xx]+=sz[yy];
    return ;
}
int main()
{
    int n,m,k;
    int u,v;
    cin >> n >> m >> k;
    for(int i  =1;i<=n;++i)
    {
        fa[i] =i;
        sz[i] = 1;
    }
    for(int i =1;i<=m;++i)
    {
        cin >>u >>v;
        deg[u]++;
        deg[v]++;
        Union(u,v);
    }
    for(int i = 1;i<=k;++i)
    {
        cin >>u >>v;
        if(get(u)==get(v))
        {
            deg[u]++;
            deg[v]++;
        }
    }
    for(int i = 1;i<=n;++i)
    {
        cout << sz[get(i)]-deg[i]-1 << " ";
    }
    return 0;
}


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

int factorial(int n)
{
    if (n <= 1)
        return 1;

    return n * factorial(n - 1);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int length;
    cin >> length;
    int a[length];
    for (int i = 0; i < length; i++)
    {
        cin >> a[i];
        // if (repeating.find(a[i]) != repeating.end())
        //     repeating[a[i]]++;
        // else
        //     repeating[a[i]] = 1;
    }
    // int first = factorial(length);
    // int second = factorial(length - 3);
    // int third = factorial(3);
    // int fact = first / (second * third);
    // for (auto i : repeating)
    // {
    //     if (i.second >= 2)
    //         fact = fact / factorial(i.second);
    // }

    //cout << fact << endl;
    int count = 0;
    for (int i = 0; i < length; i++)
    {
        for (int j = i + 1; j < length; j++)
        {
            if (a[i] != a[j])
                for (int k = j + 1; k < length; k++)
                {
                    if (a[i] == a[k] || a[j] == a[k])
                    {
                        continue;
                    }
                    else
                    {
                        if (a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[k] + a[j] > a[i])
                        {
                            count++;
                        }
                    }
                }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3628
# coding: utf-8

S = input()

flag = True

for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "L":
            flag = False
            break
    else:
        if S[i] == "R":
            flag = False
            break

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

	int sum = 0;
	for(int i = 0; i < 4; i++){
		int tmp;
		cin >> tmp;
		sum += tmp;
	}

	cout << sum / 60 << endl;
	cout << sum % 60 << endl;

	int x;
	cin >> x;

	return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) throws Exception{
        // TODO ?????????????????????????????????????????????
        String str[], ans;
        int a, b;
        int d, r;
        String f;
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        str = br.readLine().split(" ");
        a = Integer.parseInt(str[0]);
        b = Integer.parseInt(str[1]);
 
        d = a / b;
        r = a % b;
        f = String.format("%.5f", ((double)a / (double)b));
        System.out.println(d + " " + r + " " + f);
 
    }
 
}

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

int main()
{
	int d, width;
	int s = 0;
	
	
	while(cin >> d){

		width = d;

		while(d<600){
			s += width * (d*d);

			d += width;
		}
		
		cout << s << endl;
		s = 0;
	}
	return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin>>s;
    int N=s.size();
    
    int mx=N;
    char s1=s[0];
    int lens1=1,lens2=N-1;
    
    rep1(i,N-1){
        if(s1!=s[i]){
            chmin(mx,max(lens1,lens2));
            s1=s[i];
        }
        lens1++,lens2--;
    }
    cout1(mx)
}

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

int main() {
	long long n, m; cin >> n >> m;
	long long ans;
	if (n*2 >= m) {
		ans = m / 2;
		m -= m;
	}
	else {
		ans = n;
		m -= n * 2;
	}
	if (m >= 4)ans += m / 4;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
/************************************************
* Author        :RunningTime
* Created Time  :2017/4/29 20:12:32
* File Name     :C.cpp
 ************************************************/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int N = 2e5 + 5;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
ll t[N];
int n, T;

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> T;
    ll ans = 0, ed = 0;
    for (int i=1; i<=n; ++i) {
        cin >> t[i];
        if (t[i] <= ed) {
            ans += t[i] - t[i-1];
        } else {
            ans += ed - t[i-1];
        }
        ed = t[i] + T;
    }
    if (ed >= t[n]) ans += ed - t[n];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
A = []
for i in range(3):
    Ai = [int(x) for x in input().split()]
    A.append(Ai)

N = int(input())

B = []
for i in range(N):
    b = int(input())
    B.append(b)

for i in range(3):
    for j in range(3):

        if A[i][j] in B:
            A[i][j] = -1
Bingo = [
    [[0, 0], [0, 1], [0, 2]],
    [[1, 0], [1, 1], [1, 2]],
    [[2, 0], [2, 1], [2, 2]],
    [[0, 0], [1, 0], [2, 0]],
    [[0, 1], [1, 1], [2, 1]],
    [[0, 2], [1, 2], [2, 2]],
    [[0, 0], [1, 1], [2, 2]],
    [[0, 2], [1, 1], [2, 0]],
]

result = False
for bingo in Bingo:
    count = 0
    for i, j in bingo:
        if A[i][j] == -1:
            count += 1

    if count == 3:
        result = True

if result:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38256
function Main(input) {
    var firstLine = input[0].split(/\s/);
    var N = parseInt(firstLine[0], 10);
    var M = parseInt(firstLine[1], 10);
    var PS = input.slice(1).map(ps => {
        var psArray = ps.split(/\s/);
        psArray[0] = parseInt(psArray[0], 10);
        return psArray;
    });

    var ACList = new Array(N);
    ACList.fill(0);
    var WAList = new Array(N);
    WAList.fill(0);

    for (var i = 0; i < M; i++) {
        if (ACList[PS[i][0] - 1] === 0) {
            if (PS[i][1] === 'AC') {
                ACList[PS[i][0] - 1] = 1;
            } else {
                WAList[[PS[i][0] - 1]]++;
            }
        }
    }

    var AC = 0;
    var WA = 0;
    for (var i = 0; i < ACList.length; i++) {
        AC += ACList[i];
        WA += ACList[i] === 1 ? WAList[i] : 0;
    }

    console.log(`${AC} ${WA}`);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n/));

Measured memory_bytes: 62664
from collections import deque
wuniversity = deque([])
for i in range(20):
    wuniversity.append(int(input()))
 
kuniversity = deque([])
for i in range(10):
    kuniversity.append(wuniversity.pop())
 
kuniversity = sorted(kuniversity)
wuniversity = sorted(wuniversity)
 
print(wuniversity[-1]+wuniversity[-2]+wuniversity[-3], end=' ')
print(kuniversity[-1]+kuniversity[-2]+kuniversity[-3])


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

int main(){
    int x,a,b;
    cin >> x >> a >> b;
    if(a>=b)
    cout << "delicious" << endl;
    else if(a+x>=b)
    cout << "safe" << endl;
    else
    cout << "dangerous" << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int l, r;
    cin >> l >> r;
    if (r-l >= 2019) {
        cout << 0 << endl;
    } else {
        int result = 2018;
        for (int i=l; i<r; i++) {
            for (int j=i+1; j<=r; j++) {
                result = min(((i%2019)*(j%2019))%2019, result);
            }
        }
        cout << result << endl;
    }
}

Measured memory_bytes: 256
N,M=map(int,input().split())

d={}

condi = []

string = ['0']*N

flg=0
for _ in range(M):
    s,c = map(int,input().split())

    condi.append([s,c])

    if s not in d:
        d[s]=c
    elif s in d :
        if d[s]!=c:
            flg+=1

if flg!=0:
    print(-1)
    exit(0)

if 1 in d:
    if d[1]==0 and N!=1:
        print(-1)
        exit(0)

if N==1 and M==0:
    print(0)
    exit(0)

for i in range(N):
    if i==0 and 1 not in d :
        string[0] = '1'
    else:
        if i+1 in d:
            string[i] = str(d[i+1])

str_num = ''.join(string)
print(str_num)



Measured memory_bytes: 3064
#!/usr/bin/env python3


def solve(H, W, s):
    from heapq import heappop, heappush
    blacks = sum(sum(e == "#" for e in ss) for ss in s)
    hq = [(1, (0, 0))]
    visited = set()
    while hq:
        c, h_w = heappop(hq)
        h, w = h_w
        if h_w in visited:
            continue
        if h_w == (H-1, W-1):
            return H * W - blacks - c
        visited.add(h_w)
        for dh, dw in zip((0, 0, 1, -1), (1, -1, 0, 0)):
            nh, nw = nh_nw = h + dh, w + dw
            if not(0 <= nh < H and 0 <= nw < W):
                continue
            if nh_nw in visited:
                continue
            if s[nh][nw] == "#":
                continue
            heappush(hq, (c+1, nh_nw))
    return -1

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    H, W = map(int, input().split())
    s = [input() for _ in range(H)]
    print(solve(H, W, s))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 75280
open System

let L = stdin.ReadLine() |> float

let V a b = a * b * (L-a-b)

// 三分探索
// n: 反復回数
// left, right: 下端, 上端
let triSearch f n left right =
  let folder (l, r) _ =
    let t1 = (2.*l + r)/3.
    let t2 = (l + 2.*r)/3.
    if f t1 <= f t2 then (t1, r) else (l, t2)
  let (l, r) = [1..n] |> List.fold folder (left, right)
  let x = (l + r) / 2.
  (x, f x)

let result =
  let f a = snd (triSearch (V a) 100 0. (L-a))
  snd (triSearch f 100 0. L)

result |> printfn "%f"


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

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main() {
   int N; cin>>N;
   i64 cnt[5]; REP(i,5) cnt[i]=0;
   string S;
   char march[5] = {'M','A','R','C','H'};
   REP(i,N) {
       cin>>S;
       REP(i,5) if (S[0]==march[i]) cnt[i]++;
   }
   i64 ans = 0;
   ans += cnt[0]*cnt[1]*cnt[2];
   ans += cnt[0]*cnt[1]*cnt[3];
   ans += cnt[0]*cnt[1]*cnt[4];
   ans += cnt[0]*cnt[2]*cnt[3];
   ans += cnt[0]*cnt[2]*cnt[4];
   ans += cnt[0]*cnt[3]*cnt[4];
   ans += cnt[1]*cnt[2]*cnt[3];
   ans += cnt[1]*cnt[2]*cnt[4]; 
   ans += cnt[1]*cnt[3]*cnt[4];
   ans += cnt[2]*cnt[3]*cnt[4];  
   cout<<ans<<endl;
}


Measured memory_bytes: 256
Input = input().split()
W = int(Input[0])
H = int(Input[1])
x = int(Input[2])
y = int(Input[3])
r = int(Input[4])
if x >= r and y >= r and x < W and y<H and x+r <= W and y+r <= H :print("Yes")
else : print("No")


Measured memory_bytes: 5596
a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1
print(ans)

Measured memory_bytes: 39536
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();// 几个500
		int B = sc.nextInt();// 几个100
		int C = sc.nextInt();// 几个50
		int X = sc.nextInt();
		int ans = 0;
		int i,j,k;
		for (i = 0; i <= A; i++) {
			for (j = 0; j <= B; j++) {
				for (k = 0; k <= C; k++) {
					if (500 * i + 100 * j + 50 * k == X)
						ans+=1;
				}
			}
		}
		System.out.println(ans);

		
	}
}

Measured memory_bytes: 20948
n,a,b = map(int,input().split())

h = [int(input()) for i in range(n)]
diff = a-b
def solve(num):
  kaisu = 0
  for i in range(n):
    if -((-(h[i]-num*b))//diff) > 0:
      kaisu += -((-(h[i]-num*b))//diff)
  if kaisu <= num:
    return True
  else:
    return False
    
ng = 0
ok = 1000000001

while abs(ok-ng)>1:
  mid = (ok+ng)//2
  if solve(mid):
    ok = mid
  else:
    ng = mid
#  print(ng,ok)
print(ok)

Measured memory_bytes: 7072
import itertools
import numpy as np

def main():
    ans = 0
    n,m,q = map(int, input().split())
    qs = [list(map(int, input().split())) for _ in range(q)]
    l = list(itertools.combinations_with_replacement(range(1, m+1), n))
    for t in l:
        temp = 0
        for a,b,c,d in qs:
            if t[b-1] - t[a-1] == c:
                temp += d
        ans = max(ans, temp)
                
    print(ans)

if __name__ == '__main__':
    main()

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

int  main() {
string s;
int max=INT_MIN;
cin>>s;
int length=0;
for(int i=0;i<s.size();i++)
{
    if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T')
    length++;
    else
    length=0;
    if(length>max)
    max=length;
}
cout<<max;
}


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>;
const int MAX = 1000;
const int INF = 1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const int ei[] = {-2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2};
const int ej[] = {-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2};
#define PI 3.14159265358979323846264338327950L

#define WHITE 0
#define GRAY 1
#define BLACK 2

int d[MAX][MAX];

void dijkstra(vector<string> s, int h, int w, int x, int y) {
	priority_queue<tuple<int, int, int>> PQ;
	int color[MAX][MAX];
	rep(i,MAX) {
		rep(j,MAX) {
			d[i][j] = INF; color[i][j] = WHITE;
		}
	}
	d[y][x] = 0;
	PQ.push(make_tuple(0, x, y));
	color[y][x] = GRAY;
	while(!PQ.empty()) {
		tuple<int, int, int> f = PQ.top(); PQ.pop();
		int c = get<0>(f); int xx = get<1>(f); int yy = get<2>(f);
		color[yy][xx] = BLACK;
		if (d[yy][xx] < c * (-1)) continue;
		rep(v,4) {
			int nx = xx+dj[v]; int ny = yy+di[v];
			if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
			if (s[ny][nx] == '#') continue;
			if (color[ny][nx] == BLACK) continue;
			if (d[ny][nx] > d[yy][xx]) {
				d[ny][nx] = d[yy][xx];
				PQ.push(make_tuple(d[ny][nx] * (-1), nx, ny));
				color[ny][nx] = GRAY;
			}
		}
		rep(v,25) {
			int nx = xx+ej[v]; int ny = yy+ei[v];
			if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
			if (s[ny][nx] == '#') continue;
			if (color[ny][nx] == BLACK) continue;
			if (d[ny][nx] > d[yy][xx] + 1) {
				d[ny][nx] = d[yy][xx] + 1;
				PQ.push(make_tuple(d[ny][nx] * (-1), nx, ny));
				color[ny][nx] = GRAY;
			}
		}
	}
}

int main() {
	int h, w; cin >> h >> w;
	int sx, sy, tx, ty; cin >> sy >> sx >> ty >> tx;
	sx--; sy--; tx--; ty--;
	vector<string> s(h); rep(i,h) cin >> s[i];
	dijkstra(s, h, w, sx, sy);
	if (d[ty][tx] == INF) {
		cout << -1 << endl;
	} else {
		cout << d[ty][tx] << endl;
	}
}

Measured memory_bytes: 14368
#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;

#if 0
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using Int = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
#endif

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
//constexpr ll MOD = 1;
constexpr int INF = (int)1e9 + 10;
constexpr ll LINF = (ll)4e18;
constexpr double PI = acos(-1.0);
constexpr double EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

struct init_main
{
  init_main()
  {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(30) << setiosflags(ios::fixed);
  };
} init_main_;
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
template <typename T, typename U>
constexpr istream &operator>>(istream &is, pair<T, U> &p) noexcept
{
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename U>
constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept
{
  os << p.first << " " << p.second;
  return os;
}
#pragma endregion

void solve()
{
  string s, t;
  cin >> s >> t;
  int Min = INF;
  for (int i = 0; i + t.length() <= s.length(); i++)
  {
    int cnt = 0;
    rep(j, t.length())
    {
      if (t[j] != s[i + j])
        cnt++;
    }
    chmin(Min, cnt);
  }
  cout << Min << "\n";
}

int main()
{
  solve();
}


Measured memory_bytes: 3676
import java.io.BufferedReader;
//import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		//System.setIn(new FileInputStream("./input.txt"));
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String l;
		while((l = br.readLine()) != null){
			int[] a = Arrays.stream(l.split(" ")).mapToInt(Integer::parseInt).toArray();
			int s = a[0] + a[1];
			System.out.println(String.valueOf(s).length());
			/*for(int i = 0; i < 14; ++i) {
				s /= 10;
				if(s == 0){
					System.out.println(i+1);
					break;
				}
						
			}*/
		}

	}

}

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

int main() {
  int N;
  cin >> N;
  int num = N % 10 ;

  if(num == 3){
    cout << "bon";
  }else if(num == 0|num == 1|num == 6|num == 8){
    cout << "pon";
  }else{
    cout << "hon";
  }
  return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

ll x[100010];

int main(){
    int n;
    ll a, b;
    cin >> n >> a >> b;
    rep(i, n) cin >> x[i];

    ll ans = 0;

    rep(i, n - 1){
        ll diff = x[i+1] - x[i];
        ans += min(diff * a, b);
    }

    cout << ans << endl;

    return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v)                                                            \
  do {                                                                         \
    x = max(x, v);                                                             \
  } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

// tは逃げる、aは追いかける

// A) t,a間の距離が奇数のとき、最後はtが動いてゲーム終了、答えはdistance(t,a)-1
// *-*-*-*      *-*
// t     a  =>  t a
//
// B) t,a間の距離が偶数のとき、最後はaが動いてゲーム終了、答えはdistance(t,a)-1
// *-*-*-*-*      *-*-*
// t       a  =>  t   a

// takahashi くんはできるだけ、aokiくんから距離の遠い頂点vにいきたい
// その頂点vは、distance(v,t) < distance(v,a) を満す

ll N, t, a;
vector<ll> edges[200000];
vector<ll> distT(200000);
vector<ll> distA(200000);

void dfs(vector<ll> &a, ll cur, ll d, ll par) {
  a[cur] = d;
  for (auto nxt : edges[cur]) {
    if (nxt == par)
      continue;
    dfs(a, nxt, d + 1, cur);
  }
}

signed main() {
  cin >> N >> t >> a;
  rep(i, N - 1) {
    ll x, y;
    cin >> x >> y;
    edges[x].push_back(y);
    edges[y].push_back(x);
  }
  ll ans = -1;
  dfs(distT, t, 0, -1);
  dfs(distA, a, 0, -1);
  for (ll v = 1; v <= N; v++) {
    if (distT[v] < distA[v]) {
      chmax(ans, distA[v] - 1);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 16512
#include <stdio.h>

int main(void)
{
	int m, f, r,i;
	char c[] = "ABCDF";

	scanf("%d %d %d", &m, &f, &r);

	while (m >= 0 || f >= 0 || r >= 0) {
		i = m + f;
		i = (i < 80) + (i < 65) + (i < 50) + (i < 30);

		if (i == 3)	i -= (r >= 50);

		if (m == -1 || f == -1)
			printf("%c\n", c[4]);
		else
			printf("%c\n", c[i]);

		scanf("%d %d %d", &m, &f, &r);
	}

	return 0;
}

Measured memory_bytes: 600
N,P = map(int, input().split())
S = input()

if P == 2 or P == 5:
    ans = 0
    for i in range(N):
        if int(S[i]) % P == 0:
            ans += i+1
    print(ans)
else:
    mod_cnt = [0]*P
    mod_cnt[0] = 1
    k = 0.1
    t = 0
    for i in range(1, N+1):
        k = int(k * 10) % P
        t = (t + k * int(S[-i])) % P
        mod_cnt[t] += 1
    ans = 0
    for cnt in mod_cnt:
        ans += (cnt * (cnt-1)) // 2
    print(ans)


Measured memory_bytes: 41308
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n, m;
	cin >> n >> m;
	int k; cin >> k;
	bool f = false;
	REP(i, n + 1)REP(j, m + 1)
	{
		int t = i * m;
		t += j * n;
		t -= i * j * 2;
		if (k == t) f = true;
	}
	cout << (f ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
local n,c,k=io.read("*n","*n","*n")
local t={}
for i=1,n do
    t[i]=io.read("*n")
end
table.sort(t)

local bus=0
local capacity=0
local tadius=t[1]+k
for i=1,n do
    if capacity==c or tadius<t[i] then
        bus=bus+1
        tadius=t[i]+k
        capacity=0
    end
    capacity=capacity+1
end
print(bus+1)

Measured memory_bytes: 2424