akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
 
typedef struct{
  int map[16];
  int sp;
  int md;
}Board;
//左側の数字が、右側の番地に存在したときのMD
int md[16][16];
//dfsの現在のBoardの記録
Board ndfs;
int mov[4]={4,1,-1,-4};
 
int dfs(int lim,int now,int before);
int idasearch(Board x);
int calcmd(Board x);
 
int main(void){
  int i,j,sum=0;
  char x,dummy;
  Board start;
  //MD対応表作成
  for(i=0;i<15;i++)for(j=0;j<16;j++)md[i+1][j]=abs(i/4-j/4)+abs(i%4-j%4);
  /*for(i=1;i<16;i++){
    for(j=0;j<16;j++)printf("%d ",md[i][j]);
    printf("\n");
    }*/
  //読み込み
  for(i=0;i<16;i++){
    /*if(i%4!=3)scanf("%c ",&x);
    else scanf("%c%c",&x,&dummy);
    if(x>='1'&&x<='9')start.map[i]=x-'0';
    else if(x>='a'&&x<='f')start.map[i]=10+x-'a';
    else {
      start.sp = i;
      start.map[i]=0;
      }*/
    scanf("%d",&start.map[i]);
    if(start.map[i]==0)start.sp=i;
  }
  //転倒数の計算
  sum=3-start.sp/4;
  for(i=0;i<15;i++)for(j=i+1;j<16;j++)if(start.map[i]>start.map[j]&&start.map[j]!=0)sum++;
  if(sum%2==1)printf("impossible\n");
  else{
    //IDA*
    start.md = calcmd(start);
    //printf("%d\n",start.md);
    printf("%d\n",idasearch(start));
  }
  //for(i=0;i<16;i++)printf("%d",start.map[i]);
  return 0;
}
 
int calcmd(Board x){
  int i,ans=0;
  for(i=0;i<16;i++)if(x.map[i]!=0)ans+=md[x.map[i]][i];
  x.md = ans;
  return ans;
}
int idasearch(Board x){
  int ans=-1,i;
  for(i=1;i<=80;i++){
    ndfs = x;
    ans = dfs(i,0,-10);
    if(ans!=-1)break;
  }
  return ans;
}
int dfs(int lim,int now,int before){
  //if(lim==19)printf("%d %d\n",now,ndfs.md);
  int i,ans=-1,tmp;
  Board dummy = ndfs;
  //答えになっているか判定
  if(dummy.md==0)return now;
  //探索うちきり
  if(ndfs.md+now>=lim)return -1;
  for(i=0;i<4;i++){
    if(dummy.sp%4==0&&i==2)continue;
    if(dummy.sp%4==3&&i==1)continue;
    ndfs = dummy;
    //-のマスの移動
    ndfs.sp+=mov[i];
    //範囲内かどうか、一手前に戻ってないかどうか
    if(ndfs.sp>=0&&ndfs.sp<16&&before+i!=3){
      //mdをずらす
      ndfs.md -= md[dummy.map[ndfs.sp]][ndfs.sp];
      ndfs.md += md[dummy.map[ndfs.sp]][dummy.sp];
      //swap
      ndfs.map[dummy.sp]=dummy.map[ndfs.sp];
      ndfs.map[ndfs.sp]=0;
      /*for(int j=0;j<16;j++)printf("%2d",dummy.map[j]);
      printf("\n");
      for(int j=0;j<16;j++)printf("%2d",ndfs.map[j]);
      printf("\n\n");*/
      ans = dfs(lim,now+1,i);
      if(ans!=-1)break;
    }
  }
  return ans;
}
/*参考文献
http://www.ic-net.or.jp/home/takaken/nt/slide/solve15.html
プログラミングコンテスト攻略のためのアルゴリズムとデータ構造(会津大学、渡部有隆　著.2015,1)*/


Measured memory_bytes: 2140
fun main() {
    var (A, B, C) = nextIntList()
    val K = nextInt()
    var count = 0
    while (A >= B) {
        count++
        B *= 2
    }
    while (B >= C) {
        count++
        C *= 2
    }
    println(if (K >= count) "Yes" else "No")
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

Measured memory_bytes: 36408
fun main(args: Array<String>) {
    val X = (1..5).map { readLine()!!.toInt() }
        .sortedByDescending { (it % 10).let { i -> if (i == 0) Int.MAX_VALUE else i } }
        .mapIndexed { index, it -> if (it % 10 == 0 || index == 4) it else 10 * (it / 10 + 1) }
    println(X.sum())
}

Measured memory_bytes: 35980
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int P[5010], C[5010];
int score[5010][5010];
int len[5010];
bool exist[5010][5010];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    rep(i, N) {
        cin >> P[i];
        P[i]--;
    }
    rep(i, N) cin >> C[i];
    rep(i, N) {
        int x = i;
        exist[i][x] = true;
        len[i]++;
        rep(j, N) {
            x = P[x];
            score[i][j + 1] = score[i][j] + C[x];
            if(exist[i][x]) break;
            exist[i][x] = true;
            len[i]++;
        }
        //cout << len[i] << " " << score[i][len[i]] << endl;
    }
    int ans = -INF;
    rep(i, N) {
        int add = 0;
        if(score[i][len[i]] >= 0) {
            int loop = K/len[i];
            add = max(add, loop * score[i][len[i]]);
            //cout << loop << " " << score[i][len[i]] << endl;
            if(loop > 0) ans = max(ans, add);
            rep(j, min(K - loop * len[i], len[i])) {
                ans = max(ans, add + score[i][j + 1]);
            }
            if(loop > 0) {
                int add2 = (loop - 1) * score[i][len[i]];
                //cout << i << " " << add2 << endl;
                rep(j, len[i]) {
                    ans = max(ans, add2 + score[i][j + 1]);
                }
            }
        } else {
            rep(j, min(K, len[i])) {
                ans = max(ans, score[i][j + 1]);
            }
        }
    }
    cout << ans << endl;

    return 0;
}


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

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

    auto result = 0;
    for (auto i = 0, last = 0; i < N; i++)
    {
        int t; cin >> t;
        result += T;
        if (t < last) result -= last-t;
        last = t + T;
    }
    cout << result << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int k,n,a[200001],x,m;
