akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);//スキャナー作る
		StringBuilder all = new StringBuilder();//合計用？変数
		StringBuilder out = new StringBuilder();//表示用変数
		
		while(true){//----------------------------------------------------------------------+
			int h = sc.nextInt();//縦取り込み
			int w = sc.nextInt();//横取り込み
			if((h + w) <= 0){break;}//入力が 0 0 なら 繰り返し終了 
				for(int j = 0; j < h; j++){//縦の計算-----------------------------------++
					for(int i = 0; i < w; i++){//横の計算//-----------------------+++
						out = out.append("#");//out に横の数ぶん＃格納
					}//-----------------------------------------------------------+++
					out = out.append("\n");//outに縦の数ぶん#格納
				}//---------------------------------------------------------------------++
			all = all.append(out + "\n");//格納した文字列と改行文字をallに格納
			out.delete(0, out.length());//outを初期化
		}//---------------------------------------------------------------------------------+
		System.out.print(all);//0 0が入力されループ抜けたのでallに格納された全てを表示
	}
}

Measured memory_bytes: 23672
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <numeric>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;



int main() {
    int n;
    cin >> n;
    vector<int> v;
    for (int i = 1; i <= 15000; ++i){
        for (int j = 2; j <= 5; ++j) {
            if(i*j <= 30000) v.emplace_back(i*j);
        }
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    int s = 0;
    for (int i = 0; i < n-2; ++i) {
        if(i) printf(" ");
        printf("%d", v[i]);
        s += v[i];
    }
    for (int i = n-2; i < v.size(); ++i) {
        for (int j = i+1; j < v.size(); ++j) {
            if((s + v[i]+v[j])%30 == 0) {
                printf(" %d %d\n", v[i], v[j]);
                i = j = v.size();
            }
        }
    }
    return 0;
}


Measured memory_bytes: 640
A, B = map(int, input().split())
s = 0
if A > B:
    s = A + A - 1
elif B > A:
    s = B + B - 1
else:
    s = A + A
print(s)

# s = 0
# for _ in range(2):
#     if A >= B:
#         s += A
#         A -= 1
#     else:
#         s += B
#         B -= 1



Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<iomanip>
#include<functional>
#include<cctype>
#include<map>
using namespace std;
typedef long long llong;
int main() {
	int N, A, B,cnt=0,fcnt=0;
	string s;
	cin >> N >> A >> B;
	cin >> s;
	for (int i = 0; i < N; i++) {
		if (s[i] == 'c')cout << "No" << endl;
		else if (s[i] == 'a'&&cnt < A + B) {
			cout << "Yes" << endl;
			cnt++;
		}
		else if (s[i] == 'b'&&cnt < A + B&&fcnt < B) {
			cout << "Yes" << endl;
			cnt++;
			fcnt++;
		}
		else cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 896
import math
def main():
    n = int(input())
    A = list(map(int, input().split()))
    g = A[0]
    gcdl, gcdr = [0, ], [0, ]
    for i in range(1, n):
        gcdl.append(g := math.gcd(g, A[i - 1]))
    g = A[-1]
    for i in range(n - 2, -1, -1):
        gcdr.append(g := math.gcd(g, A[i + 1]))
    gcdr = gcdr[::-1]
    ans = [math.gcd(l, r) for l, r in zip(gcdl, gcdr)] + [math.gcd(gcdl[-1], A[-1]), ]
    print(max(ans))

if __name__ == '__main__':
    main()

Measured memory_bytes: 25516
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        HashSet<String> set = new HashSet<String>();
	for(int i = 0; i<N; i++)	{
            set.add(sc.next());
	}
        System.out.println((set.size()==3)?"Three":"Four");
    }
}

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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  for (uint i = 0; i < s.size();) {
    if (s.substr(i, 7) == "remaerd") {
      i += 7;
    } else if (s.substr(i, 5) == "maerd") {
      i += 5;
    } else if (s.substr(i, 6) == "resare") {
      i += 6;
    } else if (s.substr(i, 5) == "esare") {
      i += 5;
    } else {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 512
A,B,C,D = map(int, input())

pattern1 = A + B + C + D
pattern2 = A + B + C - D
pattern3 = A + B - C + D
pattern4 = A + B - C - D
pattern5 = A - B - C + D
pattern6 = A - B - C - D
pattern7 = A - B + C + D
pattern8 = A - B + C - D

if pattern1 == 7:
    print(str(A)+'+'+str(B)+'+'+str(C)+'+'+str(D)+'='+str(pattern1))
    exit()

if pattern2 == 7:
    print(str(A)+'+'+str(B)+'+'+str(C)+'-'+str(D)+'='+str(pattern2))
    exit()

if pattern3 == 7:
    print(str(A)+'+'+str(B)+'-'+str(C)+'+'+str(D)+'='+str(pattern3))
    exit()

if pattern4 == 7:
    print(str(A)+'+'+str(B)+'-'+str(C)+'-'+str(D)+'='+str(pattern4))
    exit()

if pattern5 == 7:
    print(str(A)+'-'+str(B)+'-'+str(C)+'+'+str(D)+'='+str(pattern5))
    exit()

if pattern6 == 7:
    print(str(A)+'-'+str(B)+'-'+str(C)+'-'+str(D)+'='+str(pattern6))
    exit()

if pattern7 == 7:
    print(str(A)+'-'+str(B)+'+'+str(C)+'+'+str(D)+'='+str(pattern7))
    exit()

if pattern8 == 7:
    print(str(A)+'-'+str(B)+'+'+str(C)+'-'+str(D)+'='+str(pattern8))
    exit()

Measured memory_bytes: 3064
arr = gets.chomp.chars
K = gets.chomp.to_i
N = arr.size
count = K

class String
    # a..z → 0..25
    def assign_integer
        ord - 'a'.ord
    end

    # 引数分だけアルファベットを進める
    def change_char(num)
        ((assign_integer + num) % 26).assign_alphabet
    end
end

class Integer
    # 0..25 → a..z
    def assign_alphabet
        (self + 'a'.ord).chr
    end
end

(0..K - 1).each do |i|
    if count == 0
        break
    elsif i == N - 1
        arr[i] = arr[i].change_char(count)
        break
    elsif arr[i] == 'a'
        next
    elsif arr[i].assign_integer + count > 25
        int = arr[i].assign_integer
        arr[i] = arr[i].change_char(26 - int)
        count = count - 26 + int
    end
end

puts arr.join('')


Measured memory_bytes: 15356
import java.util.Scanner;

class Main{
	static public void main (String args[]){
		Scanner scan = new Scanner(System.in);
		scan.useDelimiter("\\s");
		int val1 = 0;
		int val2 = 0;
		int area = 0;
		int around = 0;
		
		val1 = scan.nextInt();
		val2 = scan.nextInt();

		area = val1*val2;
		around = (val1 + val2)*2;
		System.out.println(area+" "+around);
	}
}

Measured memory_bytes: 26176
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0]*n

INF = 10**18

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                w = cmt + ': ' + str(x)
            else:
                w = str(x)
            print(w)
        return x


def prob():
    d = Debug()
    d.off()
    S = input()
    if len(S) == 2:
        return S
    else:
        return S[-1]+S[-2]+S[-3]
    

ans = prob()
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

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

  if(N == M)
    cout << "Yes\n";
  else
    cout << "No\n";
  
  return 0;
}


Measured memory_bytes: 3644
function cube(x) {
  return x * x * x;
}

var input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  console.log(cube(input[0]));
});

