akhauriyash/Code-Regression huggingface dataset:
local function str2tbl(s)
    local t = {string.byte(s, 1, #s)}
    for i=1, #t do
        t[i] = string.char(t[i])
    end
    return t
end

-- http://www.lua.org/pil/11.4.html
List = {}
function List.new()
  return setmetatable({first = 0, last = -1}, {__index = List})
end

function List:pushleft(value)
  local first = self.first - 1
  self.first = first
  self[first] = value
end

function List:pushright(value)
  local last = self.last + 1
  self.last = last
  self[last] = value
end

function List:popleft()
  local first = self.first
  if first > self.last then error("list is empty") end
  local value = self[first]
  self[first] = nil        -- to allow garbage collection
  self.first = first + 1
  return value
end

function List:popright()
  local last = self.last
  if self.first > last then error("list is empty") end
  local value = self[last]
  self[last] = nil         -- to allow garbage collection
  self.last = last - 1
  return value
end

function List:count()
    return self.last - self.first + 1
end

do
    local a = List.new()
    assert(a:count() == 0)
    a:pushleft(1)
    assert(a:count() == 1)
    a:pushright(1)
    assert(a:count() == 2)
    a:popleft()
    assert(a:count() == 1)
    a:popright()
    assert(a:count() == 0)
    a = nil
end

------
local H, W = io.read("*n", "*n", "*l")
local grid = {}
for i=1, H do
    grid[i] = str2tbl(io.read("*l"))
end
--[[
for i=1, H do
    for j=1, W do
        print(i,j, grid[i][j])
    end
end
]]
local count = 0
local blacks = List.new()
local blacks_used = {}
local function not_blacks_used(i, j)
    if not blacks_used[i*1000+j] then
        blacks_used[i*1000+j] = true
        return true
    end
    return false
end
for i=1, H do
    for j=1, W do
        local c = grid[i][j]
        if c == '#' then
            if not_blacks_used(i, j) then
                blacks:pushright({i, j})
            end
        end
    end
end
local tuples = {{-1,0},{1,0},{0,-1},{0,1}}
while blacks:count() > 0 do
    local next = List.new()
    while blacks:count() > 0 do
        local t = blacks:popleft()
        local i, j = t[1], t[2]
        for _, tuple in ipairs(tuples) do
            local x,y = i + tuple[1], j + tuple[2]
            if x >= 1 and x <= H and y >= 1 and y <= W then
                if not_blacks_used(x, y) then
                    next:pushright({x, y})
                end
            end
        end
    end
    count = count + 1
    blacks = next
end
print(count-1)

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

int main(){
    
    long long int n,k,ans = 0;

    cin>>n>>k;

    long long int d;
    bool D[10]={};
    bool flag;

    for(int i=0;i<k;i++){
        cin>>d;
        D[d] = true;
    }

    ans = n;
    
    while(1){

        flag = true;
        long long int temp = ans;
        while(temp != 0){
            if(D[temp%10]){
                flag = false;
                break;
            }
            temp/=10;
        }

        if(flag) break;
        
        ans++;
    }
    
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    if(S == "SUN"){
        print(7);
    }else if(S == "MON"){
        print(6);
    }else if(S == "TUE"){
        print(5);
    }else if(S == "WED"){
        print(4);
    }else if(S == "THU"){
        print(3);
    }else if(S == "FRI"){
        print(2);
    }else{
        print(1);
    }


    

}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define rep_itr(it, M) for (auto it = M.begin(); it != M.end(); ++it)
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
int N, A,B;

ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
ll modinv(ll a) {
    return modpow(a, MOD - 2);
}

ll kaizyo(ll a, int cnt) {
  ll b = 1;
  rep(i, cnt) {
    b *= a;
    b%=MOD;
    a--;
  }
  return b;
}

// numのpow乗をmodで計算する
ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}


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

  cin >> N >> A >> B;
  ll ans = 1ll;
  ll abc = pow_mod(2, N, MOD);
  ll inv_a = kaizyo(N, A)*modinv(kaizyo(A, A))% MOD;
  ll inv_b = kaizyo(N, B)*modinv(kaizyo(B, B))% MOD;
  cout << ((abc-inv_a-inv_b-1)%MOD+MOD)%MOD << "\n";
  return 0;
}

Measured memory_bytes: 256
var input = ""
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
 
process.stdin.on('end', function() {
  input = input.split("\n");

  p = input[0] + input[0]
  s = input[1]

  if (p.indexOf(s) !== -1) {
    console.log("Yes");
  } else {
    console.log("No");
  }
});

Measured memory_bytes: 15660
s=input()
n=len(s)

def Palindrome(string):
    if string==string[::-1]:
        return True
    else:
        return False

a1=int((n-1)/2)
a2=int((n+3)/2-1)