int main(){
    cin>>k>>n>>a[0];
    for(int i=1;i<n;i++){
        cin>>a[i];
        x+=a[i]-a[i-1];
        if(m<a[i]-a[i-1])m=a[i]-a[i-1];
    }
    x+=k-a[n-1]+a[0];
    if(m<k-a[n-1]+a[0])m=k-a[n-1]+a[0];
    cout<<x-m<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	string a,b,c;
	cin >> a; //cin >> b;// cin >> c;
	a[0]=='9'||a[1]=='9'?cout << "Yes"<< endl: cout << "No" << endl;

	
}

Measured memory_bytes: 256
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
sa = [0] * (n + 1)
sb = [0] * (m + 1)
for i in range(n):
  sa[i + 1] = sa[i] + a[i]
for i in range(m):
  sb[i + 1] = sb[i] + b[i]
r = m
ans = 0
for i in range(n + 1):
  if sa[i] > k:
    break
  while sa[i] + sb[r] > k:
    r -= 1
  ans = max(ans, i + r)
print(ans)


Measured memory_bytes: 47580
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST
import Data.Char


main :: IO ()
main = do
  n <- readLn :: IO Int
  ss <- map read . words <$> getLine :: IO [Integer]
  print $ solve n ss

solve n (d:ds)
  | d /= 0 = 0
  | null ds = 1
  | mn == 0 = 0
  | mx == 1 = 1
  | Map.notMember 1 cmap = 0
  | otherwise = go 1 [2..mx] -- foldl' f 1 [2..mx]
    where
      mx = maximum ds
      mn = minimum ds
      cmap = toCountMap ds
      go acc [] = acc
      go acc (ni:ns) 
        | ni > (fromIntegral n) = acc
        | otherwise = case Map.lookup ni cmap of
            Nothing -> 0
            Just cni -> go (acc `modmul` (power cniPrev cni)) ns
          where
            cniPrev = fromIntegral $ cmap Map.! (ni - 1)

      f acc ni = 
        case Map.lookup ni cmap of
          Nothing -> 0
          Just cni -> acc `modmul` (power cniPrev cni)
        where
          cniPrev = fromIntegral $ cmap Map.! (ni - 1)

toCountMap :: (Ord k) => [k] -> Map.Map k Int
toCountMap = Map.fromListWith (+) . flip zip (repeat 1)

divConst = 998244353 :: Integer
modadd x y = (x + y) `mod` divConst
modsub x y = (x - y) `mod` divConst
modmul x y = ((x `mod` divConst) * (y `mod` divConst)) `mod` divConst
moddiv x y = modmul x (power y (divConst - 2))
power x y
  | y == 0 = 1
  | y == 1 = x `mod` divConst
  | y `mod` 2 == 0 = (power x (y `div` 2))^2 `mod` divConst
  | otherwise = (power x (y `div` 2))^2 * x `mod` divConst


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,k,s;
    cin >> n >> k >> s;
    int a[n];
    rep(i,0,k) a[i] = s;
    if(s == 1e9){
        rep(i,k,n) a[i] = 1e9-1;
    }else{
        rep(i,k,n) a[i] = 1e9;
    }
    rep(i,0,n) cout << a[i] << " ";
    cout << endl;
}

Measured memory_bytes: 1792
def delta2height(arg_num):
    height = 0
    for i in range(1, arg_num):
        height += i
    return height


input_line = input().split()

west_margin = int(input_line[0])
east_margin = int(input_line[1])

delta = east_margin - west_margin

west_height = delta2height(delta)
snow_height = west_height - west_margin

print(str(snow_height))




Measured memory_bytes: 2940
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

