akhauriyash/Code-Regression huggingface dataset:
class UnionFind:
    def __init__(self, n):
        self.par = [-1 for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if not x==y: # 根が同じでない場合のみ併合する
            if self.rank[x] < self.rank[y]:
                self.par[y] += self.par[x] # 要素数を併合
                self.par[x] = y # 根を付け替えている
            else:
                self.par[x] += self.par[y]
                self.par[y] = x
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1
        
    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y) 

def main():
    import sys
    input = sys.stdin.readline
    
    N = int(input())
    X = []
    Y = []
    for i in range(1,N+1):
        x,y = map(int,input().split())
        X.append([x,i])
        Y.append([y,i])
    
    X = sorted(X,key=lambda a:a[0])
    Y = sorted(Y,key=lambda a:a[0])
    DX = []
    DY = []
    for i in range(N-1):
        x1,i1 = X[i]
        x2,i2 = X[i+1]
        DX.append([abs(x1-x2),i1,i2])
        y1,i1 = Y[i]
        y2,i2 = Y[i+1]
        DY.append([abs(y1-y2),i1,i2])
    
    DX = sorted(DX,key=lambda a:a[0])
    DY = sorted(DY,key=lambda a:a[0])
    #print(DX)
    #print(DY)
        
    ans = 0
    A = UnionFind(N)
    i,j = 0,0
    c = 0
    while c < N-1:
        if i<=N-2 and j<=N-2:
            if DX[i][0] < DY[j][0]:
                cost,m1,m2 = DX[i]
                if not A.same_check(m1,m2):
                    #print(m1,m2)
                    A.union(m1,m2)
                    c += 1
                    ans += cost
                i += 1
            else:
                cost,m1,m2 = DY[j]
                if not A.same_check(m1,m2):
                    #print(m1,m2)
                    A.union(m1,m2)
                    c += 1
                    ans += cost
                j += 1
        elif i==N-1:
            cost,m1,m2 = DY[j]
            if not A.same_check(m1,m2):
                #print(m1,m2)
                A.union(m1,m2)
                c += 1
                ans += cost
            j += 1
        else:
            cost,m1,m2 = DX[i]
            if not A.same_check(m1,m2):
                #print(m1,m2)
                A.union(m1,m2)
                c += 1
                ans += cost
            i += 1
    print(ans)
        
    
    
main()

Measured memory_bytes: 127068
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  string s, t; cin >> s >> t;
  int n = s.size();

  bool ok = true;
  rep(i, n) if (s[i] != t[i]) ok = false;
  cout << (ok ? "Yes" : "No") << "\n";
  return 0;
}


Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace AtCoder
{
    static class Program
    {
        static void Main()
        {
            //ここから

            var vs = IO.ReadLineToIntList();
            var N = vs[0];
            var K = vs[1];

            double sum = 0;
            for(var i = 1.0; i <= N; i++)
            {
                if (i >= K) { sum += 1;continue; }
                sum += Math.Pow(0.5, Math.Ceiling(Math.Log(K / i, 2.0)));
            }

            var ans = sum / N;

            //ここまで
            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }

    static class Func
    {
        static long mod = 1000000007;
        static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
        static public long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }
        static public long LCM(long a, long b) { return (long)a * b / GCD(a, b); }
        static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); }


        public static double ToAngle(this double radian)
        {
            return (double)(radian * 180 / Math.PI);
        }

        public static double ToRadian(this double angle)
        {
            return (double)(angle * Math.PI / 180);
        }

        static public long Conbination(int n,int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * Conbination(n - 1, m - 1) / m;
        }

        static public void Factoring(long num, ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for (long i = 2; i < Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }
    }

    static class IO
    {
        static public string ReadLineToString() { return Console.ReadLine(); }
        static public int ReadLineToInt() { return int.Parse(Console.ReadLine()); }
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public List<string> ReadLineToStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<int> ReadLineToIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }

        static public List<double> ReadLineToDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }

        static public void WriteStrings(object[] strings) { foreach (var o in strings) { Console.Write(o + " "); } }
    }
}

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

int main() {
	int h1, m1, h2, m2, k;

	cin >> h1 >> m1 >> h2 >> m2 >> k;

	int h = h2 - h1;
	int m = h * 60 + m2 - m1 - k;

	cout << m << endl;
}

