akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int main() {
    const i64 mod = 1e9 + 7;
    i64 n, k;
    cin >> n >> k;
    i64 l = 0, r = 0;
    i64 ans = 0;
    for (i64 i = 1; i <= n + 1; ++i) {
        l += i - 1;
        r += n - i + 1;
        if (i >= k) {
            ans += r - l + 1;
            ans %= mod;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int A,B,C,D;
    int count = 0;

    A = s.nextInt();
    B = s.nextInt();
    C = s.nextInt();
    D = s.nextInt();
    for(int time = 0; time <= 100 ; time++){
      boolean ab = false,cd = false;
      if(time >= A && time < B)ab = true;
      if(time >= C && time < D)cd = true;
      if(ab && cd)count++;
    }
    //if(C <= A && D <= A)
    //if(C >= B && D >= B)
    //if()
    System.out.printf("%d",count);
  }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
    int s;cin>>s;
    vector<int> A;A.push_back(s);
    int baket[1000000]={0};baket[s-1]=1;
    for(int i=1;i<=1000000;i++){
        if(A[i-1]%2==0){
            A.push_back(A[i-1]/2);
        }else{
            A.push_back(3*A[i-1]+1);
        }if(baket[A[i]-1]==1){
            cout<<i+1<<endl;
            return 0;
        }else{
            baket[A[i]-1]++;
        }
    }
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>

using namespace std;

long long int gcd(long long int a, long long int b) {
	//
	if (a<0) a = b;
	if (b<0) b = a;
	//
	if (b == 0) return a;
	return gcd(b, a%b);
}

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


int main(){

	long long int a, b;

	cin>> a >> b;

	cout<< lcm(a, b) << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "atcoder/all"
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
const ll mod = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> temp;

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

  for (int i = 0; i < n; i++) {
    if (a[i] == i + 1 && (i != n - 1)) {
      swap(a[i], a[i + 1]);
      ans++;
    } else if (a[i] == i + 1 && i == n - 1) {
      swap(a[i - 1], a[i]);
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3732
#include <stdio.h>
#include <stdlib.h>
int main()
{
    long long int a,b,c,d,m,n;
    scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
    m=a*b;
    n=c*d;
    if(m<=n)
    {
        printf("%lld",n);
    }
    if(m>n)
    {
        printf("%lld",m);
    }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define pb push_back
using namespace std;

const int N = (1<<20);



inline void test_case(){
        int n;
        cin >> n;
        double d = 2/(2*tan(3.14159265359/n/2));
        //cout << d << endl;
        printf("%.10f\n",sqrt(1+d*d));
}

int main(){
        ios::sync_with_stdio(0); //cin.tie(0); cout.tie(0);
        string s;
        int k;
        cin >> k;
        cin >> s;

        if(s.size() <= k){
                cout << s << endl;
        } else {
                for(int i = 0; i < k; i++) cout << s[i];
                cout <<"..."<<endl;
        }

}


Measured memory_bytes: 3640
int main(void)
{
    int N, H, W, x = 0, y = 0, i;

    scanf("%d %d %d", &N, &H, &W);

    for (i = 0; (N - i) >= W; i++)
        ;
    x = i;
    for (i = 0; (N - i) >= H; i++)
        ;
    y = i;

    printf("%d\n", x * y);
}


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

vector<pair<ll,ll>>v;
bitset<10000005>bs;

int main()
{
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);
    bs.set();
    
    ll a;
    cin>>a;
    if(a<1000) cout<<"ABC";
    else cout<<"ABD";
    return 0;
}

Measured memory_bytes: 1536
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int[] array = new int[n];

    for(int i=0; i<n; i++){
      int number = sc.nextInt();
      array[number-1] = i+1;
    }
    for(int j=0; j<n; j++){
      System.out.println(array[j]);
    }


  }
}

Measured memory_bytes: 57724
a,b = map(int,input().split())

temp=["#" for _ in range(b+2)]
mass = []
mass.append(temp)
for _ in range(a):
  mass.append(["#"] + list(input()) + ["#"])
mass.append(temp)

for retsu in mass:
  retsu = "".join(retsu)
  print(retsu)

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long k = sc.nextLong();
		long num = 0;
		long cnt = 0;
		long temp = 0;
		int index = 0;
		long mod = 0;

		List<Long> que = new ArrayList<>();

		while (true) {

			if (num < 9) {
				num++;
				que.add(num);
				cnt++;
				if (cnt == k) {
					System.out.println(num);
					return;
				}
			} else {

				while (true) {
					temp = que.get(index);
					mod = temp % 10;

					if (mod - 1 >= 0) {
						num = 10 * temp + (mod - 1);
						que.add(num);
						cnt++;

						if (cnt == k) {
							System.out.println(num);
							return;
						}
					}

					num = 10 * temp + (mod);
					que.add(num);
					cnt++;

					if (cnt == k) {
						System.out.println(num);
						return;
					}

					if (mod + 1 < 10) {
						num = 10 * temp + (mod + 1);
						que.add(num);
						cnt++;

						if (cnt == k) {
							System.out.println(num);
							return;
						}
					}

					index++;
				}

			}

		}

	}
}


Measured memory_bytes: 26964
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=b[a[0]-1]
for i in range(1,n):
  if a[i]-1==a[i-1]:
    ans+=c[a[i]-2]+b[a[i]-1]
  else:
    ans+=b[a[i]-1]
  #print(ans)
print(ans)
    

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


int main(){
  int n, i = 1, x;
  scanf("%d", &n);
  while(i <= n){
    x = i;
    if(x % 3 == 0){
      cout << " " << i;
    }else{
      while(x){
        if(x % 10 == 3){
          cout << " " << i;
          break;
        }else{
          x /= 10;
        }
      }
    }
    i++;
  }
  cout << endl;
}


Measured memory_bytes: 3148
s = int(input())
a=[s]
newnum = 0

for i in range(2,1000000):
  if a[-1]%2 == 0:
    newnum = a[-1]/2
  else:
    newnum = 3*a[-1]+1
  
  if newnum in a:
    print(i)
    break
  else:
    a.append(newnum)

Measured memory_bytes: 3060
#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 H,N;cin>>H>>N;
    vector<int> A(N,0);
    rep(i,N)cin>>A[i];
    int sum=0;
    rep(i,N)sum+=A[i];
    if(H<=sum){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
int n;
while(cin >> n, n){
vector<int> v(n);
for(int i = 0; i < n; i++){
cin >> v[i];
}
sort(v.begin(), v.end());
int sum = 0;
for(int i = 1; i < n-1; i++){
sum+=v[i];
}
cout << sum / (n-2) <<endl;
}


}

Measured memory_bytes: 1220
#include<stdio.h>
int main()
{
    int R, G, B, N;
    int count = 0;
    // 整数の入力
    scanf("%d", &R);
    scanf("%d", &G);
    scanf("%d", &B);
    scanf("%d", &N);

    for (int r = 0; r * R <= N; r++) {
        for (int g = 0; g * G <= (N - r * R); g++) {
            int n = N - (r * R) -  (g * G);
//    printf("%d %d %d\n", r, g, n);
            if ((n % B) == 0) count++;
        }
    }
    
    
    printf("%d\n", count);
/*
    // スペース区切りの整数の入力
    scanf("%d %d",&b,&c);
    // 文字列の入力
    scanf("%s",s);
    // 出力
    printf("%d %s\n",a+b+c,s);
*/
    return 0;
}
        

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std; 
using ll = long long;
struct BIT {
	ll M;
	std::vector<ll> bit;
	BIT(ll n) {
		init(n);
	}
	void init(ll n) {
		M = n;
		bit.resize(M + 1);
		fill(bit.begin(), bit.end(), 0);
	}
	ll sum(ll i) {
		ll s = 0;
		while (i > 0) {
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}
	void add(ll i, ll x) {
		while (i <= M) {
			bit[i] += x;
			i += i & -i;
		}
	}
};


int main() {
	int N;
	cin >> N;
	vector<int>A(N); 
	vector<int>A_Sort(N);
	for (int i = 0;i<N;++i) {
		cin >> A[i];
		A_Sort[i] = A[i];
	}
	sort(A_Sort.begin(),A_Sort.end());
	int l = 0;
	int r = N;
	while (l + 1 < r) {
		int c = (l + r) / 2;
		vector<int>B(N);
		for (int i = 0;i<N;++i) {
			B[i] = (A[i] < A_Sort[c]) ? -1 : 1;
		}
		vector<int>S(N);
		for (int i = 0; i < N; ++i) {
			S[i] = (i == 0) ? S[i] : S[i - 1] + B[i];
		}
		long long cnt = 0;
		BIT bit(2 * N + 1);
		bit.add(N, 1);
		for (int i = 0; i < N; ++i) {
			cnt += bit.sum(S[i] + N);
			bit.add(S[i] + N, 1);
		}
		if (cnt >= (long long)N*(N + 1)/4) {
			l = c;
		}
		else {
			r = c;
		}
	}
	cout << A_Sort[l] << endl;
	return 0;
}

Measured memory_bytes: 6428
n, t = map(int, input().split())

tmp = [input().split() for i in range(n)]
c = 1001
for i in range(n):
  #print(tmp[i])
  ctmp, ttmp = tmp[i]
  if int(ttmp) <= t and int(ctmp) < c:
    c = int(ctmp)
    
if c == 1001:
  print("TLE")
else:
  print(c)

Measured memory_bytes: 3060
using System;

namespace AOJ
{
	class QQ
	{
		public static void Main(string[] args)
		{
			for(int i = 1; i <= 9; i++)
			{
				for(int k = 1; k <= 9; k++)
				{
					Console.WriteLine(string.Format("{0}x{1}={2}", i, k, i * k));
				}
			}
		}
	}
}

Measured memory_bytes: 5584
N,M = map(int,input().split())
A = []
B = []
ans = 'No'
for i in range(N):
    A.append(input())
for i in range(M):
    B.append(input())
for i in range(N-M+1):
    for j in range(N-M+1):
        if A[i][j:M+j+1] == B[0]:
            D = 0
            for k in range(i,i+M):
                for l in range(0,M):
                    if A[k][j:M+j+1] == B[l]:
                        D += 1
            if D == M:
                ans = 'Yes'
if ans == 'Yes':
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.NoSuchElementException;

public class Main {
	int N,M;
	int[] K;
	ArrayList<Integer>[] langs,L;
	boolean[] usedLang,usedN;
	int[] union;

	public void unite(int x,int y){

		x = root(x);
		y = root(y);

		if(x < y){
			union[y] = x;
		}else{
			union[x] = y;
		}

	}

	public boolean same(int x,int y){
		return root(x) == root(y);
	}

	public int root(int x){
		return union[x] == x ? x : root(union[x]);
	}

	public void dfs1(int lang,int preN){
		usedLang[lang] = true;
		for(int n : langs[lang]){
			if(usedN[n])continue;
			unite(preN,n);
			dfs2(n);
		}
	}

	public void dfs2(int n){
		usedN[n] = true;
		for(int l : L[n]){
			if(usedLang[l])continue;
			dfs1(l,n);
		}
	}

	@SuppressWarnings("unchecked")
	public void solve() {
		N = nextInt();
		M = nextInt();
		usedN = new boolean[N];
		usedLang = new boolean[M];
		union = new int[N];
		for(int i = 0;i < N;i++){
			union[i] = i;
		}

		K = new int[N];

		L = new ArrayList[N];
		for(int i = 0;i < N;i++){
			L[i] = new ArrayList<Integer>();
		}

		langs = new ArrayList[M];
		for(int i = 0;i < M;i++){
			langs[i] = new ArrayList<Integer>();
		}

		for(int i = 0;i < N;i++){
			K[i] = nextInt();
			for(int j = 0;j < K[i];j++){
				int l = nextInt();
				L[i].add(l - 1);
				langs[l - 1].add(i);
			}
		}

		dfs2(0);

		for(int i = 0;i < N;i++){
			if(union[i] != 0){
				out.println("NO");
				return;
			}
		}
		out.println("YES");
	}

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

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 43828
#include <bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    cout << "a";
    if (a < b) cout << " < ";
    else if (a > b) cout << " > ";
    else cout << " == ";
    cout << "b" << endl;


    return 0; 
}



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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	unordered_set<int> s;
	vector<int> v;
	while (n--) {
		int a; cin >> a;
		s.insert(a);
		v.push_back(a);
	}
	if (s.size() != v.size()) cout << "NO";
	else cout << "YES";
}


Measured memory_bytes: 9276
MOD = 1000000007

N, M = map(int, input().split())
N += 1
dp = [0] * N
dp[0] = 1

for i in range(M):
    a = int(input())
    dp[a] = -1
    
for i in range(N):
    if dp[i] == -1: continue

    dp[i] %= MOD
    
    if i+1 < N and dp[i+1] != -1: dp[i+1] += dp[i]
    if i+2 < N and dp[i+2] != -1: dp[i+2] += dp[i]

print(dp[-1] % MOD)


Measured memory_bytes: 6900
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    long long H, W;
    cin >> H >> W;
    vector<string> S(H);
    for(int i = 0; i < H; i++) cin >> S[i];
    vector<int> sumg[H], sumr[W];
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(S[i][j] == '#') sumg[i].push_back(j);
        }
    }
    for(int i = 0; i < W; i++){
        for(int j = 0; j < H; j++){
            if(S[j][i] == '#') sumr[i].push_back(j);
        }
    }
    int ans = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(S[i][j] == '.'){
                int res = 0;
                if(sumg[i].size() == 0) res += W;
                else{
                    int indg = lower_bound(sumg[i].begin(), sumg[i].end(), j) - sumg[i].begin();
                    if(indg == 0) res += sumg[i][indg];
                    else if(indg == sumg[i].size()) res += W - 1 - sumg[i][indg - 1];
                    else res += sumg[i][indg] - sumg[i][indg - 1] - 1;
                }
                if(sumr[j].size() == 0) res += H;
                else{
                    int indr = lower_bound(sumr[j].begin(), sumr[j].end(), i) - sumr[j].begin();
                    if(indr == 0) res += sumr[j][indr];
                    else if(indr == sumr[j].size()) res += H - 1 - sumr[j][indr - 1];
                    else res += sumr[j][indr] - sumr[j][indr - 1] - 1;
                }
                res--;
                ans = max(ans, res);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 36480
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main
{
    public static void process(int test_number)throws IOException
    {
        int x = ni();
        pn((x >= 30) ? "Yes" : "No");
    }
 
    static final long mod = (long)1e9+7l;
    
    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc = new FastReader();
 
        long s = System.currentTimeMillis();
        int t = 1;
        //t = ni();
        for(int i = 1; i <= t; i++)
            process(i);
 
        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
    }

    static void trace(Object... o){ System.err.println(Arrays.deepToString(o)); };
    static void pn(Object o){ out.println(o); }
    static void p(Object o){ out.print(o); }
    static int ni()throws IOException{ return Integer.parseInt(sc.next()); }
    static long nl()throws IOException{ return Long.parseLong(sc.next()); }
    static double nd()throws IOException{ return Double.parseDouble(sc.next()); }
    static String nln()throws IOException{ return sc.nextLine(); }
    static long gcd(long a, long b)throws IOException{ return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{ return (b==0)?a:gcd(b,a%b); }
    static int bit(long n)throws IOException{ return (n==0)?0:(1+bit(n&(n-1))); }
    
    static class FastReader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader(){ 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()){ 
                try{ st = new StringTokenizer(br.readLine()); } catch (IOException  e){ e.printStackTrace(); } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine(){ 
            String str = ""; 
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 36664
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

using P = pair<int, int>;
void update(vector<vector<bool>> &is_visited, queue<P> &q,
            vector<vector<int>> &dist, int cx, int cy, int d) {
  if (!is_visited[cx][cy]) {
    is_visited[cx][cy] = true;
    dist[cx][cy] = d + 1;
    q.push(P(cx, cy));
  }
}

int main() {
  int H, W, K;
  cin >> H >> W >> K;

  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  sx--;
  sy--;
  tx--;
  ty--;

  vector<string> grid(H);
  rep(i, H) { cin >> grid[i]; }

  const int INF = H * W;
  vector<vector<bool>> is_visited(H, vector<bool>(W, false));
  vector<vector<bool>> is_visited_x(H, vector<bool>(W, false));
  vector<vector<bool>> is_visited_y(H, vector<bool>(W, false));

  vector<vector<int>> dist(H, vector<int>(W, INF));
  is_visited[sx][sy] = is_visited_x[sx][sy] = is_visited_y[sx][sy] = true;
  dist[sx][sy] = 0;
  queue<P> q;
  q.push(P(sx, sy));

  while (!q.empty()) {
    int x, y;
    tie(x, y) = q.front();
    q.pop();
    int d = dist[x][y];

    for (int cx = x - 1; cx >= max(0, x - K) && grid[cx][y] != '@' &&
                         dist[x][y] < dist[cx][y];  //! is_visited_x[cx][y];
         cx--) {
      is_visited_x[cx][y] = true;
      update(is_visited, q, dist, cx, y, d);
    }
    for (int cx = x + 1; cx <= min(H - 1, x + K) && grid[cx][y] != '@' &&
                         dist[x][y] < dist[cx][y];  //! is_visited_x[cx][y];
         cx++) {
      is_visited_x[cx][y] = true;
      update(is_visited, q, dist, cx, y, d);
    }
    for (int cy = y - 1; cy >= max(0, y - K) && grid[x][cy] != '@' &&
                         dist[x][y] < dist[x][cy];  //! is_visited_y[x][cy];
         cy--) {
      is_visited_y[x][cy] = true;
      update(is_visited, q, dist, x, cy, d);
    }
    for (int cy = y + 1; cy <= min(W - 1, y + K) && grid[x][cy] != '@' &&
                         dist[x][y] < dist[x][cy];  //! is_visited_y[x][cy];
         cy++) {
      is_visited_y[x][cy] = true;
      update(is_visited, q, dist, x, cy, d);
    }
  }

  int result = dist[tx][ty];
  cout << (result == INF ? -1 : result) << endl;
  return 0;
}

Measured memory_bytes: 12624
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x=0):x((x%mod+mod)%mod){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
	mint operator+(const mint a) const { return mint(*this) += a;}
	mint operator-(const mint a) const { return mint(*this) -= a;}
	mint operator*(const mint a) const { return mint(*this) *= a;}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}
	
	// for prime mod
	mint inv() const { return pow(mod-2);}
	mint& operator/=(const mint a) { return *this *= a.inv();}
	mint operator/(const mint a) const { return mint(*this) /= a;}
};

mint F[2002000];
mint nCk(ll n, ll k){
	return F[n] / (F[n-k] * F[k]);
}

int main()
{
	ll K;
	string S;
	cin >> K >> S;
	ll N = S.length();
	mint ans = 0;
	F[0] = 1;
	for(ll i = 1; i < 2002000; i++){
		F[i] = F[i-1] * i;
	}
	for(int i = 0; i <= K; i++){
		mint n25 = 25;
		mint n26 = 26;
		ans += nCk(N+K-i-1, N-1) * n25.pow(K-i) * n26.pow(i);
	}
	cout << ans.x << endl;
	return 0;
}


Measured memory_bytes: 20972
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int MOD = 1e9 + 7;

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

    int A, B, C;
    cin >> A >> B >> C;
    if (A != B && B != C && C == A)
        cout << "Yes" << endl;
    else if (A == B && B != C && C != A)
        cout << "Yes" << endl;
    else if (A != B && B == C && C != A)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        boolean c = true;
        for (int i = 0 ; i < a.length(); i++) {
            if (!a.substring(i, i + 1).equals(b.substring(2-i, 3-i))) {
                c = false;
            }
        }
        if (c) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

}

Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
#include <stack>

using namespace std;


const int six_dx[]={1,1,0,-1,-1,0};
const int six_dy[]={1,0,-1,-1,0,1};

int main()
{
    int n;
    cin>>n;
    
    long long res=0;
    while(n>1){
        res++;
        if(n%3==0) n/=3;
        else n=n/3+1;
    }
    
    cout<<res<<endl;
    
    return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,M,m;
    cin>>n;
    M=0;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]>M){m=M;M=a[i];}
    }
    vector<int> b=a;
    sort(b.rbegin(),b.rend());
    for(int i=0;i<n;i++){
        if(a[i]==M){cout<<b[1]<<endl;}
        else{cout<<b[0]<<endl;}
    }
}

