akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
using namespace std;
typedef long long ll;
const int maxn=605,mo=1e9+7;
int i,j,l,k,n,m,a[maxn>>1],b[maxn>>1],g[maxn>>1];
int f[maxn][maxn],num,F[maxn][maxn];
ll ans;
int pd(int x){return i<=x&&x<=j;}
int main(){
	scanf("%d%d",&n,&m);
	fo(i,1,m) scanf("%d%d",&a[i],&b[i]);
	g[0]=1;
	fo(i,1,n) g[i]=(ll)g[i-1]*((i<<1)-1)%mo;
	for(l=1;l<2*n;l+=2){
		fo(i,1,2*n-l){
			j=i+l,num=0;
			fo(k,1,m){
				int bz=pd(a[k])+pd(b[k]);
				if (bz==1) break;
				num+=bz>0;
			}if (k<=m) continue;
			num=((l+1)>>1)-num;
			f[i][j]=F[i][j]=g[num];
			for(k=i+1;k<j;k+=2){
				f[i][j]-=(ll)f[i][k]*F[k+1][j]%mo;
				f[i][j]+=f[i][j]<0?mo:0;
			}
			ans+=(ll)f[i][j]*g[n-m-num]%mo;
		}
	}
	printf("%lld\n",ans%mo);
}

Measured memory_bytes: 3072
#include<iostream>
#include<string>
#include<cmath>
using namespace std;


typedef int value_type; /* ソートするキーの型 */

value_type med3(value_type x, value_type y, value_type z)
/* x, y, z の中間値を返す */
{
	if (x < y)
		if (y < z) return y; else if (z < x) return x; else return z; else
			if (z < y) return y; else if (x < z) return x; else return z;
}

void quicksort(value_type *a,value_type *b, int left, int right)
/* クイックソート
* a     : ソートする配列
* left  : ソートするデータの開始位置
* right : ソートするデータの終了位置
*/
{
	if (left < right) {
		int i = left, j = right;
		value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); /* (i+j)/2ではオーバーフローしてしまう */
		while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
			while (a[i] < pivot) i++; /* a[i] >= pivot となる位置を検索 */
			while (pivot < a[j]) j--; /* a[j] <= pivot となる位置を検索 */
			if (i >= j) break;
			tmp = a[i]; a[i] = a[j]; a[j] = tmp; /* a[i],a[j] を交換 */
			tmp = b[i]; b[i] = b[j]; b[j] = tmp; /* a[i],a[j] を交換 */
			i++; j--;
		}
		quicksort(a,b, left, i - 1);  /* 分割した左を再帰的にソート */
		quicksort(a,b, j + 1, right); /* 分割した右を再帰的にソート */
	}
}