s1=s[0:a1]
s2=s[a2:n]

if Palindrome(s1) and Palindrome(s2) and Palindrome(s) == True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
            String S = sc.next();
        sc.close();
        
        String[] Sarray = new String[S.length()]; 
        String[] M = new String[S.length()]; 
        int count = 0 ;
        for(int i = 0 ; i < S.length(); i++){
            Sarray[i] = String.valueOf(S.charAt(i));
        }

        for(int i = 0 ; i < S.length(); i++){
            if(i%2 == 0){
                M[i] = "1";
            }else{
                M[i] = "0";
            }
            if(Sarray[i].equals(M[i])){
                count++;
            }
        }
        //System.out.println(count);

        if(S.length() - count < count){
            System.out.println(S.length() - count);
        }else{
            System.out.println(count);
        }
    }
}

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

int n, C;
int imos[30][100002];

int main() {
	int i, j;
	
	cin >> n >> C;
	for (i = 0; i < n; i++) {
		int s, t, c;
		cin >> s >> t >> c;
		imos[c - 1][s]++;
		imos[c - 1][t + 1]--;
	}
	
	for (i = 0; i < C; i++) {
		for (j = 0; j < 100000; j++) {
			imos[i][j + 1] += imos[i][j];
		}
	}
	
	int ans = 0;
	for (i = 0; i <= 100000; i++) {
		int cnt = 0;
		for (j = 0; j < C; j++) {
			if (imos[j][i] > 0) cnt++;
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 11904
#include<stdio.h>
#define N 2000000

unsigned int A[N];
unsigned int B[N];

int main(){

  int C[10000];

  int i,j,k,n;
  k=0;

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
    if(A[i]>k)k=A[i];
  }
  for(i=0;i<=k;i++)C[i]=0;
  for(j=1;j<=n;j++)C[A[j]]=C[A[j]]+1;
  for(i=1;i<=k;i++)C[i]=C[i]+C[i-1];
  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]=C[A[j]]-1;
  }

  for(i=1;i<=n;i++){
    if(i!=1)printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 15000
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  string S;
  cin>>S;
  for(ll i=0;i<19;i++) {
    if(i==5||i==13) {
cout<<" ";
    }
    else {
cout<<S[i];
    }
  }
  
  cout<<endl;
}


Measured memory_bytes: 3620
def solve():
    N = int(input())
    *A, = map(int, input().split())

    data = [0]*(N+1)
    def update(k, x):
        while k <= N:
            data[k] = max(data[k], x)
            k += k & -k
    def get(k):
        s = 0
        while k:
            s = max(s, data[k])
            k -= k & -k
        return s

    B = [0]*N
    for i in range(N):
        B[A[i]-1] = i

    ans = 0
    for i in range(N):
        j = B[i]
        v = get(j+1)
        update(j+1, v+i+1)
    print(N*(N+1)//2 - get(N))
solve()


Measured memory_bytes: 17864
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound, __gcd, count, find, next_permutation
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   // setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cassert> // assert
#include <cctype>  // isupper, islower, isdigit, toupper, tolower
#include <cmath>   // abs, sin, cos, tan
#include <ctime>   // clock

// __builtin_popcountll

using namespace std;
using Graph = vector<vector<int>>;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  ll a, b, c, d, e; cin >> a >> b >> c >> d >> e;
  ll s = c * 60 + d;
  ll g = a * 60 + b;
  ll ans = s - g;
  ans -= e;
  if(ans < 0) ans = 0;
  fin(ans);
  return;
}

//前処理
int main()
{
  int ti = clock();
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  //cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  //printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cassert>
#include <ctime>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
using namespace std;

#define P 998244353
int mi[20000];
int k, n;

int Pow(int x, int y) {
	int ans = 1;
	for (int i = 1; i <= y; i *= 2, x = 1LL * x * x % P)
		if (i & y)
			ans = 1LL * ans * x % P;
	return ans;
}

int C(int x, int y) {
	if (x < y)
		return 0;
	return 1LL * mi[x] * Pow(1LL * mi[y] * mi[x - y] % P, P - 2) % P;
}

int F(int n, int k) {
	// printf("?? %d %d\n", n, k);
	if (n < 0)
		return 0;
	if (n == 0)
		return 1;
	if (k == 0)
		return 0;
	
	return C(n + k - 1, k - 1);
}

int main() {
	scanf("%d%d", &k, &n);
	mi[0] = 1;
	for (int i = 1; i <= 10000; i++)
		mi[i] = 1LL * mi[i - 1] * i % P;
	for (int i = 2; i <= 2 * k; i++) {
		int cnt = 0;
		for (int j = 1; j <= k; j++)
			if (i - j <= k && 1 <= i - j && j < i - j)
				cnt ++;
		if (i % 2 == 0) {
			long long ans = 0;
			for (int j = 0; j <= cnt; j++) {
				ans += 1LL * F(n - j, k - cnt - (cnt - j) - 1) * Pow(2, j) % P * C(cnt, j) % P;
				ans += 1LL * F(n - j - 1, k - cnt - (cnt - j) - 1) * Pow(2, j) % P * C(cnt, j) % P;
				ans %= P;
			}
			printf("%lld\n", ans);
		}else {
			long long ans = 0;
			for (int j = 0; j <= cnt; j++) {
				ans += 1LL * F(n - j, k - cnt - (cnt - j)) * Pow(2, j) % P  * C(cnt, j) % P;
				ans %= P;
			}
			printf("%lld\n", ans);
		}
	}
}


Measured memory_bytes: 256
N = int(input())
S1 = input().strip()
S2 = input().strip()
mod = 10 ** 9 + 7

ans = 1
idx = 0
before_type = 0
if S1[0] == S2[0]:
    ans *= 3
    idx = 1
    before_type = 0
else:
    ans *= 6
    idx = 2
    before_type = 1

while idx < N:
    if S1[idx] == S2[idx]:
        if before_type == 0:
            ans *= 2
        idx += 1
        before_type = 0
    else:
        if before_type == 1:
            ans *= 3
        else:
            ans *= 2
        idx += 2
        before_type = 1
    ans %= mod
print(ans)


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

inline int read(){
    int X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}

inline void write(int x){
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
}

inline void writeln(int x){
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
     puts("");
}

signed main(){
    int a[10];
    
    for(int i=1;i<=5;i++){
        cin>>a[i];
        if(a[i]==0){
            cout<<i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3568
# coding: utf-8
s = gets.chomp.chars
t = gets.chomp.chars

str_size = s.size - t.size

diff = t.size
(0..str_size).each { |i|
  now_diff = 0
  new_str = s[i..i+t.size-1] # -> 文字列切り出し
  new_str.each_with_index { |str, index|
    now_diff += 1 if str != t[index]
  }
  diff = now_diff if now_diff < diff
}

p diff









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

int main(void){
  	char c;
    cin >> c;
  
  	if(c == 'a'|| c == 'i' || c == 'u' || c == 'e' || c == 'o') cout << "vowel"<<endl;
  	else cout << "consonant" << endl;
  
  	return 0;
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);
// int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
// int a[12][12];



void solve() {
  string x,y,z;
  cin >> x >> y >> z;
  cout << x[0] << y[1] << z[2] << endl;

}


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

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

int main()
{
    static bool sieve[1000000];
    int n;
    std::cin >> n;
    std::vector<int> v(n);
    for (size_t i = 0; i < n; i++) {
        std::cin >> v[i];
    }
    std::sort(v.begin(), v.end());
    if (n == 1) {
        std::cout << "1\n";
        return 0;
    }
    std::vector<int> nas = {};
    int prev = v[0] - 1;
    bool freshed = true;
    for (int i = 0; i < v.size(); i++) {
        int tmp = v[i];
        if (prev == v[i]) {
            v.erase(v.begin() + i);
            if (freshed)
                nas.push_back(prev);
            freshed = false;
            i--;
        }
        if (prev != tmp)
            freshed = true;
        prev = tmp;
    }

    n = v.size();
    int p = 0, ans = 0;
    bool cont = true;

    while (cont && p < (n - 1)) {
        for (int i = v[p] * 2; i <= v[n - 1]; i += v[p]) {
            sieve[i] = true;
        }
        for (int i = p + 1; i < n; i++) {
            if (!sieve[v[i]]) {
                p = i;
                break;
            }
            if (i == (n - 1)) {
                cont = false;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        if (std::find(nas.begin(), nas.end(), v[i]) == nas.end() && !sieve[v[i]])
            ans++;
    }
    std::cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 4752
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
  
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastInput in = new FastInput(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Sample solver = new Sample();
		solver.solve(1, in, out);
		out.close();
	}
	
	static class Sample {
	
		public void solve(int testNum, FastInput in, PrintWriter out) {
			
			String s = in.next();
			String t = in.next();
			
			int n = s.length();
			int m = t.length();
			
			int min = m;
			for(int i = 0 ; i < n - m + 1  ;i++) {
				int tmp = 0;
				for(int j = 0 ; j < m ; j++) {
					if(s.charAt(i+j) != t.charAt(j)) {
						tmp++;
					}
				}
				min = Math.min(tmp,min);
			}
			
			out.println(min);
			
	
		}
	
	}
	static class FastInput{
		private final BufferedReader in;
		private String[] buff;
		private int index = 0;
		
		public FastInput(InputStream is) {
			in = new BufferedReader(new InputStreamReader(is));
		}
		String nextLine() {
			try {
				return in.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}
		String next() {
			while (buff == null || index >= buff.length) {
				buff = nextLine().split(" ");
				index = 0;
			}
			return buff[index++];
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		Double nextDouble() {
			return Double.parseDouble(next());
		}
		
		BigInteger nextBigInteger() {
			return new BigInteger(next());
		}
		
		BigDecimal nextBigDecimal() {
			return new BigDecimal(next());
		}
		
		public int[] nextIntArray(final int n) {
			final int[] res = new int [n];
			
			for(int i = 0 ; i < n ;i++) {
				res[i] = nextInt();
			}
			return res;
		}
		
		public long[] nextLongArray(final int n) {
			final long[] res= new long [n];
			
			for(int i = 0 ; i < n ;i++) {
				res[i] = nextLong();
			}
			return res;
		}
		
		public double[] nextDoubleArray(final int n ) {
			final double[] res = new double [n];
			
			for(int i = 0 ; i < n ;i++) {
				res[i] = nextDouble();
			}
			return res;
		}
		
		
		public int[][] nextInt2DArray(final int n , final int m){
			int [][]res = new int [n][m];
			
			for(int i = 0 ; i < n ;i++) {
				for(int j = 0 ; j < m ;j++) {
					res[i][j] = nextInt();
				}
			}
			return res;
		}
		public long[][] nextLong2DArray(final int n , final int m){
			long [][]res = new long [n][m];
			
			for(int i = 0 ; i < n ;i++) {
				for(int j = 0 ; j < m ;j++) {
					res[i][j] = nextLong();
				}
			}
			return res;
		}
		
		public char[][] nextChar2DArray(final int n){
			char [][]res = new char [n][];
			
			for(int i = 0 ; i < n ;i++) {
				String s = next();
				res[i] = s.toCharArray();
			}
			
			return res;
		}
	}

}


Measured memory_bytes: 32980
import math
a, b, h, m = map(int, input().split())
rh = (h * 60 + m) / 720 * 2 * math.pi
rm = m / 60 * 2 * math.pi
if abs(rh - rm) < 180:
    r = abs(rh - rm)
    c = ((a ** 2) + (b ** 2) - (2 * a * b * math.cos(r))) ** 0.5
    print(c)
if abs(rh - rm) > 180:
    r = 360 - abs(rh - rm)
    c = ((a ** 2) + (b ** 2) - (2 * a * b * math.cos(r))) ** 0.5
    print(c)
if abs(rh - rm) == 180:
    print(a + b)

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

int main() {
  int n;
  cin >> n;
  vector<int> s(n);
  int a;
  for(int i=1; i<=n; i++){
    cin >> a;
    s[a-1] = i;
  }
  for(int i=0; i<n; i++) cout << s[i] << " ";
  cout << endl;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long
 
typedef long long ll;
ll const MOD = 998244353;
//ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;
 
inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}
 
 
 
signed main(){
    int n;
    string s;
    cin >> n >> s;
 
    vector<int> left, right;
    int r = 0, g = 0, b = 0;
    REP(i, 3*n){
        if(s[i] == 'R') r++;
        else if(s[i] == 'G') g++;
        else b++;
 
        if(r > 0 && g > 0 && b > 0){
            right.push_back(i);
            r--;
            g--;
            b--;
        }
    }
 
    r = g = b = 0;
 
    RREP(i, 3*n){
        if(s[i] == 'R') r++;
        else if(s[i] == 'G') g++;
        else b++;
 
        if(r > 0 && g > 0 && b > 0){
            left.push_back(i);
            r--;
            g--;
            b--;
        }
    }
 
    vector<int> v(3*n);
    for(auto i : left){
        v[i] = 1;
    }
    for(auto i : right){
        v[i] = 2;
    }
 
    ll ans = 1;
 
    int cnt = 0;
    REP(i, 3*n){
        if(v[i] == 0){
            ans *= cnt;
            ans %= MOD;
            cnt--;
        }else if(v[i] == 1){
            cnt++;
        }
    }
 
    cnt = 0;
    RREP(i, 3*n){
        if(v[i] == 0){
            ans *= cnt;
            ans %= MOD;
            cnt--;
        }else if(v[i] == 2){
            cnt++;
        }
    }
 
    for(int i=1; i<=n; i++){
        ans *= i;
        ans %= MOD;
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 2688
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        String[] s = str.split("/", 0);
        if(s[0].compareTo("2019")<0 && s[0].length()<=4) {
            System.out.println("Heisei");
        }else if(s[0].compareTo("2019")==0) {
            if(s[1].compareTo("04")<=0 && s[1].charAt(0)=='0') {
                if(s[2].compareTo("30")> 0 && s[1].compareTo("04")==0) {
                    System.out.println("TBD");
                    return;
                }
                System.out.println("Heisei");
            }else {
                System.out.println("TBD");
            }
        }else {
            System.out.println("TBD");
        }
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#include <cstdio>   
#define pb          push_back 
#define endl        "\n"
#define mostrar(x,y) cout<<x<<" "<<y<<endl;
#define f           first
#define s           second
#define mod         1000000007
#define EPS         1e-9
using namespace std;
typedef pair<int,int> ii;
typedef pair<pair<int,int>,int> iii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef long long ll;

 
int main(){
    ofstream out("output.txt");

    int n,l;
    cin>>n>>l;

    int manzanas[n];
    int sabor = 0;
    for(int i = 0; i<n; i++){
        manzanas[i] = l + i;
        sabor += manzanas[i];
    }
    int minimo = 10000000,buscado;
    for(int i = 0; i<n; i++){
        //cout<<manzanas[i]<<endl ;
        if(abs((sabor-manzanas[i]) - sabor ) < minimo){
            minimo = abs((sabor-manzanas[i]) - sabor );
            buscado = manzanas[i];
        }
    }
    cout <<sabor-buscado<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.PriorityQueue;
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 0;
		for(int i = 0; i < n; i++) {
			int s = sc.nextInt();
			boolean ok = false;
			int tmp = (int)Math.sqrt(s);
			for(int j = 1; j <= tmp+1; j++) {
				if((s - j) % (1 + 2 * j) == 0) {
					ok = true;
					break;
				}
			}
			if(!ok) count++;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 65876
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100005
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
// clang-format on

int is_prime[MAX_N + 1];
int d[MAX_N + 5];

void init_shieve() {
  for (int i = 1; i <= MAX_N; i++) is_prime[i] = true;
  is_prime[0] = false, is_prime[1] = false;
  for (int i = 2; i <= MAX_N; i++) {
    if (is_prime[i]) {
      for (int j = i + i; j <= MAX_N; j += i) {
        is_prime[j] = false;
      }
    }
  }
}

bool like2017(int n) { return (is_prime[n] && is_prime[(n + 1) / 2]); }

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

  // REP(i, MAX_N + 5) { cout << is_prime[i]; }

  d[0] = 0;
  REP(i, MAX_N + 5) {
    if (like2017(i)) {
      d[i + 1] = d[i] + 1;
    } else {
      d[i + 1] = d[i];
    }
  }

  int Q;
  cin >> Q;
  vector<int> l(Q), r(Q);
  REP(i, Q) { cin >> l[i] >> r[i]; }

  REP(i, Q) { cout << d[r[i] + 1] - d[l[i]] << endl; }

  return 0;
}


Measured memory_bytes: 2176
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        long n = Read.Long();
        long[] a = Read.longs();
        long []ans=new long[10000000];
        long sum = 0;
        for (int i = 0; i < n; i++)
        {
            if (a[i] > ans.Length) { sum += 1; }
            else
            {
                ans[a[i]]++;
            }
        }
      
        for(long i = 0; i < ans.Length; i++)
        {
            if (ans[i] == 0) { }
            else if (ans[i] >= i)
            {
                sum += ans[i] - i;
            }
            else { sum+=ans[i]; }
        }
        Console.WriteLine(sum);
        Console.ReadLine();
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    public static bool IsPrime(int num)
    {
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2)
        {
            if (num % i == 0)
            {
                // 素数ではない
                return false;
            }
        }

        // 素数である
        return true;
    }
}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long() { return long.Parse(Console.ReadLine()); }
    public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); }
    public static int Int() { return int.Parse(Console.ReadLine()); }
    public static int[] ints() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 101856
// Last Change: 03/22/2019 19:23:36.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  int N, M, X, left, right, ipt;
  cin >> N >> M >> X;

  left = right = 0;
  for (int i = 0; i < M; ++i) {
    cin >> ipt;
    if (ipt < X) {
      ++left;
    } else {
      ++right;
    }
  }
  cout << min(left, right) << endl;

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

/**
 * author: Acrafter
 * date: 2017/1/11
 * time: 22:03
 */
public class Main {
    private static char[][] farm = new char[100][100];
    private static char[][] visited = new char[100][100];
    private static int[] dx = {1, -1, 0, 0}, dy = {0, 0, 1, -1};
    private static Queue<P> queue = new LinkedList<P>();
    private static int result = 0;
    private static int H, W;
    static class P{
        int y, x;
        P(int y, int x){
            this.x=x;
            this.y=y;
        }
    }

    public static void main(String[] args) throws IOException {
        Scanner input = new Scanner(System.in);
        H = input.nextInt();W = input.nextInt();
        while (H != 0){
            for (int y = 0; y < H; y++) {
                char[] line = input.next().toCharArray();
                farm[y] = line;
                for (int x = 0; x < W; x++) {
                    visited[y][x] = 'O';
                }
            }
            for (int y = 0; y < H; y++) {
                for (int x = 0; x < W; x++) {
                    if(visited[y][x]=='O'){
                        bfs(y, x);
                        result += 1;
                    }
                }
            }
            System.out.println(result);
            result = 0;
            H = input.nextInt();W = input.nextInt();
        }
    }

    public static void bfs(int iy, int ix){
        visited[iy][ix] = 'X';
        queue.add(new P(iy,ix));
        for (;!queue.isEmpty();){
            P p = queue.poll();
            int y = p.y, x = p.x;
            for (int i = 0; i < 4; i++) {
                int ny = y + dy[i], nx = x + dx[i];
                if(0<=ny && ny<H && 0<=nx && nx<W && visited[ny][nx]=='O' && farm[ny][nx]==farm[y][x]){
                    visited[ny][nx] = 'X';
                    queue.add(new P(ny, nx));
                }
            }
        }
    }
}

Measured memory_bytes: 30508
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let x = read_vec::<i64>();
    let s = x.iter().cloned().collect::<HashSet<_>>();
    let mut count = 0;
    let mut consumed = 0;
    let mut ans = 1;
    let big_int = 1000_000_000 + 7;
    for i in 1..2 * n + 1 {
        if s.contains(&(i as i64)) {
            count += 1;
        }
        if i % 2 == 1 {
            continue;
        }
        if count > i / 2 {
            ans *= count;
            ans %= big_int;
            count -= 1;
            consumed += 1;
        }
    }
    for i in 1..n + 1 - consumed {
        ans *= i;
        ans %= big_int;
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 9464
import java.io.BufferedReader

fun main() {
    val br = System.`in`.bufferedReader()
    val sb = StringBuilder()
    val n = br.readInt()
    var k = br.readInt()
    val lengths = IntArray(n) { br.readInt() }
    fun isPossible(length: Int): Boolean {
        var numCuts = 0L
        for (l in lengths) {
            numCuts += (l - 1) / length
        }
        return numCuts <= k
    }


    var low = 1
    var high = 1_000_000_001
    var mid = (low + high) shr 1
    while (low != high) {
        if (isPossible(mid)) {
            high = mid
        } else {
            low = mid + 1
        }
        mid = (low + high) shr 1
    }
    print(high)
}

private const val SPACE_INT = ' '.toInt()
private const val ZERO_INT = '0'.toInt()
private const val NL_INT = '\n'.toInt()

private fun BufferedReader.readInt(): Int {
    var ret = read()
    while (ret <= SPACE_INT) {
        ret = read()
    }
    val neg = ret == '-'.toInt()
    if (neg) {
        ret = read()
    }
    ret -= ZERO_INT
    var read = read()
    while (read >= ZERO_INT) {
        ret *= 10
        ret += read - ZERO_INT
        read = read()
    }

    while (read <= SPACE_INT && read != -1 && read != NL_INT) {
        mark(1)
        read = read()
    }
    if (read > SPACE_INT) {
        reset()
    }
    return if (neg) -ret else ret
}

Measured memory_bytes: 39072
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef long long ll;

bool flag[1501];
int v[1501];
int n;

bool can(int a, int rest) {
  while(rest--)a+=a;
  return a>=n;
}

bool dfs(int now, int d, int len, int ma) {
  if (d == 0) return flag[n];
  if (d == 1) return flag[abs(now-n)];
  if (!can(ma,d)) return 0;
  // cout << now << " " << d << endl;
  // cout << "v = ";
  // REP(i, len) cout << v[i] << " ";
  // cout << endl;
  for (int i=len-1; i>=0; i--) {
    int next = v[i]+now;
    if (next<=n*3/2 && !flag[next]) {
      v[len] = next;
      flag[next] = 1;
      if (dfs(next,d-1,len+1,max(ma, next))) return 1;
      flag[next] = 0;
    }
    next = now-v[i];
    if (next > 0 && !flag[next]) {
      v[len] = next;
      flag[next] = 1;
      if (dfs(next,d-1,len+1,ma)) return 1;
      flag[next] = 0;
    }
  }
  return 0;
}

int main() {
  while(cin >> n, n) {
  //for (n=1;n<=1000;++n) {
    REP(p,14) {
      if (p == 13) {
        cout << p << endl;
        break;
      }
      //cout << "p = " << p << endl;
      memset(flag,0,sizeof(flag));
      flag[1] = 1;
      v[0] = 1;
      if (dfs(1,p,1,1)) {
        cout << p << endl;
        break;
      }
    }
  }
}

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

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

using namespace std;

int main(){
  int x,a,b;
  cin>>x>>a>>b;
  
  if(a>=b){
    cout<<"delicious";
  }else if(x+a>=b){
    cout<<"safe";
  }else{
    cout<<"dangerous";
  }
  

  return 0;
}


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

int main (){
    int a,b,x,sum;
    cin>>a;
    cin>>b;
    cin>>x;
    sum = a+b;
    if(a<=x){
        if(sum>=x){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var X int
	var Y int

	fmt.Scanf("%x", &X)
	fmt.Scanf("%x", &Y)

	if X > Y {
		fmt.Println(">")
	} else if X < Y {
		fmt.Println("<")
	} else if X == Y {
		fmt.Println("=")
	}

}


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

using namespace std;

using int64 = long long;
//const int mod = 1e9 + 7;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

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

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  double L;
  cin >> L;
  L /= 3;
  cout << L * L * L << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;
import java.lang.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String[] data = new String[n];

    HashMap<String, Long> map = new HashMap<>();

    long count = 0;

    for (int i = 0; i < n; i++) {
      data[i] = sc.next();
    }

    for (int i = 0; i < n; i++) {
      char[] temp = data[i].toCharArray();
      Arrays.sort(temp);
      String str = String.valueOf(temp);
      if (map.containsKey(str)) {
        long k = map.get(str);
        count += k;
        map.put(str,k+1);
      } else {
        map.put(str,(long)1);
      }
    }

    System.out.println(count);


  }

}


Measured memory_bytes: 53296
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    char c,t;
    cin>>c>>t;
    ll i = c == 'H', j = t == 'H';
    cout<<(i^j ? 'D' : 'H')<<endl;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from functools import reduce
import operator
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import connected_components

N = int(readline())
A = list(map(int,readline().split()))
B = list(map(int,readline().split()))

a_xor = reduce(operator.xor,A)
b_xor = reduce(operator.xor,B)

if any(x != y for x,y in zip(sorted(A + [a_xor]),sorted(B + [b_xor]))):
    print(-1)
    exit()

Adiff = [x for x,y in zip(A,B) if x != y]
Bdiff = [y for x,y in zip(A,B) if x != y]
x_to_i = {x:i for i,x in enumerate(set(Adiff + [a_xor]))}
row = [x_to_i[x] for x in Adiff]
col = [x_to_i[x] for x in Bdiff]
if a_xor != b_xor:
    row.append(x_to_i[a_xor])
    col.append(x_to_i[b_xor])
V = len(x_to_i)
graph = csr_matrix(([1]*len(row),(row,col)),(V,V))
Ncomp,comp = connected_components(graph)

counter = [0] * Ncomp
for x in Adiff:
    counter[comp[x_to_i[x]]] += 1
c = comp[x_to_i[a_xor]]
counter[c] += 1

answer = sum(x+1 for x in counter) - 2
print(answer)

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

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

  if(s =="Sunny" ){
    cout << "Cloudy" << endl;
  }else if(s == "Cloudy"){
    cout << "Rainy" << endl;
  }else if(s =="Rainy"){
    cout << "Sunny" << endl;
  }
}

Measured memory_bytes: 256
using System;

namespace ABC042C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] bufs = Console.ReadLine().Split(' ');
            int N = int.Parse(bufs[0]);
            int K = int.Parse(bufs[1]);

            int bottom = 0;

            int NTop = N;
            int scale = 0;
            while (NTop / 10 != 0)
            {
                NTop /= 10;
                scale++;
            }

            bool[] accept = new bool[10];

            bufs = Console.ReadLine().Split(' ');
            int cur = 0;
            for (int i = 0; i < 10; i++)
            {
                int D = 10;
                if (cur < K)
                {
                    D = int.Parse(bufs[cur]);
                }
                if (i == D)
                {
                    cur++;
                    if (bottom == D)
                    {
                        bottom++;
                    }
                }
                else
                {
                    accept[i] = true;
                }
            }

            int res = N;

            int foo = 1;
            while (foo <= res)
            {
                while ((res / foo) % 10 < 10)
                {
                    if (accept[(res / foo) % 10]) {
                        foo *= 10;
                        break;
                    }

                    res += foo;

                    if (foo > 1)
                    {
                        res -= res % foo;
                        foo = 1;
                        break;
                    }
                }
            }

            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13140
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 998244353
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def C(n, r):
    return fact[n] * pow(fact[n-r], mod-2, mod) * pow(fact[r], mod-2, mod) % mod

n, m, k = LI()
fact = [1] * (n+1)
for i in range(1, n+1):
    fact[i] = fact[i-1] * i
    fact[i] %= mod

ans = 0
for i in range(k+1):
    ans += C(n-1, i) * m * pow(m-1, n-1-i, mod)
    ans %= mod
print(ans)


Measured memory_bytes: 79476
import java.io.*
import java.util.*

fun solve(R: Long){
    when{
        R < 1200L -> { println("ABC") }
        R < 2800L -> { println("ARC") }
        else -> { println("AGC") }
    }
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val R = sc.next().toLong()
    solve(R)
}



Measured memory_bytes: 29596
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<=n;i++)

struct rec{
	int x1,x2,y1,y2;
	rec(){x1=99,x2=-1,y1=99,y2=-1;}
	rec(int x1,int x2,int y1,int y2):
	x1(x1),x2(x2),y1(y1),y2(y2) {}
};

int N,H,W,perm[7];
char c[51][51],kind[7];
rec r[8];

int main(){
	cin>>N;
	while(N--){
		rep(i,7)perm[i]=i;
		cin>>H>>W;
		int cur=0,ans=0;
		map<char,rec> m;
		map<char,rec>::iterator it;
		rep(i,H)rep(j,W){
			cin>>c[i][j];
			if(c[i][j]!='.'){
				rec r=m[c[i][j]];
				if(r.x1==99)kind[cur++]=c[i][j];
				r.x1=min(r.x1,j);r.x2=max(r.x2,j);
				r.y1=min(r.y1,i);r.y2=max(r.y2,i);
				m[c[i][j]]=r;
			}
		}
		ans=0;
		do{
			int ok=1;
			rep(i,cur){
				rec r=m[kind[perm[i]]];
				rep2(j,r.y1,r.y2){
					rep2(k,r.x1,r.x2){
						int ok2=0;
						rep(l,i+1)if(c[j][k]==kind[perm[l]]){ok2=1;break;}
						if(!ok2){ok=0;break;}
					}
					if(!ok)break;
				}
				if(!ok)break;
			}
			if(ok){ans=1;break;}
		}while(next_permutation(perm,perm+cur));
		cout<<(ans?"SAFE":"SUSPICIOUS")<<endl;
	}
}

Measured memory_bytes: 904
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    long long int d,x,y;
    cin>>n>>d;
    int cn=0;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        if(x*x+y*y<=d*d){
            cn++;
        }
    }
    cout<<cn;
}


Measured memory_bytes: 3584
l = [int(input()) for _ in range(4)]

cnt = 0
for c500 in range(l[0]+1):
  for c100 in range(l[1]+1):
    for c50 in range(l[2]+1):
      if c500 * 500 + c100 * 100 + c50 * 50 == l[3]:
        cnt += 1

print(cnt)

Measured memory_bytes: 3060
class Point {
	double x,y;
	
	double cross(Point t){
		return x * t.y - t.x * y;
	}
	Point sub(Point t){
		Point ret = new Point();
		ret.x = x-t.x;
		ret.y = y-t.y;
		
		return ret;
	}
}

class Main {

	public static void main( String[] args ){
		
		java.util.Scanner sc = new java.util.Scanner(System.in);
		while(sc.hasNextDouble()){
			Point A[];
			Point P = new Point();
			
			A = new Point[3];
			
			for(int i = 0; i < 3; ++i){
				A[i] = new Point();
				A[i].x = sc.nextDouble();
				A[i].y = sc.nextDouble();
			}
			P.x = sc.nextDouble();
			P.y = sc.nextDouble();
			
			boolean res = true;
			int initCCW = 0;
			for(int i = 0; i < 3; ++i){
				double d = P.sub(A[ (i+1)%3 ]).cross(A[ (i+1)%3 ].sub(A[i]));
				int sign;
				if( d < 0 ) sign = -1;
				else sign = 1;
				
				if( i == 0 ){
					initCCW = sign;
				}
				if( initCCW != sign ){
					res = false;
				}
			}
			
			
			if( res ){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
	}
}

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

int main(void){
    int q,n = 0;
    cin >> q;
    int l[q],r[q];
    for(int i = 0;i < q;i++){
        cin >> l[i] >> r[i];
        n = max(n,r[i]);
    }
    
    int is_prime[100005] = {},num[100005] = {};
    
    for(int i = 2;i <= n;i++){
        if(!is_prime[i]){
            for(int j = 2*i;j <= 100000;j += i)is_prime[j] = 1;
        }
    }
    for(int i = 3;i <= n;i++){
        if(is_prime[i] == 0 && is_prime[(i+1)/2] == 0)num[i] += num[i-1] + 1;
        else num[i] += num[i-1];
    }
    
    for(int i = 0;i < q;i++)cout << num[r[i]]-num[l[i]-1] << endl;
}

Measured memory_bytes: 2176
#include<stdio.h>
#include<map>
#include<algorithm>
#include<stack>
#include<queue>
#include<string.h>
#include<math.h>
#include<iostream>
using namespace std;
long long a,b,c,d,ans;
int main()
{
    scanf("%lld%lld%lld",&a,&b,&c);
    printf("%lld %lld %lld\n",c,a,b);
}

Measured memory_bytes: 256