akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<complex>

#define f first
#define s second
#define mp make_pair

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

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int main(){
  map<char,string> enc;
  map<string,char> dec;

  enc[' ']  = "101";
  enc['\''] = "000000";
  enc[',']  = "000011";
  enc['-']  = "10010001";
  enc['.']  = "010001";
  enc['?']  = "000001";
  enc['A']  = "100101";
  enc['B']  = "10011010";
  enc['C']  = "0101";
  enc['D']  = "0001";
  enc['E']  = "110";
  enc['F']  = "01001";
  enc['G']  = "10011011";
  enc['H']  = "010000";
  enc['I']  = "0111";
  enc['J']  = "10011000";
  enc['K']  = "0110";
  enc['L']  = "00100";
  enc['M']  = "10011001";
  enc['N']  = "10011110";
  enc['O']  = "00101";
  enc['P']  = "111";
  enc['Q']  = "10011111";
  enc['R']  = "1000";
  enc['S']  = "00110";
  enc['T']  = "00111";
  enc['U']  = "10011100";
  enc['V']  = "10011101";
  enc['W']  = "000010";
  enc['X']  = "10010010";
  enc['Y']  = "10010011";
  enc['Z']  = "10010000";

  dec["00000"]  = 'A';
  dec["00001"]  = 'B';
  dec["00010"]  = 'C';
  dec["00011"]  = 'D';
  dec["00100"]  = 'E';
  dec["00101"]  = 'F';
  dec["00110"]  = 'G';
  dec["00111"]  = 'H';
  dec["01000"]  = 'I';
  dec["01001"]  = 'J';
  dec["01010"]  = 'K';
  dec["01011"]  = 'L';
  dec["01100"]  = 'M';
  dec["01101"]  = 'N';
  dec["01110"]  = 'O';
  dec["01111"]  = 'P';
  dec["10000"]  = 'Q';
  dec["10001"]  = 'R';
  dec["10010"]  = 'S';
  dec["10011"]  = 'T';
  dec["10100"]  = 'U';
  dec["10101"]  = 'V';
  dec["10110"]  = 'W';
  dec["10111"]  = 'X';
  dec["11000"]  = 'Y';
  dec["11001"]  = 'Z';
  dec["11010"]  = ' ';
  dec["11011"]  = '.';
  dec["11100"]  = ',';
  dec["11101"]  = '-';
  dec["11110"]  = '\'';
  dec["11111"]  = '?';

  string input;
  while(getline(cin, input)){
    string buff = "";
    REP(i, input.size()){
      buff+=enc[input[i]];
      while(buff.size() >= 5){
	string tmp = buff.substr(0,5);
	buff = buff.substr(5);
	cout << dec[tmp];
      }
    }
    if(buff.size() != 0){
      while(buff.size() != 5) buff += "0";
      cout << dec[buff];
    }

    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(void){
  long int n,x[101],i,j,a,b;
  scanf("%ld",&n);
  for(i=0;i<n;i++){
    scanf("%ld",&x[i]);
  }
  b=1000000000000000000;
  for(i=1;i<101;i++){
    a=0;
    for(j=0;j<n;j++){
      a=a+(x[j]-i)*(x[j]-i);
    }
    if(a<b){
      b=a;
    }
  }
  printf("%ld\n",b);
  return 0;
}



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

int main() {
    int n;  scanf("%d", &n);

    list<int> L;

    rep(i, n){
        char z[50]; scanf("%s", z);
        if (z[0] == 'i'){
            int a; scanf("%d", &a);
            L.push_front(a);
        } else if (z[6] == 'F'){
            L.pop_front();
        } else if (z[6] == 'L'){
            L.pop_back();
        } else {
            int a; scanf("%d", &a);
            for(list<int>::iterator it = L.begin(); it != L.end(); it++){
                if (*it == a){
                    L.erase(it);
                    break;
                }
            }
        }
    }

    int j = 0;
    for(list<int>::iterator it = L.begin(); it != L.end(); it++){
        if(j++){
            printf(" ");
        }

        printf("%d", *it);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 34340
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <utility>

using namespace std;

int main(){
	vector<pair<int,int> > list;
	pair<int,int> pa;
	int n,m;
	int self;
	while(1){
		list.clear();
		scanf("%d %d",&n,&m);
		if(n == 0 && m == 0){ break; }
		for(int i = 0;i < m;i++){
			pa.first = 0;
			pa.second = m - i;
			list.push_back(pa);
		}
		for(int i = 0;i < n;i++){
			for(int j = 0;j < m;j++){
				scanf("%d",&self);
				list[j].first += self;
			}
		}
		sort(list.begin(),list.end(),greater<pair<int,int> >());
		vector< pair<int,int> >::iterator it;
		for(it = list.begin();it < list.end();it++){
			printf("%d",m - (*it).second + 1);
			if(it != list.end() - 1){
				printf(" ");
			}
		}
		printf("\n");
	}
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
using namespace std;
int N, result, arr[25];

int main()
{
    scanf("%d", &N);
    for(int i = 0; i < N; i++)
    {
        scanf("%d", &arr[i]);
    }
    for(int i = 0; i < N; i++)
    {
        int num;
        scanf("%d", &num);
        if(num < arr[i])
        {
            result += arr[i] - num;
        }
    }
    printf("%d", result);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> s(H, vector<char>(W));
    REP(i, H){
        REP(j, W){
            cin >> s[i][j];
        }
    }

    vector<vector<int>> dist(H, vector<int>(W, -1));
    queue<pair<int,int>> que;

    dist[0][0] = 0;
    que.push(make_pair(0, 0));

    //BFS実行部分//
    while(!que.empty()){
        pair<int, int> current_pos = que.front();   //キューの先頭の確認
        int x = current_pos.first;
        int y = current_pos.second;
        que.pop();

        REP(dir, 4){
            int next_x = x + dx[dir];
            int next_y = y + dy[dir];

            if(next_x < 0 || next_x >= H || next_y < 0 || next_y >= W){
                continue;
            }
            if(s[next_x][next_y] == '#') continue;

            if(dist[next_x][next_y] == -1){
                que.push(make_pair(next_x, next_y));
                dist[next_x][next_y] = dist[x][y] + 1;
            }
        }
    }

    int coun = 0, ans = 0;
    if(dist[H-1][W-1] == -1){
        cout << -1 << endl;
    }
    else{
        REP(i, H){
            REP(j, W){
                if(s[i][j] == '.') coun++;
            }
        }
        ans = coun -1 - dist[H-1][W-1];
        cout << ans << endl;
    }
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, n,m) for (int i = (int)(n); i < (int)(m); i++)

#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

typedef long long ll;

vector<string> split(string,string);

//template<typename T>
//void swap(T*,T*);
//char ToUpper (char cX) { return toupper(cX); }

bool isR(string s);

int N;
int A[3][3];
int b[10];

int main()
{
    rep(i,3)
    {
        rep(j,3) 
            cin >> A[i][j];
    }
    cin >> N;
    rep(i,N)
        cin >> b[i];

   rep(i,N)
   {
       rep(j,3)
       {
           rep(k,3)
           {
               if(A[j][k] == b[i])
               {
                   A[j][k] = -1;
               }
           }
       }
   }

    bool is = false;
    rep(i,3)
    {
        if(A[i][0] == -1 && A[i][1] == -1 && A[i][2] == -1)
        {
            is = true;
        }
    }
    
    rep(i,3)
    {
        if(A[0][i] == -1 && A[1][i] == -1 && A[2][i] == -1)
        {
            is = true;
        }
    }
    
    if(A[0][0] == -1 && A[1][1] == -1 && A[2][2] == -1)
    {
        is = true;
    }
    
    if(A[0][2] == -1 && A[1][1] == -1 && A[2][0] == -1)
    {
        is = true;
    }
   
    Yes(is);
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main() {
    int N;
    double ans = 0.0, x[10];
    char u[10][4];
    scanf("%d%*c", &N);
    for (int i = 0; i < N; i++) {
        scanf("%lf %s%*c", &x[i], u[i]);
        if (strcmp(u[i], "JPY") == 0) ans += x[i];
        else ans += x[i] * 380000.0;
    }
    printf("%f\n", ans);
    return 0;
}

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

using namespace std;

void Main() {
    int D, N;
    cin >> D >> N;

    int ans = 0;
    if (N < 100) {
        ans = N;
        for (int i = 0; i < D; ++i) {
            ans *= 100;
        }
        cout << ans << endl;
    }
    else {
        if (D == 0) {
            cout << 101 << endl;
        }
        else if (D == 1) {
            cout << 10100 << endl;
        }
        else {
            cout << 1010000 << endl;
        }
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3652
package main

import "fmt"

func abs(x int) int{
  if x < 0{
    return -x
  } else{
    return x
  }
}

func main() {
  var a, b, c, d int
  fmt.Scan(&a, &b, &c, &d)
  if (abs(a-b) <= d && abs(b-c) <= d) || abs(a-c) <= d{
    fmt.Println("Yes")
  }else{
    fmt.Println("No")
  }
}

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

using namespace std;

int main(void){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  string str;
  
  if(a+b > c+d) str = "Left";
  else if(a+b == c+d) str = "Balanced";
  else str = "Right";
  
  cout << str << endl;
}

Measured memory_bytes: 384
/**
 *      purpose : AGC 28 A
 *      author  : kyomukyomupurin
 *      created : 2018-11-06 20:26:30
**/

#include <bits/stdc++.h>
using namespace std;
#define int64 long long
#define print(x) cout << (x) << '\n'

int64 gcd(int64 x, int64 y){
    if (x % y == 0) return y;
    else return gcd(y, x % y);
}

int64 lcm(int64 x, int64 y){
    if (x % y == 0) return x;
    else if (y % x == 0) return y;
    else return x * y / gcd(x, y);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int64 N, M; cin >> N >> M;
    string S, T; cin >> S >> T;

    int64 x = lcm(N, M);
    //int64 y = gcd(N, M);

    int64 ss = 0; int64 tt = 0;

    while (ss <= N && tt <= M){
        if (S[ss] != T[tt]){
            print(-1); return 0;
        }
        else {
            ss += (x / M); tt += (x / N);
        }
    }
    print(x); 
    
    return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  priority_queue<double> a;
  rep(i,n) {
    double t;
    cin >> t;
    a.push(t);
  }

  rep(i,m) {
    double k;
    k = a.top();
    a.pop();
    a.push(k/2);
  }

  ll ans = 0;
  rep(i,n) {
    ans += (ll) a.top();
    a.pop();
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4392
#!/usr/bin/python3
# -*- coding: utf-8 -*-

n = int(input())
mod = 10 ** 9 + 7


def prime_factorization(n):
    i = 2
    primes = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            primes.append(i)
        i += 1
    if n > 1:
        primes.append(n)
    return primes


divisor = {}
for i in range(2, n + 1):
    primes = prime_factorization(i)
    for p in primes:
        if p in divisor:
            divisor[p] += 1
        else:
            divisor[p] = 1

ans = 1
for d in divisor.values():
    ans *= d + 1
ans %= mod
print(ans)


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();

		System.out.println((a+b)*h/2);
	}

}


Measured memory_bytes: 23636
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;

int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
    int p=0;
	// ユークリッドの方法
	while( m > n )
	{
        m = m/2;
        p+=1;
	}
	return p;
}//gcd

int main()
{
    int a,b;
  cin >> a >> b;
  cout << 6-a-b;
}

Measured memory_bytes: 256
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

const double PI = acos(-1);
typedef long long ll;
#define int ll
#define fori(n) for(int i=0; i<int(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }


typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;

void solve() {
    cini(n);
    cini(m);
    cinai(a,n);
    int sum=0;
    for(int i=0; i<n; i++)
        sum+=a[i];

    int cnt=0;
    for(int i=0; i<n; i++) {
        if(a[i]*4*m>=sum)
            cnt++;
    }
    if(cnt>=m)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

signed main() {
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
        solve();
}



Measured memory_bytes: 256
from collections import defaultdict

N, M = map(int, input().split())
S = [0] + list(map(int, input().split()))
T = [0] + list(map(int, input().split()))
mod = 10 ** 9 + 7
sum_dp = []
for i in range(N+1):
    sum_dp.append([0] * (M+1))

for i in range(1, N+1):
    for j in range(1, M+1):
        temp = 0
        if(S[i] == T[j]):
            temp = sum_dp[i-1][j-1] + 1
        sum_dp[i][j] = (sum_dp[i-1][j] + sum_dp[i][j-1] - sum_dp[i-1][j-1] + temp)
        sum_dp[i][j] %= mod
        
print(sum_dp[N][M] + 1)


Measured memory_bytes: 72412
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
//**Snippetリスト**//
//rep, vin, all//
//gcdlcm, isPrime, eratos, modinv, bitSearch, bitList, dfs, bfs, dijkstra, UnionFind, COM, digitDP//
ll i, j, k, l, m, n; ll N, M, K, H, W, L;
ll MOD = 1000000007; ll INF = 9999999999999; ll ans = 0;
vl flag, color; vll path; vl D;
//***********//
int main() {
	ll T;
	cin >> N >> T;
	vpll F(N);
	for (i = 0; i < N; i++) {
		cin >> F[i].first >> F[i].second;
	}
	sort(F.begin(), F.end());
	vl dp(T+1);
	for (int i = 0; i < N; i++) {
		for (int j = T - 1; j >= 0; j--) {
			int k = min(T, j + F[i].first);
			dp[k] = max(dp[k], dp[j] + F[i].second);
		}
	}
	cout << dp[T] << endl;
}
	


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

int main() {
    long n;
    string S;
    cin >> n;
    S = to_string(n);

    for (long i = 0; i < 3; i++) {
        if (S[i] == '1') {
            S[i] = '9';
        }
        else if (S[i] == '9') {
            S[i] = '1';
        }
    }

    long ans = stoi(S);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <iostream>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;
const int MOD = 998244353;

int main(void) {
  ll n, k;
  scanf("%lld%lld", &n, &k);
  ll res = 0;
  if(k % 2 == 0) {
    ll h = k/2;
    res = (n/k) * (n/k) * (n/k);
    res += ((n+h)/k) * ((n+h)/k) *((n+h)/k);
  } else {
    res = (n/k) * (n/k) * (n/k);
  }
  cout << res << endl;
  
  return 0;
}


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

#define int long long
#define MOD 1000000007

int32_t main() {
	int h,w;
	cin>>h>>w;
	vector<vector<char> > mat(h,vector<char>(w));
	for(int i=0;i<h;i++) {
	    for(int j=0;j<w;j++) {
	        cin>>mat[i][j];
	    }
	}
	vector<vector<int> > dp(h,vector<int>(w));
	dp[0][0] = 1;
	bool isbloked = false;
	for(int i=1;i<h;i++) {
	    if(mat[i][0]=='#') {
	        isbloked = true;
	    }
	    if(isbloked) {
	        dp[i][0] = 0;
	    }
	    else {
	        dp[i][0] = dp[i-1][0];
	    }
	}
	isbloked = false;
	for(int j=1;j<w;j++) {
	    if(mat[0][j]=='#') {
	        isbloked = true;
	    }
	    if(isbloked) {
	        dp[0][j] = 0;
	    }
	    else {
	        dp[0][j] = dp[0][j-1];
	    }
	}
	for(int i=1;i<h;i++) {
	    for(int j=1;j<w;j++) {
	        if(mat[i][j]=='#') {
	            dp[i][j] = 0;
	        }
	        else {
	            dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
	        }
	    }
	}
	cout<<dp[h-1][w-1];
	return 0;
}


Measured memory_bytes: 12164
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = INT64_MAX;

string s;
vector<ll> cur;
vector<vector<ll>> pos;

ll cnt() {
	vector<ll> dp(s.size() + 1);

	for (int i = 0; i < s.size(); i++) {
		dp[i + 1] = dp[i];
		for (auto cur : pos[i]) {
			dp[i + 1] = max(dp[i + 1], dp[cur] + (i - cur - 1));
		}
	}
	return dp[s.size()];
}

ll sol() {
	ll ans = 0, pr = 0, sz = 0;

	pos.resize(s.size());
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0' && i != 0 && i != s.size()) {
			int j = i - 1, j2 = i + 1;
			while (j >= 0) {
				if (s[j] == '1') {
					j--;
				}
				else {
					break;
				}
			}

			while (j2 < s.size()) {
				if (s[j2] == '1') {
					j2++;
				}
				else {
					break;
				}
			}
			j++;
			j2--;
			if (j == i || j2 == i) continue;

			for (int k = j; k < i; k++) {
				pos[i + 1].push_back(k);
			}

			for (int k = i + 1; k <= j2; k++) {
				pos[k].push_back(i - 1);
			}
		}
	}

	return cnt();
}

int main()
{
	fastInp;

	ll n;
	cin >> n;

	cin >> s;
	
	cout << sol();

	return 0;
}

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

int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;

    if (x + r > W || y + r > H || x - r < 0 || y - r < 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 3116
/*
Arthor : Ender_zzm
E-mail zzm_ender_wiggin@outlook.com
Blog ender-zzm.enbar.cn
*/
#include <bits/stdc++.h>
using namespace std;

inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
inline int readint(){
    register int x = 0, flag = 1;
    register char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), Isdigit(ch = getchar()));
	return x * flag;
}

inline long long readlong() {
	register long long x = 0, flag = 1;
	register char ch;
	while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), Isdigit(ch = getchar()));
	return x * flag;
}
template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define For(i, x, y) for (int i = (x); i <= (y); i++) 
#define Rep(i, x, y) for (int i = (x); i >= (y); i--) 
#define ri readint
#define rl readlong

const int Mod = 1e9 + 7;
const int maxn = 2010;	
const int NN = 2000 * 2000 + 20;
int n, k;
int f[maxn][maxn];
int fac[NN], inv[NN];
int Pow(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = 1ll * ans * x % Mod;
		x = 1ll * x * x % Mod;
		y >>= 1;
	}
	return ans;
}
long long C(int n, int m) {
	return 1ll * fac[n] * inv[m] % Mod * inv[n - m] % Mod;
}
int main() {
	n = ri(), k = ri();
	if (k == 1) {
		puts("1"); return 0;
	}
	fac[0] = 1;
	for (int i = 1; i <= n * k; i++) {
		fac[i] = 1ll * fac[i - 1] * i % Mod;
	}
	inv[n * k] = Pow(fac[n * k], Mod - 2);
	for (int i = n * k - 1; i >= 0; i--) {
		inv[i] = 1ll * inv[i + 1] * (i + 1) % Mod;
	}
	for (int i = 1; i <= n; i++) {
		f[i][0] = 1;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= i; j++) {
			f[i][j] += f[i - 1][j];
			if (j == 0) continue;
			(f[i][j] += 1ll * f[i][j - 1] * (n - j + 1) % Mod * C(n * k - i - (j - 1) * (k - 1) - 1, k - 2) % Mod) %= Mod;
		}
	}
	cout << f[n][n];
	return 0;
}


Measured memory_bytes: 48628
import java.util.Scanner;

/**
 * AOJ id=0023
 * Circles Intersection
 * @author scache
 *
 */
public class Main {
	public static void main(String[] args) {
		Main p = new Main();
	}

	public Main() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i=0;i<n;i++){
			double xa = sc.nextDouble();
			double ya = sc.nextDouble();
			double ra = sc.nextDouble();
			double xb = sc.nextDouble();
			double yb = sc.nextDouble();
			double rb = sc.nextDouble();
			solve(xa, ya, ra, xb, yb, rb);
		}
		
	}

	public void solve(double xa, double ya, double ra, double xb, double yb, double rb) {
		double c = (xa-xb)*(xa-xb)+(ya-yb)*(ya-yb);
		double rd = (ra-rb)*(ra-rb);
		double r = (ra+rb)*(ra+rb);
		double eps = 0;
		if(c<rd-eps && ra>rb)
			System.out.println(2);
		else if(c<rd-eps && ra<=rb)
			System.out.println(-2);
		else if(c<=r+eps)
			System.out.println(1);
		else
			System.out.println(0);
		
		
	}

}