// ????????´??°?????????????°?????????¶?????°??????????????????
const int MAX_N = 1<<20;
struct RMQRUQ {
  int n, dat[MAX_N*2-1], lazy[MAX_N*2-1];
  bool flag[MAX_N*2-1];
  RMQRUQ(){}
  RMQRUQ(int n_) {init(n_);}
  void init(int n_) {
    n = 1; while(n < n_) n *= 2;
    REP(i, n*2-1) dat[i] = INT_MAX, lazy[i] = 0, flag[i] = false;
  }
  void eval(int k, int l, int r) {
    if(flag[k]) {
      dat[k] = lazy[k];
      if(r-l>1) {
        lazy[2*k+1] = lazy[k]; flag[2*k+1] = true;
        lazy[2*k+2] = lazy[k]; flag[2*k+2] = true;
      }
      flag[k] = false;
    }
  }
  void update(int a, int b, ll x) {update(a,b,x,0,0,n);}
  void update(int a, int b, ll x, int k, int l, int r) {
    eval(k, l, r);
    if(b <= l || r <= a) return;
    if(a <= l && r <= b) {
      lazy[k] = x;
      flag[k] = true;
      eval(k, l, r);
    } else {
      update(a, b, x, 2*k+1, l, (l+r)/2);
      update(a, b, x, 2*k+2, (l+r)/2, r);
      dat[k] = min(dat[2*k+1], dat[2*k+2]);
    }
  }
  ll query(int a, int b) {return query(a,b,0,0,n);}
  ll query(int a, int b, int k, int l, int r) {
    eval(k, l, r);
    if(b <= l || r <= a) {
      return INT_MAX;
    }
    if(a <= l && r <= b) {
      return dat[k];
    }
    ll vl = query(a, b, 2*k+1, l, (l+r)/2);
    ll vr = query(a, b, 2*k+2, (l+r)/2, r);
    return min(vl, vr);
  }
};