Measured memory_bytes: 15736
import math

n, m = map(int, input().split())
mod = 10 ** 9 + 7

if abs(n-m) > 1:
    print(0)
else:
    ans = 1

    for i in range(1, n+1):
        ans = ans * i % mod
    for j in range(1, m+1):
        ans = ans * j % mod

    if abs(n-m) == 0:
        print(2 * ans % mod)
    else:
        print(ans % mod)

Measured memory_bytes: 3060
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector>
 
#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<limits>
#include<tuple>
#include<utility>
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define rep1(i,n)  for(ll i=1; i<=n; i++)
#define rrep1(i,n) for(ll i=n; 1<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define INF 1e18
using ll = long long;
using namespace std;

int main(){
  int t,x;  cin >> t >> x;
  cout << setprecision(6) << (double)t/x;
}

Measured memory_bytes: 256
;;; Utils

(defmacro read-numbers-to-list ()
  `(read-from-string
    (concatenate 'string "(" (read-line) ")")))


(defmacro read-line-to-array (dimension)
  (if (< dimension 0)
      (error "invalid arguments for dimension.")
      `(make-array ,dimension :initial-contents (read-numbers-to-list))))

(defmacro read-line-to--char-list ()
  `(concatenate 'list (read-line)))

(defmethod make-cumlative-sum ((sequence list))
  (labels ((inner (sequence &optional (acc '(0)))
             (if (null sequence)
                 (reverse acc)
                 (inner (rest sequence) (cons (+ (first sequence)
                                                 (first acc))
                                              acc)))))
    (inner sequence)))





(defmethod princ-for-each-line ((sequence list))
  (labels ((inner (sequence)
             (if (null sequence)
                 nil
                 (progn
                   (fresh-line)
                   (princ (first sequence))
                   (inner (rest sequence))))))
    (inner sequence)))

(defmethod princ-for-each-line ((sequence array))
  (dotimes (i (length sequence))
    (fresh-line)
    (princ (aref sequence i))))



;;; Write code here

(defparameter *mod* (+ (expt 10 9) 7))

(defun calc-squared-sum (xs)
  (reduce #'+
          (mapcar (lambda (x)
                    (* x x))
                  xs)))

(defun sum (xs)
  (reduce #'+ xs))

(defun solve (n xs)
  (mod (floor (- (* (sum xs)
                    (sum xs))
                 (calc-squared-sum xs))
              2)
       *mod*))

(defun main ()
  (let ((n (read))
        (xs (read-numbers-to-list)))
    (format t "~a~%" (solve n xs))))

(main)


Measured memory_bytes: 69844
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int MAX=200005;
const int mod=1e9+7;
//ll a[MAX],x[MAX],b[MAX];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m,sum=0;
    cin>>n>>m;
    sum=n*(n-1)/2+m*(m-1)/2;
    cout<<sum;

}


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

static const int MOD = 1000000007;

int N;
int H[2][100002];
int mm[100002];
int mx[100002];

int solve() {
	if (H[0][N - 1] != H[1][0]) {
		return 0;
	}
	mm[0] = H[0][0];
	mx[0] = H[0][0];
	for (int i = 1; i < N; ++i) {
		mm[i] = 1;
		mx[i] = min(H[0][i], H[1][i]);
		if (H[0][i] < H[0][i - 1]) {
			return 0;
		}
		if (H[0][i] > H[0][i - 1]) {
			mm[i] = max(mm[i], H[0][i]);
			mx[i] = min(mx[i], H[0][i]);
		}
	}
	mm[N - 1] = H[1][N - 1];
	mx[N - 1] = H[1][N - 1];
	for (int i = 0; i < N - 1; ++i) {
		if (H[1][i] < H[1][i + 1]) {
			return 0;
		}
		if (H[1][i] > H[1][i + 1]) {
			mm[i] = max(mm[i], H[1][i]);
			mx[i] = min(mx[i], H[1][i]);
		}
	}
	int ans = 1;
	for (int i = 1; i < N; ++i) {
		long long d = max(0, mx[i] - mm[i] + 1);
		ans = (int)((ans * d) % MOD);
	}
	return ans;
}

int main(int argc, char *argv[])
{
	cin >> N;
	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < N; ++j) {
			cin >> H[i][j];
		}
	}
	cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>

#define P 1000000007

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<long long> a, l, r;
	a.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			l.push_back(a[i]);
		}
		else {
			r.push_back(a[i]);
		}
	}
	if (n % 2 == 0) {
		cout << r[r.size() - 1];
		for (int i = r.size() - 2; i >= 0; i--) {
			cout << " " << r[i];
		}
		for (int i = 0; i < l.size(); i++) {
			cout << " " << l[i];
		}
	}
	else {
		cout << l[l.size() - 1];
		for (int i = l.size() - 2; i >= 0; i--) {
			cout << " " << l[i];
		}
		for (int i = 0; i < r.size(); i++) {
			cout << " " << r[i];
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x7f
#define MAX_INF_VAL 0x7f7f7f7f
#define pi 3.141592653589
#define eps 1e-10
//#define p 2173412051LL
//#define sz 2

using namespace std;

int main() {
	int s, w;
	scanf( "%d%d", &s, &w );
	if( w >= s )
		printf( "unsafe" );
	else
		printf( "safe" );
	return 0;
}

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

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

using namespace std;
using lint=long long;

const long long INF=1LL<<61;

int main(){
	int n; scanf("%d",&n);
	vector<lint> a(n);
	rep(i,n) scanf("%lld",&a[i]);

	vector<lint> sum1(n+1);
	{
		auto tmp=a;

		vector<int> right(n);
		rep(i,n) right[i]=i;

		for(int i=n-2;i>=0;i--){
			sum1[i]=sum1[i+1];
			int pos=i;
			while(pos<n-1 && a[pos]>a[pos+1]){
				int r=right[pos+1];
				while(a[pos]>a[pos+1]){
					sum1[i]+=2*(r-pos);
					a[pos+1]*=4;
					if(pos+1<r) a[r]*=4;
				}
				pos=r;
			}
			right[i]=pos;
		}

		a=tmp;
	}

	vector<lint> sum2(n+1);
	{
		auto tmp=a;

		vector<int> left(n);
		rep(i,n) left[i]=i;

		for(int i=2;i<=n;i++){
			sum2[i]=sum2[i-1];

			int pos=i-1;
			while(pos>=1 && a[pos-1]<a[pos]){
				int l=left[pos-1];
				while(a[pos-1]<a[pos]){
					sum2[i]+=2*(pos-l);
					a[pos-1]*=4;
					if(l<pos-1) a[l]*=4;
				}
				pos=l;
			}
			left[i-1]=pos;
		}

		a=tmp;
	}

	lint ans=INF;
	rep(i,n+1) ans=min(ans,sum1[i]+sum2[i]+i);
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 7252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}


pair<int, int> E[200001];
int H[200001];
int kotae[100001];
int Vis[100001];
void sagasu(int P, int D, int C) {
	if (D == 0 && kotae[P] == 0) kotae[P] = C;
	else if (Vis[P] < D) {
		Vis[P] = D;
		if (kotae[P] == 0) kotae[P] = C;
		for (int p = H[P]; p; p = E[p].second) {
			sagasu(E[p].first, D - 1, C);
		}
	}
}

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


	int N, M, Q;
	N = getint();
	M = getint();
	for (int i = 1; i < 2 * M; i += 2) {
		int a = getint(), b = getint();
		E[i] = mp(a, H[b]);
		H[b] = i;
		E[i + 1] = mp(b, H[a]);
		H[a] = i + 1;
	}
	Q = getint();
	int v[100000], d[100000], c[100000];
	rep(i, Q) {
		v[i] = getint();
		d[i] = getint();
		c[i] = getint();
	}
	for (int i = Q - 1; i >= 0; i--) {
		sagasu(v[i], d[i], c[i]);
	}
	rep1(i, N) {
		putint(kotae[i]);
	}

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

Measured memory_bytes: 5632
import fractions

N = int(input())
A = list(input().split())
monster = list(sorted([int(A[i]) for i in range(N)]))
ans = float('inf')
MIN = monster[0]

for i in range(N):
    tmp = monster[i]
    ans = min(ans, int(fractions.gcd(tmp, MIN)))

print(ans)

Measured memory_bytes: 17816
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++){
			array[i] = sc.nextInt();
		}
		
		for (int i = 0; i < n / 2; i++){
			int temp = array[i];
			array[i] = array[n - i - 1];
			array[n - i - 1] = temp;
		}
		
//		for (int i = 0; i < n; i++){
//			System.out.print(!(i == n - 1)? array[i] + " " : array[i]);
//		}
		for (int i = 0; i < n - 1; i++){
			System.out.print(array[i] + " ");
		}
		System.out.println(array[n - 1]);
	}
}

Measured memory_bytes: 19028
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
//#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void println(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int a, b; cin >> a >> b;
    if(a == b) {
        cout << "Draw" << endl;
    } else if(a == 1) {
        cout << "Alice" << endl;
    } else if(b == 1) {
        cout << "Bob" << endl;
    } else {
        if(a > b) { 
            cout << "Alice" << endl;
        } else {
            cout << "Bob" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
#define ll long long int
#define itn int 

#define M 100000000000000001
using namespace std;
int main()
{
   ll n,k;cin>>n>>k;ll arr[100003]={0};
   ll dp[400002];
   for(ll i=0;i<n;i++)
   {
       dp[i]=M;
   }
   for(ll i=0;i<n;i++)
   {
       cin>>arr[i];
   }

for(ll i=1;i<=k;i++)
{
    dp[i]=abs(arr[i]-arr[0]);
}
for(ll i=k+1;i<n;i++)
{
    
    for(ll j=i-1;j>=i-k&&j>=0;j--)
    {
        dp[i]=min(dp[i],abs(arr[i]-arr[j])+dp[j]);
    }
    
}
cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;
import java.util.Arrays;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        int j = 0;
        for(int i = 2;i <= 55555;i++){
            if(i % 5 == 1 && isPrime(i)){
                a[j++] = i;
            }
            if(j == N){
                break;
            }
        }
        for(int i = 0;i < N;i++){
            System.out.print(a[i]);
            if(i == N-1){
                break;
            }
            System.out.print(" ");
        }
        System.out.println();
    }
    public static boolean isPrime(int x){
        if(x == 1){
            return false;
        }
        for(int i = 2;i < x;i++){
            if(x % i == 0){
                return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 21588
#include <iostream>
int main(){
int a,b;
std::cin >>a >>b;
//std::cout <<a <<b;
if(1<=a&&a<=9&&1<=b&&b<=9)
{
	printf("%d\n",a*b);
}

else /*if(a<1||9<a||b<1||9<b)*/{
	printf("-1");
}
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>

#define PI (3.1415926535898)

int main(void) {

	int n;
	int s[1000];
	double total;
	for(;;) {
		total = 0;
		scanf("%d", &n);
		if (n == 0) {
			break;
		}

		double m = 0;
		for (int i = 0; i < n; i++) {
			scanf("%d", &s[i]);
			m = m + s[i];
		}
		double ave = m / n;

		for (int i = 0; i < n; i++) {
			double tmp =  (s[i] - ave) * (s[i] - ave);
			total += tmp;
		}

		double hensa = sqrt(total / (double)n);
		printf("%lf\n", hensa);

	}

}

Measured memory_bytes: 2760
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll ans[6010]={0};
    int x,y,z,n,fir,i,j,k;
    ll a[1010],b[1010],c[1010];

    scanf("%d%d%d%d",&x,&y,&z,&n);
    for(i=0;i<x;i++)
        scanf("%lld",&a[i]);
    for(i=0;i<y;i++)
        scanf("%lld",&b[i]);
    for(i=0;i<z;i++)
        scanf("%lld",&c[i]);
    sort(a,a+x);
    sort(b,b+y);
    sort(c,c+z);
    fir=0;
    for(i=x-1;i>=0;i--)
    {
        if(x-i-1>=n)
            break;
        for(j=y-1;j>=0;j--)
        {
            if(y-j-1>=n) break;

            for(k=z-1;k>=0;k--)
            {
                if(z-k-1>=n) break;
                ans[fir]=a[i]+b[j]+c[k];
                if(ans[fir]<=ans[n])
                    break;
                else fir++;
                if(fir==n)
                    {sort(ans,ans+2*n);
                    fir=0;
                    }
            }

        }
    }
    sort(ans,ans+2*n);
    for(i=2*n-1;i>=n;i--)
        printf("%lld\n",ans[i]);
    return 0;
}


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

using namespace std;
int main(int argc, const char * argv[]) {
    int H,W;
    int i,j;
    while (true) {
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        else{
            for (j=0; j<H; j++) {
                if (j==0||j==H-1) {
                    for (i=0; i<W; i++){
                        cout << '#';
                    }
                    cout << endl;
                }else {
                    for (i=0; i<W; i++){
                        if(i==0 ||i==W-1)
                            cout << '#';
                        else cout << '.';
                    }
                    cout << endl;
                }
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n,m,k;
    IN(n,m,k);
    bool f = false;
    rep(l,n+1){
        rep(c,m+1){
            if(c*(n-l)+l*(m-c) == k) f = true;
        }
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

ll n, m;
vector<ll> x;

void solve() {
    sort(x.begin(), x.end());
    ll diff[m - 1];
    rep(i, m - 1) diff[i] = abs(x[i + 1] - x[i]);
    sort(diff, diff + m - 1, greater<>());
    ll ans = 0;
    for (int j = n-1; j < m - 1; ++j) {
        ans += diff[j];
    }
    cout << ans << endl;
}

int main() {
    cin >> n >> m;
    x.resize(m);
    rep(i, m) cin >> x[i];
    solve();
    return 0;
}

Measured memory_bytes: 1792
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
	}
	
	mod& operator=(const ll & tx) {
		x = tx;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return (x + m2.x) % MOD;
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return (x - m2.x + MOD) % MOD;
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return (x * m2.x) % MOD;
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return mod(((*this).x * (*this).inv().x) % MOD);
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}

/* TEMPLATE ENDS HERE */

int main() {
	int n;
	cin >> n;
	if (n & 1) {
		printf("%Lf\n", (ld)((n + 1) / 2) / (ld) n);
	} else {
		cout << "0.5" << endl;
	}
	return 0;
}


Measured memory_bytes: 3728
import java.util.Scanner; 
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x = 1;
		int N = scan.nextInt();
		int K = scan.nextInt();
		for(int i = 0; i < N; i++) {
			if(x * 2 < x + K) x = x * 2;
			else x = x + K;
		}
		System.out.println(x);
		scan.close();
	}
}


Measured memory_bytes: 23124
#------------------------template--------------------------#
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import*
from io import BytesIO, IOBase
def vsInput():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
ALPHA='abcdefghijklmnopqrstuvwxyz'
M=10**9+7
EPS=1e-6
def value():return tuple(map(int,input().split()))
def array():return [int(i) for i in input().split()]
def Int():return int(input())
def Str():return input()
def arrayS():return [i for i in input().split()]


#-------------------------code---------------------------#
#vsInput()


s=list(input().split('S'))

# print(s)

ans=0
for i in s:
    ans=max(len(i),ans)

print(ans)
    







    

        





                

    









    

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

int main(){
  long long n;
  cin>>n;
  string s;
  while(n>0){
      n--;
      s+=('a'+n%26);
      n=n/26;
  }
  reverse(s.begin(),s.end());
  cout<<s<<endl;
}

Measured memory_bytes: 3632
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

const int N = 2*1e5 + 10;
struct DSU
{
	int totlst;
	int link[N] , sz[N];
 
	DSU(){}
 
	DSU(int n) 
	{
		for(int i=1;i<=n;i++)
		{
			link[i]=i;
			sz[i]=1;
		}
		totlst=n;
	}
 
	int find(int x)
	{

		if(x==link[x])
		{
			return x;
		}
		return link[x] = find(link[x]);

	}
 
	bool same(int a,int b)
	{
		return (find(a)==find(b));
	}
 
	void unite(int a,int b)
	{
		a = find(a);
		b = find(b);
 
		if(a==b)
		{
			return;
		}
 
		totlst--;
 
		if(sz[a]<sz[b]) 
		{
			sz[b]+=sz[a];
			sz[a]=0;
			link[a]=b;
		}
		else
		{
			sz[a]+=sz[b];
			sz[b]=0;
			link[b]=a;  
		}    
	}
 
	int getSize(int k)
	{
		return sz[find(k)];
	}
 
	int getDisjointsets()
	{
		return totlst;
	}
};	

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j;

	int n,m;
	cin>>n>>m;

	DSU g(n);

	for(i=0;i<m;i++)
	{
		int u,v;
		cin>>u>>v;
		g.unite(u,v);
	}

	int cnt=0,Max=0;

	for(i=1;i<=n;i++)
	{
		if(g.find(i)==i)
		{
			d(i);
			Max=max(Max,(g.getSize(i)));
		}
	}

	cout<<Max<<endl;
	

}

Measured memory_bytes: 6768
a,b,c,d = map(int,input().split())
l = []
l.append(a*c)
l.append(a*d)
l.append(b*c)
l.append(b*d)
if a<=0<=b:
  l.append(0)
elif c<=0<=d:
  l.append(0)
print(max(l))

Measured memory_bytes: 61692
#include <cstdio>
int n;
char s[105],t[105];
int ans=500;
int main()
{
  scanf("%d",&n);
  scanf("%s%s",s,t);
  int l=0;
  int x,y;
  while(l<=n){
    x=l; y=0;
	while(x<n&&s[x++]==t[y++]);
	if(x==n&&s[x-1]==t[y-1])
	  {ans=2*n-x+l;break;}
	l++;
  }
  if(ans==500)printf("%d",n*2);
  else printf("%d",ans);
  return 0;
}


Measured memory_bytes: 128
import sys
import itertools

s=input()

if len(s)==1:
    print(int(s))
    sys.exit()


S=0

for i in itertools.product([0,1],repeat=len(s)-1):
    sm=0
    st=0
    for j in range(len(i)):
        if i[j]==1:
            sm+=int(s[st:j+1])
            st=j+1
            if j==len(s)-2:
                sm+=int(s[j+1:len(s)])
        elif j==len(s)-2:
            sm+=int(s[st:len(s)])
    S+=sm

print(S)

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>

int main(void){
  int n, m, a, b;
  scanf("%d %d %d %d", &n, &m, &a, &b);
  int x, y;
  int maxx = a;
  int miny = b;
  int i;
  for(i = 0; i < n; i++){
    scanf("%d", &x);
    if(x > maxx){
      maxx = x;
    }
  }
  for(i = 0; i < m; i++){
    scanf("%d", &y);
    if(y < miny){
      miny = y;
    }
  }
  if(maxx < miny){
    printf("No War\n");
  }else{
    printf("War\n");
  }
}


Measured memory_bytes: 128
#include<stdio.h>

int main(){
  int W, H, N;
  int x[101], y[101], a[101], i;
  scanf("%d %d %d", &W, &H, &N);
  for(i=0; i<N; i++){
    scanf("%d %d %d", &x[i], &y[i], &a[i]);
  }

  int wu[]={W, H}, wd[]={W, 0}, lu[]={0, H}, ld[]={0, 0};
  int S = 1;
  for(i=0; i<N; i++){
    if(a[i] == 1){
      if(lu[0] < x[i] && wu[0] > x[i]){
        lu[0] = x[i];
        ld[0] = x[i];
      }else if(wu[0] <= x[i]){
        S = 0;
        break;
      }
    }else if(a[i] == 2){
      if(wu[0] > x[i] && lu[0] < x[i]){
        wu[0] = x[i];
        wd[0] = x[i];
      }else if(lu[0] >= x[i]){
        S = 0;
        break;
      }
    }else if(a[i] == 3){
      if(ld[1] < y[i] && lu[1] > y[i]){
        ld[1] = y[i];
        wd[1] = y[i];
      }else if(lu[1] <= y[i]){
        S = 0;
        break;
      }
    }else if(a[i] == 4){
      if(lu[1] > y[i] && ld[1] < y[i]){
        lu[1] = y[i];
        wu[1] = y[i];
      }else if(ld[1] >= y[i]){
        S = 0;
        break;
      }
    }
  }

  if(S > 0){
    printf("%d", (lu[1] - ld[1]) * (wd[0] - ld[0]));
  }else{
    printf("0");
  }

  return 0;
}

Measured memory_bytes: 128
isPrime :: Int -> Bool
isPrime 1 = False
isPrime 2 = True
isPrime x =
  let limit = floor . sqrt $ fromIntegral x
  in  not $ any (\k -> x `mod` k == 0) [2..limit]

main = do
  _ <- getLine
  content <- getContents
  let inputs = map (read :: String -> Int) $ lines content
  putStrLn $ show . length $ filter isPrime inputs

Measured memory_bytes: 5608
/*
 * https://atcoder.jp/contests/abc157/tasks/abc157_d
 */
#include <bits/stdc++.h>
 
using namespace std;

// ショートハンド
// #define ll intに変えればメモリ節約
#define ll long long

/* 
 * ループ系のマクロ
 * `REP(i, 10) { cout << i; }`のように、変数名,回数で動く
 */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/*
 * 正規表現系
 */
#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

const int MOD = 1e9 + 7;

ll n,k, res;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> k;
    // 選択する数ごとにループ回す
    REPS(i, k, n + 2) {
        ll m,M;
        // i = 3の場合、最低は0 + 1 + 2 = 3
        // 3の次は0 + 1 + 3 = 4と必ず最大値まで連番で取れる
        m = i * (i -1) / 2;
        // 最大値はn = 10の場合、8 + 9 + 10 = 27
        // 等差数列の和の公式からi * ((n - (i - 1)) + n) / 2
        M = i * (2 * n - (i - 1)) / 2;
        res = (res + M - m + 1) % MOD;
    }
    cout << fixed << res;
    return 0;
}

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

int main() {
	ll n;
	cin>>n;
	ll ten=1,eight=1,nine=1;
	for(int i=0;i<n;i++){
		ten=(ten*10)%mod;
		eight=(eight*8)%mod;
		nine=(nine*9)%mod;
	}
	ll ans=(ten+eight)%mod;
	ans=(ans-nine+mod)%mod;
	ans=(ans-nine+mod)%mod;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3640
#ifdef __GNUC__
#pragma GCC target("avx2")
#pragma GCC optimize ("O20")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC optimize("unroll-loops")
#define iss std::cin
#endif
#include "bits/stdc++.h"
#define rep(i, times) for(ll i = 0; i < (times); ++i)
#define p(x) (cout << x << "\n")
using ll = long long; using ld = long double; using namespace std;

#ifndef __GNUC__
string text =
R"X(5 2
3 1 2 5
2 2 3
1 0)X";
stringstream iss{text};
#endif

class Switches
{
	ll N{0}, M{0}, allS{0}, cnt{0};
	vector<vector<ll>> s;
	vector<ll> p;
	void inp( ) {
		iss >> N >> M;
		s.resize(M);
		rep(m, M) {
			ll K; iss >> K;	s[m].resize(K);
			rep(k, K) { iss >> s[m][k]; }
		}
		p.resize(M); rep(m, M) { iss >> p[m]; }
	}
	inline ll Non(ll m) {//m番目の電球につながっているスイッチでonのものの個数
		ll con{0};
		for (auto &p : s[m]) {// m番目の電球につながっているp番目のスイッチ
			if ((allS >> (p - 1)) & 1) ++con; //スイッチpがonかどうか
		}
		return con;
	}
	inline bool light(ll m) {//m番目の電球がつくか？
		return ((Non(m) & 1)  == p[m]);
	}
	inline bool allonQ( ) {//全部の電球がつくか
		rep(m, M) { if (!light(m)) return false; }
		return true;
	}
	void changeSwitch( ) {
		for (ll b = 0; b < ll(1 << N); ++b) {
			allS = b;//スイッチの状態を変える
			if (allonQ( )) ++cnt;
		}
	}
public:
	void procedures( ) {
		inp( );
		changeSwitch( );
		p(cnt);
	}
};

int main( ) {
	cin.tie(0);	ios::sync_with_stdio(0);
	class Switches a; a.procedures( );
}

Measured memory_bytes: 3660
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
using namespace std;
 

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pb push_back
#define forn(i, n) for (int i = 0; i < n; ++i)
#define int long long

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

 
const int MAXN = 1e5 + 5;
const ll MOD = 998244353;
const ll INF = INT64_MAX;


random_device rd;
mt19937 rnd(rd());


signed main() {
	FAST_IO;
	int n;
	cin >> n;
	int ac = 0, tle = 0, re = 0, wa = 0;
	forn(i, n) {
		string s;
		cin >> s;
		if (s == "AC") {
			ac++;
		}
		if (s == "TLE") {
			tle++;
		}
		if (s == "RE") {
			re++;
		}
		if (s == "WA") {
			wa++;
		}
	}
	cout << "AC x " << ac << "\n";
	cout << "WA x " << wa << "\n";
	cout << "TLE x " << tle << "\n";
	cout << "RE x " << re << "\n";
 	return 0;
}

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

int H, W, N, A, now = 0;

int makeNumber() {
  if (!A) {
    cin >> A;
    now++;
  }
  A--;
  return now;
}

void makeVector(int n) {
  vector<int> V(W);
  for (int i = 0; i < W; i++) V.at(i) = makeNumber();
  if (n % 2) reverse(V.begin(), V.end());
  for (int i = 0; i < W; i++) {
    if (i != 0) cout << " ";
    cout << V.at(i);
  }
  cout << "\n";
}

int main() {
  cin >> H >> W >> N;
  for (int i = 0; i < H; i++) makeVector(i);
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int N, M;
  cin >> N >> M;
  vector<string> A(N), B(M);
  bool ans = false;
  bool bad = false;
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < M; i++) cin >> B[i];
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      bad = false;
      if(A[i][j] == B[0][0]){
        for(int t = 0; t < M && i + t < N; t++){
          for(int k = 0; k < M && k + j < N; k++){
            if(A[i+t][j+k] != B[t][k]){
              bad = true;
              break;
            }
            if(t == M-1 && k == M-1){
              ans = true;
            }
          }
          if(bad){
            break;
          }
        }
      }
    }
  }
  if(ans){
    cout << "Yes" <<endl;
  } else{
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <utility>
using namespace std;

typedef long long ll;
constexpr int inf = 1e6;

int main(){
  int n; cin >> n;
  int p[n+1], t[n+1];
  for(int i=1; i<=n; i++) {
    cin >> p[i];
    t[p[i]] = i;
  }

  int cnt = 0, m = 0;
  for(int i=1; i<n; i++){
    if(t[i] < t[i+1]) cnt++;
    else cnt=0;

    m = max(m, cnt);
  }

  cout << n-m-1 << endl;

  return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N, K, A[5000], L, R;
	cin >> N >> K;
	L = -1, R = N;
	for (int i = 0; i < N; i++) cin >> A[i];
	sort(A, A + N);
	while (R - L > 1) {
		long long MID = (L + R) / 2;
		static bool DP[5010][5010] = {};
		for (int i = 0; i <= N; i++) {
			for (int j = 0; j < K; j++) DP[i][j] = false;
		}
		DP[0][0] = true;
		for (int i = 0; i < N; i++) {
			if (i == MID) {
				for (int j = 0; j < K; j++) {
					DP[i + 1][j] = DP[i][j];
				}
				continue;
			}
			for (int j = 0; j < K; j++) {
				if (DP[i][j]) {
					DP[i + 1][j] = true;
					if (j + A[i] < K) DP[i + 1][j + A[i]] = true;
				}
			}
		}
		bool check = false;
		for (int i = max(0LL, K - A[MID]); i < K; i++) {
			if (DP[N][i]) check = true;
		}
		if (check) R = MID;
		else L = MID;
	}
	cout << R << endl;
}

Measured memory_bytes: 24704
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

int main(){
  int n;
  cin >> n;
  vector<pair<int, int> > pairs(n);
  
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    pairs[i] = make_pair(a, b);
  }
  
  sort(pairs.begin(), pairs.end(), sort_pair_second<int, int>());

  int time = 0;
  for(int i=0; i<n; i++){
    time += pairs[i].first;
    if(time > pairs[i].second){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 1792
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
#include <ios>
#include <iomanip>

using namespace std;

int main(){
    string s;
    cin >> s;
    int max=0;
    int len=0;
    for(int i=0; i<s.length() ;i++){
        if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
            len++;
        }else{
            if(len>=max){max=len;}
            len=0;
        }
    }
    if(len>=max){max=len;}
    cout<<max<<endl;
    return 0;
}



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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long x;
  cin >> x;
  long long a, b;
  for(a = -1000; a <= 1000; a++){
    for(b = 1000; b >= -1000; b--){
      if(pow(a,5)-pow(b,5) == x){
        cout << a << " " << b;
        return 0;
      }
    }
  }
  return 0;
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    ll st = 1;
    ll lim = 1000000000000000000ll;
    ll A[N]; rep(i, N) cin >> A[i];
    sort(A, A+N);
    rep(i, N){
        ll a; a = A[i];
        if(a == 0){
            st = 0; continue;
        }
        if(st > lim/a){
            cout << -1 << endl;
            return 0;
        }
        st *= a;
    }
    cout << st << endl;
    return 0;
}

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

using namespace std;

long long n, a[100005];

int main() {
    cin >> n;
    long long now = 0;
    while (n > 0) {
        n--;
        a[++now] = n % 26;
        n /= 26;
    }
    for (long long i = now; i >= 1; i--) {
        char c = a[i] + 'a';
        cout << c;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n , sum = 0;
    cin >> n;
    int arr[n];
    for (int i = 0 ; i < n ; i++)
        cin >> arr[i] , sum ^=  arr[i];
    for (int i = 0 ; i < n ; i++)
        cout << (int)(sum ^ arr[i]) << ' ';
    cout << endl;
}


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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define I_1000000007 (1000000007)
#define I_998244353   (998244353)
#define I_INF             (1<<28)
#define L_INF           (1LL<<60)
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"
template<class T> inline bool chmin(T& a, const T& b) {
  if (a > b) { a = b; return true; } else return false;
}
template<class T> inline bool chmax(T& a, const T& b) {
  if (a < b) { a = b; return true; } else return false;
}

namespace solver {
  using namespace std;
  using ll = long long;

  int N, Q, qs[20020], is[20020], ls[20020], rs[20020], BIT[30][500050];
  char cs[20020];
  string S;

  void init() {
    cin >> N >> S >> Q;
    rep(i, Q) {
      cin >> qs[i];
      if(qs[i] == 1) {
        cin >> is[i] >> cs[i];
      } else {
        cin >> ls[i] >> rs[i];
      }
    }
  }

  int query(char c, int i) {
    int ci = c - 'a';
    int res = 0;
    while(i > 0) {
      res += BIT[ci][i];
      i -= (i & -i);
    }
    return res;
  }

  void update(char c, int i, int d) {
    int ci = c - 'a';
    while (i <= N) {
      BIT[ci][i] += d;
      i += (i & -i);
    }
    return;
  }

  void solve() {
    rep(i, N) {
      update(S[i], i+1, 1);
    }
    rep(i, Q) {
      if(qs[i] == 1) {
        update(S[is[i]-1], is[i], -1);
        S[is[i]-1] = cs[i];
        update(S[is[i]-1], is[i], 1);
      } else {
        int ans = 0;
        rep(j, 26) {
          int l = query('a'+j, ls[i]-1);
          int r = query('a'+j, rs[i]);
          if(l < r) ans++;
        }
        cout << ans << "\n";
      }
    }
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 52380
def pre_cmb(N, MOD):
    FACT = [1, 1]  # 階乗
    INV = [0, 1]  # 各iの逆元
    FACTINV = [1, 1]  # 階乗の逆元

    for i in range(2, N + 1):
        FACT.append((FACT[-1] * i) % MOD)
        INV.append(pow(i,MOD-2,MOD))
        FACTINV.append((FACTINV[-1] * INV[-1]) % MOD)
    PRELIST = FACT, FACTINV
    return PRELIST


def cmb(N, R, MOD, PRELIST):
    FACT, FACTINV = PRELIST
    if (R < 0) or (N < R):
        return 0
    R = min(R, N - R)
    return FACT[N] * FACTINV[R] * FACTINV[N-R] % MOD


n, m, k = map(int, input().split())
mod = 998244353

prelist = pre_cmb(n, mod)

cnt = 0
for i in range(k + 1):
    cnt += (m * pow(m - 1, n - i - 1, mod) * cmb(n - 1, i, mod, prelist)) % mod

print(cnt % mod)


Measured memory_bytes: 32708