Measured memory_bytes: 20696
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
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;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

//for(i=0; i<N; i++) cin >> a[i];


ll H, W;
ll sx, sy, gx, gy;
ll d[1111][1111];
ll clr[1111][1111];
string s[1111];

void solve() {
  ll i, j, k;
  priority_queue<pair<ll, pll>> q;
  
  for(i=0; i<H; i++) for(j=0; j<W; j++) d[i][j]=INF;
  d[sx][sy]=0;
  q.push(make_pair(0, pll(sx, sy)));
  
  while(q.size()) {
    ll x=q.top().sc.ft;
    ll y=q.top().sc.sc;
    ll u=-q.top().ft;
    q.pop();
    
    if(clr[x][y]) continue;
    clr[x][y]=1;
    
    for(i=-2; i<=2; i++) {
      for(j=-2; j<=2; j++) {
        ll tx=x+i, ty=y+j;
        if(tx<0 || tx>=H || ty<0 || ty>=W) continue;
        if(s[tx][ty]=='#') continue;
        
        if(abs(i)<=1 && abs(j)<=1 && abs(i+j)==1) {
          q.push(make_pair(-u, pll(tx, ty)));
          chmin(d[tx][ty], u);
        }else {
          q.push(make_pair(-u-1, pll(tx, ty)));
          chmin(d[tx][ty], u+1);
        }
        
      }
    }
    
  }
  
}