RMQRUQ seg;
signed main(void)
{
  int n;
  cin >> n;
  seg.init(n);
  int q;
  cin >> q;
  REP(i, q) {
    int a;
    cin >> a;
    if(!a) {
      int s, t, x;
      cin >> s >> t >> x;
      t++;
      seg.update(s, t, x);
    } else {
      int s, t;
      cin >> s >> t;
      t++;
      cout << seg.query(s, t) << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 5456
#include <cstdio>
#include <cstring>
using namespace std;
int main(void){
    char s[101];
    scanf("%s",s);
    int d = strlen(s)-1;
    int n[101];
    
    int c=0;
    for(int i=0;i<=d;i++){
        n[i] = s[i] - 'a';
    }
    for(int i=0;i<=d/2;i++){
        if(n[i] != n[d-i]) c++;
    }
    
    printf("%d\n",c);
    return 0;
}


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

//入力：整数N
//出力：Nの平方根以下の最大の整数
int64_t sqrt(int64_t x){
    int64_t s=0;
    for(int64_t i=0; i <= x; i++){
        if(i*i > x){
            s = i-1;
            break;
        }
    }
    return s;
}







//入力：整数N
//出力:AB＝Nなる(A,B)であって|A-B|が最小の組(A,B)（AはB以下）のBの方
int64_t factor(int64_t N){
    int64_t B=0; //B=0と初期化するのを省略するとバグる
    int64_t M = sqrt(N);
    for(int64_t i=0; i < M; i++){
        if( N % (M - i) == 0 ){
            B = N / (M - i) ;
            break;
        }
    }
    return B;
}

/*
//入力：整数N
//出力：10進表記でのNの桁数
int64_t digit(int64_t x){
    int64_t d=1;
    for(int64_t i=0; i < x;i++){
        if( pow(10,i) <= x && x < pow(10,i+1)){
            d = i+1 ;
            break ;
        }
    }
    return d;
}
*/


//入力：整数N
//出力：10進表記でのNの桁数
int digit(int64_t x){
    int counter = 0;
    if(x == 0){
    return 1;
    }
  	while( x != 0){
    x = x/10 ;
    counter++;
    }
    return counter ;
}


int main(){

//入力を受け取る
int64_t N;
cin >> N ;


cout << digit(factor(N)) << endl;




}






Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,m,y,j,i,k,l,b,p;
  char s[10];
  scanf("%d %d",&n,&m);
  j=n;
  y=m;
  if(n>4)j=4;
  if(m>4)y=4;
  l=1<<(j+y);//printf("%d\n",l);
  for(i=0;i<l;i++){
    p=i;
    for(k=b=0;k<y+j;k++){
      s[y+j-k-1]='A';
      if(p%2){
	s[y+j-k-1]='B';
	b++;
      }
      p/=2;
    }
    s[k]=0;
    if(b-y)continue;
    printf("%s",s);
    if(n==6)printf("AA");
    if(m==6)printf("BB");
    if(n==5)printf("A");
    if(m==5)printf("B");
    if(n==5&&m==5)printf("\n%sBA",s);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 600
class Dinic:
    def __init__(self, len_X, len_Y):
        self.len_X, self.len_Y = len_X, len_Y
        self.edges = [[] for _ in range(len_X)]
        self.matched = [-1] * len_Y
        self.visited = set()

    def add_edge(self, x, y):
        self.edges[x].append(y)

    def dfs(self, x):
        """
        :param x: X側の未マッチングの頂点の1つ
        :param visited: 空のsetを渡す（外部からの呼び出し時）
        :return: 増大路が見つかればTrue
        """
        for next_x in self.edges[x]:
            if next_x in self.visited:
                continue
            self.visited.add(next_x)
            if self.matched[next_x] == -1 or self.dfs(self.matched[next_x]):
                self.matched[next_x] = x
                return True
        return False

    def solve(self):
        res = 0
        for x in range(self.len_X):
            self.visited = set()
            res += self.dfs(x)
        return res


#################################################################################################

N = int(input())

X = []
Y = []
for i in range(N):
    X.append([int(i) for i in input().split()])

for i in range(N):
    Y.append([int(i) for i in input().split()])

dinic = Dinic(len(X), len(Y))

for i in range(len(X)):
    for j in range(N):
        if X[i][0] < Y[j][0] and X[i][1] < Y[j][1]:
            dinic.add_edge(i, j)

print(dinic.solve())


Measured memory_bytes: 73664
#include<bits/stdc++.h>
#define ll long long
#define rg register
using namespace std;
const int MAXN=10;
int Deg[MAXN];
int main()
{   for(rg int i=1,A,B;i<=3;i++) scanf("%d%d",&A,&B),Deg[A]++,Deg[B]++;
	sort(Deg+1,Deg+5),Deg[1]==1&&Deg[2]==1&&Deg[3]==2&&Deg[4]==2?puts("YES"):puts("NO");
}


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define nl puts("");
#define pb push_back
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define line puts("-------");
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
typedef long long int ll;
using namespace std;
int main()
{
    char ch;
    cin>>ch;
    cout<<++ch;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long ans=1;
const int M=1e9+7;
int main() {
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		ans=ans*i%M;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int n, d;
    cin >> n >> d;
    vector<vector<int>> ps(n, vector<int>(d));
    for (auto& row : ps)
    {
        for (auto& elem : row)
        {
            cin >> elem;
        }
    }

    auto dist2 = [&](int i, int j) {
        int ans = 0;
        for (int k = 0; k < d; k++)
        {
            const auto diff = ps[i][k] - ps[j][k];
            ans += diff * diff;
        }
        return ans;
    };
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            const auto d2 = dist2(i, j);
            bool success = false;
            for (int k = 1; k * k <= d2; k++)
            {
                if (k * k == d2)
                {
                    success = true;
                }
            }
            if (success)
            {
                count++;
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
using namespace std;
typedef long long ll;
// cd test ; rm -R ./*; cd .. 

int main(void) {
  int n, m;
  cin >> n >> m;

  tuple<int, int, int> tp[m];
  
  rep (i, m) {
    int p, y;
    cin >> p >> y;
    tp[i] = make_tuple(p, y, i);
  }

  sort(tp, tp + m);

  pair<int, int> ans[m];

  map<int, int> mp;

  rep (i, m) {
    int p, y, idx;
    tie(p, y, idx) = tp[i];
    mp[p]++;
    ans[idx] = make_pair(p, mp[p]);
  }
  rep (i, m) {
    cout << setw(6) << setfill('0') << ans[i].first;
    cout << setw(6) << setfill('0') << ans[i].second << endl;;
  }
  
}
  

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

int main(void){
    int a = 1, N, K;
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        if(2 * a > a + K){
            a += K;
        }else{
            a *= 2;
        }
    }
    cout << a << endl;
}

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

ll n, m, x, y, z, p, q, r;
string str1, str2;
ll dp[100][5];

ll color(ll pos, ll prv)
{
    if(pos == n) return 1;

    if(dp[pos][prv] != -1) return dp[pos][prv];

    ll p = 0, q = 0, r = 0;

    if(str1[pos] != str2[pos]){

        if(prv == 0) p = 6 * color(pos + 2, 1);
        else if(prv == 1) p = 3 * color(pos + 2, 1);
        else p = 2 * color(pos + 2, 1);

    }

    else{
        if(prv == 0) p = 3 * color(pos + 1, 2);
        else if(prv == 1) p = color(pos + 1, 2);
        else p = 2 * color(pos + 1, 2);
    }

    return dp[pos][prv] = p % mod;

}

int main()
{
    memset(dp, -1, sizeof(dp));

    cin >> n >> str1 >> str2;

    ll ans = color(0, 0);
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
package main
 
import (
  "fmt"
)

func main() {
  var n int
  fmt.Scan(&n)
  h := make([]int, n)
  
   for i := range h {
    fmt.Scan(&h[i])
  }
  
  //n段目に降りた時の移動回数
  count := 0
  max := 0
  
  //次のマスに移動できる場合、回数を加算
  //移動できない場合、最高記録を保持してから回数を初期化する
  for i := 0; i < n-1; i++ {
    if h[i+1] <= h[i] {
      count++
    } else {
      if max < count { 
        max = count
      }
      count = 0 
    }
  }
  
  //最後のマスへの移動で最高記録を更新した場合
  if max < count {
        max = count
  }
  
  fmt.Println(max)
}

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

int main()
{
    int n, m; cin>>n>>m;
    vector<pair<int, int>> p;
    for(int a, b; m--; ) {
        cin>>a>>b;
        p.emplace_back(a, -b);
    }
    sort(begin(p), end(p));
    
    int res=1;
    int L=0, R=n+1;
    for(auto& e: p) {
        int a=e.first;
        int b=-e.second;
        if (a>=R) {
            ++res;
            L=a, R=b;
        }
        else {
            L=a, R=min(R, b);
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
// (setq-default c-basic-offset 2)

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

  // vector<int> x(n);
  // vector<int> y(n);

  int ret = 0;
  long long dd = (long long)(d) * (long long)d;
  for (int i = 0; i < n; ++i) {
    long long x, y;
    cin >> x >> y;

    long long dist = x * x + y * y;
    if (dist <= dd) {
      ++ret;
    }
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<cstdio>
#include<cstring>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
const int maxn=10000+10;
const int maxm=100000+10;
int n,m;

struct node
{
    char s[20];
    bool operator <(const node& rhs)const
    {
        return strcmp(s,rhs.s)<0;
    }
};

map<node,int> mp;

struct Edge
{
    node u,v;
    bool flag;
} e[maxm];

vector<int> G[maxn];
int pre[maxn],low[maxn];
int dfs_clock;

void tarjan(int u,int fa)
{
    low[u]=pre[u]=++dfs_clock;
    for(int i=0; i<G[u].size(); i++)
    {
        int v=G[u][i];
        if(v==fa)
            continue;
        if(!pre[v])
        {
            tarjan(v,u);
            low[u]=min(low[u],low[v]);
        }
        else
            low[u] = min(low[u],pre[v]);
    }
}

int main()
{
    while(scanf("%d%d",&n,&m)==2)
    {
        int id=0;
        mp.clear();
        dfs_clock=0;
        memset(pre,0,sizeof(pre));
        for(int i=1; i<=n; i++)
            G[i].clear();
        for(int i=0; i<m; i++)
        {
            e[i].flag=false;
            scanf("%s%s",e[i].u.s,e[i].v.s);
            if(mp.find(e[i].u)==mp.end())
                mp[e[i].u]= ++id;
            if(mp.find(e[i].v)==mp.end())
                mp[e[i].v]= ++id;
            int x = mp[e[i].u], y=mp[e[i].v];
            G[x].push_back(y);
            G[y].push_back(x);
        }
        tarjan(1,-1);
        bool ok=true;
        for(int i=1; i<=n; i++)
            if(!pre[i])
            {
                ok=false;
                break;
            }
        if(!ok)
            printf("0\n");
        else
        {
            int ans=0;//计数桥总数
            for(int i=0; i<m; i++)
            {
                int u=mp[e[i].u], v=mp[e[i].v];
                if(low[u]>pre[v]||low[v]>pre[u])
                    e[i].flag=true,ans++;
            }
            printf("%d\n",ans);
            /*for(int i=0; i<m; i++)
                if(e[i].flag)
                    printf("%s %s\n",e[i].u.s,e[i].v.s);*/
        }
    }
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int p[] = new int[N];
		int sum =0;
		for (int i=0;i<N;i++) {
			p[i] = sc.nextInt();
			sum +=p[i];
		}
		int front =0;
		int min = Integer.MAX_VALUE;
		for (int i=0;i<N;i++) {
			front +=p[i];
			if (min >Math.abs(sum-2*front)) {
				min = Math.abs(sum-2*front);
			}
		}
		System.out.println(min);
	}
}


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

int main(){
    int a,b;
    cin >> a >> b;
    int cnt = 0;
    int ans = 1;
    cnt = a;
    if (cnt >= b) ans = 1;
    else{
        while(cnt < b){
            cnt = (cnt - 1) + a;
            ans++;
        }
    }
    cout << ((b == 1)? 0 : ans) << endl;
    return 0;
}

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

int kaijo(int n) {
    if (memo[n] != 0) return memo[n];
    else return memo[n] = n * kaijo(n - 1);
}

int counter(int n, vector<int> pq, int j) {
    int c = 0;
    for (int i = j; i < n; i++) {
        if (pq[i] < pq[j]) c++;
    }
    return c;
}

int main() {
    memo[0] = 1;
    memo[1] = 1;
    int n, pa = 0, qb = 0;
    cin >> n;
    vector<int> p(n);
    vector<int> q(n);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];
    rep (i, n) {
        pa += counter(n, p, i) * kaijo(n - i - 1);
        qb += counter(n, q, i) * kaijo(n - i - 1);
    }
    if (pa - qb > 0) cout << pa - qb << endl;
    else cout << qb - pa << endl;
}

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

int main() {
  long long N, D;
  cin >> N >> D;
  
  vector<long long> X(N), Y(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
  }
  
  long long cnt = 0;
  for (int i = 0; i < N; i++) {
    long double d = sqrt(pow(X[i],2) + pow(Y[i],2));
    if (d <= D) {
      cnt++;
    }
  }
    
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 6488
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}

main(){
  int x,a;
  cin>>x>>a;

  if(x<a){
    cout<<0<<endl;
  }else{
    cout<<10<<endl;
  }
}


Measured memory_bytes: 256
N, M = map(int, input().split())
a = []
ans = -1
MOD = 10 ** 9 + 7
if N == 1:
    ans = 1
else:
    if M > 0:
        a += [int(input())]
    for i in range(M - 1):
        a += [int(input())]
        if a[i + 1] - a[i] == 1:
            ans = 0
            break
    a.append([-1])
if not ans in [0, 1]:
    memo = [0] * (N + 1)
    memo[0] = 1
    memo[1] = 1
    try:
        if a[0] == 1:
            a.pop(0)
            memo[1] = 0
    except:
        pass
    j = 0
    for i in range(N - 1):
        if i + 2 == a[j]:
            j += 1
            continue
        memo[i + 2] = memo[i] + memo[i + 1]
        memo[i + 2] = memo[i + 2] % MOD
    else:
        ans = memo[i + 2]
print(ans)


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

using namespace std;

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

typedef long long ll;

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

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

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

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

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

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


struct Edge {
    ll to;
    ll weight;
    Edge(ll t, ll w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, ll>;


typedef vector<vector<int> > Matrix;

const int INF = 100000000;
Matrix d;

void warshall_floyd(int n) { // nは頂点数
    for (int i = 0; i < n; i++)      // 経由する頂点
        for (int j = 0; j < n; j++)    // 開始頂点
            for (int k = 0; k < n; k++)  // 終端
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

int main() {
    int n; cin >> n;
    vector<int> a(n);
    int sum = 0;
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }

    int candidate1 = sum/n;
    int candidate2 = candidate1+1;

    int ans = 0;
    rep(i, n) {
        ans += pow(a[i]-candidate1, 2);
    }
    int tmp = 0;
    rep(i, n) {
        tmp += pow(a[i]-candidate2, 2);
    }

    chmin(ans, tmp);

    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 256
from collections import deque
s=deque(list(input()))
q=int(input())
rev=1

for i in range(q):
    a=list(input().split())
    if a[0]=='1':
        rev*=-1
    else:
        if a[1]=='1':
            if rev>0:
                s.appendleft(a[2])
            else:
                s.append(a[2])
        else:
            if rev>0:
                s.append(a[2])
            else:
                s.appendleft(a[2])

a=[]
for i in range(len(s)):
    a+=s.popleft()    
if rev<0:
    a=a[::-1]
print(''.join(a))

Measured memory_bytes: 11108
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S, T; cin >> S >> T;
  bool ans = true;
  for(int i = 0; i < S.length(); i++){
    if(S[i] != T[i]) ans = false;
  }
  if(ans) cout << "Yes";
  else cout << "No";
  return 0;
}


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

using LL = long long int;
using uLL = unsigned long long int;
using uint = unsigned int;
using ld = long double;


int main(){
	cin.tie(NULL);
	ios_base::sync_with_stdio(0);
    int  n, m;
    cin >> n >> m;
    cout << n*(n-1)/2+m*(m-1)/2 << '\n';

	return 0;
}


Measured memory_bytes: 256
/*
a=n*2^(-x)*5^(-y)

みたいな変換をかける

整数同士ならなんでも


少数と整数の組みは

それぞれの少数
a [2:-x, 5: -y]に対して
2がx以上かつ5がy以上の整数がいくつあるのか

表を作ればまあ、

2^14>1e4
5^6>1e4
*/
#include<bits/stdc++.h>
using namespace std;
long divnum(long x,long e){
  return (x%e==0? divnum(x/e,e)+1 :0);
}
int main(){
  long N; cin>>N;
  vector<pair<long,long>>A;
  vector<vector<long>>C(100,vector<long>(100,0));
  vector<vector<long>>D(101,vector<long>(101,0));

  for(long i=0;i<N;i++){
    string a;cin>>a;
    if(a.find(".")==string::npos){
      long x=atol(a.c_str());
      A.push_back(pair<long,long>(divnum(x,2),divnum(x,5)));
      C[divnum(x,2)+50][divnum(x,5)+50]++;
    }
    else{
      long p=a.length()-a.find(".")-1;
      long x=atol((a.substr(0,a.find("."))+a.substr(a.find(".")+1,-1)).c_str());
      A.push_back(pair<long,long>(divnum(x,2)-p,divnum(x,5)-p));
      C[divnum(x,2)-p+50][divnum(x,5)-p+50]++;
      
    }
  }
  // p,q以上の和が欲しいので2次元累積和
  for(long i=0;i<100;i++)for(long j=0;j<100;j++){
    D[i+1][j+1]=C[i][j]
      +D[i+1][j]
      +D[i][j+1]
      -D[i][j];
  }
 
  long ans=0;
  for(long i=0;i<N;i++){
    
    //x=p,qとして
    // -p以上, -q以上が欲しい
    
    ans+=D[100][100]
      -D[100][-A[i].second+50]
      -D[-A[i].first+50][100]
      +D[-A[i].first+50][-A[i].second+50];
    if(A[i].first>=0&&A[i].second>=0)ans--;
  }
  cout<<ans/2;
  
}

Measured memory_bytes: 7624
#include <iostream>
#include <queue>
#include <vector>

int main() {
  int n, m;
  std::cin >> n >> m;

  // 経路
  std::vector<std::vector<int>> path(n);

  for (int i = 0; i < m; ++i) {
    int u, v;
    std::cin >> u >> v;
    --u, --v;
    // 順経
    path[u].push_back(v);
  }

  int s, t;
  std::cin >> s >> t;
  --s, --t;

  const int goal = 3 * t;

  // 到着タグ
  std::vector<int> visited(3 * n);
  for (auto &v : visited) v = -1;

  visited[3 * s] = 0;

  std::queue<int> order;
  order.push(3 * s);

  while (!order.empty() && (visited[goal] == -1)) {
    int now = order.front();
    order.pop();

    int step = visited[now] + 1;

    auto &next_list = path[now / 3];
    for (auto next : next_list) {
      int next_pos = 3 * next + step % 3;
      auto &v = visited[next_pos];
      if (v == -1) {
        v = step;
        order.push(next_pos);
      }
    }
  }

  if (visited[goal] != -1) {
    std::cout << visited[goal] / 3 << std::endl;
  } else {
    std::cout << -1 << std::endl;
  }

  // // debug
  // std::cout << "=====" << std::endl;
  // for (int i = 0; i < visited.size(); i += 3) {
  //   printf("%5d %5d %5d\n", visited[i], visited[i + 1], visited[i + 2]);
  // }
}

Measured memory_bytes: 6912
#include<iostream>
using namespace std;
int main(){
	int s,k;
	cin>>k>>s;
	int c=0;
	for(int x=0;x<=k;x++){
	for(int y=0;y<=k;y++){
int	z=s-(x+y);
	if(z>=0&&z<=k){
		c++;
	}
	}	
		
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll int
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define pii pair<ll,ll>

using namespace :: std;

const ll maxn=1e6+500;
const ll mod=998244353;
const ll inf=1e9+500;

ll c[maxn];

void good(){
    cout<<"Yes";
    exit(0);
}
void bad(){
    cout<<"No";
    exit(0);
}
int main()
{
    ll n;
    cin>>n;
    ll mi=n;
    ll ma=0;
    for(ll i=0;i<n;i++){
        ll v;
        cin>>v;
        c[v]++;
        mi=min(mi,v);
        ma=max(ma,v);
    }
    if(ma-mi>1){
        bad();
    }
    if(ma==mi){
        if(ma==n-1){
            good();
        }
        else{
            if(ma*2<=n){
                good();
            }else{
                bad();
            }
        }
    }
    if(c[mi]>=ma){
        bad();
    }
    if(c[mi]+(ma-c[mi])*2>n){
        bad();
    }
    good();
}


Measured memory_bytes: 640
import math

N, K = [int(i) for i in input().split()]

output = 0
for i in range(1, N+1):
    cnt = 0
    while True:
        if i * 2 ** cnt >= K:
            break
        cnt += 1
    output += (1/N) * (0.5 ** cnt)

print(output)

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(ll i = (m); i < (n); ++i)

#define INF 1e9
const ll mod = 1e9+7;
const int MAX = 510000;
const int MOD = 1000000007;

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;
}
ll ans = 1;
ll N;


int main(){
  COMinit();
  ll n, k;
  cin >> n >> k;
  N = n;
  if(k==1){
    cout << n*(n-1) % mod << endl;
    return 0;
  }
  ans = 1;
  FOR(i, 1, min(N+1, k+1)){
    ans += (COM(N, i) *COM(N-i+i-1, i))%mod;
    ans %= mod;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 12288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MS(a) memset(a,0,sizeof(a))
#define MP make_pair
#define PB push_back
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3fLL;
inline ll read(){
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//////////////////////////////////////////////////////////////////////////
const int maxn = 1e5+10;

ll a[maxn*3],l[maxn*3],r[maxn*3];

int main(){
	priority_queue<int,vector<int>,greater<int> > pq;
	priority_queue<int> pq2;

	int n;
	scanf("%d",&n);
	for(int i=1; i<=3*n; i++){
		a[i] = read();
	}

	ll sum = 0;
	for(int i=1; i<=2*n; i++){
		pq.push(a[i]);
		sum += a[i];
		while((int)(pq.size()) > n){
			int t = pq.top();
			pq.pop();
			sum -= t;
		}
		l[i] = sum;
	}

	sum = 0;
	for(int i=3*n; i>n; i--){
		pq2.push(a[i]);
		sum += a[i];
		while((int)(pq2.size()) > n){
			int t = pq2.top();
			pq2.pop();
			sum -= t;
		}
		r[i] = sum;
	}

	ll ans = -INFLL;
	for(int i=n; i<=2*n; i++){
		ans = max(l[i]-r[i+1],ans);
	}
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7416
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();

    int ab = Math.abs(a-b);
    int bc = Math.abs(b-c);
    int ca = Math.abs(c-a);

    if (ca <= d) {
      System.out.println("Yes");
    } else if (ab <= d && bc <= d) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 21844
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<cmath>
#include<algorithm>
using namespace std;

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

    vector<int> A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];

    sort(A.begin(), A.end());

    vector<int> v(1E6 + 1, 0);
    for (int i = 0; i < N; i++) {
        if (v[A[i]]) {
            v[A[i]]++;
           continue;
        }

        for (int j = A[i]; j <= 1E6; j += A[i])
            v[j]++;
    }

    int ans = 0;
    for (int i = 0; i < N; i++)
        if (v[A[i]] == 1)
            ans++;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7948
//CODING ME ACCHHA KARNEKA HAI TERKO TO BAS PRACTICE KARTE REH
#include <bits/stdc++.h>
#define pragma
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define aisort sort(a,a+n)
#define adsort sort(a,a+n,greater<ll>())
#define PI 2 * acos(0)

typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef set<ll> Set;

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;

//MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

//POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

//MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}
    
//PRIME
    bool isPrime(ll n) { if (n <= 1)  return false; if (n <= 3)  return true;if (n%2 == 0 || n%3 == 0) return false; for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false; return true; } 

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y;
}




Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<int> S(n);
    rep(i, n) {
        cin >> S[i];
    }
    int q;
    cin >> q;
    vector<int> T(q);
    rep(i, q) {
        cin >> T[i];
    }

    int ans = 0;

    rep(i, q) {
        rep(j, n) {
            if(T[i] == S[j]) {
                ans++;
                break;
            }
        }
    }

    cout << ans;

    cout << endl;
    return 0;
}


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

mod = 998244353
N = int(input())
X = []
for _ in range(N):
    x, d = map(int, input().split())
    X.append((x, x + d))

X = sorted(X, key = lambda x: x[0])
L = [(0, -(10**9+1), 10**9+1)]
P = [-1] * (N+1)
for i, (x, y) in enumerate(X):
    while L[-1][2] <= y:
        if L[-1][2] > x and P[i+1] < 0:
            P[i+1] = L[-1][0]
        L.pop()
    if P[i+1] < 0:
        P[i+1] = L[-1][0]
    L.append((i+1, x, y))

C = [[] for _ in range(N+1)]
for i, p in enumerate(P):
    if p >= 0:
        C[p].append(i)

Y = [1] * (N+1)
for i in range(N+1)[::-1]:
    s = 1
    for j in C[i]:
        s = s * (Y[j] + 1) % mod
    Y[i] = s

print(Y[0])

Measured memory_bytes: 97192
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n,k;
	cin >> n >> k;
	ll a[n];
	ll mini=1;
	rep(i,0,n){
		cin >> a[i];
	}
	cout << (n-1)/(k-1) + bool((n-1)%(k-1));
	return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */


Measured memory_bytes: 1024
#include <stdio.h>

int main(){
	int n;
	scanf("%d", &n);
	if (1<= n&&n <=10000);
	int i=n%1000;
	int j= 1000-i;
	int k=n/1000;
	
	if (j==1000){
		printf("0");
	}
	else{
	
	printf ("%d\n", j);
}
	return 0;
}

Measured memory_bytes: 1704
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char arr[3];
    cin>>arr;
    if(arr[0]=='7' || arr[1]=='7' || arr[2]=='7')
    cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpii = vector<pll>;

int main(){
  ll a, b, x;
  cin >> a >> b >> x;

  ll ans = b / x - a / x;

  if(a % x == 0){
    ans++;
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define SZ(x) ((int)(x).size())
#define MEM(x,a) memset(x,a,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1000000007,N=1e5+5,M=1e5+5,INF=0x3f3f3f3f;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//head

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x,y,z;
    cin>>x>>y>>z;
    cout<<z<<' '<<x<<' '<<y;
    return 0;
}

Measured memory_bytes: 256
N,K= map(int,input().split())
H = list(map(int,input().split()))

def calc_steps(fromi,toi):
    return abs(H[toi] - H[fromi])

costs = [0 for _ in range(N)]
# N <= Kのとき
if N <= K:
    K = N-1

# 最初のK段のコスト。O(K**2)
for toi in range(1,K+1):
    onestep = calc_steps(0, toi)
    nsteps = [costs[fromi] + calc_steps(toi,fromi) for fromi in range(1,toi)]
    costs[toi] = min([onestep] + nsteps)

# 計算済みK段から次の段へのコスト計算。O(KN)
# c1, c2, [c3,,,c3+k], next
for lasti in range(K,N):
    cost = 10**9
    for fromi in range(1,K+1):
        # 次の段へのコストは直近K段までのコスト ＋ その段からのコスト
        nsteps = costs[lasti - fromi] + calc_steps(lasti, lasti - fromi)
        cost = min(cost, nsteps)
    costs[lasti] = cost
    # print(costs)

print(costs[-1])


Measured memory_bytes: 56544