int main() {
	string s;
	int N;
	int *X, *L;
	int *S, *T;
	cin >> N;
	X = new int[N];
	L = new int[N];
	S = new int[N];
	T = new int[N];
	for (int i = 0;i < N;i++)cin >> X[i] >> L[i];
	for (int i = 0;i < N;i++) {
		S[i] = X[i] - L[i];
		T[i] = X[i] + L[i];
	}
	
	/*
	for (int i = 0; i<N; i++) {
		for (int j = i + 1; j<N; ++j) {
			if (T[i] > T[j]) {
				int tmp = T[i];
				T[i] = T[j];
				T[j] = tmp;
				tmp = S[i];
				S[i] = S[j];
				S[j] = tmp;
			}
		}
	}
	*/
	quicksort(T, S, 0, N - 1);
	int ans = 0;
	int t = -1000000000;
	for (int i = 0;i < N;i++) {
		if (t <= S[i]) {
			ans++;
			t = T[i];
		}
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define repf(i, n) for(int i=1; i<(int)(n+1); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
using namespace std;

bool check(int bit, vector<vector<pair<int, int>>> &v){
    int n = v.size();
    rep(i, n){
        // 正直者じゃないならスルー
        if(!(bit & (1<<i))) continue;
        // 正直者なら証言を精査
        for(auto p: v[i]){
            // 矛盾があったら終了
            if(((bit>>p.first)&1)^p.second) return false;
        }
    }
    return true;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli n;
    cin >> n;
    vector<vector<pair<int, int>>> v(n, vector<pair<int, int>>(0));

    rep(i, n){
        int ai;
        cin >> ai;
        v[i].resize(ai);
        rep(j, ai){
            cin >> v[i][j].first >> v[i][j].second;
            v[i][j].first--;
        }
    }
    
    int ans = 0;
    for(int bit = 0; bit<(1<<n); bit++){
        if(check(bit, v)){
            // 正直者の数を数える
            int cnt = 0;
            rep(i, n) if(bit & (1<<i)) cnt++;
            ans = max(ans, cnt);
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, -1)
#define RREP(i, n, k) for(auto i = n; i != k; i--)

#define debug(x) cerr << #x << " " << x << endl
#define print(x) cout << x;
#define println(x) cout << x << endl;
#define spc << " " <<

#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define eb emplace_back
#define np next_permutation

using ll = long long;
using Pii = pair<int, int>;
using Tiii = tuple<int, int, int>;
template<class T>using V = vector<T>;
template<class T>using VV = vector<vector<T>>;
using Vi = vector<int>;
using VVi = vector<vector<int>>;

int a[3], b[3];
bool ans;

bool dfs(bool closed[], int here_i, int step) {
   closed[here_i] = true;
   if (step == 3) {
      ans = true;
      return true;
   }

   rep(next_i, 4) {
      if (next_i != here_i && !closed[next_i]) {
         rep(j, 3) {
            if (a[j]-1==here_i && b[j]-1==next_i) {
               if (dfs(closed, next_i, step+1)) return true;
            }
            if (b[j]-1==here_i && a[j]-1==next_i) {
               if (dfs(closed, next_i, step+1)) return true;
            }
         }
      }
   }

   closed[here_i] = false;
   return false;
}

int main() {
   rep(i, 3) {
      cin >> a[i] >> b[i];
   }

   bool closed[4]; rep(i, 4) closed[i] = false;
   rep(i, 4) if (dfs(closed, i, 0)) break;
   cout << (ans ? "YES" : "NO") << endl;

   return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, p: "List[int]"):

    ans = 0
    
    for i in range(N-1):
        if(i+1 == p[i]):
            p[i],p[i+1] = p[i+1],p[i]
            ans += 1

    if(N == p[N-1]):
        ans += 1

    print(ans)

    # for i in range(N-1):
        
    #     if(i+1 == p[i]):
    #         p[i],p[i+1] = p[i+1],p[i]
    #         ans += 1

    # for i in range(N-1,-1,-1):
    #     if(i+1 == p[i]):
    #         p[i],p[i-1] = p[i-1],p[i]
    #         ans += 1    

    # print(ans)

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, p)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14452
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
long long MOD = pow(10, 9) + 7;

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long calc(long long n, long long a) {
  long long ans = 1;
  for (long long i = 1; i <= a; i++) {
    ans = (ans * (n - i + 1)) % MOD;
    ans = (ans * modpow(i, MOD-2, MOD)) % MOD;
  }
  return ans % MOD;
}

int main() {
  long long n, a, b;
  cin >> n >> a >> b;
  int64_t ans = modpow(2, n, MOD) - 1;
  // cout << ans << endl;
  // cout << calc(n, a) << endl;
  ans = (ans - calc(n, a)) + MOD;
  ans = (ans - calc(n, b)) + MOD;
  cout << ans % MOD << endl;
}

Measured memory_bytes: 256
a,b,c,d = map(int,input().split())
phase_change = True

while a > 0 and c > 0:
    if phase_change == True:
        c -= b
        phase_change = False
    else:
        a -= d
        phase_change = True

if a > 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9180
def holiday(n):
  if n == 'SUN':
    return 7
  elif n == 'MON':
    return 6
  elif n == 'TUE':
    return 5
  elif n == 'WED':
    return 4
  elif n == 'THU':
    return 3
  elif n == 'FRI':
    return 2
  elif n == 'SAT':
    return 1
  
n = input()
print(holiday(n))

Measured memory_bytes: 2940
l = input().split()

a = int(l[0])
b = int(l[1])
c = int(l[2])

if(a < b):
   if(b < c):
      print(a, b, c)
   else:
      print(a, c, b)
elif(b < c):
   print(b, c, a)
else:
   print(c, b, a)


Measured memory_bytes: 5596
#include <stdio.h>
#include <string.h>

int main(){
  char S[5][110] = {};
  scanf("%s %s %s", S[0], S[1], S[2]);
  int turn = 0;
  while(S[turn][0] != 0){
    int next_turn = S[turn][0] - 'a';
    for(int i = 0; i < strlen(S[turn]) - 1; i++){
      S[turn][i] = S[turn][i+1];
    }
    S[turn][strlen(S[turn])-1] = 0;
    turn = next_turn;
  }
  printf("%c\n", 'A' + turn);
  return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); //入出力高速化
  int A,B,Q; cin >> A >> B >> Q;
  vector<ll> s(A+2), t(B+2), x(Q);
  s[0] = t[0] = -1e12;
  s[A+1] = t[B+1] = 1e12;
  rep(i,A) cin >> s[i+1];
  rep(i,B) cin >> t[i+1];
  rep(i,Q) cin >> x[i];
  
  vector<ll> ans(8);
  rep(q,Q) {
    int y = lower_bound(all(s),x[q]) - s.begin();
    int z = lower_bound(all(t),x[q]) - t.begin();
    ans[0] = abs(x[q] - s[y]) + abs(s[y] - t[z]);
    ans[1] = abs(x[q] - s[y-1]) + abs(s[y-1] - t[z]);
    ans[2] = abs(x[q] - s[y]) + abs(s[y] - t[z-1]);
    ans[3] = abs(x[q] - s[y-1]) + abs(s[y-1] - t[z-1]);
    ans[4] = abs(x[q] - t[z]) + abs(t[z] - s[y]);
    ans[5] = abs(x[q] - t[z-1]) + abs(t[z-1] - s[y]);
    ans[6] = abs(x[q] - t[z]) + abs(t[z] - s[y-1]);
    ans[7] = abs(x[q] - t[z-1]) + abs(t[z-1] - s[y-1]);
    sort(all(ans));
    cout << ans[0] << endl;
  }
}

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

int main () {
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);
    a.push_back(k + a.at(0));
    int ans = 0;
    rep(i, n) {
        ans = max(ans, a.at(i+1) - a.at(i));
    }
    printf("%d\n",k-ans);
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

int main(){
  int a,b,ans=0;
  scanf("%d%d",&a,&b);
  if(b*10*8/100==a){
    printf("%d",b*10);
    return 0;
  }
  else if(a*100%8==0 && a*10/8==b){
    printf("%d",a*100/8);
    return 0;
  }
  else if(a*100%8!=0 && a*10/8==b){
    printf("%d",a*100/8+1);
    return 0;
  }
  else{
    printf("-1");
    return 0;
  }
}

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

int num_count[10];
uint64_t limit;

static bool check753()
{
  return num_count[3] > 0 && num_count[5] > 0 && num_count[7] > 0;
}

uint64_t dfs(uint64_t n)
{
  static const int64_t nums[] {3, 5, 7};

  if (n > limit) return 0;

  uint64_t res(0);
  if (check753()) res++;

  for (int i = 0; i < 3; i++) {
    num_count[nums[i]]++;
    res += dfs(n * 10 + nums[i]);
    num_count[nums[i]]--;
  }
  return res;
}

int main()
{
  cin >> limit;
  cout << dfs(0) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <iostream>
#define MAXN 50

long long N, P;
long long A[MAXN] = {};

long long combination(long long n, long long m);

void solve() {
	std::cin >> N;
	std::cin >> P;

	long long odd = 0, even = 0;

	for (long long i = 0; i < N; i++) {
		std::cin >> A[i];
		if (A[i] % 2 == 0) even++;
		else odd++;
	}

	long long ans = 0;

	if (P == 0) {

		for (long long even_ind = 0; even_ind <= even; even_ind++) {
			for (long long odd_ind = 0; odd_ind <= odd; odd_ind += 2) {
				ans += combination(even, even_ind) * combination(odd, odd_ind);
			}
		}
	}
	else {
		for (long long even_ind = 0; even_ind <= even; even_ind++) {
			for (long long odd_ind = 1; odd_ind <= odd; odd_ind += 2) {
				ans += combination(even, even_ind) * combination(odd, odd_ind);
			}
		}
	}

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

long long fact(long long n) {
	if (n <= 1) {
		return 1;
	}
	return n * fact(n - 1);
}


long long combination(long long n, long long m) {
	if(n<m) return 0;
	long long ans=1;
	for(int i=0;i<m;i++) ans=ans*(long long)(n-i)/(long long)(i+1);
	return ans;
}


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


Measured memory_bytes: 256
place = []
bn,fn,rn=[4,3,10]
for i in range(bn):
    place.append([])
    for j in range(fn):
        place[i].append([])
        for k in range(rn):
            place[i][j].append(0)

count = int(input())
for i in range(count):
    b,f,r,v = map(int, input().split())
    place[b-1][f-1][r-1] += v

for i in range(bn):
    for j in range(fn):
        line = ""
        for k in range(rn):
            line += " "
            line += str(place[i][j][k])
        print(line)
    if(i == bn -1):
        break
    mark = ""
    for i in range(20):
        mark += "#"
    print(mark)

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

using namespace std;

typedef long long ll;


int main() {
	#ifdef FUN
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#else
		#define endl "\n"
	#endif

    int n, k;
    cin >> n >> k;

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

    for (int i = 1; i < n; ++i) {
        if (a[i] + a[i - 1] >= k) {
            cout << "Possible" << endl;
            for (int j = 1; j < i; ++j)
                cout << j << endl;

            for (int j = n - 1; j > i; --j)
                cout << j << endl;

            cout << i << endl;
            return 0;
        }
    }

    cout << "Impossible" << endl;
}


Measured memory_bytes: 1152
#include<iostream>
#include <iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

 
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(int n, int k){
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w,a,b,ans=0;
    cin>>h>>w>>a>>b;
    COMinit();
    rep(i,h-a+1){
        ans += COM(b+i-2,b-1)*COM(h-i+w-b-1,h-i);
        ans %=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 12288
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::input;
//use proconio::marker::Chars;
use proconio::marker::Usize1;
//use std::collections::HashSet;
//use std::collections::HashMap;
//use std::collections::BTreeMap;
use std::cmp::*;
//use std::num;

fn main() {
    input! {
        n:usize,x:Usize1,y:Usize1

    }
    let mut d = vec![vec![0; n]; n];
    let mut e = vec![0; n];
    //println!("{},{}", x, y);
    for i in 0..n - 1 {
        for j in i + 1..n {
            // println!("{},{}", i, j);
            if j <= x || y <= i {
                //     println!("a");
                d[i][j] = j - i;
                e[d[i][j]] += 1;
                continue;
            }
            if i <= x && y <= j {
                //  println!("b");
                d[i][j] = x - i + j - y + 1;
                e[d[i][j]] += 1;
                continue;
            }
            if i <= x && j < y {
                //    println!("c");
                d[i][j] = x - i + min(j - x, y - j + 1);
                e[d[i][j]] += 1;
                continue;
            }
            if x < i && y <= j {
                //   println!("d");
                d[i][j] = j - y + min(i - x + 1, y - i);
                e[d[i][j]] += 1;
                continue;
            }
            if x < i && j < y {
                //  println!("e");

                d[i][j] = min(j - i, i - x + y - j + 1);
                e[d[i][j]] += 1;
            }
            // println!("f");
        }
    }
    for i in 0..n {
        //   println! {"{:?}", d[i]}
    }
    for i in e.iter().skip(1) {
        println!("{}", i);
    }
}


Measured memory_bytes: 33428
#include <stdio.h>
int memo[11][400];
void dfs(int route[],int sum);
int C;

int main(){
	int i,j;
	for(i=0;i<=10;i++){
		for(j=0;j<400;j++)memo[i][j]=0;
	}
	int route[10];
	int sum;

	for(i=0;i<10;i++)route[i]=-1;
	for(i=0;i<=9;i++){
		sum=0;
		route[0]=i;
		dfs(route,sum);
		route[0]=-1;
	}
	int N;
	int S;
	while(scanf("%d %d\n",&N,&S)!=EOF){
		if(S>=400 || N>10){
			printf("0\n");
		}else{
			printf("%d\n",memo[N][S]);
		}
	}



	return 0;
}

void dfs(int route_[],int sum){
	int route[10];
	int used[10];
	int i;
	for(i=0;i<10;i++)used[i]=0;
	int now=-1;
	for(i=0;i<10;i++){
		route[i]=route_[i];
		if(route[i]!=-1){
			now=i;
			used[route[i]]=1;
		}
	}
	sum+=(now+1)*route[now];
	memo[now+1][sum]+=1;
	if(now==10-1){
		//if(S==sum)Ans++;
		return;
	}

	for(i=0;i<=9;i++){
		if(used[i]==0){
			route[now+1]=i;
			dfs(route,sum);
			route[now+1]=-1;
		}
	}
	sum-=(now+1)*route[now];
	return;
}

Measured memory_bytes: 632
#include<iostream>
#include<queue>
#include<set>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

class state{
public:
  int now,n,cnt;
  vector<int> data;
  bool operator<(const state & a)const{
    rep(i,n)if ( data[i] !=a.data[i])return data[i] < a.data[i];
    return false;
  }
  bool solved(vector<int> &tar){
    rep(i,tar.size()){
      if ( data[i] != tar[i])return false;
    }

    return true;
  }
  
  bool move(set<state>&S,queue<state> &Q,vector<int> &tar){
    while(now < n && data[now] == tar[now])now++;
    if ( now == n){
      if(  solved(tar))return true;
      else return false;
    }
    int move=tar[now]-data[now];
    data[now]=(10+data[now]+move)%10;
    cnt++;
    if ( S.find(*this)== S.end())S.insert(*this),Q.push(*this);
    for(int i=now+1;i<n;i++){
      data[i]=(10+data[i]+move)%10;
      if ( S.find(*this)==S.end())S.insert(*this),Q.push(*this);
    }

    return false;
  }

};

int solve(state & ini,vector<int> tar){
  set<state> S;
  queue<state> Q;
  Q.push(ini);
  S.insert(ini);
  while(!Q.empty()){
    state now = Q.front();
    
    Q.pop();
    if ( now.solved(tar) )return now.cnt;
    if ( now.move(S,Q,tar))return now.cnt;
  }
  return -1;
}

main(){
  int n;
  string a;
  while(cin>>n && n){
    state ini;
    ini.cnt=0;ini.n=n;ini.now=0;
    vector<int> tar;
    cin>>a;
    rep(i,n)ini.data.push_back(a[i]-'0');
    cin>>a;
    rep(i,n)tar.push_back(a[i]-'0');

    while(ini.now < ini.n && ini.data[ini.now]==tar[ini.now])ini.now++;

    cout << solve(ini,tar)<<endl;
  }
}

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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, start, end) for(int i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define INFL (1e18)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

template<typename A, size_t N, typename T>
void array_fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    int n;
    cin >> n;
    vector<ll> nums(n), gcd_left(n+1, 0LL), gcd_right(n+1, 0LL);

    rep(i, n) cin >> nums[i];


    rep(i, n) gcd_left[i+1] = gcd(gcd_left[i], nums[i]);
    for(int i = n-1; i >= 0; -- i) gcd_right[i] = gcd(gcd_right[i+1], nums[i]);

    ll ans = -1;
    rep(i, n){
        ans = max(ans, gcd(gcd_left[i], gcd_right[i+1]));
    }

    cout << ans << endl;
}

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

using namespace std;
using ll = long long int;
constexpr ll M = 1e9 + 7;
inline ll sum_1(const ll n) { return ((n * (n + 1)) / 2) % M; }
inline ll sum_2(const ll n) { return ((n * (n + 1) * (2 * n + 1)) / 6) % M; }
inline ll sum_3(const ll n) { return (((n * (n + 1)) / 2) % M * ((n * (n + 1)) / 2) % M) % M; }
inline ll sum_1(const ll i, const ll j) { return (sum_1(j) - sum_1(i - 1) + M) % M; }
inline ll sum_2(const ll i, const ll j) { return (sum_2(j) - sum_2(i - 1) + M) % M; }
inline ll sum_3(const ll i, const ll j) { return (sum_3(j) - sum_3(i - 1) + M) % M; }

void solve() {
    string s;
    cin >> s;
    cout << ((s[2]==s[3] && s[4]==s[5]) ? "Yes" : "No") << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifdef D_LOCAL
        freopen("in.in", "r", stdin);
        freopen("out.out", "w", stdout);
    #endif

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

void swap(int& a,int& b);

using namespace std;

int main()
{
    int N,t[100];
    int num=0;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>t[i];
    }
    for(int i=0;i<N;i++){
        for(int j=1;j<N-i;j++){
            if(t[j-1]>t[j]){
                swap(t[j-1],t[j]);
                num++;
            }
        }
    }
    cout<<t[0];
    for(int i=1;i<N;i++){
        cout<<" "<<t[i];
    }
    cout<<endl;
    cout<<num<<endl;
}
void swap(int& a,int& b)
{
    int c;
    c=a;
    a=b;
    b=c;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
char c[a][b];
int d[a+2][b+2];
for(int i=0;i<a;i++){
for(int j=0;j<b;j++){
cin>>c[i][j];
if(c[i][j]=='.') d[i][j]=0;
if(c[i][j]=='#') d[i][j]=1;}
}
for(int i=0;i<a;i++){
for(int j=0;j<b;j++){
if(d[i][j]==1&&(i==0||d[i-1][j]==0)&&(i==a-1||d[i+1][j]==0)&&(j==0||d[i][j-1]==0)&&(j==b-1||d[i][j+1]==0)){
cout<<"No";
return 0;}
}
}
cout<<"Yes";
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
	string n;
	cin >> n;
	int k;
	cin >> k;
	ll dp[101][2][4];
	rep(i, 101) rep(j, 2) rep(l, 4) dp[i][j][l] = 0;
	dp[0][0][0] = 1;
	for(int i = 1; i <= n.size(); i++) {
		int d = n[i - 1] - '0';
		// no smaller to no smaller
		dp[i][0][0] = 0;
		for(int l = 1; l <= 3; l++)  dp[i][0][l] = dp[i - 1][0][l - (d > 0)];
		// no smaller to smaller
		if(d > 0) {
			for(int l = 0; l < 4; l++) {
				dp[i][1][l] += dp[i - 1][0][l];
				if(l >= 1) dp[i][1][l] += dp[i - 1][0][l - 1] * (d - 1);
			}
		}
		// smaller to smaller
		for(int l = 0; l < 4; l++) {
			dp[i][1][l] += dp[i - 1][1][l];
			if(l >= 1) dp[i][1][l] += dp[i - 1][1][l - 1] * 9;
		}
	}
	cout << dp[n.size()][0][k] + dp[n.size()][1][k] << endl;
}				


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int count = 0;


void sort(int n, int a[]){
  int tmp;
  int min;
  int i ,j;
  for(i = 0; i < n; i++){
    min = i;
    int flag = 0;
    for(j = i; j < n; j++){
      if(a[j] < a[min]){
        min = j;
        flag = 1;
      }
    }
    tmp = a[i];
    a[i] = a[min];
    a[min] = tmp;
    if(flag == 1){
      count++;
    }
  }
}


int main(void){

  int a[100] = {};
  int n;
  int i;

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

  sort(n , a);

  for(i = 0; i < n-1; i++){
    printf("%d ", a[i]);
  }
  printf("%d\n", a[i]);
  printf("%d\n", count);

  return 0;
}



Measured memory_bytes: 2036
package main

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

func main() {
	defer flush()

	N := readInt()
	M := readInt()
	Q := readInt()

	t := make([][]int, N+1)
	for i := 0; i < N+1; i++ {
		t[i] = make([]int, N+1)
	}

	for i := 0; i < M; i++ {
		L := readInt()
		R := readInt()
		t[L][R]++
	}

	for i := 0; i < N+1; i++ {
		for j := 0; j < N; j++ {
			t[i][j+1] += t[i][j]
		}
	}

	for i := 0; i < Q; i++ {
		p := readInt()
		q := readInt()
		result := 0
		for i := p; i < q+1; i++ {
			result += t[i][q] - t[i][i-1]
		}
		println(result)
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdoutWriter, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


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

long long N, K;

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

	long long ans = 0;
	if(K == 0){
		cout << N * N  << endl;
		return 0;
	}
	for(long long i = K+1; i <= N; i++){
		long long divi = N/i;
		long long rest = N%i;

		ans += divi * (i - K);
		ans += max((long long)0, rest - K + 1);
		//cout << "b=" << i << " num = " << divi * (i - K) << "," << max((long long)0, rest - K)<< endl;
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
import sys

def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())

n, k = ISI()
l = [1] * n
for i in range(k):
	input()
	a=ILI()
	for j in a:
		l[j-1]=0
print(sum(l))

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

int main() {
  int N;
  cin >> N;
  
  int sum, dig;
  
  int M = N;
  while(M > 0){
    dig = M % 10;
    sum += dig;
    M = M / 10;
  }
  if(N % sum == 0){
    cout << "Yes" << endl;
  }
  else{
    cout<< "No" << endl;
  }
}

Measured memory_bytes: 256
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let s: Vec<usize> = it.next().unwrap().chars().map(|c| c.to_digit(10).unwrap() as usize).collect();
    assert!(s[0] != 0);
    let k: usize = it.next().unwrap().parse().unwrap();
    let mut dp = vec![0usize; k + 2];
    dp[0] = 1;
    for _ in 1..s[0] {
        dp[1] += 1;
    }
    let mut sup = 1;
    for &d in s.iter().skip(1) {
        let mut next = vec![0; k + 2];
        for i in 0..(k + 1) {
            for _ in 1..10 {
                next[i + 1] += dp[i];
            }
            next[i] += dp[i];
        }
        if d > 0 && sup <= k {
            next[sup] += 1;
        }
        if sup + 1 <= k {
            for _ in 1..d {
                next[sup + 1] += 1;
            }
        }
        if d > 0 {
            sup += 1;
        }
        dp = next;
    }
    let mut ans = dp[k];
    if sup == k {
        ans += 1;
    }
    println!("{}", ans);
}

fn main() {
    run();
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  lint H,W,N;
  cin>>H>>W>>N;
  map<pair<int,int>,int> m;
  REP(i,N){
    int a,b;
    cin>>a>>b;
    FOR(ii,-1,2)FOR(jj,-1,2){
      if(a+ii<2 or a+ii>H-1 or b+jj<2 or b+jj>W-1)continue;
      m[make_pair(a+ii,b+jj)]+=1;
    }
  }
  lint ans[10]={0};
  ans[0]=(H-2)*(W-2);
  for(auto e:m){
    ans[e.second]++;
    ans[0]--;
  }
  // FOR(i,1,H+1){
  //   FOR(j,1,W+1)cerr<<m[make_pair(i,j)];
  //   cerr<<endl;
  // }
  REP(i,10)cout<<ans[i]<<endl;
  return 0;
}


Measured memory_bytes: 56448
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, Q: int, L: "List[int]", R: "List[int]", p: "List[int]", q: "List[int]"):

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int

    C = [[0] * (N) for _ in range(N)] # C[l][r]: L = l, R = rを満たす列車の本数
    for i in range(M):
        L = int(next(tokens)) - 1
        R = int(next(tokens)) - 1
        C[L][R] += 1

    T1 = [[0] * (N) for _ in range(N)] # T1[l][r]: L = l, R <= rを満たす列車の本数
    for l in range(N):
        for r in range(N):
            if l > r:
                continue
            if l == r:
                T1[l][r] = C[l][r]
            else:
                T1[l][r] = T1[l][r-1] + C[l][r]

    T2 = [[0] * (N) for _ in range(N)] # T2[l][r]: L >= l, R <= rを満たす列車の本数
    for r in range(N):
        for l in range(N-1, -1, -1):
            if l > r:
                continue
            if l == r:
                T2[l][r] = T1[l][r]
            else:
                T2[l][r] = T2[l+1][r] + T1[l][r]

    for i in range(Q):
        p = int(next(tokens))-1
        q = int(next(tokens))-1
        print(T2[p][q])

if __name__ == '__main__':
    main()


Measured memory_bytes: 15548
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>
#define rep(i,n) for(int i=0; i<n; i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

int main(){
	ll N,K;
	cin >> N >> K;

	ll ans=1;
	ll bb=-1;
	for(ll j=1; j<K; j++){
		bb+=2*j;
	}
	for(ll i=K; i<N+1; i++){
		ans += N*i-bb;
		ans %= mod;
		bb+=2*i;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T> bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
    for (auto &e : t) {
        fill_v(e, v);
    }
};
int n;
vector<vector<int>> G;
vector<int> v1, v2, d;
vector<P> res;
void dfs(int i) {
    v1[i] = 1;
    for (auto &e : G[i]) {
        if (!v1[e]) { //子
            dfs(e);
        }
    }
    for (auto &e : G[i]) {
        if (!v2[e]) { //子でない
            if (d[i] % 2) {
                res.push_back(P(i, e));
                d[i]++;
            } else {
                res.push_back(P(e, i));
                d[e]++;
            }
        }
    }
    v2[i] = 1;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m;
    cin >> n >> m;
    if (m % 2) {
        cout << -1 << endl;
        return 0;
    }
    G.resize(n);
    v1.resize(n);
    v2.resize(n);
    d.resize(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(0);
    for (auto &p : res) {
        cout << p.first + 1 << " " << p.second + 1 << endl;
    }
}


Measured memory_bytes: 15984
from decimal import Decimal, ROUND_HALF_UP


N = int(input())
lst_a = list(map(int, input().split()))


a_ave = sum(lst_a) / N
target_val = int(Decimal(str(a_ave)).quantize(Decimal("0"), rounding=ROUND_HALF_UP))
ans = sum([(a - target_val)**2 for a in lst_a])
print(ans)


Measured memory_bytes: 5076
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<string > vecstr;
int main()
{
  int n;
  cin >> n;
  vecint a(n,0);
  int num4 = 0;
  int numodd = 0;
  REP(i,n){
    cin >> a[i];
    if(a[i]%4 == 0)num4++;
    if(a[i]%2 != 0)numodd++;
  }
  if( num4 + numodd == n && num4 >= numodd - 1){
    cout << "Yes" << endl;
  }else if(num4 >= numodd){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int a, b, c; cin >> a >> b >> c;

    if (a + b + c >= 22) {
        puts("bust");
    } else {
        puts("win");
    }
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
int n,a=0;
cin >> n;
int l[2*n];
for(int i=0;i<2*n;i++)
cin >> l[i];
sort(l,l+2*n);
for(int i=0;i<2*n;i=i+2)
a=a+l[i];
cout << a;
return 0;
}

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

#define st first
#define nd second
#define pb push_back

typedef long long   ll;
typedef double      db;
typedef long double ldb;

typedef pair <int, int> pii;
typedef pair <ll,  ll>  pll;
typedef pair <ll,  db>  pdb;
typedef pair <ldb, ldb> pldb;

template <typename T>
void   Debug (T begin, T end);
int    si    ();
ll     sl    ();
string ss    (int);
db     sf    ();
ldb    slf   ();
void   pi    (int, char = '\n');
void   pl    (ll, char = '\n');
void   pf    (db, char = '\n');
void   plf   (ldb, char = '\n');
void   ps    (string, char = '\n');

ll russian(ll, ll, ll);
ll fastpow(ll, ll, ll);
ll slowpow(ll, ll, ll);
ll _gcd(ll, ll);
ll _lcm(ll, ll);
ll extgcd(ll, ll, ll&, ll&);
ll _inv(ll, ll);

const int INF  = 1e9;
const ll  LINF = 1e18;

int main()
{
    int n = si();
    char last = 0;
    int res = 0;

    for (int i = 0; i < n; ++i)
    {
        char c;
        scanf(" %c", &c);
        if (c != last)
            ++res;
        last = c;
    }

    pi(res);

    return 0;
}

template <typename T>
void Debug(T begin, T end)
{
    printf("\nDEBUG:\n");
    while (begin != end)
        printf("%d ", *begin),
        begin++;
    printf("\n\n");
}

template <typename T>
T scanf_t(string s)
{
    T a;
    scanf(s.c_str(), &a);
    return a;
}

template <typename T>
void printf_t(T a, string s, char end_l)
{
    s.push_back(end_l);
    printf(s.c_str(), a);
}

int si() { return scanf_t<int>("%d"); }
ll sl() { return scanf_t<ll>("%lld"); }
db sf() { return scanf_t<db>("%f"); }
ldb slf() { return scanf_t<ldb>("%Lf"); }

void pi(int a, char end_l) { printf_t<int>(a, "%d", end_l); }
void pl(ll a, char end_l) { printf_t<ll>(a, "%lld", end_l); }
void pf(db a, char end_l) { printf_t<db>(a, "%lf", end_l); }
void plf(ldb a, char end_l) { printf_t<ldb>(a, "%Lf", end_l); }

void ps(string a, char end_l)
{
    string s = "%s";
    s.push_back(end_l);
    printf(s.c_str(), a.c_str());
}

string ss(int NN)
{
    char T[NN];
    scanf("%s", T);
    return (string)T;
}

ll fastpow(ll a, ll k, ll m)
{
    ll r = 1LL;
    while (k)
    {
        if (k & 1LL)
            r = (r * a) % m;
        a = (a * a) % m;
        k >>= 1LL;
    }
    return r;
}

ll slowpow(ll a, ll k, ll m)
{
    ll r = 1LL;
    while (k)
    {
        if (k & 1LL)
            r = russian(r, a, m);
        a = russian(a, a, m);
        k >>= 1LL;
    }
    return r;
}

ll russian(ll a, ll k, ll m)
{
    ll r = 0LL;
    while (k)
    {
        if (k & 1LL)
            r = (r + a) % m;
        a = (a + a) % m;
        k >>= 1LL;
    }
    return r;
}

ll _gcd(ll a, ll b)
{
    while (b)
        swap(a %= b, b);
    return a;
}

ll _lcm(ll a, ll b)
{
    return a / _gcd(a, b) * b;
}

ll extgcd(ll a, ll b, ll& k, ll& l)
{
    if (b == 0)
    {
        k = 1; l = 0;
        return a;
    }
    ll res = extgcd(b, a % b, l, k);
    l -= a / b * k;
    return res;
}

ll _inv(ll a, ll p)
{
    return fastpow(a, p - 2, p);
}


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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int l, k;
    cin >> l >> k;
    auto dp = make_v(l + 1, 2, 0LL);
    dp[0][0] = 1;
    REP(i, 0, l) {
        dp[i + 1][1] += dp[i][0];
        dp[i + 1][0] += dp[i][1];
        if (i + k <= l) {
            dp[i + k][1] += dp[i][0];
        }
    }
    ll ans = 0;
    REP (i, 0, l + 1) {
        ans += dp[i][1];
    }
    cout << ans << endl;
    return 0;
}



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

public class Main {
    long n, s;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextLong();
        s = sc.nextLong();
        solve();
    }

    void solve() {
        long sqrtN = (long)Math.sqrt(n);
        long minB = -1;
        if (n <= s) {
            if (n == s) {
                minB = n + 1;
            }
            System.out.println(minB);
            return;
        }
        for (int b = 2; b <= sqrtN; b++) {
            long copyN = n;
            long sumDigits = 0;
            while (copyN > 0) {
                sumDigits += copyN % b;
                copyN /= b;
            }
            if (sumDigits == s) {
                minB = b;
                break;
            }
        }
        if (minB == -1) {
            for (long p = sqrtN; p >= 1; p--) {
                long b = (n - s)/ p + 1;
                if (b <= 1) {
                    continue;
                }
                long copyN = n;
                long sumDigits = 0;
                while (copyN > 0) {
                    sumDigits += copyN % b;
                    copyN /= b;
                }
                if (sumDigits == s) {
                    minB = b;
                    break;
                }
            }
        }
        System.out.println(minB);
    }

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

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 23252
#ifndef KHOKHO
//#pragma GCC optimize("O3")
#endif
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
//#define CHKR
#define ll long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define ARRS int(1e6+500)
#define MAX ((long long)(1e18+1))
#define EP ((double)(1e-12))
#define HS1 ((ll)(1000001329))
#define HS2 ((ll)(1000001531))
#define MOD ((long long)1000000007ll)
#define AT9 ((long long)1000000000ll)
#define PI 3.14159265358979323846264338327950288419716939937510
#define LG 20
ll a[400][400];
ll f[400];
ll c[400];
ll l[400];


int main(){
	#ifdef KHOKHO
		freopen("in.in","r",stdin);
		freopen("out.out","w+",stdout);
	#endif //KHOKHO
	ll n,m,p;
	cin>>n>>m;
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			cin>>a[i][j];
			a[i][j]--;
		}
		c[a[i][0]]++;
	}
	ll mx=0;
	for(int i=0; i<m; i++){
		if(c[i]>c[mx])mx=i;
	}
    ll pas=n;
    for(int t=0; t<m-1; t++){
		pas=min(pas,c[mx]);
		//cout<<mx+1<<" "<<c[mx]<<endl;
		f[mx]=1;
		for(int i=0; i<n; i++){
            while(f[a[i][l[i]]]){
				c[a[i][l[i]]]--;
				l[i]++;
				c[a[i][l[i]]]++;
			}
		}
		mx=-1;
		for(int i=0; i<m; i++){
			if(f[i])continue;
			if(mx==-1||c[i]>c[mx])mx=i;
		}
    }
    cout<<pas;
	return 0;
}


Measured memory_bytes: 1152
x1,y1,x2,y2=map(int,input().split())
x3=x2-(y2-y1)
y3=y2+(x2-x1)
x4=x3-(x2-x1)
y4=y3-(y2-y1)
print("{} {} {} {}".format((x3),(y3),(x4),(y4)))

Measured memory_bytes: 3060
/*
    AUTHOR : TANMAY SINHA
    INORMATION TECHNOLOGY
    BIT MESRA ,RANCHI
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ld long double
#define ull unsigned long long int
#define ll long long int
#define pb(x) push_back(x)
#define eb(x) emplace_back()
#define mp make_pair
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define rep(j,L,R) for(j=L;j<R;j++)
#define per(i,L,R) for(i=L;i>= R;i--)
#define all(con) (con).begin(),(con).end()
#define fi first
#define se second
#define foreach(iter,con) for(auto iter=(con).begin(); iter!=(con).end(); iter++)
#define DEBUG
#ifdef DEBUG
#define deb2(args...) {dbg,args; cerr<<endl;}
#else
#define deb2(args...)
#endif
struct debb{template<typename T> debb& operator,(const T &v){cerr<<v<<" ";return *this;}}dbg;
#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)
#define printa(a,L,R) rep(i,L,R) cout << a[i] <<' ';cout<<"\n";
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
template<typename T>T gcd(T a,T b){if(b==0)return a;else return gcd(b,a%b);}
template<typename T>T lcm(T a,T b){return a/gcd(a,b)*b;}
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=((res%p)*(x%p))%p;y=y>>1;x=(x*x)%p;}return res;}
ll pow1(ll x,ll y){ll res=1;while(y>0){if(y&1)res=(res*x);y=y>>1;x=x*x;}return res;}
const ll INF = 1e18l+10,N = 1e5+10,MAX = 1e6+5;
#define sq(X) ((X)*(X))

int main()
{
    SPEED
    string s,t;
    ll n,i;
    cin>>n>>s>>t;
    for(i=0;i<n;i++)
    {
        cout<<s[i]<<t[i];
    }
    cout<<"\n";
}






Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string.h>
#define INF 123456789
#define MOD 1000000007


int main()
{

	int N, M;

	scanf("%d%d", &N, &M);

	printf("%d\n", (N - 1) * (M - 1));

	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int N;
        int[][] Bingo = new int[3][3];
        boolean[][] Check_Bingo = new boolean[3][3];
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                Bingo[i][j] = sc.nextInt();
            }
        }
        N = sc.nextInt();
        int[] ArrN = new int[N];
        for (int i = 0; i < N; i++) {
            ArrN[i] = sc.nextInt();
            //danh dau vao o Check_Bingo nhung noi gia tri mang Arr trung voi gia tri mang Bingo
            for(int j = 0 ; j < 3 ; j++)
            {
                for(int k = 0 ; k < 3; k++)
                {
                    if(ArrN[i] == Bingo[j][k])
                    {
                        Check_Bingo[j][k] = true;
                    }
                }
            }
        }
        //3 th bingo o hang ngang va hang doc
        for(int i = 0 ; i < 3 ; i++)
        {
            if(Check_Bingo[i][0] == true && Check_Bingo[i][1] == true && Check_Bingo[i][2] == true)
                Exit_bingo();
            else if(Check_Bingo[0][i] == true && Check_Bingo[1][i] == true && Check_Bingo[2][i] == true)
                Exit_bingo();
        }
        if(Check_Bingo[2][2] == true && Check_Bingo[1][1] == true && Check_Bingo[0][0] == true) Exit_bingo();
        else if(Check_Bingo[0][2] == true && Check_Bingo[1][1] == true && Check_Bingo[2][0] == true) Exit_bingo();
        System.out.println("No");

    }
    public static void Exit_bingo()
    {
        System.out.println("Yes");
        System.exit(0);
    }
}


Measured memory_bytes: 35784