int main(void) {
  ll i, j, k;
  
  
  cin >> H >> W;
  cin >> sx >> sy >> gx >> gy;
  sx--; sy--; gx--; gy--;
  for(i=0; i<H; i++) cin >> s[i];
  
  solve();
  if(d[gx][gy]==INF) pt(-1);
  else pt(d[gx][gy]);
  
}
 
 




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

typedef struct{

  double x,y;
}Pointxy;

void koch(int n,Pointxy a,Pointxy b){
  Pointxy s,t,u;

  double th=M_PI*60.0/180.0;

  if(n==0){
    return;
  }

  s.x=(2.0*a.x+1.0*b.x)/3.0;
  s.y=(2.0*a.y+1.0*b.y)/3.0;
  t.x=(1.0*a.x+2.0*b.x)/3.0;
  t.y=(1.0*a.y+2.0*b.y)/3.0;
  u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

  koch(n-1,a,s);
  printf("%f %f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%f %f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%f %f\n",t.x,t.y);
  koch(n-1,t,b);
}


int main(){
  Pointxy a,b;
  int n;

  scanf("%d",&n);

  a.x=a.y=b.y=0;
  b.x=100;

  printf("%f %f\n",a.x,a.y);

  koch(n,a,b);

  printf("%f %f\n",b.x,b.y);
  return 0;
}