Measured memory_bytes: 3200
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in();
	auto V=vecin(N);
	auto R=minmax_element(ALL(V));
	auto P=((*R.second)+(*R.first))/2;
	out(max((*R.second)-P,(*R.first)-P));
	return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll num[100005]={0};
int main(){
  ll n,sum=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>num[i];
    sum+=num[i];
  }
  ll kn=n*(n+1)/2;
  if(sum%kn!=0){
    cout<<"NO"<<endl;
    return 0;
  }
  ll kai=sum/kn;
  for(int i=0;i<n;i++){
    int nxt=(i+1)%n;
    ll del=num[nxt]-num[i]-kai;
    if(del>0){
      cout<<"NO"<<endl;
      return 0;
    }
    del*=-1;
    if(del%n!=0){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
int main(int argc, char const *argv[]) {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> a(m, 0);

  for (size_t i = 0; i < n; i++) {
    int k;
    std::cin >> k;
    for (size_t j = 0; j < k; j++) {
      int a_val;
      std::cin >> a_val;
      a[a_val - 1]++;
    }
  }

  int count = 0;
  for (const auto i : a) {
    if (i == n) {
      count++;
    }
  }

  std::cout << count << std::endl;
}


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

using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> A(N + 1);
    vector<int> B(N);
    for (int i = 0; i < N + 1; ++i) {
        cin >> A[i];
    }
    for (int i = 0; i < N; ++i) {
        cin >> B[i];
    }

    ll ans = 0;
    for (int i = N - 1; i >= 0; --i) {
        int mons1 = min(A[i + 1], B[i]);
        A[i + 1] -= mons1;
        B[i] -= mons1;
        ans += mons1;
        int mons2 = min(A[i], B[i]);
        A[i] -= mons2;
        B[i] -= mons2;
        ans += mons2;
    }

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

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

using namespace std;

int a, b, ans;

int main() {
	cin >> a >> b;
	if(b <= 1) {puts("0"); return 0;}
	if(b <= a) puts("1");
	else {
		int k = b - a;
		if(k % (a - 1) == 0) {
			ans += k / (a - 1);
		}
		else ans += k / (a - 1) + 1;
		ans += 1;
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 256
def insertionSort(A,N):
    for i in range(0,N):
        v = A[i]
        j = i -1
        while j>=0 and A[j] > v :
            A[j+1] = A[j]
            j-=1
        A[j+1] = v
        print(*A, sep=" ")

N = int(input())
A = list(map(int,input().split()))
insertionSort(A,N)


Measured memory_bytes: 5984
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include <random>
#define ll long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string a[10];
    rep(i,3){
        cin>>a[i];
        cout<<(char)(a[i][0]-'a'+'A');
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){ 
  ll N,K; cin >> N >> K; ll sum = 0;
  vector<ll> A(N); for(ll i = 0; i < N; i++){ cin >> A[i]; sum += A[i];}
  
  //考えられるのは、sumの約数しかありえない
  
  set<ll> s;
  ll ans = 1LL; //ans　は　答えとなりうるsの要素に過ぎない
  for(ll i = 1; i*i <= sum; i++){
    if( sum % i == 0){ s.insert(i); s.insert(sum/i);}
  }
  //sにsum の約数列挙
  
  for(auto ne : s){
    ll cnt = 1LL << 60;
    //caliculate cnt in this part
    vector<ll> r(N);
      for(ll i = 0; i < N; i++){ r[i] = A[i]%ne;}
    sort(r.begin(),r.end());
    ll rsum = 0;
    for(ll i = 0; i < N; i++){ rsum += ne-r[i];}
    ll lsum = 0;
    for(ll j = 0; j < N; j++){
      lsum += r[j]; rsum -= ne - r[j]; 
     
      
     cnt = min(max(lsum,rsum), cnt); }
      
    
    if(cnt <= K){ ans = max(ans, ne);}
  }
  
  cout << ans << endl; return 0;}
    
  

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

using namespace std;

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

  string t = "";
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != 'x') {
      t += s[i];
    }
  }

  int n = t.size();
  bool ok = true;
  for (int i = 0; i < n / 2; i++) {
    if (t[i] != t[n - i - 1]) ok = false;
  }

  if (ok) {
    int l = 0, r = (int)s.size() - 1, ans = 0;
    while (l < r) {
      if (s[l] == 'x') {
        if (s[r] != 'x')
          l++, ans++;
        else
          l++, r--;
      } else {
        if (s[r] == 'x')
          r--, ans++;
        else
          l++, r--;
      }
    }
    cout << ans << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 640
s=input().rstrip().split()
h=int(s[0])
w=int(s[1])
res =0
if h == 1 or w == 1:
  res = 1
elif h%2==0:
    res = (h/2) * w
else:
    if w%2==0:
        res = int(h/2) * w +  w/2  
    else:
        res = int(h/2) * w + int(w/2) + 1
print(int(res))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define LL long long int
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
 
    // LL N;
    LL S;
    cin>> S;
    vector<LL> dp(S+1,0);
    dp[0]=1;
    dp[1]=0;
    dp[2]=0;
    for(LL i=3;i<=S;i++)
    {
        for(LL j=3;j<=i;j++)
        {
            dp[i]=(dp[i]+dp[i-j])%mod;
        }
    }
    cout<<dp[S]<<endl;
    // cin >> N;
    // LL prod=1;
    // for(LL i=1;i<=N-2;i++)
    // {
    //     prod= (prod *10)%mod;
    // }
    // cout<<(prod*(N)*(N-1))%mod<<" ";
    // cout<< (((prod*(N))%mod)*(N-1)) %mod;
}

Measured memory_bytes: 3660
<?php
fscanf(STDIN, "%d", $n);
for ($i = 0; $i < $n; $i++) {
	fscanf(STDIN, "%d %d %d", $x[], $y[], $h[]);
	if (!isset($b) && $h[$i] > 0) {
		$b = [$x[$i], $y[$i], $h[$i]];
	}
}
for ($px = 0; $px <= 100; $px++) {
	for ($py = 0; $py <= 100; $py++) {
		$ph = $b[2] + abs($px - $b[0]) + abs($py - $b[1]);
		$f = 0;
		for ($i = 0; $i < $n; $i++) {
			$hh = $h[$i] + abs($px - $x[$i]) + abs($py - $y[$i]);
			if ($h[$i] && $ph != $hh || !$h[$i] && $ph > $hh) {
				$f = 1;
				break;
			}
		}
		if (!$f) exit("$px $py $ph");
	}
}

Measured memory_bytes: 4728
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
typedef pair<ll, ll> LP;
 
ll POW(ll m,ll n)
{
  if(n<0) return 0;
  if(n==0) return 1;
  return m*POW(m,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll CON(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return m*CON(m-1,n)/(m-n);
}
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
 
int main()
{
  ll h,w,a[600][600],b[600][600],n;
  cin >> h >> w;
  n=0;
  rep(i,h){
    rep(j,w){
      cin >> a[i][j];
    }
  }
  rep(i,h){
    rep(j,w){
      b[i][j]=a[i][j];
    }
  }
  rep(i,h){
    rep(j,w-1){
      if(a[i][j]%2==1){a[i][j+1]++;
                       n++;
                      }
    }
  }
  rep(i,h-1){if(a[i][w-1]%2==1){a[i+1][w-1]++;
                             n++;
                             }
            }
  printf("%lld\n",n);
  rep(i,h){
    rep(j,w-1){
      if(b[i][j]%2==1){b[i][j+1]++;
                       printf("%lld ",i+1);
                       printf("%lld ",j+1);
                       printf("%lld ",i+1);
                       printf("%lld\n",j+2);
                      }
    }
  }
  rep(i,h-1){if(b[i][w-1]%2==1){b[i+1][w-1]++;
                              printf("%lld ",i+1);
                              printf("%lld ",w);
                              printf("%lld ",i+2);
                              printf("%lld\n",w);
                             }
            }
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
#define mp make_pair
using namespace std;
int n, m, u, v, ind[200020], dist[200020], ans = 0;
set<pair<int,int>> ord;
vector<int> g[200020];
int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) cin >> u >> v, g[u].push_back(v), ind[v]++;
	for (int i = 1; i <= n; i++) ord.insert(mp(ind[i],i));
	while (ord.size()>0) {
		auto cur = *ord.begin();
		ord.erase(*ord.begin());
		for (auto xx: g[cur.second]) {
			int cf = ind[xx];
			ord.erase(mp(cf, xx));
			ord.insert(mp(cf-1, xx));
			ind[xx]--;
			dist[xx] = max(dist[xx],dist[cur.second] + 1);
		}
	}
	for (int i = 1; i <= n; i++) ans = max(ans, dist[i]);
	cout << ans ;
}

Measured memory_bytes: 14208
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    map<char, int> M = {{'M', 0}, {'A', 1}, {'R', 2}, {'C', 3}, {'H', 4}};
    ll cnt[5] = {};
    REP(i, N) {
        string S;
        cin >> S;
        if (S[0] == 'M' || S[0] == 'A' || S[0] == 'R' || S[0] == 'C' || S[0] == 'H') {
            cnt[M[S[0]]]++;
        }
    }
    ll res = 0;
    REP(i, 3) {
        FOR(j, i + 1, 5, 1) {
            FOR(k, j + 1, 5, 1) {
                res += cnt[i] * cnt[j] * cnt[k];
            }
        }
    }
    cout << res << endl;
    return 0;
}


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

#define l_ength size

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

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

int d[2][100100],u[100100],v[100100];

vector<int> g[100100];
queue<int> q;

int main(void){
	int n,a[2],i,k,s,t,ans=-INF;
	cin >> n >> a[0] >> a[1]; --a[0]; --a[1];
	fill(d[0],d[2],INF);
	for(i=1; i<n; ++i){
		cin >> u[i] >> v[i];
		--u[i]; --v[i];
		g[u[i]].push_back(v[i]);
		g[v[i]].push_back(u[i]);
	}
	for(k=0; k<2; ++k){
		q.push(a[k]);
		d[k][a[k]] = 0;
		while(!q.empty()){
			s = q.front();
			q.pop();
			for(i=(g[s].l_ength()-1); i>=0; --i){
				t = g[s][i];
				if(d[k][t] > d[k][s] + 1){
					d[k][t] = d[k][s] + 1;
					q.push(t);
				}
			}
		}
	}
	for(i=1; i<n; ++i){
		if(d[0][u[i]] > d[1][u[i]] && d[0][v[i]] > d[1][v[i]]){
			continue;
		}
		ans = max(ans,min(d[1][u[i]],d[1][v[i]]));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7424
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;

void debug(vec &v) {
	int n = v.size();
	rep(i, n) {
		if (i > 0)cout << " ";
		cout << v[i];
	}
	cout << endl;
}

ll mod_pow(ll x, ll n) {
	ll ret = 1;
	while (n > 0) {
		if (n % 2)ret = ret * x%mod;
		x = x * x%mod; n >>= 1;
	}
	return ret;
}
struct perm {
private:
	int sz;
	vector<ll> p, invp;
public:
	perm(int n) {
		sz = n + 1;
		p.resize(sz), invp.resize(sz);
		p[0] = 1;
		rep1(i, sz - 1) {
			p[i] = p[i - 1] * i%mod;
		}
		invp[sz - 1] = 1;
		ll cop = mod - 2, x = p[sz - 1];
		while (cop) {
			if (cop % 2)invp[sz - 1] = invp[sz - 1] * x%mod;
			cop >>= 1; x = x * x % mod;
		}
		per(i, sz - 1) {
			invp[i] = invp[i + 1] * (i + 1) % mod;
		}
	}
	ll comb(ll x, ll y) {
		if (x < y || y < 0)return 0;
		ll ret = p[x];
		(ret *= invp[y]) %= mod;
		(ret *= invp[x - y]) %= mod;
		return ret;
	}
	ll combP(ll x, ll y) {
		if (x < y || y < 0)return 0;
		return p[x] * invp[x - y] % mod;
	}
};
perm pm(1 << 22);

ll dp[2001];
ll rdp[2002];
ll nex[2001];

void solve() {
	int n, k; cin >> n >> k;
	if (k == 1) {
		cout << 1 << endl; return;
	}
	dp[1] = 1;
	for (int i = 2; i < 2002; i++)rdp[i] = 1;
	rep1(i, n - 1) {
		for (int j = 1; j <= i + 1; j++) {
			int num = i * k - (j - 1);
			nex[j] = (rdp[i + 1] - rdp[j - 1])*pm.comb(num + k - 2, num);
			nex[j] = (nex[j] % mod + mod) % mod;
		}
		for (int j = 1; j <= i + 1; j++) {
			dp[j] = nex[j];
			rdp[j + 1] = (rdp[j] + dp[j]) % mod;
		}
	}
	ll ans = rdp[n + 1];
	rep1(i, n)ans = ans * i%mod;
	cout << ans << endl;
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(12);
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	//stop
	return 0;
}


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

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

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

Measured memory_bytes: 256
n,m=gets.split.map(&:to_i)
all=[]
check_first=[]
check_last=[]

m.times.each do
v=gets.split.map(&:to_i)
if v[0]==1
    check_first<<v[1]
elsif v[1]==n
    check_last<<v[0]
end
    

end
#p check_last
#p check_first
if (check_first & check_last)[0]!=nil
   # p check_first & check_last
    puts "POSSIBLE"
else
puts "IMPOSSIBLE"
end

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

int mod = 1'000'000'007;

bool check(string tmp){
    if (tmp[1] == 'A' && tmp[2] == 'G' && tmp[3] == 'C') return false;
    if (tmp[1] == 'G' && tmp[2] == 'A' && tmp[3] == 'C') return false;
    if (tmp[1] == 'A' && tmp[2] == 'C' && tmp[3] == 'G') return false;
    if (tmp[0] == 'A' && tmp[2] == 'G' && tmp[3] == 'C') return false;
    if (tmp[0] == 'A' && tmp[1] == 'G' && tmp[3] == 'C') return false;
    return true;
}

int main(){
    vector<char> s = {'T', 'A', 'G', 'C'};
    vector<string> t;
    map<string, int> mp;
    for (int i = 0; i < 4; i++){
        for (int j = 0; j < 4; j++){
            for (int k = 0; k < 4; k++){
                string p = "";
                p += s[i]; p += s[j]; p += s[k];
                mp[p] = t.size();
                t.push_back(p);
            }
        }
    }
    int n;
    cin >> n;
    vector<vector<long long>> dp(n + 1, vector<long long>(64, 0));
    dp[0][0] = 1;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < 64; j++){
            for (int k = 0; k < 4; k++){
                string tmp = t[j];
                tmp += s[k];
                string id = "";
                id += tmp[1]; id += tmp[2]; id += tmp[3];
                if (check(tmp)) {
                    dp[i + 1][mp[id]] += dp[i][j];
                    dp[i + 1][mp[id]] %= mod;
                }
            }
        }
    }
    long long ans = 0;
    for (int i = 0; i < 64; i++) ans += dp[n][i], ans %= mod;
    cout << ans << endl;
}

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

using namespace std;

int sdy[]={-1,0,0,1,0};
int sdx[]={0,-1,1,0,0};
int mdy[]={0,0,0,-1,-1,-1,1,1,1};
int mdx[]={-1,0,1,-1,0,1,-1,0,1};
int ldy[]={0,0,0,-1,-1,-1,1,1,1,2,0,0,-2};
int ldx[]={-1,0,1,-1,0,1,-1,0,1,0,-2,2,0};


int main(){

	int field[10][10];
	memset(field,0,sizeof(field));

	int x,y,size;
	char cm;
	while(cin>>x>>cm>>y>>cm>>size){
		//field[y][x]++;
		if(size==1){
			for(int i = 0; i < 5; i++){
				int py=y+sdy[i];
				int px=x+sdx[i];
				if(py>=0&&px>=0&&py<10&&px<10){
					field[py][px]++;
				}
			}
		}
		else if(size==2){
			for(int i = 0; i < 9; i++){
				int py=y+mdy[i];
				int px=x+mdx[i];
				if(py>=0&&px>=0&&py<10&&px<10){
					field[py][px]++;
				}
			}
		}
		else{
			for(int i = 0; i < 13; i++){
				int py=y+ldy[i];
				int px=x+ldx[i];
				if(py>=0&&px>=0&&py<10&&px<10){
					field[py][px]++;
				}
			}
		}
	}

	int maxConcentration=0;
	int cnt=0;
	for(int i = 0; i < 10; i++){
		for(int j = 0; j < 10; j++){
			if(field[i][j]==0)
				cnt++;
			maxConcentration=max(maxConcentration,field[i][j]);
		}
	}
	cout<<cnt<<endl;
	cout<<maxConcentration<<endl;

	return 0;
}

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

int main()
{
  string str;
  cin >> str;
  for(int i=0;i<3;i++){
    if(str[i] == '7'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <iostream>

using namespace std;

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

	for (int i = 0; i < s.length(); i++)
	{
		if (s.find(p) != string::npos) {
			cout << "Yes" << endl;
			return 0;
		}
		s = s.substr(1) + s[0];
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3224
def readinput():
    n=int(input())
    shogensList=[]
    for i in range(n):
        a=int(input())
        shogens=[]
        for _ in range(a):
            shogen=list(map(int,input().split()))
            shogens.append(shogen)
        shogensList.append(shogens)
    return n, shogensList

def isMujun(shogensList, shojikiList):
    for shojiki in shojikiList:
        shogens=shogensList[shojiki]
        #print('shogens: {}'.format(shogens))
        #print('shojikiList: {}'.format(shojikiList))
        for x,y in shogens:
            if(y==1):
                if not (x-1 in shojikiList):
                    return True
            else:
                if x-1 in shojikiList:
                    return True
    return False

def main(n,shogensList):
    maxShojiki=0
    for x in range(2**n):
        shojikiList=[]
        b=1
        for i in range(n):
            if (x&b==b):
                shojikiList.append(i)
            b=b*2
        #print('shojikiList: {}'.format(shojikiList))
        #print(isMujun(shogensList, shojikiList))
        if not isMujun(shogensList, shojikiList):
            maxShojiki=max(maxShojiki, len(shojikiList))
    return maxShojiki

if __name__=='__main__':
    n,shogensList=readinput()
    ans=main(n,shogensList)
    print(ans)
 

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

int main(){
  long long x;
  cin>>x;
  long long money=100;
  int age=0;
  while(1){
    if(money>=x) break;
    else{
      age++;
      money*=1.01;
    }
  }
  cout<<age<<endl;
}

Measured memory_bytes: 3636
// Problem : D - Friends
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

// $%U%$
// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll x,ll y,ll m){if(y==0)return 1;ll p=power(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll nCr(ll n,ll r,ll m){if(r>n)return 0;ll a=1,b=1,i;for(i=0;i<r;i++){a=(a*n)%m;--n;}while(r){b=(b*r)%m;--r;}return (a*power(b,m-2,m))%m;}
#define Test int t;cin>>t;while(t--)
#define endl '\n'
void solve()
{
	int n,m;
	cin >> n >> m;
	int ans=0;
	set<pair<int,int>> s,s2;
	vector<vector<int>> adj(n);
	for(int i=0;i<m;++i)
	{
		int x,y;
		cin >> x >> y;
		--x;
		--y;
		if(s.find({x,y})!=s.end())
		continue;
		adj[x].push_back(y);
		adj[y].push_back(x);
		s.insert({x,y});
		s.insert({y,x});
	}
	vector<int> vis(n);
	for(int i=0;i<n;++i)
	{
		if(vis[i]) continue;
		queue<int> q;
		set<int> te;
		te.insert(i);
		q.push(i);
		
		vis[i]=1;
		while(!q.empty())
		{
			int t=q.front();q.pop();
			for(int u:adj[t])
			{
				te.insert(u);
				if(!vis[u])
				q.push(u);
				vis[u]=1;
			}
		}
		ans=max(ans,(int)te.size());
	}
	cout << ans << endl;
	
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//Test
	solve();
	return 0;
}


Measured memory_bytes: 42972