akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace competitive_programming
{
    class Program
    {
        static void Main(string[] args)
        {
            var main = new Program();
            main.solve();
        }

        void solve()
        {
            long k = long.Parse(Console.ReadLine());
            Queue<long> queue = new Queue<long>();
            for(int i = 1;i <= 9; i++)
            {
                queue.Enqueue(i);
                //Console.WriteLine(i);
            }

            for(int i = 0;i < k - 1 ; i++)
            {
                var x = queue.Dequeue();
                if (x % 10 != 0) queue.Enqueue(10 * x + x % 10 - 1);
                queue.Enqueue(10 * x + x % 10);
                if (x % 10 != 9) queue.Enqueue(10 * x + x % 10 + 1);

                //Console.WriteLine(x);
            }
            Console.WriteLine(queue.Dequeue());
        }
    }

    struct Vector2
    {
        public Vector2(long x, long y)
        {
            this.x = x;
            this.y = y;
        }
        public long x;
        public long y;
    }

    struct Vector3
    {
        public int x;
        public int y;
        public int z;
    }
}


Measured memory_bytes: 15072
/* AOJ 0078
 *
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0078
 *
 */

#include <stdio.h>

int m[15][15];

void newdiagonal(int size, int*x, int*y);
void wrap(int size, int*x, int*y);

void wrap(int size, int*x, int*y){
    if(*x<0){
        *x=size-1;
        newdiagonal(size, x, y);
    }
    if(*y<0){
        *y=size-1;
        newdiagonal(size, x, y);
    }
    if(size <= *x){
        *x=0;
        newdiagonal(size, x, y);
    }
    if(size <= *y){
        *y=0;
        newdiagonal(size, x, y);
    }
}

void newdiagonal(int size, int*x, int*y){
    if(m[*y][*x]){
        *x -=1;
        *y +=1;
        wrap(size, x, y);
    }
}



void next(int size, int*x, int*y){
    *x +=1;
    *y +=1;
    wrap(size, x, y);
    newdiagonal(size, x, y);
}

void magic(int size){
    int i;
    int range;
    int x, y;

    range = size*size +1;
    x = size/2;
    y = x+1;

    for(i=1;i<range;i++){
        m[y][x] = i;
        if(i!= size*size)
            next(size, &x, &y);
    }
}

void clean(void){
    int i; 
    int j;
    for(i=0;i<15;i++){
        for(j=0;j<15;j++){
            m[j][i]=0;
        }
    }
}

void print(int size){
    int i; 
    int j;
    for(j=0;j<size;j++){
        for(i=0;i<size;i++){
            printf("%4d",m[j][i]);
        }
        printf("\n");
    }
}