Measured memory_bytes: 636
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

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

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int a,b;
    cin>>a>>b;
    cout<<a*b;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll>   pairl;
typedef vector<ll>     vl;
typedef vector<ll>     vll;
typedef vector<vector<ll> > vvl;
const   int            infi = numeric_limits<int>::max();
const   ll             infl = numeric_limits<ll>::max();
const   double         eps = 0;
const   int            ms  = 0;

const ll MOD = 1000000007;


int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    //cout << (1ull<<60) << endl;
    int N;
    cin >> N;
    vl A(N);
    rep(i, N)cin >> A[i];
    vvl B(N, vl(60, -1));
    rep(i, N){
        ll a = A[i];
        rep(j, 60){
            B[i][j] = (((1ull << j) & a) != 0);
        }
    }

    vvl O(N, vl(60, 0));
    vvl Z(N, vl(60, 0));
    
    ll ans = 0;
    rep(j, 60){
        O[0][j] = (B[0][j] == 1);
        Z[0][j] = (B[0][j] == 0);
    }
    for(int i = 1; i < N; i++){

        rep(j, 60){
            
            ll a = (1ull << j)%MOD;
            ll b = B[i][j];
            if(b== 1){
                ans = (ans +  (Z[i-1][j]*a)%MOD )%MOD;
                O[i][j] = (O[i-1][j]+1)%MOD;
                Z[i][j] = (Z[i-1][j])%MOD;

            }
            else{
                ans = (ans + (O[i-1][j]*a)%MOD)%MOD;
                O[i][j] = (O[i-1][j])%MOD;
                Z[i][j] = (Z[i-1][j]+1)%MOD;
            }
        }
    }

        cout << ans << endl;

    return 0;
}

