akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int H, W;
vector<string> A(1010);
queue<pair<int, int>> q;
int dy[4] = {1, -1, 0, 0};
int dx[4] = {0, 0, 1, -1};
int map[1010][1010];

void bfs(int y, int x) {
    for (int ib=0; ib<4; ++ib) {
        int Y = y + dy[ib];
        int X = x + dx[ib];
        if (Y>=0 && Y<H && X>=0 && X<W && map[Y][X]<0) {
            map[Y][X] = map[y][x] + 1;
            q.push(make_pair(Y, X));
        }
    }
}

int main() {
    cin >> H >> W;
    for (int i=0; i<H; ++i) cin >> A[i];

    for (int i=0; i<H; ++i) {
        for (int j=0; j<W; ++j) {
            if (A[i][j] == '#') {
                q.push(make_pair(i, j));
                map[i][j] = 0;
            }
            else map[i][j] = -1;
        }
    }

    while (!q.empty()) {
        auto p = q.front();
        int y = p.first;
        int x = p.second;
        q.pop();

        bfs(y, x);
    }

    int ans = 0;
    for (int i=0; i<H; ++i) {
        for (int j=0; j<W; ++j) {
            ans = max(ans, map[i][j]);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 13568
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        input_inner!{$s, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

#[allow(unused_macros)]
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, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($exp_input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                let start = std::time::Instant::now();
                let input = solve($exp_input);
                let end = start.elapsed();
                assert_eq!(input, $output, "{}.{:03}", end.as_secs(), end.subsec_millis());
                assert!(end.as_secs() <= 2, "expected_sec: {}sec, actual_sec: {}sec", 2, end.as_secs());
                assert!(end.as_secs() <= 1, "expected_sec: {}sec, actual_sec: {}sec", 1, end.as_secs());
                assert!(end.subsec_millis() <= 10, "expected_ms: {}ms, actual_ms: {}ms", 10, end.subsec_millis());
                assert!(end.subsec_millis() <= 2, "expected_ms: {}ms, actual_ms: {}ms", 2, end.subsec_millis());
            )*
        }
    };
}

test! {
r#"2 3 3"# => r#"0 2"#,
r#"500000000000 500000000000 1000000000000"# => r#"0 0"#,

}

fn solve(src: &str) -> String {
    let mut src_iter = src.split_whitespace();
    input! {
        source = src_iter,
        a: u64,
        b: u64,
        k: u64,
    }

    let (x, y) = {
        if a > k {
            (a - k, b)
        } else if k > a {
            let ka = k - a;
            (0, if b >= ka { b - ka } else { 0 })
        } else {
            (0, b)
        }
    };

    format!("{} {}", x, y)
}

Measured memory_bytes: 4352
#include<stdio.h>

int main(void)
{
	int x,y,i,j;
	while(1){
		scanf("%d %d",&x,&y);
		if(x==0 && y==0) break;
		if(x<0 || y<0);
		else if(x<=300 && y<=300){
			for(i=0;i<x;i++){
				for(j=0;j<y;j++){
					printf("#");
				}
				printf("\n");
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;
import core.stdc.stdlib;
import std.math;

void main() {
  int N, K, Q; readf("%d %d %d\n", &N, &K, &Q);
  auto Pn = new int[N];

  for(int i=0; i<Q; i++) {
    auto A = readln.chomp.to!int;
    Pn[A-1]++;
  }
  foreach(P; Pn) writeln(P > Q-K ? "Yes" : "No");
}


Measured memory_bytes: 3964
mod=10**9+7

def add(a, b):
    return (a + b) % mod

def sub(a, b):
    return (a + mod - b) % mod

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, y//2)**2 * x % mod

def div(a, b):
    return mul(a, power(b, mod-2))

def cc(ii):
    iii=1
    for ii in range(1,ii+1):
        iii=iii*ii
    return iii

def cmb(a,b):
    iii=1
    for ii in range(a-b+1,a+1):
        iii=(iii*ii)%mod
    iiii=1
    for ii in range(1,b+1):
        iiii=(iiii*ii)%mod
#        print("ii,iiii:",ii,iiii)
#    print("a:",a,"b:",b,"iii:",iii,"iiii:",iiii)
#    print("a:",a,"b:",b,"a-b:",a-b,"a!:",iii,"b!:",iiii,"cmb:",iii//iiii)
    return div(iii,iiii)        


n,k=map(int,input().split())

ib=k-1
ir=n-ib

for i in range(1,ib+2):
#    cb=cc(ib)//cc(ib-i+1)//cc(i-1)
#    cr=cc(ir)//cc(ir-i)//cc(i)
    cb=cmb(ib,i-1)
    cr=cmb(ir,i)
#    print("ib:",ib,i-1,cb,"ir:",ir,i,cr)
    print(mul(cb,cr))
    


Measured memory_bytes: 9340
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
def my_pow(base, n, mod):
    if n == 0:
        return 1
    x = base
    y = 1
    while n > 1:
        if n % 2 == 0:
            x *= x
            n //= 2
        else:
            y *= x
            n -= 1
        x %= mod
        y %= mod
    return x * y % mod

N, P = map(int, input().split())
S = input()

if P == 2 or P == 5:
    ans = 0
    for i, c in enumerate(S[::-1]):
        if int(c) % P == 0:
            ans += N - i
    print(ans)
    exit()

cnt = [0] * P
base = 1
cur = 0
for c in S[::-1]:
    cur += (base * int(c)) % P
    cnt[cur % P] += 1
    base *= 10 
    base %= P
ans = 0
for i in cnt:
    if i == 0:
        continue
    ans += i * (i - 1) // 2
print(ans + cnt[0])





Measured memory_bytes: 9804
mod = 998244353

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

if D[0] != 0:
    print(0)
else:
    nums = [0]*n
    for d in D:
        nums[d] += 1
    
    imp = False
    end = False
    
    if nums[0] > 1:
        imp = True
        
    for i in range(1,n):
        if nums[i] == 0:
            end = True
        else:
            if end:
                imp = True
                break
            
    if imp:
        print(0)
    else:
        ans = 1
        for i in range(1,n):
            if nums[i] == 0:
                break
            ans = ans*pow(nums[i-1], nums[i], mod)%mod
        print(ans)

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

string a,b="CF"; 
int al,bl;

int main(){
    getline(cin,a);
    al=a.length();
    for(int i=0;i<al;i++)
        if(a[i]==b[bl])
        { 
            bl++;
            if(bl==2) 
                break;
        }
    if(bl==2) cout<<"Yes"; 
    else cout<<"No";
    cout<<endl;
    return 0;
}

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

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

ll mod=1e9+7;

using namespace std;


ll inputValue(){
	ll a;
	cin >> a;
	return a;
};

void inputArray(int * p, ll a){
	rep(i, a){
		cin >> p[i];
	}
};

template<typename T>
void inputVector(vector<T>& p, ll a){
	rep(i, a){
		T input;
		cin >> input;
		p.emplace_back(input);
	}
}


template <typename T>
void output(T a) {
	cout << a << "\n";
}



int main(int argc, const char * argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
  ll l;
  cin >> l;

  double dl = double(l);
  cout << fixed <<  setprecision(6) << dl/3 * dl/3 * dl/3 << endl;

}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Stack;

public class Main {
	
	public static int RPN(ArrayList<String> in) {
		int output = 0;
		String ops = "+-/*";
		Stack<String> nums = new Stack<>();
		
		for (String s : in) {
			if (!ops.contains(s)) {
				nums.push(s);
			} else {
				int b = Integer.parseInt(nums.pop());
				int a = Integer.parseInt(nums.pop());
				int op = ops.indexOf(s);
				if (op == 0) {
					nums.push(String.valueOf(a + b));
				} else if (op == 1) {
					nums.push(String.valueOf(a - b));
				} else if (op == 2) {
					nums.push(String.valueOf(a / b));
				} else if (op == 3) {
					nums.push(String.valueOf(a * b));
				}
				
			}
		}
		output = Integer.parseInt(nums.pop());
		
		return output;
	}
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		ArrayList<String> input = new ArrayList<>();
		
		while (in.hasNext()) {
			input.add(in.next().trim());
		}
		System.out.println(RPN(input));
		
		in.close();
	}
}



Measured memory_bytes: 26260
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int a[305][305];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	rep(i, n) rep(j, n) cin >> a[i][j];
	rep(i, n) rep(j, n) rep(k, n){
		if(a[i][j] + a[j][k] < a[i][k]){
			cout << -1 << endl;
			return 0;
		}
	}
	ll ans = 0;
	rep(i, n) rep(j, n) if(i != j){
		int f = 1;
		rep(k, n) if(k != i && k != j){
			if(a[i][k] + a[k][j] == a[i][j]){
				f = 0;
				break;
			}
		}
		if(f) ans += a[i][j];
	}
	cout << ans / 2 << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a[5],k;

    cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;

    for(int i = 0; i < 5;i++){
        for(int j = i+1; j < 5;j++){
            if(a[j]-a[i] > k) {
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////

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

    int K;
    cin >> K;

    unordered_set<int64> seen;
    queue<int64> Q;

    auto Add = [&] (int64 v) {
        if (!seen.count(v)) {
            seen.insert(v);
            Q.push(v);
        }
    };
    
    for (int i = 1; i <= 9; i++) {
        Add(i);
    }

    for (; !Q.empty(); ) {
        auto el = Q.front();
        Q.pop();

        K--;

        if (!K) {
            cout << el << "\n";
            return 0;
        }

        int last = el % 10;

        if (last)
            Add(el * 10 + last - 1);
        Add(el * 10 + last);
        if (last < 9)
            Add(el * 10 + last + 1);
    }

    return 0;
}


Measured memory_bytes: 15688
#include <iostream>
#include <string>
#include <cstdio>
#include <map>
#include <algorithm>
using namespace std;

int main() {
	long long int x, y;
	long long int S1, S2, S3;
	long long int maxs = 0, mins = 10000000001;
	cin >> x >> y;
	for (int i = 1; i <= x ; i++) {
		S1 = i*y;
		if ((x - i) % 2 == 0 || y % 2 == 0) {
			S2 = (x*y - S1) / 2;
			S3 = S2;
		}
		else {
			S2 = (max(x - i, y) / 2)*min(x - i, y);
			S3 = x*y - S1 - S2;
		}

		if (max(S1, max(S2, S3)) - min(S1, min(S2, S3)) < mins)mins = max(S1, max(S2, S3)) - min(S1, min(S2, S3));
	}
	

	for (int i = 1; i <= y; i++) {
		S1 = i*x;
		if ((y - i) % 2 == 0 || x % 2 == 0) {
			S2 = (x*y - S1) / 2;
			S3 = S2;
		}
		else {
			S2 = (max(y - i, x) / 2)*min(y - i, x);
			S3 = x*y - S1 - S2;
		}

			if (max(S1, max(S2, S3)) - min(S1, min(S2, S3)) < mins)mins = max(S1, max(S2, S3)) - min(S1, min(S2, S3));
		
	}

	cout << mins<< "\n";
	cin >> x;
	return 0;
}

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

typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

signed main() {
    int N, D;
    cin >> N >> D;

    int ans = ceil((double)N / (2 * D + 1));
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll n = -1;
  while (n != 0) {
    ll sum = 0;
    cin >> n;
    if (n == 0)
      return 0;
    vector<ll> a;
    for (int i = 0; i < n; i++) {
      int x;
      cin >> x;
      a.push_back(x);
      sum += x;
    }
    double mean = sum * 1.0 / n;
    int cnt = 0;
    for (int i = 0; i < n; i++)
      if (a[i] <= mean)
        cnt++;
    cout << cnt << endl;
  }
}


Measured memory_bytes: 3268
#include<iostream>
#include<algorithm>
using namespace std;
int n;
double ans,v[100],tem;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    sort(v,v+n);
    for(int i=0;i<n-1;i++){
        tem=(v[i]+v[i+1])/2;
        v[i+1]=tem;
    }
    cout<<v[n-1]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    long long n;
    cin >> n;
    string s;
    int ac=0,wa=0,tle=0,re=0;
    for (int i=0;i<n;i++)
    {
        cin >> s;
        if (s=="AC")
            ac++;
        else if (s=="WA")
            wa++;
        else if (s== "TLE")
            tle++;
        else
            re++;

    }

    cout <<"AC x " << ac << "\nWA x " << wa
    << "\nTLE x " << tle << "\nRE x "<< re;

return 0;
}


Measured memory_bytes: 3248
# N,M = map(int, input().split())
S = input()
T = input()
N = len(S)

def restore(s):
    t = list(s[:])
    for i in range(len(t)):
        if t[i] == "?":
            t[i] = "a"
    return "".join(t)


cand = []
for i in range(N):

    j = i
    ti = 0

    # print(T,S, "j: ", j, "ti: ", ti)
    while ti < len(T) and j < len(S) and (S[j] == "?" or S[j] == T[ti]):
        ti += 1; j += 1
        # print("\t[while] ti: ", ti, "j: ", j)

    if ti == len(T):
        cand.append( S[0:i] + T + S[i +  len(T):]  )
        
    else:
        continue

if len(cand) == 0:
    print("UNRESTORABLE")
else:
    ans = restore(cand[-1])
    print(ans)

        


Measured memory_bytes: 39152
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-11 16:56:30
*/

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

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    int ans[3] = {-1, -1, -1};
    for (int a = 0; a <= n; a++) {
        for (int b = 0; b <= n-a; b++) {
            int c = n - a - b;
            if (10000*a + 5000*b + 1000*c == y) {
                ans[0] = a;
                ans[1] = b;
                ans[2] = c;
            }
        }
    }

    for (int i = 0; i < 3; i++) {
        cout << ans[i] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
ans = 0

def ryuka(a,b,count):
    global ans
    c = a + b
    if count == n:
        ans = c
    else:
        count = count + 1
        ryuka(b,c,count)
        
if n == 0 or n ==1 or n == 2:
    l = [2,1,3,4]
    print(l[n])
else:
    ryuka(2,1,2)        
    print(ans)

Measured memory_bytes: 3064
n,m = map(int,input().split())
l = []
for i in range(m):
    a,b = map(int,input().split())
    c = 0
    for j in map(int,input().split()):
        c += (1<<(j-1))
    l.append((c,a))
dp = {0:0}
for i in l:
    items = list(dp.items())
    for j in items:
        ij = (i[0] | j[0], i[1] + j[1])
        if not dp.get(ij[0]):
            dp[ij[0]] = ij[1]
        else:
            if dp[ij[0]] > ij[1]:
                dp[ij[0]] = ij[1]

print(dp.get(2**n-1,-1))


Measured memory_bytes: 4272
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main implements Closeable {

  private InputReader in = new InputReader(System.in);
  private PrintWriter out = new PrintWriter(System.out);

  public void solve() {
    int n = in.ni(), k = in.ni();
    final int MOD = (int) 1e9 + 7;
    long min = 0, max = 0;
    for (int i = 0; i < k; i++) {
      min += i;
      max += (n - i);
    }
    long result = 0;
    for (int i = k; i <= n + 1; i++) {
      result += Math.abs(max - min) + 1;
      result %= MOD;
      min += i;
      max += (n - i);
    }
    out.println(result);
  }

  @Override
  public void close() throws IOException {
    in.close();
    out.close();
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int ni() {
      return Integer.parseInt(next());
    }

    public long nl() {
      return Long.parseLong(next());
    }

    public void close() throws IOException {
      reader.close();
    }
  }

  public static void main(String[] args) throws IOException {
    try (Main instance = new Main()) {
      instance.solve();
    }
  }
}


Measured memory_bytes: 33048
import math
from collections import deque
from collections import defaultdict

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

a = readChar()
b = readChar()

al = len(a)
bl = len(b)

if al>bl:
	print("GREATER")
	exit()
elif al<bl:
	print("LESS")
	exit()

for i in range(al):
	if a[i]>b[i]:
		print("GREATER")
		exit()
	elif a[i]<b[i]:
		print("LESS")
		exit()

print("EQUAL")

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

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

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k; cin >> n >> k;
    if(k > n/2 + (n % 2)) cout << "NO";
    else cout << "YES";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

template<typename T>
class CumulativeSum{
public:
  Int n;
  vector<T> sum;
  vector<T> A;
  Int added;
  CumulativeSum():n(-1),added(0){}
  CumulativeSum(Int n):n(n), sum(n+1), A(n+1),added(0){}
  CumulativeSum(const vector<T> &B):n(B.size()), sum(n+1), A(n+1),added(0){
    for(Int i=1;i<=n;i++) sum[i] = sum[i-1] + B[i-1];
  }

  void apply(){
    for(Int i=1;i<=n;i++) A[i] = A[i] + A[i-1];
    for(Int i=1;i<=n;i++) A[i] = A[i] + A[i-1];
    for(Int i=1;i<=n;i++) sum[i] = sum[i] + A[i-1];
    added = 0; A.clear(); A.resize(n+1);
  }

  //[l, r)にxを加算
  void add(Int l, Int r, T x){
    added = 1;
    assert(l <= r && 0 <= l && r <= n);
    A[l] = A[l] + x;
    A[r] = A[r] - x;
  }

  //[l, r)の和を得る
  T get(Int l,Int r){
    assert(l<=r && 0<=l && r<=n);
    if(added) apply();
    return sum[r] - sum[l];
  }
};




signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N, K;
  cin>>N>>K;


  double ans = 0;
  for(int i=1;i<=N;i++){
    {
      int a = i;
      double p = 1;
      while(a < K) a *= 2, p *= 0.5;
      ans += p;
    }

  }

  cout<<ans/N<<endl;
  

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<map>
#include<vector>
#include<algorithm>
#include <stdio.h>
#include<set>
#include<string>
#include<unordered_map>
#include<math.h>
#include<cmath>
#include<iomanip>
#include<queue>
#include<stack>
#define ll long long
using namespace std;
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);


int main()
{
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll sum = 0;
	sum += min(k, a);
	k -= sum;
	ll z = min(k, b);
	k -= z;
	ll x = min(k, c);
	sum -= x;
	cout << sum;
	return 0;
}

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

int main(){
  char c;
  cin >> c;
  char d = toupper(c);
  cout << (c == d? "A" : "a") << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    REP(i, n)
        cin >> p[i];
    
    int cnt = 0;
    FOR(i, 1, n-1){
        if((p[i-1] < p[i] && p[i] < p[i+1]) || 
        (p[i-1] > p[i] && p[i] > p[i+1]))
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    for(;;){
        int m,n,N;
        cin>>m;
        if(!m) return 0;
        cin>>n>>N;
        vector<int> p(m);
        rep(i,0,m) cin>>p[i];
        int ma=-1;
        rep(i,n,N+1){
            ma=max(ma, p[i-1]-p[i]);
        }
        rer(i,N+1,n){
            if(ma==p[i-1]-p[i]){
                cout <<i<<"\n";
                break;
            }
        }
    }
}


Measured memory_bytes: 3164
package main

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

func main() {
	N := nextInt()
	S := nextBytes()

	hist1 := map[int]bool{}
	hist2 := map[int]bool{}
	hist3 := map[int]bool{}

	for i := 0; i < N; i++ {
		n := int(S[i] - '0')

		for h2 := range hist2 {
			hist3[h2*10+n] = true
		}

		for h1 := range hist1 {
			hist2[h1*10+n] = true
		}

		hist1[n] = true
	}

	fmt.Println(len(hist3))
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

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

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 768
import sys
from io import StringIO
import unittest
import os


# 実装を行う関数
def resolve():
    # 数値取得サンプル
    #   1行N項目 x, y = map(int, input().split())
    #   N行N項目 x = [list(map(int, input().split())) for i in range(n)]

    # 文字取得サンプル
    x = input()

    if x == "SUN":
        print(7)
    elif x == "MON":
        print(6)
    elif x == "TUE":
        print(5)
    elif x == "WED":
        print(4)
    elif x == "THU":
        print(3)
    elif x == "FRI":
        print(2)
    elif x == "SAT":
        print(1)


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """SAT"""
        output = """1"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """SUN"""
        output = """7"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 49516
import fractions
n = int(input())
a = list(map(int, input().split()))
m = 0
ans = 0

for i in range(n):
  m = m*a[i]//fractions.gcd(m, a[i])
m -= 1

for i in range(n):
  ans += m%a[i]

print(ans)

Measured memory_bytes: 5304
n, c = [int(i) for i in input().split()]
D = [[int(i) for i in input().split()] for j in range(c)]
C = [[int(i) for i in input().split()] for j in range(n)]

# for i in range(c):
#   for j in range(c):
#     for k in range(c):
#       d = D[i][j] + D[j][k]
#       if D[i][k] > d:
#         D[i][k] = d

sum_d = [[0] * c for i in range(3)]
mod_c = [[0] * c for i in range(3)]

for i in range(n):
  for j in range(n):
      mod_c[(i+j)%3][C[i][j]-1] += 1

for i in range(c):
    for j in range(c):
        for k in range(3):
            sum_d[k][j] += D[i][j] * mod_c[k][i]
      
max_d = 1000 * (n//3+1)
ans = max_d * n**2
      
for i in range(c):
  for j in range(c):
    for k in range(c):
      if i != j != k != i:
        ans = min(ans, sum_d[0][i] + sum_d[1][j] + sum_d[2][k])
        
print(ans)

Measured memory_bytes: 5492
def pin(type=int):
    return map(type,input().split())
    
#どっかで最悪計算量の入力データを用意する関数を作ろう？
"""
"""

#solution:
def dfs_search_2Dgrid(h,w):
    #if h,wが迷路の外->Noneを返す
    #if もう通った点->None
    #通った点のリスト？に記録
    #二次元グリッドなので4方向に進もうとしてみよう
    pass
#input
N,K=pin()
ans=0
n=N
while (n>0):
    n//=K
    ans+=1
print(ans)

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

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

    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] x = new int[n];
        for(int i =0; i<n ; i++){
            x[i] = sc.nextInt();
        }

        int minX = Arrays.stream(x).min().getAsInt();
        int maxX = Arrays.stream(x).max().getAsInt();

        int minValue = Integer.MAX_VALUE;
        int[] power = new int[n];
        for(int i = minX; i <= maxX; i++){ //i是p可以选择的位置
            for(int j = 0; j<x.length; j++){ //j是x的下标
                power[j] = (x[j]-i)*(x[j]-i);
            }
            minValue = Math.min(minValue, Arrays.stream(power).sum());
        }

        System.out.println(minValue);
    }
}

Measured memory_bytes: 28628
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = list(int(input()) for _ in range(n))

for i in range(n):
    for j in range(3):
        for k in range(3):
            if b[i] == a[j][k]:
                a[j][k] = 0
                break

for i in range(3):
    if a[i][0] == 0 and a[i][1] == 0 and a[i][2] == 0:
        print("Yes")
        break
    elif a[0][i] == 0 and a[1][i] == 0 and a[2][i] == 0:
        print("Yes")
        break
else:
    if a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0:
        print("Yes")
    elif a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 3064
'''
全量のリストを用いると検索対象が大きくなってしまうため、ディクショナリで都度追加/削除する
'''

N = int(input())

A = {}

for _ in range(N):
    tmp = int(input())
    if tmp in A:
        del A[tmp]
    else:
        A[tmp] = 1

print(len(A))

Measured memory_bytes: 15072
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int,int_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_pair tree<pair<int,int>,int_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> pi; 
#define PI 3.1415926535897932384
#define FOR(i,vv,n) for(int i=vv;i<n;i++)
#define FORR(i,n,vv) for(int i=n-1;i>=vv;i--)
#define ve vector 
#define maxind(v) (max_element(v.begin(),v.end())-v.begin())
#define minind(v) (min_element(v.begin(),v.end())-v.begin())
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007ll
#define M1 100000000000000000ll
#define PRECISE cout.precision(18);
#define BS(v,n) binary_search(v.begin(),v.end(),n)
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.begin(),v.end(),greater <int>())
#define F first
#define S second




int main(){

    FAST
//	PRECISE

ll n,c,k;
cin>>n>>c>>k;
ve <ll> time(n,0);
ve <ll> v(n,0);
FOR(i,0,n)
cin>>v[i];
srt(v);
ll ans=0;
ll ma=0;
ll ca=0;

FOR(i,0,n){

if(v[i]>ma){
	ans++;
	ca=1;
	ma=v[i]+k;	
}
else if(ca==c){
	ans++;
	ca=1;
	ma=v[i]+k;
}
else{
	ca++;
}



}
cout<<ans;
return 0;
 }

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <map>
#include <numeric>
using namespace std;

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

#define PI 3.14159265358479

typedef long long ll;
typedef vector<long long int> vi;
typedef vector<long long int>::iterator vit;

int main(){
	ll d, s = 0;
	while (cin >> d){
		REP(i, 600 / d - 1){
			s += pow((i + 1)*d, 2)*d;
		}
		cout << s << "\n";
		s = 0;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <string>
#define SIZE 415
#define MOD 1000000007

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

int dp[2][SIZE][SIZE];
int now[SIZE][SIZE];
int A[SIZE],B[SIZE];
int pa[SIZE];
int pb[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&A[i]);
		A[i]--;
		pa[A[i]]=i;
	}
	for(int i=0;i<n;i++)
	{
		scanf("%d",&B[i]);
		B[i]--;
		pb[B[i]]=i;
	}
	if(A[0]==B[0])
	{
		puts("0");
		return 0;
	}
	A[n]=n,B[n]=n;
	pa[n]=pb[n]=n+1;
	int pos=0;
	memset(dp,0,sizeof(dp));
	dp[pos][1][1]=1;
	for(int i=1;i<=n;i++)
	{
		pos^=1;
		memset(dp[pos],0,sizeof(dp[pos]));
		for(int j=1;j<=n+1;j++)
		{
			for(int k=0;k<=n/3;k++)
			{
				now[j][k]=0;
			}
		}
		for(int j=1;j<=n;j++)
		{
			for(int k=0;k<=n/3;k++)
			{
				int vl=dp[pos^1][j][k];
				if(vl==0) continue;
				//A[i] を使わないとき
				if(pb[A[i]]<j)//Bに入ってる
				{
					dp[pos][j][k]+=vl;
					if(dp[pos][j][k]>=MOD) dp[pos][j][k]-=MOD;
				}
				else if(k>0)//Cに入れる
				{
					dp[pos][j][k-1]+=(int) ((ll) vl*(ll) k%MOD);
					if(dp[pos][j][k-1]>=MOD) dp[pos][j][k-1]-=MOD;
				}
				//A[i]を使うとき
				if(pb[A[i]]>=j)
				{
					now[j][k]+=vl;
					if(now[j][k]>=MOD) now[j][k]-=MOD;
				}
			}
		}
		for(int j=1;j<=n;j++)
		{
			if(A[i]<n&&B[j]==A[i]) continue;
			for(int k=0;k<=n/3;k++)
			{
				int vl=now[j][k];
				if(vl==0) continue;
				//B[j] を使わない
				if(pa[B[j]]<=i)
				{
					now[j+1][k]+=vl;
					if(now[j+1][k]>=MOD) now[j+1][k]-=MOD;
				}
				else if(k>0)
				{
					now[j+1][k-1]+=(int) ((ll) vl*(ll) k%MOD);
					if(now[j+1][k-1]>=MOD) now[j+1][k-1]-=MOD;
				}
				//B[j] を使う
				if(pa[B[j]]>i)
				{
					dp[pos][j+1][k+1]+=vl;
					if(dp[pos][j+1][k+1]>=MOD) dp[pos][j+1][k+1]-=MOD;
				}
			}
		}
	}
	ll ret=dp[pos][n+1][1];
	//printf("%lld\n",ret);
	for(int i=0;i<n/3;i++)
	{
		ret*=(ll) (3*i+1);
		ret%=MOD;
		ret*=(ll) (3*i+2);
		ret%=MOD;
	}
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 2304
N, X, Y = map(int, input().split())
ans = {}
for i in range(1, N):
    ans[i] = 0

for i in range(1, N+1):
    for j in range (i+1, N+1):
        if (i <= X and j <= X) or (i >= Y and j >= Y):
            ans[j - i] += 1
        elif i <= X and (j > X and j <= Y):
            temp = min (j - i, (Y - j + 1) + (X - i))
            ans[temp] += 1
        elif (i >= X and i < Y) and j >= Y:
            temp = min (j - i, (i - X + 1) + (j - Y))
            ans[temp] += 1
        elif (i > X and j < Y):
            temp = min (j - i, (Y-j) + 1 + (i-X))
            ans[temp] += 1
        else:
            temp = min (j - i, (j - Y) + (X - i) + 1)
            ans[temp] += 1
for k in ans:
    print(ans[k])

Measured memory_bytes: 3572
N, M = map(int, input().split())
E = [[] for _ in range(N)]
for _ in range(M):
  A, B = map(int, input().split())
  E[A-1] += [B-1]
  E[B-1] += [A-1]

ans = [-1]*N
T = [0]
while len(T)>0:
  P = T
  T = []
  for x in P:
    for e in E[x]:
      if ans[e]==-1:
        T += [e]
        ans[e] = x

print("Yes")
for a in ans[1:]:
  print(a+1)


Measured memory_bytes: 34924
loop {
  m, f, r = gets.chomp.split(' ').map { |i| i.to_i }
  if m == -1 and f == -1 and r == -1 then break
  else
    if    m == -1 or f == -1 then puts 'F'
    elsif m+f >= 80 then puts 'A'
    elsif m+f >= 65 then puts 'B'
    elsif m+f >= 50 then puts 'C'
    elsif m+f >= 30 and r >= 50 then puts 'C'
    elsif m+f >= 30 and r < 50 then puts 'D'
    else puts 'F'
    end
  end
}

Measured memory_bytes: 6108
#include <bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<pr, ut> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=5+3*1e+4;
const ut INF=1<<30;
const ld eps=1e-6;
const LL mod=7+1e+9;
 
LL memo[1001][1001];
int N, K;

int rec(int n, int k){
	if(n >= N)
		return 1;
	if(memo[n][k] != -1)
		return memo[n][k];
	
	int res = 0;
	REP(i,K){
		if(i != k)
			res += rec(n + 1, i);
	}
	return memo[n][k] = res;
}

int main() {
	memset(memo, -1, sizeof(memo));
	cin >> N >> K;
	cout << rec(0, 1000) << endl;
    return 0;	
}


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

int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> broken(n+1);
    rep(i,m){
        int a;
        cin >> a;
        broken[a] = 1;
    }
    vector<int> dp(n+2);
    const int mod = 1000000007;
    dp[n] = 1;
    for(int i = n-1; i >= 0; --i){
        if(broken[i]) {
            dp[i] = 0;
            continue;
        }
        dp[i] = (dp[i+1] + dp[i+2]) % mod;
    }
    cout << dp[0] << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    int MOD = (int)998244353;

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

    void run() {

        int n = sc.nextInt();

        Map<Integer, Integer> map = new HashMap<>();

        for (int i=0; i<n; i++) {
            int tmp = sc.nextInt();
            if (map.containsKey(tmp)) {
                map.remove(tmp);
            } else {
                map.put(tmp, 1);
            }
        }

        System.out.println(map.size());

    }
}



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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=(x);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef string ss;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll i=1,a,b,t,sum = 0;
    cin >> a >> b >> t;
    while(a*i <= t+0.5){
        sum += b;
        i++;
    }
    cout << sum << endl;
   return 0;
}


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

#define int long long

template <typename T>
struct UF {
  int n;
  T d;
  vector<int> r, p;
  vector<T> ws;
  UF() {}
  UF(int sz, T d_) :
    n(sz), d(d_), r(n, 1), p(n), ws(n, d) { iota(p.begin(), p.end(), 0); }
  int find(int x) {
    if ( x == p[x] ) {
      return x;
    } else {
      int t = find(p[x]);
      ws[x] += ws[p[x]];
      return p[x] = t;
    }
  }

  T weight(int x) {
    find(x);
    return ws[x];
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  void unite(int x, int y, T w) {
    w += weight(x);
    w -= weight(y);
    x = find(x); y = find(y);
    if ( x == y ) return;
    if ( r[x] < r[y] ) swap(x, y), w = -w;
    r[x] += r[y];
    p[y] = x;
    ws[y] = w;
  }

  T diff(int x, int y) {
    return weight(y) - weight(x);    
  }
};

signed main(){
	int n;
	while(cin>>n,n){
		UF<int> U(2*n,0);
		map<string,int>M;
		int cnt=0,F=0;
		for(int i=0;i<n;i++){
			int a,D;
			string b,c,e,d;
			cin>>a>>b>>c>>d>>e;
			d=d.substr(3);
			stringstream SS(d);
			SS>>D;
			//cout<<D<<endl;
			if(!M.count(b)) M[b]=cnt++;
			if(!M.count(e)) M[e]=cnt++;
			if(U.same(M[b],M[e])&&U.diff(M[b],M[e])!=D)F=1;
			U.unite(M[b],M[e],D);
			//cout<<F<<endl;
		}
		if(F)goto L;
		cout<<"Yes"<<endl;
		if(0){
			L:;
			cout<<"No"<<endl;
		}
	}
}


Measured memory_bytes: 3184
n = int(input())


def num2alpha(num):
    if num <= 26:
        return chr(64+num)
    elif num % 26 == 0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num % 26)


print(num2alpha(n).lower())

Measured memory_bytes: 9176
#include <iostream>
#include <vector>
using namespace std;
const int MAX = 1000000;
const int INF = 1<<29;
int main(){
  vector<int> dp_1(MAX+1,INF);
  vector<int> dp_2(MAX+1,INF);
  vector<int> poll(1000,0);
  for(int i = 0;i < 200;i++)poll[i] = i*(i+1)*(i+2)/6;
  dp_1[0] = 0;
  dp_2[0] = 0;
  for(int i = 1;i < MAX;i++){
    dp_1[i] = i;
    dp_2[i] = i;
    for(int j = 0;i-poll[j]>=0;j++){
      dp_1[i] = min(dp_1[i],dp_1[i-poll[j]]+1);
      if(poll[j] % 2 == 1)dp_2[i] = min(dp_2[i],dp_2[i-poll[j]]+1);
    }
  }
  int n;
  //  cout << "aaaaaa" << endl;
  while(cin >> n,n != 0){
    cout << dp_1[n] << " " << dp_2[n] << endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 8792
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
  cin.tie(0);
	int k;
  cin >> k;
  string s;
  cin >> s;
  int len = s.length();
  if(len<=k)
  {
  	cout << s ;
    //continue;
  }
  else{for(int i=0;i<k;i++){
    cout << s[i];
  }
  cout <<"...";}
  return 0;
}

Measured memory_bytes: 3652