int main(){
    int n;

    while(scanf("%d", &n)==1 && n){
        clean();
        magic(n);
        print(n);
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <cmath>
#include <limits>
#include <iostream>
using namespace std;

int main() {
  long long n,d;
  cin >> n >> d;
  
  vector<long long> x(n),y(n);
  for(long long i=0; i<n; i++)
    cin >> x.at(i) >> y.at(i);
  
  long long count = 0;
  long long r;
  
  for(long long i=0; i<n; i++){
    r = x.at(i) * x.at(i) + y.at(i) * y.at(i);
    if(sqrt(r) <= d)
      count++;
  }
  
  cout << count << endl;
  
  
}

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

map<string, int> mp;
int main() {
	int n;
	scanf("%d", &n);
	long long ans = 0;
	for(int i = 0; i < n; i++) {
		string temp;
		cin >> temp;
		sort(temp.begin(), temp.end());
		if(mp.count(temp)) ans += mp[temp];
		mp[temp]++;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
 
typedef long long ll;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define DBGV(v,n) forn(i,n) cout << v[i] << " "; cout << endl
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl
#define MAXN 30005
#define INF 1000000007


int main()
{ 
	FIN;
	
	#ifdef input
		freopen("T2.txt", "r", stdin);
	#endif
	
	vector <int> v(5);
	int pos = -1;
	for(int i=0; i<5; i++)
	{
		cin >> v[i];
		if(v[i]==0) pos=i+1;
	}
	cout << pos << endl;
	
	return 0;
}


Measured memory_bytes: 3564
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<sstream>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;


int main()
{
 int a,b,c,d;
 cin >> a >>b >> c >>d;
 int num1 = ceil(a * 1.0/ d);
 int num2 = ceil(c * 1.0 / b);
 if(num1 >= num2)
  cout << "Yes" <<endl;
 else
  cout << "No" << endl; 

 return 0;
}

Measured memory_bytes: 3592
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

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

int main() {
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}


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

#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;

int main(){
    while(true){
    int n,m;
    cin >> n >> m;
    if(n == 0 && m == 0) return 0;
    int h[n];
    int w[m];
    rep(i,0,n) cin >> h[i];
    rep(i,0,m) cin >> w[i];

    vector<int> cumsumh;
    cumsumh.push_back(0);
    rep(i,0,n) cumsumh.push_back(cumsumh[i] + h[i]);

    vector<int> cumsumw;
    cumsumw.push_back(0);
    rep(i,0,m) cumsumw.push_back(cumsumw[i] + w[i]);

    vector<int> combh;
    rep(i,1,n+1){
        rep(j,i,n+1){
            combh.push_back(cumsumh[j] - cumsumh[i-1]);
        }
    }
    
    vector<int> combw;
    rep(i,1,m+1){
        rep(j,i,m+1){
            combw.push_back(cumsumw[j] - cumsumw[i-1]);
        }
    }

    sort(combh.begin(),combh.end());
    sort(combw.begin(),combw.end());

    int ans = 0;
    for(auto e: combh){
        ans += upper_bound(combw.begin(),combw.end(),e) - lower_bound(combw.begin(),combw.end(),e);
    }
    cout << ans << endl;
    }

}


Measured memory_bytes: 19804
#include<stdio.h>

int main(void){
    int a, b, c;
    scanf("%d %d %d",&a, &b, &c);
    if((a < b && a < c) && b < c){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 2104
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();

		int mod = 1000000007;
		long total = power(2, n, mod);
		long ra = nCr(n, a, mod);
		long rb = nCr(n, b, mod);
		long ans = total - ra - rb - 1 + mod + mod;
		ans %= mod;
		System.out.println(ans);
	}

	static long power(long x, long n, int m) {
		if (n == 0) {
			return 1;
		}
		long val = power(x, n / 2, m);
		val = val * val % m;
		if (n % 2 == 1) {
			val = val * x % m;
		}
		return val;
	}

	static long nCr(long n, int r, int m) {
		long val = 1;
		for (int i = 1; i <= r; i++) {
			val = val * ((n - i + 1) % m) % m;
			val = val * modinv(i, m) % m;
		}
		return val;
	}

	static long modinv(long a, int m) {
		long b = m;
		long u = 1;
		long v = 0;
		long tmp = 0;

		while (b > 0) {
			long t = a / b;
			a -= t * b;
			tmp = a;
			a = b;
			b = tmp;

			u -= t * v;
			tmp = u;
			u = v;
			v = tmp;
		}

		u %= m;
		if (u < 0) u += m;
		return u;
	}
}


Measured memory_bytes: 23124
#include<stdio.h>

//this file is not a C file but a C++ file                                      
void seisekiduke(void);//宣言                                                   

int main(void){
    int stnum;//the number of the student                                       
    while(1) {
        scanf(" %d", &stnum);
        if(stnum == 0) {
            break;
        }
        for(int i = stnum - 1;i >= 0;i -= 1) {
            seisekiduke();//一名の生徒の成績を付ける                            
        }
    }
    return 0;
}

void seisekiduke(void) {
    int pm, pe, pj = 0;//score                                                  
    char grade;
     scanf(" %d %d %d", &pm, &pe, &pj);
        if((pm == 100 || pe == 100 || pj == 100) ||
           (pm + pe) / 2 >= 90                   ||
           (pm + pe + pj) / 3 >= 80) {
           grade = 'A';
        }else if((pm + pe + pj) / 3 >= 70 ||
                (((pm + pe + pj) / 3 >= 50) && (pm >= 80 || pe >= 80))){
            grade = 'B';
        }else{
            grade = 'C';
        }
        printf("%c\n", grade);

}

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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N,P;
vector<int> A;
ll dp [51] [2];

int main()
{
	scanf("%d%d",&N,&P);
	A.assign(N,0);
	FOR(i,0,N){
		scanf("%d",&A [i]);
	}

	dp [0] [0] = 1;
	FOR(i,0,N) FOR(j,0,2){
		dp [i + 1] [j] += dp [i] [j];
		if(A [i] % 2 == 1){
			dp [i + 1] [!j] += dp [i] [j];
		}
		else{
			dp [i + 1] [j] += dp [i] [j];
		}
	}

	printf("%lld\n",dp [N] [P]);

	return 0;
}


Measured memory_bytes: 256
def main():
    S = list(input())
    K = int(input())
    cnt = 0
    if K == 1:
        T = S
        for i in range(len(T)-1):
            if T[i] == T[i+1]:
                T[i+1] = '.'
        ans = T.count('.')
        print(ans)
        return

    if len(S) == 1:
        ans = max(0, (K - (K%2==1))//2)
        print(ans)
        return

    if len(set(S)) == 1:
        tmp = len(S)*K
        tmp = tmp - (tmp%2 == 1)
        ans = tmp//2
        print(ans)
        return

    T3 = S + S + S
    for i in range(len(T3)-1):
        if T3[i] == T3[i+1]:
            T3[i+1] = '.'
    
    T2aster = T3[len(S):(2*len(S))].count('.')
    T3aster = T3.count('.')
    ans = T3aster + T2aster * (K-3)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9152
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main() {
	string s;
	cin >> s;

	SORT(s);

	REP(i, s.length()-1) {
		if (s[i] == s[i + 1]) {
			cout << "no" << endl;
			return 0;
		}
	}

	ANS("yes");
	


	return 0;
}



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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0;i < n;++i) cin >> a[i];
    ll ans = 0,mx = 0;
    for (int i = 0;i < n;++i) {
        if (mx > a[i]) ans += mx-a[i];
        mx = max(mx,(ll)a[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4044
# エラトステネスの篩, 累積和
def make_prime_table(N):
    sieve = list(range(N + 1))
    sieve[0] = -1
    sieve[1] = -1
    for i in range(2, int(N ** 0.5) + 1):
        if sieve[i] != i:
            continue
        for j in range(i * i, N + 1, i):
            if sieve[j] == j:
                sieve[j] = i
    return sieve


max_lr = 10 ** 5

prime_table = make_prime_table(max_lr)

cs = [0] * (max_lr + 1)
for i in range(3, max_lr + 1, 2):
    if prime_table[i] == i and prime_table[(i + 1) // 2] == (i + 1) // 2:
        cs[i] = 1
for i in range(1, max_lr + 1):
    cs[i] += cs[i - 1]

Q = int(input())
result = []
for _ in range(Q):
    l, r = map(int, input().split())
    result.append(cs[r] - cs[l - 1])
print('\n'.join(str(i) for i in result))


Measured memory_bytes: 24876
#include <iostream>

using namespace std;

template<typename T>
class BinTree {
private:
    struct Node {
        T val;
        Node *parent;
        Node *left;
        Node *right;
    };

    Node *root;

    void inner_print_inorder(Node *x) {
        if (x == NULL) return;

        inner_print_inorder(x->left);
        cout << " " << x->val;
        inner_print_inorder(x->right);

        return;
    }

    void inner_print_preorder(Node *x) {
        if (x == NULL) return;

        cout << " " << x->val;
        inner_print_preorder(x->left);
        inner_print_preorder(x->right);

        return;
    }

public:
    BinTree() {
        root = NULL;
    }

    void insert(T val) {
        Node *z = new Node;
        z->val = val;
        z->parent = NULL;
        z->left = NULL;
        z->right = NULL;

        Node *y = NULL;
        Node *x = root;
        while (x != NULL) {
            y = x;
            if (val < x->val) {
                x = x->left;
            } else {
                x = x->right;
            }
        }
        z->parent = y;

        if (y == NULL) {
            root = z;
        } else if (z->val < y->val) {
            y->left = z;
        } else {
            y->right = z;
        }

        return;
    }

    void find(T val) {
        Node *x = root;

        while (x != NULL) {
            if (x->val == val) {
                cout << "yes" << endl;
                return;
            } else if (x->val > val) {
                x = x->left;
            } else {
                x = x->right;
            }
        }

        cout << "no" << endl;
        return;
    }

    void print_inorder() {
        inner_print_inorder(root);
        cout << endl;
        return;
    }

    void print_preorder() {
        inner_print_preorder(root);
        cout << endl;
        return;
    }
};

int main() {
    int32_t n;
    cin >> n;

    BinTree<int32_t> bt;
    for (int32_t i = 0; i < n; i++) {
        string command;
        cin >> command;

        if (command == "insert") {
            int32_t val;
            cin >> val;
            bt.insert(val);
        } else if (command == "find") {
            int32_t val;
            cin >> val;
            bt.find(val);
        } else if (command == "print") {
            bt.print_inorder();
            bt.print_preorder();
        }
    }

    return 0;
}

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

typedef long long ll;

#define PB push_back
#define MP make_pair

int GCD(int x, int y) {
    if (y == 0) return x;
    return GCD(y, x % y);
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    int a[n]; 
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<int> l(n, 1), r(n, 1);
    l[0] = a[0];

    for (int i = 0; i < n - 1; ++i) {
        l[i + 1] = GCD(l[i], a[i + 1]);
    }

    r[n - 1] = a[n - 1];
    for(int i = n - 1; i > 0; --i) {
        r[i - 1] = GCD(r[i], a[i - 1]);
    }

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (i == 0) ans = max(ans, r[i + 1]);
        else if (i == n - 1) ans = max(ans, l[i - 1]);
        else ans = max(ans, GCD(r[i + 1], l[i - 1]));
    }
    cout << ans << "\n";
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* print new lines
*/

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

int64_t factorial(int n) {
    int64_t cal = 1;
    for (int k = 1; k <= n; k++) {
        cal *= k;
        cal %= 1000000007;
    }
    return cal;
}

int main() {
    int N, M; cin >> N >> M;
    int t = abs(N - M);
    if (t >= 2) {
        cout << 0 << endl;
    } else {
        int64_t fn, fm, ans;
        int e = 1;
        if (!t) e = 2;
        fn = factorial(N);
        fm = factorial(M);
        ans = e * fn * fm % 1000000007;
        cout << ans << endl;
    }
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
typedef pair<ll, ll> P;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

struct mint {
  long long x; // typedef long long ll;
  mint(long long 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(long long 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;}

long long modpow(long long a, long long n) {
  long long atai = 1;
  while (n > 0) {
    if (n % 2) {
      atai *= a;
	  atai%=MOD;
      n-=1;
    } 
    a *= a;
    a%=MOD;
    n /= 2;
  }
  return atai;
}
int main(){
	ll n;
    cin>>n;
    mint ans=modpow(10,n)-modpow(9,n)*2+modpow(8,n);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3620
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::iter::*;
#[allow(unused_imports)]
use std::*;

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
#[test]
        fn solve_test() {
            $(
                {
                    let mut out = Vec::<u8>::new();
                    solve($input,&mut out);
                    let out_str =str::from_utf8(&out).unwrap();
                    assert_eq!(&out_str, &$output);
                }
            )*
        }
    };
}
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
#[allow(unused_mut)]
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr,str) => {
        $iter.next().unwrap()
    };

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

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

fn main() {
    let mut out = std::io::stdout();

    solve(&stdin!(), &mut out);
}

#[allow(unused_mut)]
fn solve<W: std::io::Write>(src: &str, out: &mut W) {
    #[allow(unused_macros)]
    macro_rules! out {
        ($fmt:expr) => {{
            let _ = out.write_fmt(format_args!($fmt));
        }};
        ($fmt:expr, $($args:tt)*) => {{
            let _ = out.write_fmt(format_args!($fmt, $($args)*));
        }};
    }
    #[allow(unused_macros)]
    macro_rules! outln {
        ($fmt:expr) => {{
            out!(concat!($fmt,"
"));
        }};
        ($fmt:expr, $($args:tt)*) => {{
            out!(concat!($fmt, "
"), $($args)*);
        }};
    }

    input! {
        source = src,
        x:isize,
        k:usize,
        d:isize,
    }

    let c = min(k, (x.abs() / d).abs() as usize);
    k -= c;
    let r = d * c as isize;
    x = if x > 0 { x - r } else { x + r };
    if x.abs() < d.abs() {
        k %= 2;
    }
    while k > 0 {
        k -= 1;
        x = if x > 0 { x - d } else { x + d };
    }
    out!("{}", x.abs());
}
test! {}


Measured memory_bytes: 2140
# -*- coding: utf-8 -*-

i = input()

c = 0
c_list = []

if len(i) == 1:
    if i in ['A', 'C', 'G', 'T']:
        print(1)
        exit()
    else:
        print(0)
        exit()

for moji in i:
    if moji in ['A', 'C', 'G', 'T']:
        c += 1
        c_list.append(c)
    else:
        c_list.append(c)
        c = 0

print(max(c_list))

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

int n;
vector<int> s[500];
vector<int> e[30];
bool saw[500];

bool f(int p, int ori){
	if(saw[p] && p == ori) return false;
	if(saw[p]) return true;
	saw[p] = true;
	rep(i,e[p].size()){
		if(!f(e[p][i],ori)) return false;
	}
	return true;
}

void solve(){
	rep(i,500) saw[i] = false;
	rep(i,500) s[i].clear();
	rep(i,30) e[i].clear();
	rep(i,n){
		string str;
		cin >> str;
		rep(j,str.size()){
			int x = str[j]-'a';
			s[i].push_back(x);
		}
	}
	for(int i = 0; i < n-1; i++){
		int t = min(s[i].size(),s[i+1].size());
		bool ok = false;
		rep(j,t){
			if(s[i][j] != s[i+1][j]){
				e[s[i][j]].push_back(s[i+1][j]);
				ok = true;
				break;
			}
		}
		if(!ok){
			if(s[i].size() > s[i+1].size()){
				puts("no");
				return;
			}
		}
	}
	rep(i,30) sort(e[i].begin(),e[i].end());
	rep(i,30) e[i].erase(unique(e[i].begin(),e[i].end()),e[i].end());
	rep(i,30){
		rep(j,500) saw[j] = false;
		if(!f(i,i)){
			puts("no");
			return;
		}
	}
	puts("yes");

}

int main(){
	while(true){
		cin >> n;
		if(n == 0) break;
		solve();
	}
}

Measured memory_bytes: 1276
#include <iostream>
#include<algorithm>
#include <vector>
#include <iomanip>
#include<string.h>
#include<stdio.h>


int main()
{
    long N;
    std::vector<long> V;
    std::cin >> N;
    for(long i=0; i<N; i++){
        long temp;
        std::cin >> temp;
        V.push_back(temp);
    }
    std::sort(V.begin(),V.end());
    double value=V[0];
    for(long i=1; i<N; i++){
        value=((double)value+(double)V[i])/(double)2.0;
    }
    std::cout << value << std::endl;
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
#define MOD 1000000007

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  ll N;
  cin >> N;
  vector<pair<double,double>> towns;
  rep(i, N){
    double x, y;
    cin >> x >> y;
    towns.emplace_back(x, y);
  }
  double ans = 0;
  rep(i, N) rep(j, i){
    double dist = sqrt(pow(towns[i].first - towns[j].first, 2) + pow(towns[i].second - towns[j].second, 2));
    ans += dist;
  }
  ans = ans * 2 / N;
  printf("%.10f\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iomanip>
using namespace std;
 
#define REP(i,n) for(long long (i)=0;(i)<(long long)(n);(i)++)
#define RREP(i,n) for(long long (i)=(long long)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;
 
int main() {
 
    string s; cin >> s;
    if (s.find("AC") != string::npos) {
    	cout << "Yes" << endl;
    } else {
    	cout << "No" << endl;
    }
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define vin(v, N) vi v; rep(i, N) {int x; cin >> x; v.push_back(x);}

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)

const int MAX_N = 1e5 + 5;

void solve() {
    int N;
    cin >> N;
    int ans = 0;
    REP(i, 1, N-1) {
        ans += (N-1)/i;
    }
    cout << ans;
}

//#define LOCAL 1

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

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();

    return 0;
}


Measured memory_bytes: 3648
n = int(input())
h = list(map(int, input().strip().split()))

flg = 0
cnt = 1

for i in range(1,len(h)):
    for j in range(0,i):
        if h[j]>h[i]:
            flg =1
    if flg == 0:
        cnt += 1
    else:
        flg = 0

print(cnt)

Measured memory_bytes: 3060
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N,L = inpl()
aa = inpl()
tmp = 0
for i in range(N-1):
	if aa[i] + aa[i+1] >= L:
		tmp += 1
		ind = i+1

if tmp == 0:
	print('Impossible')
else:
	print('Possible')
	for i in range(1,ind):
		print(i)
	for i in reversed(range(ind,N)):
		print(i)


Measured memory_bytes: 15272
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main()
{
  int N;cin >> N;
  vector<int>A(N);
  rep(i,N)cin >> A[i];
  if(N==1){cout << 1 << endl;return 0;}

  int ans=1;
  int asc=-1;
  rep(i,N-1){
    if(asc==-1){
      if(A[i+1]==A[i])continue;
      asc=(A[i]<=A[i+1]?0:1);
    }
    else{
      if((asc==0&&A[i]>A[i+1])||(asc==1&&A[i]<A[i+1])){
        ans++;
        asc=-1;
      }
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int A,B,C;
    cin>>A>>B>>C;
    int S=max({A,B,C});
    S=S*3-A-B-C;
    if(S%2==0){cout<<S/2<<endl;}
    else{cout<<(S+3)/2<<endl;}
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	ll x,y,z;
	cin >> x;
	y = x / 500; z = (x%500)/5;
	cout << (y*1000+z*5) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
#define endl '\n'
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

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

    string s;
    cin >> s;
    for(int i = 0; i < (int) s.size(); ++i){
        cout << 'x';
    }
    cout << endl;
}


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

using namespace std;

using llong = long long int;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000007;
const static int INF = 1<<30;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<llong> A(n), B(n);
    rep(i, n) cin >> A[i] >> B[i];
    sort(all(A));
    sort(all(B));

    llong mi, ma;
    if (n % 2) {
        mi = A[n/2];
        ma = B[n/2];
    } else {
        mi = A[n/2 - 1] + A[n/2];
        ma = B[n/2 - 1] + B[n/2];
    }

    cout << ma - mi + 1 << endl;
    
    return 0;
}


Measured memory_bytes: 6368
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

LL modpow(LL n) {
	LL ans = 1;
	LL two = 2;
	while (n > 0) {
		if (n % 2 == 1) {
			ans = ans*two%MOD;
		}

		two = two*two%MOD;
		n /= 2;
	}

	return ans;
}

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

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

	for (int i=n - 1; i >= 0; i -= 2) {
		if (i == 0) {
			if (tb[i] != 1) {
				cout << "0" << endl;
				return 0;
			}
		}
		else {
			if (tb[i] != 2) {
				cout << "0" << endl;
				return 0;
			}
		}

		
	}

	
	cout << modpow((LL)(n / 2)) << endl;
	return 0;
}

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

int dep[200010],dp[200010];
vector<int> e[200010];

int d;

void dfs(int x,int p){
	for(int it:e[x])
		if(it!=p)
			dep[it]=dep[x]+1,dfs(it,x),d=max(d,dp[x]+1+dp[it]),dp[x]=max(dp[x],1+dp[it]);
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=1,u,v;i<n;i++){
		cin>>u>>v;
		e[u].emplace_back(v);
		e[v].emplace_back(u);
	}
	dfs(1,0);
	if(d%3!=1)	cout<<"First"<<endl;
	else	cout<<"Second"<<endl;	
}


Measured memory_bytes: 24704
//============================================================================
// Name        : ITP_1_8_D.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <string>
using namespace std;

int main() {
	string str_s, str_p;
	int i,j;
	bool able=false;
	getline(cin,str_s);
	getline(cin,str_p);
	for(i=0; i<(int)str_p.length()-1; ++i) {
		str_s+=str_s[i];
	}
	for(i=0; i<(int)str_s.length()-(int)str_p.length()+1;++i) {
		for(j=0; j<(int)str_p.length(); ++j) {
			if(str_s[i+j]!=str_p[j]) {
				break;
			}
		}
		if(j==(int)str_p.length()) {
			able=true;
		}
	}
	cout << (able?"Yes":"No") << endl;
	return 0;
}

Measured memory_bytes: 3188
import java.util.Scanner;
 class Main {
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		// TODO Auto-generated method stub
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		
		if(a < b){
			System.out.println("a < b");
		}
		else if(a > b){
			System.out.println("a > b");
		}
		else {
			System.out.println("a == b");
		}
		
	}

}

Measured memory_bytes: 26228
#include <iostream>
#include <string>

using namespace std;

int main(){
  string str;
 getline(cin,str);
  for(int i=0;i<str.size();i++){
if('a'<=str[i]&&str[i]<='z')str[i]+=('A'-'a');
  }
  cout << str << endl;
}

Measured memory_bytes: 1172
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;

typedef long long int lli;
lli pascal[1010][1010];
const int MOD=100000007;

int main(){
  pascal[0][0]=1;
  for(int i=1;i<1010;i++){
    pascal[i][0]=pascal[i][i]=1;
    for(int j=1;j<i;j++)
      pascal[i][j]=(pascal[i-1][j] + pascal[i-1][j-1])%MOD;
  }

  int r,c,sx,sy,gx,gy;
  cin>>r>>c>>sx>>sy>>gx>>gy;
  int t=0;
  int xx,yy;
  xx=min(abs(sx-gx),r-abs(sx-gx));
  yy=min(abs(sy-gy),c-abs(sy-gy));
  if(r == abs(sx-gx)*2) t++;
  if(c == abs(sy-gy)*2) t++;
  cout << (pascal[xx+yy][xx]<<t)%MOD << endl;
  return 0;
}

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

using namespace std;


vector<int> dev(int n) {
    vector<int> ret;
    
    for(int i=1; i*i<=n; ++i) {
        if(n%i == 0) {
            ret.push_back(i);
            
            if(i!=1 && i*i!=n) {
                ret.push_back(n/i);
            }
        }
    }

    ret.push_back(n);

    return ret;
}

int main() {
    int n, a[100000];

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

    sort(a, a+n);

    int ans = -1;
    for (int i=0; i<2; i++) {
        auto vec = dev(a[i]);
        size_t len = vec.size();

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

        for (int j=0; j<len; j++) {
            int cont = 0;
            for (int k=0; k<n; k++) {
                if (a[k]%vec[j] == 0) cont++;
            }

            //cout << cont << endl;

            ans = (cont >= n-1) ? max(ans, vec[j]) : ans;
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 640
import copy
import math

# a = get_int()
def get_int():
    return int(input())
# a = get_string()
def get_string():
    return input()
# a_list = get_int_list()
def get_int_list():
    return [int(x) for x in input().split()]
# a_list = get_string_list():
def get_string_list():
    return input().split()
# a, b = get_int_multi()
def get_int_multi():  # a, b = get_int_multi()
    return map(int, input().split())
# a_list = get_string_char_list()
def get_string_char_list():
    return list(str(input()))
# print("{} {}".format(a, b))
# for num in range(0, a):
# a_list[idx]
# a_list = [0] * a
'''
while (idx < n) and ():

    idx += 1
'''

def main():

    a_list = get_string_char_list()
    ans = 0
    count = 0
    for s in a_list:

        if s in ("A","C","G","T"):
            count += 1
            ans = max(ans, count)
        else:
            count = 0
    print(ans)

if __name__ == '__main__':
    main()




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

int main()
{
    ll h,n,a,s=0;
    cin>>h>>a;
    while(a--){
        cin>>n;
        s+=n;
    }
    if(s>=h)cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
m, d = [int(_) for _ in input().split(' ')]

answer = 0
for i in range(2, d + 1):
    d1 = i % 10
    d10 = i // 10
    for j in range(4, m + 1):
        if d1 >= 2 and d10 >= 2 and d1 * d10 == j:
            answer += 1
print(answer)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

    static int inf = 1000000000;

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        int m = Integer.parseInt(scan.next());
        int[] a = new int[m];
        int[][] c = new int[m][];
        for (int i = 0; i < m; i++) {
            a[i] = Integer.parseInt(scan.next());
            int b = Integer.parseInt(scan.next());
            c[i] = new int[b];
            for (int j = 0; j < b; j++) {
                c[i][j] = Integer.parseInt(scan.next());
            }
        }
        scan.close();

        int[][] dp = new int[m + 1][1 << n];
        for (int i = 0; i <= m; i++) {
            for (int j = 0; j < (1 << n); j++) {
                dp[i][j] = inf;
            }
        }
        dp[0][0] = 0;

        for (int i = 0; i < m; i++) {
            for (int j = 0; j < (1 << n); j++) {
                if (dp[i][j] == inf) {
                    continue;
                }

                // 選ばない
                dp[i + 1][j] = Math.min(dp[i + 1][j], dp[i][j]);

                // 選ぶ
                int after = j;
                for (int k : c[i]) {
                    after |= (1 << (k - 1));
                }
                dp[i + 1][after] = Math.min(dp[i + 1][after], dp[i][j] + a[i]);
            }
        }

        if (dp[m][(1 << n) - 1] != inf) {
            System.out.println(dp[m][(1 << n) - 1]);
        } else {
            System.out.println(-1);
        }
    }

}


Measured memory_bytes: 67236
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = 998244353;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;


template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


void solve() {
	ll n;
	cin >> n;
	ll a[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	cout << a[n - 1] << en;
}

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

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 4020;
typedef long long ll;
const int mod = 924844033;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
int fac[maxn];
int n, k;
int f[maxn][maxn][2];
int id[maxn];
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	fac[0] = 1;
	for(int i = 1;i < maxn;++i) fac[i] = (ll) fac[i - 1] * i % mod;
	cin >> n >> k;
	id[0] = 998244353;
	int tot = 0;
	for(int i = 1;i <= k;++i) {
		for(int j = i;j <= n;j += k) id[++tot] = j;
		for(int j = i;j <= n;j += k) id[++tot] = j;
	}
	f[0][0][0] = 1;
	for(int i = 1;i <= tot;++i) {
		for(int j = 0;j <= i + 1 >> 1;++j) {
			f[i][j][0] = (f[i - 1][j][0] + f[i - 1][j][1]) % mod;
			if(id[i] - id[i - 1] == k && j)
				f[i][j][1] = f[i - 1][j - 1][0];
		}
	}
	int ans = 0;
	for(int i = 0;i <= n;++i) {
		ans = (ans + (i & 1 ? mod - 1 : 1ll) * (f[tot][i][0] + f[tot][i][1]) % mod * fac[n - i]) % mod;
	}
	std::cout << ans << '\n';
}


Measured memory_bytes: 123904
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,m,k=0,g,x,f,t;
    cin>>m>>n;
    if(m > n)
    {
        cout<<"safe\n";
    }
    else
    {
        cout<<"unsafe\n";
    }

}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <map>
using namespace std;

map<string, int> mp;
int main() {
	string S; int K; cin >> S >> K;
	for(int i=0; i<S.size(); ++i){
		for(int j=1; i+j<=S.size(); ++j){
			++mp[S.substr(i, j)];
			if(mp.size()>5){
				auto itr=mp.end();
				--itr;
				bool flag = itr->first == S.substr(i, j);
				mp.erase(itr);
				if(flag) break;
			}
		}
	}
	auto itr=mp.begin();
	for(int i=1; i<K; ++i) ++itr;
	cout << itr->first << endl;
	return 0;
}

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

using namespace std;

long long calc(long long h, long long w){
	long long res = h * w, a, b, c, d, e;
	for(int i = 1; i <= h - 1; i++){
		a = i * w;
		b = (long long)((h - i + 1) / 2) * w;
		c = (long long)((h - i) / 2 )* w;
		d = (h - i) * (long long)((w + 1) / 2);
		e = (h - i) * (long long)(w / 2);
		res = min(res, max({a, b, c}) - min({a, b, c}));
		res = min(res, max({a, d, e}) - min({a, d, e}));
	}
	return res;
}

int main(){
	long long h, w, ans = 0;
	cin >> h >> w;
	ans = min(calc(h, w), calc(w, h));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main() {
	int n,k;
	scanf("%d",&n);
	scanf("%d", &k);
	int ans=1;
	int i;
	for ( i = 0; i < n; i++){
		if (ans * 2 > ans + k)
			ans += k;
		else
			ans *= 2;
	}
	printf("%d ", ans);
	return 0;
}

Measured memory_bytes: 128
import sys
import bisect
input = sys.stdin.readline

mod = 998244353

class BITree:
    def __init__(self,n):
        self.s = [-10**9-1]*(n+1)
        self.n = n
    def change(self,idx,val):
        # 1-index
        while idx < self.n+1:
            self.s[idx] = max(self.s[idx],val)
            idx += idx&(-idx)
        return
    def get(self,idx):
        # 1-index
        res = -10**9-1
        while idx > 0:
            res = max(res,self.s[idx])
            idx -= idx&(-idx)
        return res


n = int(input())
ans = 1
XD = []
X = []
for i in range(n):
    x,d = map(int,input().split())
    XD.append((x,d))
    X.append(x)
XD.sort()
X.sort()
dp = [0]*(n+1)
dp[-1] = 1
# dp[i] = 左からi+1番目から右側での問題文のやつ(ただしi = nのとき1)
# dp[0] を知りたい
BIT = BITree(n)
for i in range(n-1,-1,-1):
    x,d = XD[i]
    will = max(x+d,BIT.get(bisect.bisect_left(X, x+d)))
    BIT.change(i+1,will)
    # print(bisect.bisect_left(X, will)+1)
    dp[i] = dp[i+1] + dp[bisect.bisect_left(X, will)]
    dp[i] %= mod
print(dp[0])

Measured memory_bytes: 85212
import sys

s = list(input())
t = list(input())
m = len(s) - len(t)

for i in range(m + 1):
    ok = True
    for j in range(len(t)):
        if s[m - i + j] != '?' and s[m - i + j] != t[j]:
            ok = False
            break
    if ok:
        s[m - i : m - i + len(t)] = t
        for j in range(len(s)):
            if s[j] == '?':
                s[j] = 'a'
        print(''.join(s))
        sys.exit()

print("UNRESTORABLE")

Measured memory_bytes: 3064
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools, os, pdb
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)
def perr(s): return print(s, file=sys.stderr)

N = _I()
H = LI()

# どこからはじめるか
compare_list = []
for i in range(N-1):
    if H[i] >= H[i+1]:
        compare_list.append(True)
    else:
        compare_list.append(False)

perr(compare_list)

streak = 0
ans = 0
for idx, i in enumerate(compare_list):
    if i == True:
        streak = streak + 1
        ans = max(ans, streak)
    else:
        streak = 0
print(ans)


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

mod = 10**9+7
N, K = map(int, input().split())
A = list(map(int, input().split()))

Mi = []
for a in A:
    if a != 0:
        Mi.append((abs(a), a//abs(a)))

Mi.sort(reverse=True)

if len(Mi) < K:
    ans = 0
else:
    ans = 1
    seg = 1
    lastinv = -1
    lastpu = -1
    for i in range(K):
        a, iv = Mi[i]
        seg *= iv
        if iv == -1:
            lastinv = a
        else:
            lastpu = a
        ans = ans * a % mod

    if seg == -1:
        fpu = -1
        fmi = -1
        ind = K
        while ind < len(Mi):
            a, iv = Mi[ind]
            ind += 1
            if iv == -1:
                if fmi == -1:
                    fmi = a
            else:
                if fpu == -1:
                    fpu = a
        
        if lastpu == -1:
            if fpu != -1:
                ans = ans * fpu * pow(lastinv, mod-2, mod) % mod
            elif 0 in A:
                ans = 0
            else:
                ans = -1
                for i in range(K):
                    ans = ans * Mi[-i-1][0] % mod
        elif fpu == -1 or fmi == -1:
            if fpu == -1 and fmi == -1:
                if 0 in A:
                    ans = 0
                else:
                    ans = -ans
            elif fpu == -1:
                ans = ans * fmi * pow(lastpu, mod-2, mod) % mod
            else:
                ans = ans * fpu * pow(lastinv, mod-2, mod) % mod
        elif lastpu * fpu > lastinv * fmi:
            ans = ans * fpu * pow(lastinv, mod-2, mod) % mod
        else:
            ans = ans * fmi * pow(lastpu, mod-2, mod) % mod
    
print(ans % mod)
            

Measured memory_bytes: 107436