Measured memory_bytes: 459648
module Main where

import Data.Maybe
import qualified Data.ByteString.Lazy.Char8 as B
import Control.Monad
    

readLine:: B.ByteString -> [Int]
readLine s = map (fst . fromJust . B.readInt) (B.words s)

readLines :: [B.ByteString] -> [[Int]]
readLines [] = []
readLines (s:ss) = readLine s : readLines ss

main :: IO() 
main = do
    contents <- B.getContents
    let lines = B.lines contents
        [n] = readLine (head lines)
        ans = show (n*n*n)
    putStrLn ans



Measured memory_bytes: 3512
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const long double PI = acos(-1);
const long long INF = (1 << 30);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  ll n;
  cin >> n;
  vector<ll> a(n);
  for(ll i = 0; i < n; i++) cin >> a[i];

  ll ans = 0;
  for(ll i = 0; i < 60; i++){
    ll o = 0, e = 0;
    for(ll j = 0; j < n; j++){
      if((a[j] >> i) & 1) o++;
      else e++;
    }

    ll res = 0;
    res = 1LL << i;
    res %= mod;
    res *= (e * o) % mod;
    ans += res;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <stdio.h>
#include <string>

int main(){
	int a,b,c;
	std::cin >> a>>b>>c;
	if(a==b and b==c) std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;
	return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

    // Rust version 1.15.1, which is used by AtCoder,
    // does not support std::str::FromStr for char
    ($iter:expr, char) => {
        $iter.next().unwrap().chars().next().expect("Parse error")
    };

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

#[allow(unused_imports)]
fn main() {
    use std::cmp::max;
    use std::cmp::min;
    use std::collections::HashMap;

    input!{
        x: i32,
        a: i32,
        b: i32,
    }
    let ans = if (x-a).abs() < (x-b).abs() {
        'A'
    } else {
        'B'
    };
    println!("{}", ans);
}


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

int main() {
	string s;
	cin >> s;
	int x;
	if (s == "111") {
		x = 3;
	}
	else if (s == "110" || s == "101" || s == "011") {
		x = 2;
	}
	else if (s == "100" || s == "010" || s == "001") {
		x = 1;
	}
	else if (s == "000") {
		x = 0;
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
class Program{
	static void Main(){
		string s;
		while((s = Console.ReadLine()) != null){
			int ans = 0;
			int n = int.Parse(s);
			if(n<=36){
				if(n>18) n = 36-n;
				ans = (n+1)*(n+2)*(n+3)/6;
				if(n>9) ans -= 2*(n-9)*(n-8)*(n-7)/3;
			}
			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >>B>>C>>D;
  if((C-C%B)/B < (A-A%D)/D){
  cout << "Yes"<< endl;
  }
  else if((C-C%B)/B == (A-A%D)/D && C%B == 0){
  cout << "Yes"<< endl;
  }
  else if((C-C%B)/B == (A-A%D)/D && A%D==0){
  cout << "No"<< endl;
  }
  else if((C-C%B)/B == (A-A%D)/D){
  cout << "Yes"<< endl;
  }
  else if((C-C%B)/B -1 == (A-A%D)/D && C%B==0 && A%D>0){
  cout << "Yes"<< endl;
  }
  else {
  cout << "No"<< endl;
  }
  return 0;
}

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

using namespace std;

const int Maxn = 1e2+7;
const int Maxw = 1e5+7;

int n, W;
long long dp[Maxw];

int main()
{
    cin >> n >> W;
    for(int i = 1, wi, vi; i <= n; ++i)
    {
        cin >> wi >> vi;
        for(int j = W; j >= wi; --j)
            dp[j] = max(dp[j], dp[j-wi]+vi);
    }
    cout << dp[W] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
typedef unsigned long long u64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  u64 c = k;
  for (int i = 1; i < n; ++i) {
    c *= (k-1);
  }
  cout << c << endl;;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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;}

void solve(){
    ll n;cin>>n;
    vl a(n);rep(i,n)cin>>a[i];
    
    ll sz=1;
    ll cnt=0;
    rep(i,n){
        if(i==0){
            cnt+=a[i]-1;
        }else if(a[i]==sz+1){
            sz++;
        }else{
            cnt+=(a[i]-1)/(sz+1);
        }
    }
    cout<<cnt<<endl;
}

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


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(int argc, char*argv[])
{
  const int B = 0, W = 1;
  int l, k;
  cin >> l >> k;
  const int top = l + k;
  long long dp[2][top];
  for(int i = 0; i < top; i++) {
    dp[W][i] = 0;
    dp[B][i] = 0;
  }
  dp[W][0] = 1;
  dp[B][0] = 0;
  long long s = 0;
  for(int i = 0; i < l; i++) {
    dp[W][i+1] += dp[B][i]; 
    dp[B][i+1] += dp[W][i];
    dp[B][i+k] += dp[W][i];
    s += dp[B][i];
  }
  s += dp[B][l];
  
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)


int main() {

int N,K; cin >> N >> K ;

ll ans=0;
while(N>0){
  N/=K;
  ans++;
}

cout << ans << endl;

return 0;
}

Measured memory_bytes: 256
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    			
    		Scanner scan =new Scanner(System.in);
    		
    		int n=Integer.parseInt(scan.next());
    		if (n%2==0) {
    			System.out.print(n);
    		}else {
    			System.out.print(n*2);
    		}
    		
     
    }
    }
// end 

Measured memory_bytes: 23636
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int[] input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        //string input= Console.ReadLine();
        int input =int.Parse(Console.ReadLine());
        string st = input.ToString();
        Console.WriteLine(st.Contains("9")?"Yes":"No");


        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法
 
        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();

    }
}

Measured memory_bytes: 13140
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader reader = new FastReader();
        BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));
        try {
            int n, k;
            n = reader.nextInt();
            k = reader.nextInt();

            boolean haveSnacks[] = new boolean[n];

            for (int j = 0; j < k; j++) {
                int d = reader.nextInt();
                for (int x = 0; x < d; x++) {
                    int a = reader.nextInt();
                    haveSnacks[a - 1] = true;
                }
            }
            
            int ans = 0;
            for (int j = 0; j < n; j++) {
                if (!haveSnacks[j])
                    ans++;
            }
            
            log.write(ans + "\n");
            log.flush();
            log.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

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

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

    public String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return str;
    }
}