Measured memory_bytes: 3596
#include <stdio.h>
int main(void)
{
  char s[100002],*p,c;
  char a[256]={0};
  scanf("%s",s);
  for(p=s;*p!='\0';++p){
    a[*p]=1;
  }
  for(c='a';c<='z';++c){
    if(a[c]==0) break;
  }
  if(c>'z')
    printf("None\n");
  else
    printf("%c\n", c);
  return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int x, t;

int main() {
	cin >> x >> t;
	cout << max(x-t, 0) << ln;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	s := nextString()
	bs := []byte(s)
	cnt := 0
	for i := 0; i < len(bs)/2; i++ {
		if bs[i] != bs[len(bs)-1-i] {
			cnt++
		}
	}
	fmt.Println(cnt)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    const int A = 26;
    const int M1 = 1e2;
    const int M2 = 1e3;
    int D; cin >> D;
    vector<int> c(A);
    REP(i,A) cin >> c[i];
    vector<vector<int>> s(D,vector<int>(A));
    REP(i,D) REP(j,A) cin >> s[i][j];

    vector<int> last(A,-1);
    vector<int> ans(D);
    REP(i,D) {
        int mx = 0,a = -1;
        REP(j,A) {
            int tmp = (i-last[j])*c[j] + s[i][j];
            if (mx < tmp) {
                mx = tmp;
                a = j;
            }
        }
        ans[i]=a;
        last[a] = i;
    }
    auto calc = [&](const vector<int> &a){
        vector<int> l(A,-1);
        int score = 0;
        REP(i,D) {
            score += s[i][a[i]];
            l[a[i]] = i;
            REP(j,A) {
                score -= c[j]* (i-l[j]);
            }
        }
        return score;
    };

    int maxscore = calc(ans);

    random_device seed_gen;
    mt19937 engine(seed_gen());
    REP(_,M1) {
        int mx = maxscore;
        vector<int> a1(ans);
        REP(__,M2) {
            vector<int> a2(a1);
            a2[engine()%D] = engine() % A;
            int tmp = calc(a2);
            if (mx < tmp) {
                swap(a1,a2);
                mx = tmp;
            }
        }
        if (maxscore < mx) {
            swap(ans,a1);
            maxscore = mx;
        }
    }

    REP(i,D) OUT(ans[i]+1)

    return 0;
}

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int n; cin >> n;
    string s = to_string(n);

    reverse(s.begin(), s.end());
    if(n==stoi(s)) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}

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

void solve(long long N, long long M, std::vector<long long> a,
           std::vector<long long> b) {
    vector<ll> res(N+1);
    for (int i = 0; i < a.size(); i++) {
	res[a[i]]++;
	res[b[i]]++;
    }
    for (int i = 1; i < res.size(); i++) {
	cout << res[i] << endl;
    }
}

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

  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> a(M);
  std::vector<long long> b(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &a[i]);
    scanf("%lld", &b[i]);
  }
  solve(N, M, std::move(a), std::move(b));
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mps 1000000007
int main()
{
    long long a,b,c,x,y,z;
    cin>>a>>b>>c;
    x=max(max(a,b),c);
    z=min(min(a,b),c);
    y=a+b+c-x-z;
    int ans=0;
    if(x-z)
    {
        while(x%2==0 && y%2==0 && z%2==0)
        {
            ans++;
            a=(y+z)/2;
            b=(x+z)/2;
            c=(x+y)/2;
            x=a;
            y=b;
            z=c;
        }
        printf("%d\n",ans);
    }
    else
    {
        if(y%2)
            printf("0\n");
        else
            printf("-1\n");
    }
    return 0;
}


Measured memory_bytes: 256
import sys
X,K,D = map(int, input().split())
if X < 0: X = abs(X) #Xがマイナスならプラスに変換しておく

if X // D > K:
    X = X - (K * D)
    print(X)
    sys.exit() #ここはOK