Measured memory_bytes: 26828
#include <iostream>
#include <cmath>
#include <string>
#include <string.h>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>
#include <climits>

using namespace std;

typedef struct list {
  int v;
  struct list *prev;
  struct list *next;
} LIST;

LIST *ListFirst=NULL;
LIST *ListLast=NULL;

LIST *search(int x){
  LIST *l;
  if(ListFirst==NULL)
  return NULL;

  l=ListFirst;
  for(;;){
    if(l->v==x)
    return l;
    if(l->next==NULL)
    return NULL;
    else
    l = l->next;
  }
}

void insert(int x){
  LIST *l;
  l = (LIST*)malloc(sizeof(LIST));
  l->v=x;
  l->prev=NULL;
  l->next=ListFirst;
  if(ListFirst)
    ListFirst->prev=l;
  ListFirst = l;
  if(ListLast==NULL){
    ListLast=l;
  }

}

void deleteList(LIST *l){
  if(l->prev && l->next){
    l->prev->next=l->next;
    l->next->prev=l->prev;
  }
  else if(l->prev == NULL && l->next){
    l->next->prev=NULL;
    ListFirst = l->next;
  }
  else if(l->next == NULL && l->prev){
    l->prev->next=NULL;
    ListLast = l->prev;
  } else {
    ListFirst = ListLast = NULL;
  }
  free(l);
}

void delete_l(int x){
  LIST *l;
  l = search(x);
  if(l!=NULL){
    deleteList(l);
  }
}

void deleteFirst(){
  //printf("%p %p %p\n",ListFirst,ListFirst->prev,ListFirst->next);
  deleteList(ListFirst);
}

void deleteLast(){
  //printf("%p %p %p\n",ListLast,ListLast->prev,ListLast->next);
  deleteList(ListLast);
}

void outputList(LIST *l){
  while(l!=NULL){
    printf("%d",l->v);
    l=l->next;
    if(l)
      putchar(' ');
      else
      putchar('\n');
  }
}

int main()
{
  int n,v;
  char cmd[12];

  scanf("%d\n",&n);

  for(int i=0;i<n;i++){
    scanf("%s ",cmd);
    if(strcmp(cmd,"insert")==0){
      scanf("%d\n",&v);
      insert(v);
    //outputList(ListFirst);
    }
    if(strcmp(cmd,"delete")==0){
      scanf("%d\n",&v);
      delete_l(v);
    //outputList(ListFirst);
    }
    if(strcmp(cmd,"deleteFirst")==0){
      deleteFirst();
    //outputList(ListFirst);
    }
    if(strcmp(cmd,"deleteLast")==0){
      deleteLast();
    //outputList(ListFirst);
    }
  }

  outputList(ListFirst);
}



Measured memory_bytes: 34412
import java.util.*;

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

        for(int i = 0; i < n; i++) {
        	arr[i][0] = sc.nextInt();
        	arr[i][1] = sc.nextInt();
        }
        long[] diff = new long[n];
        for(int i = 0; i < n; i++) {
            if(arr[i][0] == 0) continue;
        	diff[i] = arr[i][1] - arr[i][0];
        }
        if(arr[n-1][0] != 0) {
            long num = arr[n-1][1];
            while(num < arr[n-1][0]) {
                  num += arr[n-1][1];
            }
            diff[n-1] = num - arr[n-1][0];
        }
        
        
        for(int i = n-2; i >= 0; i--) {
        	long factor = (diff[i+1] - diff[i] + arr[i][1] - 1) / arr[i][1];
        	diff[i] = factor * arr[i][1] + diff[i];
        }
        System.out.println(diff[0]);
    }
}


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

#define ll            long long
#define pb            push_back
#define si            set <int>
#define F             first
#define S             second
#define mii           map<int ,int >
#define msi           map<string,int >
#define mis           map<int , string>
#define fr(i,a,b)     for(int  i=a;i<=b;i++)
#define loop(i,n)     for(int i=0;i<n;i++)
#define all(v)        v.begin(),v.end()
#define vi            vector<int >
#define vii           vector<pair<int , int >>
#define vs            vector<string>
#define sz(x)         (int )x.size()
#define M             1000000007
#define mp            make_pair
#define input(arr,n)  loop(i,n) cin>>arr[i]
#define output(arr,n) loop(i,n) cout<<arr[i]<<" "
#define mod           998244353
#define sof           sizeof
using namespace std;
int gcd(int a,int b){
  if(b==0)return a;
  return gcd(b,a%b);
}