if (X // D) <= K:
    if X % D >= abs((X % D)-D):
        if (K - (X // D)) % 2 == 1:
            print(abs((X % D)-D))
            sys.exit()
        else:
            print(X % D)
            sys.exit()
    else:
        if (K - (X // D)) % 2 == 1:
            print(abs((X % D)-D))
            sys.exit()
        else:
            print(X % D)
            sys.exit()





Measured memory_bytes: 9032
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

#define INF 1e9
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;


int main() {
    int n;
    cin >> n;
    int ans = 1;
    while(true) {
        if (ans * 2 <= n) ans *= 2;
        else goto last;
    }
    last:
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
	
		int N = keyboard.nextInt();
		int K = keyboard.nextInt();
		
		if(K != 1) {
			System.out.println(N - K);
		}else {
			System.out.println(0);
		}
		keyboard.close();	
	}
}

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

int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<char>> a(n,vector<char>(n));
    vector<vector<char>> b(m,vector<char>(m));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>a.at(i).at(j);
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<m;j++){
            cin>>b.at(i).at(j);
        }
    }
    int x=0;
    for(int k=0;k<=n-m;k++){
        for(int l=0;l<=n-m;l++){
            x=0;
            for(int i=0;i<m;i++){
               for(int j=0;j<m;j++){
                   if(a.at(i+k).at(j+l)==b.at(i).at(j)) x++;
                }
            }
            if(x==pow(m,2)) break;
        }
        if(x==pow(m,2)) break;
    }
    if(x==pow(m,2)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

const long long MOD = 1000000007;
struct mint {
  long long x;
  mint(long long x = 0) noexcept : x((x + MOD) % MOD) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x -= a.x) < 0) x += MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(long long t) const {
    if (t == 0) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(MOD - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};

constexpr int MAX = 1e6 + 10;

long long f[MAX], finv[MAX], inv[MAX];

void CombInit() {
  f[0] = f[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    f[i] = f[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

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

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

int main(){
  int N, M; cin >> N >> M;
  CombInit();

  mint ALL = 1;
  ALL *= Perm(M, N);
  ALL *= Perm(M, N);

  rep1(i, N) {
    mint cnt = Comb(N, i);
    cnt *= Perm(M, i);
    cnt *= Perm(M - i, N - i);
    cnt *= Perm(M - i, N - i);
    if (i % 2 == 1) cnt *= -1;
    ALL += cnt;
  }
  cout << ALL.x << endl;
}


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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

map<int, llong> cnt;

int gcd(int x, int y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	int n, x;
	cin >> n >> x;
	vector<int> a(n);
	for (auto&& i : a) {
		cin >> i;
	}
	sort(begin(a), end(a));
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (x >= a[i]) {
			x -= a[i];
			if (x > 0 && i == n - 1) break;
			ans++;
		}
		else break;
	}
	cout << ans << "\n";
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  string s;
  cin>>s;
  if(s=="AAA" || s=="BBB") cout<<"No";
  else cout<<"Yes";
}


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

bool solve(string s){
    bool isP=true;
    for(int i=0;i<s.size();i++){
        if(s[i]!=s[s.size()-i-1]){
            isP=false;
            break;
        }
    }
    return isP;
}

int main(){
    string s;cin>>s;
    int l=(s.size()-1)/2;
    int r=(s.size()+3)/2;

    if(solve(s)&&solve(s.substr(0,l))&&solve(s.substr(r-1))){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
  
}

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

max_count = 0
current_height = 0
current_count = 0

for idx in range(N):
	height = H[idx]
	if(height > current_height):
		max_count = max(max_count, current_count)
		current_height = height
		current_count = 0
	else:
		current_height = height
		current_count += 1


max_count = max(max_count, current_count)
print(max_count)

Measured memory_bytes: 14252
import bisect
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}
# b = list(map(lambda x: math.ceil(x/10)*10, a))


n, l, t = map(int, input().split())
pos = []
count = 0
for i in range(n):
    x, w = map(int, input().split())
    pos.append((x+t*(3-2*w)) % l)
    count += (x+t*(3-2*w))//l
pos.sort()
count %= n
ans = pos[count:]+pos[:count]
for i in ans:
    print(i)


Measured memory_bytes: 8960
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    S = Scanner.string()
    T = Scanner.string()
    N = len(S)
    ans = 0
    for i in range(N):
        if S[i] != T[i]:
            ans += 1

    print(ans)


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 10824
#include <stdio.h>

#define MAX_N 45

int main(){
  int N,i,dp[MAX_N] = {1,1};
  for(i = 2 ; i < MAX_N ; i++){
    dp[i] = dp[i-1] + dp[i-2];
  }
  scanf("%d",&N);
  printf("%d\n",dp[N]);
  return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <stack>
#include <cstdio>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <iterator>
#include <sstream>
#define popcount(x) __builtin_popcount(x)
#define oddparity(x) __builtin_parity(x)
#define clz(x) __builtin_clz(x)
#define ctz(x) __builtin_ctz(x)
#define sf scanf
#define pf printf
using namespace std;

int i, n, l;
string x;
multiset<string>ms;
multiset<string>::iterator it;

int main()
{
    sf("%d %d", &n, &l);
    for (i = 0; i < n; i++) {
        cin >> x;
        ms.insert(x);
    }
    for (i = 0, it = ms.begin(); i < n; i++, it++) {
        cout << *it;
    }
    pf("\n");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
long long gcd(long long a, long long b)
{
    return b ? gcd(b, a % b) : a;
}
const long long mod = 1000000007;
long long pw[200200] = { 1 };

int main()
{
    map<pair<ll,ll>,pair<ll,ll> > cnt;
    for (int i = 1; i < 200200; i++) pw[i] = (pw[i - 1] * 2) % mod;
    int n;
    cin>>n;
    long long a = mod - 1;
    while(n--)
    {
        ll x,y;
        cin>>x>>y;
        if(x==0&&y==0)
        {
            a++;continue;
        }
        if(make_pair(x,y)<make_pair(0LL,0LL)) x=-x,y=-y;
        ll g=gcd(abs(x),abs(y));
        x/=g,y/=g;
        if(y>0) cnt[ {x,y}].first++;
        else cnt[ {-y,x}].second++;
    }
    long long r = 1;
	for (auto& p : cnt){
		r = r * (pw[p.second.first] + pw[p.second.second] - 1) % mod;
	}

	printf ("%lld\n", (a + r) % mod);
}


Measured memory_bytes: 20788
#include <stdio.h>
#include <math.h>
int main(void)
{
    int a,b,c,max;
    scanf("%d%d%d",&a,&b,&c);
    if(a>=b){
        if(a>=c)
            max=a;
        else
            max=c;
    }
    else if(b>=a){
        if(b>=c)
            max=b;
        else
            max=c;
    }
    else
        max=c;
    printf("%d\n",max*9+a+b+c);

    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int N = Integer.parseInt(sc.next());
			int M = Integer.parseInt(sc.next());
			if (N == 0 && M == 0) break;
			int r = Integer.parseInt(sc.next());
			int[][] imos = new int[M][2000];
			for (int i = 0; i < r; i++) {
				int t = Integer.parseInt(sc.next());
				int n = Integer.parseInt(sc.next());
				int m = Integer.parseInt(sc.next()) - 1;
				int s = Integer.parseInt(sc.next());
				if (s == 1)
					imos[m][t]++;
				else
					imos[m][t]--;
			}
			for (int i = 0; i < M; i++) {
				for (int j = 1; j < 2000; j++) {
					imos[i][j] += imos[i][j - 1];
				}
			}
			int q = Integer.parseInt(sc.next());
			for (int i = 0; i < q; i++) {
				int s = Integer.parseInt(sc.next());
				int e = Integer.parseInt(sc.next());
				int m = Integer.parseInt(sc.next()) - 1;
				int ans = 0;
				for (int j = s; j < e; j++) {
					if (imos[m][j] != 0)
						ans++;
				}
				System.out.println(ans);
			}
		}
	}
}


Measured memory_bytes: 365592
c = [list(map(int, input().split())) for _ in range(3)]
b = [i[0] for i in c]
if  len(set([i - j[1] for i, j in zip(b, c)])) == 1 and  len(set([i - j[2] for i, j in zip(b, c)])) == 1:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3060
x,y = map(int,input().split())
#xをベースに
r = 0 #→2 ↑1
u = x #→1 ↑2

while y != r + u*2:
    u -= 2
    r += 1
    if u < 0: #到達する方法がない
        print(0)
        exit()

#modありのコンビネーション計算
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9 + 7
N = u+r+1 #必要な数
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

print(cmb(u+r,r,mod))


Measured memory_bytes: 88084
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int cnt =0;
        int max = 0;

        for(int i = 0;i<s.length();i++){
            if(s.charAt(i)=='A'||s.charAt(i)=='T'||s.charAt(i)=='C'||s.charAt(i)=='G'){
                cnt++;
                if(max<cnt){
                    max = cnt;
                }
            }else{
                cnt = 0;
            }
        }
        System.out.println(max);
        
    }
}


Measured memory_bytes: 21716
x,n = map(int,input().split())

if n==0:
    print(x)
else:
    a = list(map(int,input().split()))
    lower = min(a)
    upper = max(a)
    mini = 10000005
    res = -1
    for i in range(lower-1,upper+2):
        if i not in a:
            if abs(x-i)<mini:
                mini = abs(x-i)
                res = i

    print(res)


Measured memory_bytes: 9188
#include<stdio.h>
int main(){
int a,b,c,tmp;
scanf("%d %d %d",&a,&b,&c);
if(a>b){
tmp=a;
a=b;
b=tmp;
}
if(b>c){
tmp=b;
b=c;
c=tmp;
}
if(a>b){
tmp=a;
a=b;
b=tmp;
}
printf("%d %d %d\n",a,b,c);
return 0;
}


Measured memory_bytes: 2108
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;

namespace AtCoder
{
	public class Program
	{
		static void Main()
		{
			int n = int.Parse(Console.ReadLine());
			var a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

			long sum = a.Sum();
			long sunuke = 0;
			long arai = sum;

			long ans = long.MaxValue;
			for (int i = 0; i < n - 1; i++) {
				sunuke += a[i];
				arai -= a[i];

				long val = Math.Abs(sunuke - arai);
				ans = Math.Min(ans, val);
			}

			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 36420
#include<bits/stdc++.h>
using namespace std;
int st[100005];
int main()
{
    int g,t;
    long long x,q,w,e,r,nt,re=0;
    multiset<int>k;
    scanf("%d",&t);
    for(g=0;g<t;g++){
        scanf("%d",&x);
        st[--x]=g;
    }
    k.insert(-1),k.insert(-1),
    k.insert(t),k.insert(t);
    for(g=t-1;g>=0;g--){
        k.insert(st[g]);
        auto z=k.find(st[g]);
        z++, e=*z;
        z++, r=*z;
        z--, z--;
        z--, w=*z;
        z--, q=*z;
        nt=(((r-e)*(st[g]-w))+((w-q)*(e-st[g])));
        re+=(nt*(g+1));
    }
    printf("%lld\n",re);
    return 0;
}


Measured memory_bytes: 5376
import heapq
N,M=map(int,input().split())
A=list(map(lambda x: x*(-1),list(map(int,input().split()))))
A.sort()
B=[]
for i in range(N):
    heapq.heappush(B,A[i])
for i in range(M):
    heapq.heappush(B,(((heapq.heappop(B))*(-1))//2)*(-1))
print((sum(B))*(-1))

Measured memory_bytes: 14180
import itertools

n, m, r = map(int, input().split())
rs = list(map(int, input().split()))
rs = [r-1 for r in rs]

inf = float('inf')
dists = [[inf] * n for _ in range(n)]
for i in range(n):
    dists[i][i] = 0

for mm in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    dists[a][b] = c
    dists[b][a] = c

## Warshall–Floyd
for k in range(n):
    for i in range(n):
        for j in range(n):
            dists[i][j] = min(dists[i][j], dists[i][k] + dists[k][j])

tours = []
for perm in itertools.permutations(rs):
    d = 0
    for i in range(r-1):
        d += dists[perm[i]][perm[i+1]]
    tours.append(d)
print(min(tours))
    


Measured memory_bytes: 73816
"use strict";
function main(input) {
    const S = input.replace("\n", "");
    const O = "RUD";
    const E = "LUD";
    let flg = true;
    for (let idx in S) {
        idx = parseInt(idx);
        if ((idx + 1) % 2 && -1 == O.indexOf(S[idx])) {
            flg = false;
            break;
        }
        if (idx % 2 && -1 == E.indexOf(S[idx])) {
            flg = false;
            break;
        }
    }
    console.log(flg ? "Yes" : "No");
    return;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29772
#include <stdio.h>
int main(void)
{
    char S[4], T[4];
    scanf("%s %s", S, T);
    int count = 0;
    if(S[0] == T[0]) count++;
    if(S[1] == T[1]) count++;
    if(S[2] == T[2]) count++;
    printf("%d", count);
}

Measured memory_bytes: 128
dic = {}
n = int(input())
for i in range(n):
  word = input()
  if (word not in dic):
    dic[word] = 1
  else:
    val = dic[word]
    val += 1
    dic.update([(word, val)])
m = int(input())
for i in range(m):
  word = input()
  if (word not in dic):
    dic[word] = -1
  else:
    val = dic[word]
    val -= 1
    dic.update([(word, val)])
ans = max(dic.values())
print(max(ans, 0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
const int mod = 1000000007;
//const int mod = 998244353;
 

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);
 
bool vector_finder(std::vector<ll> vec, ll number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
  }
  else { // 発見できなかったとき
    return false;
  }
}


// M * (M-1)^(N-1-K) * N-1 C K
int main(int argc, const char * argv[]) {
    ll X,N; cin >> X >> N;
    vector<ll> P(N);
    
    ll index;
    ll max_p = -1000;
    ll min_p = 1000;
    for(ll i=0;i<N;i++){
        cin >> P[i];
    }
    
    sort(P.begin(),P.end());
        
    for(ll i=0;i<N;i++){
        if(P[i]<=X){
            index = i;
        }
        if(max_p <= P[i])
            max_p = P[i];
        if(min_p >= P[i])
            min_p = P[i];
    }
    
    if(N==0){
        cout << X << endl;
        return 0;
    }
    
    map<ll,ll> MAP;
    ll min_abs = 10000;
    ll ans;
    for(ll i=min_p-5;i<max_p+5;i++){
        if(vector_finder(P,i)) continue;
            
        ll ABS = abs(X-i);
        if(min_abs >= ABS){
            if(MAP.find(ABS) == MAP.end()){//まだ値が存在しない場合
                MAP[ABS] = i;
                min_abs = ABS;
                ans = i;
            }
        }
        
    }
    cout << ans << endl;
    
    return 0;
}



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

poin = B[A[0]-1]

for i in range(1,N):
  poin += B[A[i]-1]
  if A[i] - A[i-1] == 1:
    poin += C[A[i-1]-1]
    
print(poin)

Measured memory_bytes: 3064
using System;
using System.IO;

namespace CA {
	class Prg {
		static void Main() {
			int i = int.Parse(Console.ReadLine());
			string[] s = Console.ReadLine().Split(' ');
			while (i-- != 0) {
				Console.Write(s[i]);
				if (i != 0) Console.Write(" ");
			}
			Console.WriteLine();
        }
	}
}

Measured memory_bytes: 8992
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    auto n = lread();
    auto k = lread();
    long ans = 1;
    foreach (i; 0 .. n)
    {

        ans = min(ans * 2, ans + k);
    }
    writeln(ans);
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 3580
s = input()
k = ['A', 'G', 'C', 'T']
i = 0

while i < len(s):
    if s[i] in k:
        s = s
    else:
        s_changed = s[:i] + 'z' + s[i + 1:]
        s = s_changed
    i += 1

s_split = s.split('z')
ans = len(max(s_split, key=len))
print(ans)

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


long long int Exp(long long int exp_n,long long int exp_e, long long exp_mod);


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


long long int Exp(long long int exp_n,long long int exp_e, long long int exp_mod){
  long long int exp_o = 1;
  long long int exp_x=exp_n;
  long long int exp_tmp;
  
  while(0<exp_e){
    exp_tmp = exp_e/2;
    if(exp_e - exp_tmp*2 == 1){
      exp_o = exp_o*exp_x;
      if(exp_o>exp_mod){
        exp_o=exp_o%exp_mod;
      }
    }
    
    exp_x = exp_x*exp_x;
    if(exp_x>exp_mod){
      exp_x=exp_x%exp_mod;
    }
    exp_e = exp_tmp;
  }
  return exp_o;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
  }
  int ans = 0;
  for (int i = 0; i < n - 1; ++i) {
    if (p[i] == i + 1) {
      swap(p[i], p[i + 1]);
      ++ans;
    }
  }
  if (p[n - 1] == n) {
    ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
import java.util.*;

public class Main{
   Scanner in = new Scanner(System.in);

   void solve(){
        HashMap<String, Integer> map = new HashMap<>();
        String min = "";
        String[] line = in.nextLine().split(" ");

        for(String s : line){
            if(map.containsKey(s)){
                map.put(s, map.get(s) + 1);
            }else{
                map.put(s, 1);
            }
            if(min.length() < s.length()){
                min = s;
            }
        }
        String maxStr = "";
        int maxVal = 0;
        for(String s: map.keySet()){
            if(maxVal < map.get(s)){
                maxVal = map.get(s);
                maxStr = s;
            }
        }
        System.out.println(maxStr + " " + min);
        
   }

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

Measured memory_bytes: 25760
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()



int main(void){

    int N, A, B, ans;
    cin >> N >> A >> B;

    ans = N*A;
    if(ans<B){
        cout << ans << endl;

    }else{
        cout << B << endl;
    }
	
    return 0;
}


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

class Main {
	static PrintStream out = System.out;
	static Scanner in = new Scanner(System.in);

	public static void main(String[] args) {
		int n = in.nextInt();
		int a = in.nextInt();
		long min = a,max = a,sum = a;
		for (int i = 1; i < n; i++) {
			a = in.nextInt();
			min = Math.min(a, min);
			max = Math.max(a, max);
			sum += a;
		}
		out.println(String.format("%d %d %d", min, max, sum));
	}
}

Measured memory_bytes: 31952
#include<iostream>
using namespace std;
int main() {
	int n = 0;
	for (int i = 0; i < 4; i++){
		int b;
		cin >> b;
		n += b;
	}
	int a = n % 60;
	int k = (n - a) / 60;
	cout << k << endl << a << endl;
	char c;
	cin >> c;
}

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

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

  for(int i=0; i<a.size()-1; ++i){
    if(a[i]==a[i+1])a.erase(a.begin()+i);
  }

  n=a.size();

  int ans=0, flg=0;
  if(n>=2 && a[0]<a[1])flg=1;
  else if(n>=2 && a[0]>a[1])flg=-1;

  for(int i=1; i<n; ++i){
    if(i==n-1){++ans; break;}
    if(a[i]<a[i+1] && flg==-1){
      if(n>i+2 && a[i+1]<a[i+2])flg=1;
      else if(n>i+2 && a[i+1]>a[i+2])flg=-1;
      ++ans;
    }
    if(a[i]>a[i+1] && flg==1){
      if(n>i+2 && a[i+1]<a[i+2])flg=1;
      else if(n>i+2 && a[i+1]>a[i+2])flg=-1;
      ++ans;
    }
  }

  if(n==1)ans=1;

  cout<<ans<<endl;
}

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

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

ll const mod = 1e9+7;

//約数列挙
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

ll p5(ll i) {
  ll ans = 1;
  ans*=i;
  ans*=ans;
  ans*=ans;
  ans*=i;
  return ans;
}

int main() {
  ll X,A,B;
  cin >> X;
  for(ll i=0;i<1000;i++) {
    ll j = i-1;
    while (p5(i)-p5(j)<=X) {
      if (p5(i)-p5(j)==X) {
        cout << i << ' ' << j << endl;
        return 0;
      }
      else {
        j--;
      }
    }
  }
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

typedef long long ll;

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

// const int C ;
// const int M = 1000000007;

int dist(char x) {
  if (x == 'a') return 0;
  int d = (x - 'a');
  return 26 - d;
}

int main () {
  string S;
  int K;
  cin >> S >> K;
  string ans = "";
  for (auto x : S) {
    int d = dist(x);
    char c;
    if (K >= d) {
      c = 'a';
      K -= d;
    } else {
      c = x;
    }
    ans = ans + c;
  }
  ans[ans.size()-1] = ans[ans.size()-1] + K%26;
  cout << ans << endl;
}


Measured memory_bytes: 824
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// ****************************************CODE***************************************//


ll n, k;
ll h[110000];
ll dp[110000];

int main() {
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> h[i];
    for(int i = 0; i < 110000; i++) dp[i] = inf;

    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 1; j <= k; j++){
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
        }
    }

    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1920
#include<iostream>
using namespace std;
int main(){
    int n,a[5][4][11];
    for(int i=1;i<5;i++){
        for(int j=1;j<4;j++){
            for(int k=1;k<11;k++){
                a[i][j][k]=0;
            }
        }
    }
    cin>>n;
    for(int i=0;i<n;i++){
        int b,f,r,v;
        cin>>b>>f>>r>>v;
        a[b][f][r]+=v;
    }
    for(int i=1;i<5;i++){
        for(int j=1;j<4;j++){
            for(int k=1;k<11;k++){
                cout<<' '<<a[i][j][k];
            }
            cout<<endl;
        }
        if(i!=4)cout<<"####################\n";
    }
    return 0;
}


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

int main() {
    int n, m;
    string s;
    cin >> n >> m >> s;
    reverse(s.begin(), s.end());
    vector<int> jmp(n + 1);
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '0')
            jmp[i] = i;
        else
            jmp[i] = jmp[i - 1];
    }

    int pt = 0;
    vector<int> ans;
    while (pt < n) {
        int to = jmp[min(n, pt + m)];
        if (pt == to) {
            cout << -1 << endl;
            return 0;
        }
        ans.push_back(to - pt);
        pt = to;
    }
    reverse(ans.begin(), ans.end());
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
#define ll long long
#define f(i, x, n) for(int i = x; i < n; i++)
#define dbg(x) cout << x << endl
#define dbg2(x, y) cout << x << " " << y << endl
#define dbg3(x, y, z) cout << x << " " << y << " " << z << endl
#define mod 1000000007
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    int a[3][3];
    f(i, 0, 3){
        f(j, 0, 3){
            cin >> a[i][j];
            
        }
    }
    int n;
    cin >> n;
    int num;
    f(k, 0, n){
        cin >> num;
        f(i, 0, 3){
            f(j, 0, 3){
                if(a[i][j] == num){
                    a[i][j] = 0;
                }
            }
        }
    }
    f(i, 0, 3){
        if(a[i][0] + a[i][1] + a[i][2] == 0){
            dbg("Yes");
            return 0;
        }
    }
    f(i, 0, 3){
        if(a[0][i] + a[1][i] + a[2][i] == 0){
            dbg("Yes");
            return 0;
        }
    }
    if(a[1][1] + a[2][2] + a[0][0] == 0){
        dbg("Yes");
        return 0;
    }
    if(a[0][2] + a[1][1] + a[2][0] == 0){
        dbg("Yes");
        return 0;
    }
    dbg("No");
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline
EPS = 10**(-8)
INF = 10**16

N, M = map(int, input().split())
graph = [set() for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    graph[a-1].add(b-1)

dp = [0]*N
dps = [0]*N
dpl = [0]*N
for n in reversed(range(N-1)):
    for p in graph[n]:
        if dp[p] != -1:
            dps[n] += dp[p]
            dpl[n] += 1
    if dpl[n] > 0:
        dp[n] = dps[n]/dpl[n] + 1
    else:
        dp[n] = -1

Weight = [0]*N
Weight[0] = 1
for n in range(N):
    for p in graph[n]:
        Weight[p] += Weight[n]/dpl[n]

ans = dp[0]
for n1 in range(N):
    if len(graph[n1]) != 1:
        for n2 in graph[n1]:
            newE = (dps[n1]-dp[n2])/(dpl[n1]-1) + 1
            tmp = dp[0] - Weight[n1]*dp[n1] + Weight[n1]*newE
            if tmp < ans:
                ans = tmp

print(ans)

Measured memory_bytes: 19260
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        public static void Main()
        {
            var tmp = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int n = tmp[0];
            int a = tmp[1];
            int b = tmp[2];
            var sum = Enumerable.Range(1, n).Where(
                x =>
                {
                    var s = x.ToString()
                    .ToCharArray()
                    .Select(y => int.Parse(y.ToString()))
                    .Sum();

                    return s >= a && s <= b;
                })
                .Sum();
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
#define rep(i,n) for(ll i=0;i<(n);i++)
int main() {
	ll a, b, x;
	cin >> a >> b >> x;
	cout << ((x >= a && a + b >= x) ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 256