bool isPrime(int num){
    
    if(num==2) return true;
    if(num<2 || num%2==0) return false;
    for(int i = 3; i*i <=num; i+=2) {
       if(num % i == 0) {
          
          return false;
       }
    }
    return true;
   
}

bool comp(const pair<int,int> &a,const pair<int,int> &b){
  return a.F>b.F;
}



void solve(){
  // a simple dp problem
  int n;
  cin>>n;
  int arr[n];
  input(arr,n);
  int f[n];
  f[0]=0;
  f[1]=abs(arr[1]-arr[0]);
  fr(i,2,n-1){
    f[i]=min(abs(arr[i]-arr[i-2])+f[i-2],abs(arr[i]-arr[i-1])+f[i-1]);
  }
  cout<<f[n-1];



}




signed main()   
{
  ios_base::sync_with_stdio(false);
  cin.tie(0); 
  cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout); 
  #endif  

  int t;
  t=1;
  //cin>>t;
  loop(i,t){

      solve();
      if(i<t-1) cout<<"\n";
  }

  
  
  //directed graph
    



}
  


  



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

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define REVREP(i, n)      for(ll i = n - 1; i >= 0 ; i--)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
#define MOD               998244353

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
ll _accumulate(const VL &v) { return accumulate(ALL(v), (ll)0); }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// 枝定義
struct Edge
{
	int	from;
	int	to;
	Edge(){}
	Edge(int a, int b) : from(a), to(b){}
};

// dfs
vector<vector<int>>	G;
vector<bool>		isUsed;
VL 					ans;
VL					c;
ll					idx;
ll					ansAll;
void dfs(int from, int to)
{
	for (auto nextTo : G[to]) {
		if (from != nextTo) {
			if (!isUsed[nextTo]) {
				ans[nextTo] = c[idx];
				ansAll += c[idx];
				isUsed[nextTo] = true;
				idx++;
				dfs(to, nextTo);
			}
		}
	}
}

// 処理
void Solve()
{
	int N;
	cin >> N;
	vector<Edge>	edgeList;
	REP(i, N - 1) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		edgeList.emplace_back(a, b);
	}
	c.resize(N);
	REP(i, N) cin >> c[i];
	sort(ALL(c), greater<ll>());

	// グラフ作成
	G.clear();
	G.resize(N);
	for (auto one : edgeList) {
		G[one.from].emplace_back(one.to);
		G[one.to].emplace_back(one.from);
	}

	isUsed.resize(N, false);
	ans.resize(N, 0);
	ans[0] = c[0];
	idx++;
	dfs(-1, 0);

	cout << ansAll << endl;
	for(auto one : ans) {
		cout << one << endl;
	}
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef   long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI 3.141592653

int main() 
{
    FAST;
    ll n,m;
    cin>>n>>m;
    ll a[m];
    ll x=0;
    for(int i=0;i<m;i++)
    {
        cin>>a[i];
        x+=a[i];
    }
    if(x>n)
        cout<<-1;
    else
        cout<<n-x;
    return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
/* nichijou */
template<class T,class U>
bool cmax(T & a, const U & b) {return a < b ? a = b, 1 : 0;}
template<class T,class U>
bool cmin(T & a, const U & b) {return b < a ? a = b, 1 : 0;}
/* data type */
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define F first
#define S second
/* STL container */
typedef vector<int> vi;
typedef vector<ll> vll;
#define SZ(a) ((int)(a).size())
#define ALL(a) begin(a), end(a)
#define CLR(a) (a).clear()
#define BK(a) ((a).back())
#define FT(a) ((a).front())
#define DB(a) (a).pop_back()
#define DF(a) (a).pop_front()
#define PB push_back
#define EB emplace_back
/* I gave you my heart and then you turned around. */
void _BG(const char * s) {cerr<<s<<endl;}
template<class T, class ... TT>
void _BG(const char * s,T a, TT...b)
{
    for (size_t c = 0; *s && (c || *s != ','); cerr << *s++)
        c += count(ALL("([{"),*s) - count(ALL(")]}"),*s);
    cerr << " = " << a;
    if (*s) {
        cerr << ", ";
        ++s;
    }
    _BG(s,b...);
}
#ifdef PR3PONY
#define BG(...) do { \
    cerr << __PRETTY_FUNCTION__ << ':' << __LINE__ << ": "; \
    _BG(#__VA_ARGS__,__VA_ARGS__); \
} while(0)
#else
#define BG(...)
#endif
/* Good Luck && Have Fun ! */
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A);
    for (int & x : a) cin >> x;
    vector<int> b(B);
    for (int & x : b) cin >> x;
    int ans = *min_element(ALL(a)) + *min_element(ALL(b));
    while (M--) {
        int x, y, c;
        cin >> x >> y >> c;
        --x, --y;
        ans = min(ans, a[x] + b[y] - c);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024