akhauriyash/Code-Regression huggingface dataset:
/*
    AUTHOR:shivam51
    IIESTS
*/
  #include<bits/stdc++.h>
  using namespace std;
  //
  #define MAX 100001
  #define md 1000000007
  #define add accumulate
  #define ll long long int
  #define ff first
  #define ss second
  #define pb push_back
  #define mp make_pair
  #define vll vector<ll>
  #define lb lower_bound
  #define ub upper_bound
  #define pll pair<ll,ll>
  #define vpll vector<pll>
  #define all(v) v.begin(), v.end()
  #define rep(i,k,n) for(int i=k;i<n;i++)
  #define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
  #define repa(a,n) for(int i=a;i<n;i++)
  //
  //
  int main(){
    ll n;
    cin>>n;
    int arr[n],pre[n],suf[n];
    rep(i ,0 ,n)
      cin>>arr[i];
    pre[0]=arr[0];
    suf[n-1]=arr[n-1];
    rep(i,1,n){
      pre[i]=__gcd(pre[i-1],arr[i]);
    }
    for(int i=n-2;i>=0;i--){
      suf[i]=__gcd(suf[i+1],arr[i]);
    }
    int ans=max(pre[n-2],suf[1]);
    rep(i,1,n-1){
      ans=max(ans,__gcd(pre[i-1],suf[i+1]));
    }
    cout<<ans;
    return 0;
  }

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n,k;cin>>n>>k;
    vector<ll>a(n);
    vector<ll>b(n);
    rep(i,n)cin>>a[i]>>b[i];
    ll ans=0;
    for(int i=29;i>=0;i--){
        ll cnt=0;
        if(((1<<i)&k)==0)continue;
        rep(l,n){
            bool f=1;
            for(int j=29;j>=i;j--){
                if((a[l]&(1<<j))>(k&(1<<j)))f=0;
            }
            if((1<<i)&a[l])f=0;
            if(f)cnt+=b[l];
        }
        ans=max(ans,cnt);
    }
    ll cnt=0;
    rep(i,n){
        bool f=1;
        for(int j=29;j>=0;j--){
            if((a[i]&(1<<j))>(k&(1<<j)))f=0;
        }
        if(f)cnt+=b[i];
    }
    ans=max(ans,cnt);
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void) {
	int n,a,b,sum;
	scanf("%d", &n);
	scanf("%d", &a);
	scanf("%d", &b);
	sum = n * a;
	if (sum < b) {
		printf("%d", sum);
	}
	else {
		printf("%d", b);
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  int A, B, ans	= 0;
  cin >> A>>B;
  if(A>B) {
    ans += max(A, 0);
    A--;
  } else {
    ans += max(B, 0);
    B--;
  }
  if(A>B) {
    ans += max(A, 0);
    A--;
  } else {
    ans += max(B, 0);
    B--;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-

[N, M] = [int(i) for i in input().split()]
a_list = []
for m in range(M):
    a_list.append(int(input()))

stairs_status = [-1] * (N + 1)
stairs_status[0] = 1
for a in a_list:
    stairs_status[a] = 0

for n in range(1, N + 1):
    if n == 1:
        if stairs_status[n] == -1:
            stairs_status[n] = stairs_status[n - 1]
    else:
        if stairs_status[n] == -1:
            stairs_status[n] = stairs_status[n - 1] + stairs_status[n - 2]

#print(stairs_status)
print(stairs_status[-1] % 1000000007)



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

int main() {

	int W, H, x, y;
	cin >> W >> H >> x >> y;

	int is_multiple = 0;
	if (W == x * 2 && H == y * 2) {
		is_multiple = 1;
	}

	printf("%lf %d", double(W) * double(H) / 2, is_multiple);

}


Measured memory_bytes: 256
from collections import deque

def shuffle(in_list, number):

    new_list = in_list[number:len(in_list)] + in_list[0:number]

    return new_list

if __name__ == "__main__":

    while(True):
        param = input()

        if param == "-":
            break

        deck = [c for c in param]

        param = input()
        n = int(param)

        for _ in range(n):
            param = input()
            nn = int(param)
            deck = shuffle(deck, nn)

        res = "".join(deck)
        print(res)



Measured memory_bytes: 6000
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
  int X;
  cin >> X;
  int Amax = 0;
  if(X < 4) printf("%d\n",X);
  else{
    for(int i = 2; i*i <= X; i++){
      int A = i;
      while(A*i <= X){
        A *= i;
      }
      Amax = max(Amax,A);
    }

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


Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

LL n;
 
int main(){
    cin >> n;
    LL ans = HINF<LL>();
    for(LL i = 1;i <= sqrt(n + 1);i++){
        if(n % i == 0){
            ans = min(ans, i + n/i - 2);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from heapq import heapify, heappop, heappush

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    A = [int(a) for a in input().split()]
    q = []
    heapify(q)
    for a in A: heappush(q, -a)
    for m in range(M):
        a = -heappop(q)
        if a == 0: 
            heappush(q, -a)
            break
        else:
            a //= 2
            heappush(q, -a)
    ans = 0
    for _ in range(N):
        ans -= heappop(q)
    print(ans)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 14172
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>

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

typedef long long ll;

using namespace std;

ll gcd(ll n, ll m){
    return m == 0 ? n : gcd(m, n % m);
}

int main() {
    ll a, b, c, d = 0;
    cin >> a >> b >> c >> d;
    ll all = b - a + 1;
    ll muls_c = b / c - (a - 1) / c;
    ll muls_d = b / d - (a - 1) / d;
    ll muls_cd = b / (c * d / gcd(c,d)) - (a - 1) / (c * d / gcd(c,d));
    ll ans = all - muls_c - muls_d + muls_cd;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a;
	int sum = 0;
	rep(i,n){
		int s;cin >> s;
		if(s % 10 != 0) a.pb(s);
		sum += s;
	}
	if(a.size() == 0){
		cout << 0 << endl;
		return 0;
	}
	sort(a.begin(),a.end());
	if(sum % 10 == 0) sum -= a.at(0);
	cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

const int MAX = 2e6+1;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
  if(n >= MAX){
    ll tmp = 1;
    rep(i,k){
      tmp *= (n-i);
      tmp %= MOD;
    }
    return tmp*finv[k]%MOD;
  }

  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll POW(ll x, ll n){
  ll ret = 1;

  if(n < 0){// n < 0 にも対応
    n *= -1;
    x = inv[x];
  }

  while(0 < n){
    if(n%2 == 0){
      x = x*x%MOD;
      n /= 2;
    }
    else{
      ret = ret*x%MOD;
      n--;
    }
  }

  return ret;
}

vi MP(string s){
  vi A(s.size()+1);
  A[0] = -1;
  int j = -1;
  rep(i,s.size()) {
    while(j >= 0 && s[i] != s[j]) j = A[j];
    j++;
    A[i+1] = j;
  }
  return A;
}

vi Manacher(string s){
  vi R(s.size());
  int i = 0, j = 0;
  while(i < s.size()){
    while(i-j >= 0 && i+j < s.size() && s[i-j] == s[i+j]) ++j;
    R[i] = j;
    int k = 1;
    while(i-k >= 0 && i+k < s.size() && k+R[i-k] < j) R[i+k] = R[i-k], k++;
    i += k; j -= k;
  }
  return R;
}

vi Z_algorithm(string &s){
  vi Z(s.size());
  Z[0] = s.size();
  int i = 1, j = 0;
  while(i < s.size()){
    while(i+j < s.size() && s[j] == s[i+j]) j++;
    Z[i] = j;
    if(j == 0){++i; continue;}
    int k = 1;
    while(i+k < s.size() && k+Z[k] < j) Z[i+k] = Z[k], ++k;
    i += k; j -= k;
  }
  return Z;
}

ll f(int r,int c){
  return COM(r+c,r);
}

ll F(int r,int c){
  return COM(r+c+2,r+1)-1;
}

int main(){
  int r1,c1,r2,c2; cin >> r1 >> c1 >> r2 >> c2;
  r1--; c1--;
  COMinit();
  ll ans = (F(r2,c2)-F(r2,c1)-F(r1,c2)+F(r1,c1))%MOD;
  while(ans < 0) ans += MOD;
  cout << ans << endl;
}


Measured memory_bytes: 47104
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n, sum = 0;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      sum += a[i] * a[j];
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
open Scanf
open Printf

let flip f x y = f y x

let rec range a b = if a >= b then [] else a :: range (a+1) b

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)

let rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f
let rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)

let () =
  let n = read_int () in let a = read_int () in printf "%d\n" (n*n-a)


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC073A
{
    class Program
    {
        static void Main(string[] args)
        {
            String n;

            n = Console.ReadLine();

            if (n[0] == '9' || n[1] == '9')
                Console.WriteLine("Yes");

            else
                Console.WriteLine("No");

            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 13140
while True:
    h,w = map(int,input().split())
    if h == 0 and w == 0:
        break
    else:
        for j in range(h):
            if j == 0 or j == int(h)-1:
                print("#" * w)
            else:
                print("#", end = "")
                print("." * (w-2), end ="")
                print("#")
        print()


Measured memory_bytes: 5632
#include <iostream>
#include <cmath>
#include <vector>
#include <iomanip>
using namespace std;
using ll = long long;

const long double PI = acos(-1.0);
const int MOD = 1e9 + 7;

int main() {
    string t;
    cin >> t;
    int n = t.size();

    string ans = "";
    int cnt = 0;
    for(int i = 0; i < n; i++) {
        if(t[i] == '?') {
            cnt++;
            continue;
        }

        if(cnt % 2 == 0) {
            for(int j = 0; j < cnt; j++) {
                ans += 'D';
            }
        }
        else {
            for(int j = 0; j < cnt/2; j++) {
                ans += "DP";
            }
            ans += 'D';
        }
        ans += t[i];
        cnt = 0;
    }

    if(cnt % 2 == 0) {
        for(int j = 0; j < cnt; j++) {
            ans += 'D';
        }
    }
    else {
        for(int j = 0; j < cnt/2; j++) {
            ans += "DP";
        }
        ans += 'D';
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3924
#include <bits/stdc++.h>
#define LL long long
#define FOR(i,c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define F first
#define S second
using namespace std;

const LL mod = 1e9 + 7;

template<typename T> T gcd(T a, T b) { return b == 0?a: gcd(b, a % b); }
template<typename T> T LCM(T a, T b) { return a*(b/gcd(a, b)); }
template<typename T> T expo(T base, T e, T mod) { T res = 1;
  while(e > 0) { if(e&1) res = res * base % mod; base = base * base % mod; e >>= 1; }
  return res;
}
template<typename T, typename S> T expo(T b, S e){if(e <= 1)return e == 0?1: b;\
	return (e&1) == 0?expo((b*b), e>>1): (b*expo((b*b), e>>1));}
template<typename T, typename S> T modinv(T a, S mod) { return expo(a, mod-2, mod); }
template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
	os<<"("<<t.first<<", "<<t.second<<")";
	return os;
}
template<class T> std::ostream& operator<<(std::ostream &os, const std::vector<T> &t) {
	os<<"["; FOR(it,t) { if(it != t.begin()) os<<", "; os<<*it; } os<<"]";
	return os;
}
#define gc getchar_unlocked
template <typename T> void in(T &x) {
	T c = gc(); while(((c < 48) || (c > 57)) && (c!='-')) c = gc();
	bool neg = false; if(c == '-') neg = true; x = 0; for(;c < 48 || c > 57;c=gc());
	for(;c > 47 && c < 58;c=gc())	x = (x*10) + (c - 48); if(neg)	x = -x;
}

const int MAXN = 1e5 + 3;
const int MAXDIST = 10;

int n, m, q;
vector<int> adj[MAXN];
int dist[MAXN];
int C[MAXN];
int dd[MAXN];

struct data {
	int v, d, c;
} qs[MAXN];

void go(int r, int color, int d) {
	if(d > dist[r]) {
		dist[r] = d;
		queue<int> q;
		q.push(r);
		vector<int> V;
		dd[r] = 0;
		while(q.size() > 0) {
			int f = q.front();
			q.pop();
			V.push_back(f);
			// cout << "D: " << f << endl;
			if(C[f] == 0) C[f] = color;
			for(auto &elem: adj[f]) {
				if(dd[elem] == -1 && dist[elem] < d - (dd[f] + 1)) {
					dd[elem] = dd[f] + 1;
					q.push(elem);
					dist[elem] = d - dd[elem];
				}
			}
		}
		for(auto &elem: V) dd[elem] = -1;
	}
}

int main() {
	memset(dd, -1, sizeof dd);
	memset(dist, -1, sizeof dist);
	int a, b;
	in(n), in(m);
	for(int i = 0; i < m; i++) {
		in(a), in(b);
		adj[a].push_back(b), adj[b].push_back(a);
	}
	in(q);
	for(int i = 0; i < q; i++) {
		in(qs[i].v), in(qs[i].d), in(qs[i].c);
	}
	for(int i = q - 1; i >= 0; i--) {
		go(qs[i].v, qs[i].c, qs[i].d);
	}
	for(int i = 1; i <= n; i++) {
		printf("%d\n", C[i]);
	}
  return 0;
}


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

int main(){
    ll N, K;
    cin >> N >> K;
    vector<double> acc(N+1, 0);
    rep(i, 1, N+1){
        double p;
        cin >> p;
        acc[i] = acc[i-1] + (p+1) / 2;
    }
    double ans = -1;
    rep(i, 1, N-K+2){
        ans = max(ans, acc[i+K-1] - acc[i-1]);
    }
    printf("%.12lf\n", ans);
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int day[] = new int[scan.nextInt()];
		
		for(int i = 0; i < day.length - 1;i++) {
			day[scan.nextInt() - 1]++;
			
		}
		
		for(int data : day) {
			System.out.println(data);
			
		}
		
		
	}
}



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


int main(void)
{
    int a,b,c;
    cin >> a >> b >> c;

    if(c-(a-b)<0)
    {
        cout << 0 << endl;
    }
    
    else
    {
        cout << c-(a-b) << endl;
    }
    

    return 0;
}

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

int main() {
    long long N; cin >> N;
    if(N & 1) cout << "0\n";
    else {
        long long res = 0;
        for(long long cur = 5; cur <= N; cur *= 5) {
            res += (N / cur) / 2;
            if(cur > (N + 4) / 5) break;
        }
        cout << res << '\n';
    }   
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	string a;
	cin>>a;
	bool c=false;
	for(int i=0;i<a.length();i++){
		if(c==true){
			if(a[i]=='F') {
				cout<<"Yes";
				return 0;
			}
		}else if(a[i]=='C') c=true;
	}
	cout<<"No";
	return 0;
}

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

int solve(int *cr, int n) {
  int m[101][101];
  for (int i = 1; i <= n; i++) m[i][i] = 0;

  for (int length = 2; length <= n; length++) {
    for (int begin = 1; begin <= n - length + 1; begin++) {
      int end = begin + length - 1;
      m[begin][end] = numeric_limits<int>::max();
      for (int k = begin; k <= end - 1; k++) {
        m[begin][end] = min(m[begin][end], m[begin][k] + m[k + 1][end] + cr[begin - 1] * cr[k] * cr[end]);
      }
    }
  }
  return m[1][n];
}

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

  int n;
  cin >> n;

  int cr[101];

  for (int i = 1; i <= n; i++) {
    cin >> cr[i - 1] >> cr[i];
  }

  cout << solve(cr, n) << endl;

  return 0;
}

Measured memory_bytes: 3188
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

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

  string s;
  cin >> s;
  REP(i, s.size() - 1) {
    if (s[i] == s[i + 1]) {
      cout << i + 1 << " " << i + 2 << endl;
      return 0;
    }
    if (i < s.size() - 2) {
      if (s[i] == s[i + 2]) {
        cout << i + 1 << " " << i + 3 << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1" << endl;
  return 0;
}


Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))

#for i in range(0,n):
#  print (a.count(i+1))
#  a= [a[j] for j in range(0, len(a)) if a[j] != i+1]
#
#  print (a)

kekka= [0] * (n+1)
for i in range(0,n-1):
  kekka[a[i]]+=1

for i in range(1,n+1):
  print (kekka[i])

Measured memory_bytes: 32240
#include <iostream>
#include <string>
template<class T,class C> T min(T a,C b){ return ((a)<(T)(b) ? (a) : (T)(b)); }
using namespace std;
int main(){
  int i,n,result=50,tmp=0,a;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a;
    tmp = 0;
    while(a%2==0){
      a /= 2;
      tmp++;
    }
    result = min(result,tmp);
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3676
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		String ans = "Three";

		for (int i = 0; i < n; i++) {
			if (sc.next().equals("Y")) {
				ans = "Four";
				break;
			}

		}
		System.out.println(ans);
		System.exit(0);
	}
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int a[n];
	int i,j;
	for(i=0;i<n;i++)
	cin>>a[i];
	int b[n];
	memset(b,0,sizeof(b));
	b[1]=abs(a[1]-a[0]);
	for(i=2;i<n;i++)
	{
		int x=INT_MAX;
		for(j=i-1;j>=max(i-k,0);j--)
		x=min(x,b[j]+abs(a[i]-a[j]));
		b[i]=x;
	}
	cout<<b[n-1];
}

Measured memory_bytes: 4268
#include<iostream>
#include<string>
#include<stdlib.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int S[1000];
int top=0;

void push(int x){
    S[++top]=x;
}

int pop(){
    --top;
    return S[top+1];
}

int main()
{
    string x;
    while(cin >> x){
        if(x=="+"){
            push(pop()+pop());
        }
        else if(x=="-"){
            int a=pop();
            int b=pop();
            push(b-a);
        }
        else if(x=="*"){
            push(pop()*pop());
        }
        else{
            push(atoi(x.c_str()));
        }
    }
    cout << pop() << endl;
    return 0;
}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eb emplace_back

int table[10007];
int main() {
    fill_n(table, 10007, inf);
    int V, E; cin >> V >> E;
    if (E == 0) {rep(i, V) cout << i << endl; return 0;}
    vector<int> v[V];
    rep(i, E) {
        int s, t; cin >> s >> t;
        v[t].eb(s);
    }
    vector<int> ans;
    int c = 0;
    rep(i, V) if (v[i].size() == 0) {table[i] = 1; ans.eb(i); c++;}
    while (1) {
        int wflg = 0;
        int flg = 0;
        rep(k, V) {
            //cout << "k " << k << endl;
            if (table[k] != inf) continue;
            flg = 0;
            rep(i, v[k].size()) {
                int bef = v[k][i];
                if (table[bef] == inf) {flg = 1; break;}
            }
            if (flg) continue;
            ans.eb(k);
            table[k] = 1;
            c++;
            if (c == V) {wflg = 1; break;}
        }
        //cout << "wflg " << wflg << endl;
        if (wflg) break;
    }
    rep(i, V) cout << ans[i] << endl;
    
}



Measured memory_bytes: 3856
#include <stdio.h>
int main()
{
	int n,i;
	char c[150];
	scanf("%d",&n);
	getchar();
	gets(c);
	if(n%2!=0)printf("No\n");
	  else {
	  	for(i=n/2;i<n;i++)
	  	if(c[i]!=c[i-n/2])
	  	 {
	  	 	
		  printf("No\n");
		  return 0;
		   }
		   printf("Yes\n");
	  	
	  }
}

Measured memory_bytes: 128
import Control.Monad
import Data.List
main = readLn >>= main'
    where
        main' 0 = return ()
        main' n = replicateM n getLine >>= print . solve >> main

data Elem = Val { val :: Int } | Sum | Prod
    deriving (Show, Eq)

solve :: [String] -> Int
solve = consumeAll . foldl' ff ([], [])
    where
        ff (acc, ds) x
            | null ds || head ds <= d = (next : acc, d : ds)
            | otherwise = ff (acc', ds') x
            where
                d = depth x
                x' = drop d x
                next
                    | x' == "*" = Prod
                    | x' == "+" = Sum
                    | otherwise = Val $ read x'
                (acc', ds') = consume (head ds) acc ds

        depth = inner 0
            where
                inner n (x : xs)
                    | x == '.' = inner (n + 1) xs
                    | otherwise = n

        consume 0 vs ds = (vs, ds)
        consume n vs ds
            | v' == Sum = (sum' ys : vs', ds')
            | otherwise = (product' ys : vs', ds')
            where
                (ys, v' : vs') = splitAt c vs
                ds' = drop c ds
                c = count ds
                count = inner 0
                    where
                        inner m (x : xs)
                            | n == x = inner (m + 1) xs
                            | otherwise = m
                        inner m _ = m

                sum' = Val . foldl' (\acc x -> acc + val x) 0
                product' = Val . foldl' (\acc x -> acc * val x) 1

        consumeAll (vvs@(v : _), dds@(d : _))
            | d == 0 = val v
            | otherwise = consumeAll (vs, ds)
            where
                (vs, ds) = consume d vvs dds

Measured memory_bytes: 4076
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.System.*;


public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(in.readLine());
        int n = Integer.parseInt(st.nextToken());
        int m = Integer.parseInt(st.nextToken());
        if (n!=m) {
            out.println("No");
        }
        else{
            out.println("Yes");
        }

    }

}


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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> A(200009);
  for(int i=0;i<N;i++)cin >> A[i];
  vector<int> q(200001);
  for(int i=0;i<=200000;i++)q[i]=0;
  for(int i=0;i<N;i++){q[A[i]]++;}
  sort(q.begin(),q.end());
  reverse(q.begin(),q.end());
  for(int i=0;i<K;i++){N-=q[i];}
  cout << N << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <utility>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <stack>

using namespace std;

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

const int INF = 1 << 28;

int w, h;
int field[32][32];
int sx, sy;
int gx, gy;

int ofs[4][2] = {
  {0,1},
  {1,0},
  {-1,0},
  {0,-1}
};

bool ok(int p, int n)
{
  return 0 <= p && p < n;
}

bool dfs(int x, int y, int d, int n)
{
  if( d >= n ) {
    return false;
  }

  bool res = false;
  rep(i, 4) {
    int dx = ofs[i][0];
    int dy = ofs[i][1];
    int nx = x;
    int ny = y;
    int idx = 0;
    while(ok(nx, w) && ok(ny, h) && !field[ny][nx]) {
      nx += dx;
      ny += dy;
      if(nx == gx && ny == gy) {
        return true;
      }
      ++idx;
    }
    if( idx > 1 && ok(nx, w) && ok(ny, h) ) {
      field[ny][nx] = 0;
      res |= dfs(nx - dx, ny - dy, d + 1, n);
      field[ny][nx] = 1;
    }
  }
  return res;
}

int idfs(int sx, int sy)
{
  int idx = 1;
  while( idx <= 10 && !dfs(sx, sy, 0, idx) ) {
    ++idx;
  }
  if( idx > 10 ) {
    return -1;
  } else {
    return idx;
  }
}

int main()
{
  while( cin >> w >> h, (h|w) ) {
    rep(i, h) rep(j, w) {
      int v;
      cin >> v;
      field[i][j] = v & 1;
      if( v & 2 ) {
        if( v & 1 ) {
          gx = j;
          gy = i;
        } else {
          sx = j;
          sy = i;
        }
      }
    }

    cout << idfs(sx, sy) << endl;
  }
  return 0;
}

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

int main(){
    
    // 1. 入力情報.
    LL N;
    int Q;
    scanf("%lld %d", &N, &Q);
    
    // 2. クエリ回答.
    LL v, w;
    rep(i, Q){
        scanf("%lld %lld", &v, &w);
        if(N == 1){
            printf("%lld\n", min(v, w));
        }else{
            // 2-1. v <= w に 変換.
            if(v > w) swap(v, w);
            
            // 2-2. w の 祖先 を 計算.
            set<LL> s;
            s.insert(w);
            LL q, r;
            while(w > 1){
                q = (w - 2) / N + 1;
                s.insert(q);
                w = q;
            }
            
            // 2-3. v の 祖先 を 計算.
            while(v > 1){
                if(s.count(v) > 0) break;
                q = (v - 2) / N + 1;
                v = q;
            }
            
            // 2-4. 出力.
            printf("%lld\n", v);
        }
    }
    return 0;
    
}

Measured memory_bytes: 1280
h, w, k = map(int, input().split())
grid = [input() for _ in range(h)]


def bit_to_set(bit, n):
    result = set()
    for b in range(n):
        if (1 << b) & bit:
            result.add(b)
    return result


ans = 0
mask = (1 << w) - 1
for b in range(1 << (h + w)):
    p = bit_to_set(b >> w, h)
    q = bit_to_set(b & mask, w)
    tmp = 0
    for i in range(h):
        if i in p:
            continue
        for j in range(w):
            if j in q:
                continue
            if grid[i][j] == '#':
                tmp += 1
    if tmp == k:
        ans += 1

print(ans)


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

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

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

    // 素数である
    return true;
}

int prime[100010];
int s[100010];
int main(){
    int q; cin >> q;
    for(int i=3;i<=100000;++i){
        if(IsPrime(i) && IsPrime((i+1)/2)){
            prime[i] = 1;
        }
    }
    for(int i=0;i<100010;++i) s[i+1] = s[i] + prime[i];
    for(int i=0;i<q;++i){
        int l,r; cin >> l >> r;
        ++r;
        cout << s[r] - s[l] << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
N, K = gets.split.map &:to_i
MOD = 10**9 + 7

$memo = {}
def fact(n)
  $memo[n] ||= n < 2 ? 1 : n * fact(n - 1)
end

def comb(n, k, mod = MOD)
  fact(n) / fact(n-k) / fact(k) % mod
end

(1..K).each{|n|
  blue_box = n
  blue = K - n
  red_box = blue_box + 1
  red = (N - K) - (n - 1)
  # p [blue, red]
  blue_way = comb(blue + blue_box - 1, blue)
  red_way = comb(red + red_box - 1, red)
  p blue_way * red_way % MOD
}

Measured memory_bytes: 6780
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        x: i64,
    }
    println!("{}", (x + 1000 - 1) / 1000 * 1000 - x);
}


Measured memory_bytes: 2176
<?php
$n = trim(fgets(STDIN));
$bx = $by = $bt = 0;

$flag = true;
for($i = 0; $i < $n; $i++){
    list($t, $x, $y) = explode(" ", trim(fgets(STDIN)));
    $d = abs($x-$bx)+abs($y-$by);
    if($t-$bt >= $d && ($t - $bt - $d) % 2 == 0){
        //OK
    }else{
        $flag = false;
    }
    $bx = $x;
    $by = $y;
    $bt = $t;
}
echo $flag ? "Yes" : "No";



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

int main()
{
  int n, m;
  cin >> n >> m;
  int *N = new int[n];

  for(int i=0; i<n; i++) N[i] = 0;

  for(int i=0; i<m; i++){
    int a, b;
    cin >> a >> b;
    N[a-1]++;
    N[b-1]++;
  }

  for(int i=0; i<n; i++){
    cout << N[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <string>


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

  int h, w;
  std::cin >> h >> w;

  std::string upper(w + 2, '#');
  std::cout << upper << std::endl;
  std::string s;
  for (int i = 0; i < h; i++) {
    std::cin >> s;
    std::cout << '#' << s << '#' << std::endl;
  }
  std::cout << upper << std::endl;

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	int n;
	cin >> n;
	if(n==0) break;
	vector<int> in(n);
	vector<int> p(n);
	vector<int> q(n);
	vector<int> r(n);
	REP(i,n)
	{
	    cin >> in[i] >> p[i] >> q[i] >> r[i];
	}
	int P,Q,R,C;
	bool NAflg = true;
	cin >> P >> Q >> R >> C;
	REP(i,n){
	    if(p[i] <= P && q[i] <= Q && r[i] <= R){
		int c = 4*(p[i]+r[i]) + 9 * q[i];
		if(c<=C){
		    cout << in[i] << endl;;
		    NAflg = false;
		}
	    }
	}
	if(NAflg) cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 1216
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int a[12][12];
int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    rep(i, n){
        cin >> c[i];
        rep(j,m) cin >> a[i][j];
    }
    int ans = inf;
    rep(s, 1<<n) { //s冊分、買う|買わないの2択を全列挙（2^）
        int cost = 0;
        vector<int> d(m); //各アルゴリズムの理解度
        rep(i, n) { // 各本調べる
            if(s>>i&1) { // その本が1が立ってたら=買うフラグなら
                cost += c[i]; //コストに加算
                rep(j, m)d[j] += a[i][j]; //本を読むことで上がる各理解度をそれぞれ加算
            }
        }
        bool ok = true;
        rep(j, m) if(d[j] < x) ok = false; //各アルゴリズムの理解度がx以上になるか
        if(ok) ans = min(ans, cost); //x以上になった組み合わせの最小コスト
    }
    if(ans == inf) cout << -1 << endl; //回答がない場合-1
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define pb push_back
#define opr iterator
#define vi vector<int>
typedef long long ll;
using namespace std;
int tot;
int n,k;
vector<int> can[2001];
bool visit[2001];
int dfs(int pos1,int pos2,int num,int nk)
{
	ll ans=1;
	int size=can[pos1].size();
	if(num!=nk)
	{
		for(int i=0;i<size;i++)
		{
			if(can[pos1][i]==pos2)
			{
				continue;
			}
			ans+=dfs(can[pos1][i],pos1,num+1,nk);
		}
	}
	return ans;
}
int main()
{
	cin>>n>>k;
	for(int i=1;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		can[a].pb(b);
		can[b].pb(a);
	}
	int cnt=0;
	if(k%2==0)
	{
		for(int i=1;i<=n;i++)
		{
			cnt=max(cnt,dfs(i,-1,0,k/2));
		}
	}
	else
	{
		for(int i=1;i<=n;i++)
		{
			for(int p=0;p<can[i].size();p++)
			{
				int j=can[i][p];
				cnt=max(cnt,(dfs(i,j,0,(k-1)/2)+dfs(j,i,0,(k-1)/2)));
			}
		}
	}
	cout<<max(n-cnt,0)<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<string> blue(n);
    for(int i=0; i < n; i++) cin >> blue[i];
    int m;
    cin >> m;
    vector<string> red(m);
    for(int i=0; i < m; i++) cin >> red[i];
    int ans=0;
    auto calc = [&](string s){
        int buf = 0;
        for(string t: blue) {
            if (t == s) buf++;
        }
        for(string t: red) {
            if (t == s) buf--;
        }
        return buf;
    };

    for (string t: blue) {
        ans = max(ans, calc(t));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <string.h>
#include <string>
#include <complex>

using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
#define Rep(i,n) for(int i = 1; i <= n; ++i)
#define lowbit(x) ((x)&(-x))
//#pragma comment(linker,"/STACK:1024000000,1024000000")
#define eps 1e-2
#define sqr(x) ((x)*(x))
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef complex<double>cp;
template<class T>inline void rread(T&num){
    num=0;T f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
    num*=f;
}
const ll inf = 1e18;
const int maxn = 1e6 +10, mod = 1e9 + 7;
const double pi = acos(-1);
ll gcd (ll a, ll b)
{return ( a ? gcd(b%a, a) : b );}
void exgcd(ll a,ll b,ll &d,ll& x,ll& y)
{
    if(!b){d=a;x=1;y=0;}
    else {exgcd(b,a%b,d,y,x);y-=x*(a/b);}
}
cp power(cp a, int n)
{cp p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n)
{ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod)
{ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
//head
ll n,m,r;
bool judge(ll x)
{
    ll d = max(0ll,x-n);
    if(m-2*x-d*2>=0)return true;
    else return false;

}
int main()
{

    while(~scanf("%lld",&n))
    {

        cout<<800*n-200*(n/15)<<endl;


    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a,b;
	cin >> a >> b;
  	if( a*b % 2 == 0)
    {
      cout << "Even" << endl;
    }
  else
  {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort()
p = 1
done = 0

if A[0] == 0:
  print(0)
else:
  for An in A:
    p = p * An
    if p > 10 ** 18:
      print(-1)
      done = 1
      break
  if done == 0:
    print(p)

Measured memory_bytes: 21776
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#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()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
typedef pair<pill,int> PA;
//ll MOD;
ll MOD = 1000000007;
// ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	ll weight;
};
ll dp[55][55][2*55*55]={0};
int n,k;
int main(){
	cin>>n>>k;
	dp[0][0][0]=(ll)1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=i;j++){
			for(int ki=0;ki<=2*i*(i+1);ki++){
				if(j>=1&&ki-2*j>=0){
					dp[i][j][ki]+=dp[i-1][j-1][ki-2*j];
					dp[i][j][ki]%=MOD;
				}
				if(ki-2*j>=0){
					dp[i][j][ki]+=(dp[i-1][j][ki-2*j]*(ll)(2*j+1))%MOD;
					dp[i][j][ki]%=MOD;
				}
				if(ki-2*j>=0){
					ll num=((j+1)*(j+1))%MOD;
					dp[i][j][ki]+=(dp[i-1][j+1][ki-2*j]*num)%MOD;
					dp[i][j][ki]%=MOD;
				}
			}
		}
	}
	cout<<dp[n][0][k]%MOD<<endl;
}


Measured memory_bytes: 129280
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int func(int x){
  if(x%100!=0) return 0;
  return func(x/100)+1;
}

int main(){
  int d,n;
  cin>>d>>n;
  int cnt=0;
  for(int x=1;;x++){
    if(func(x)==d){
      cnt++;
      if(cnt==n){
        cout<<x<<endl;
        return 0;
      }
    }
  }
}

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

const int INF = 1e9;

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

  int b[n];
  int idx1 = 0;
  int idx2 = n-1;
  int i = n-1;
  while (i>=0) {
    b[idx1] = a[i];
    if (i-1>=0) {
      b[idx2] = a[i-1];
    }
    ++idx1;
    --idx2;
    i = i-2;
  }
  for (int i=0; i<n; i++) {
    cout<<b[i]<<" ";
  }
  cout<<endl;
}

Measured memory_bytes: 3712
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

class UF
{
private:
    int         num;
    vector<int> par;
    vector<int> siz;
    vector<ll>  wt;   // diff from par
public:
    vector<ll> parval;   // val of root
public:
    UF(int n): num(n) {
        par.resize(n);
        siz.resize(n);
        wt.resize(n);
        parval.resize(n);
        int i;
        for(i=0; i<n; i++) {
            par[i]=i; siz[i]=1;
            wt[i]=0;
            parval[i]=0;
        }
    }
	
    int find(int x) {
        int p=par[x];
        if(x==p) {
            return x;
        }
        int q=find(p);
        ll diff=wt[q]-wt[p];
        wt[x]-=diff;
        return par[x]=q;
    }

    bool unite(int x, int y, ll diff) {     // val[y]=val[x]+diff
        int px=find(x);
        int py=find(y);
        ll diff0=wt[y]-wt[x];
        diff-=diff0;

        x=find(x);
        y=find(y);
        if(x==y) {
            return (wt[y]==wt[x]+diff);
        }
        if(siz[x]<siz[y]) {
            par[x]=y;
            siz[y]=siz[x]+siz[y];
            //val[y]=val[x]+val[y];
            wt[x]=-diff;
        }
        else {
            par[y]=x;
            siz[x]=siz[x]+siz[y];
            //val[x]=val[x]+val[y];
            wt[y]=diff;
        }
        return true;
    }

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

    int size(int x) {
        return siz[find(x)];
    }

    ll GetWt(int x) {
        int p=find(x);
        return wt[x];
    }

    int ngroup() {
    //int ngroup( int& ans ) {
        int count=0;
        int i;
        for(i=0; i<num; i++) {
            if(par[i]==i) {
                count++;
                //ans += (val[i]? siz[i]: siz[i]-1);
            }
        }
        return count;
    }

    void print() {
        int i;
        printf("par: "); for(i=0; i<num; i++) printf("%d ", par[i]); printf("\n");
        printf("wt:  "); for(i=0; i<num; i++) printf("%lld ", GetWt(i)); printf("\n");
    }
};

void solve()
{
    int n,m;
    scanf("%d%d", &n, &m);
    UF uf(n);
    int i;
    int cnt=0;
    for(i=0; i<m; i++) {
        int l,r,d;
        scanf("%d%d%d", &l, &r, &d); l--; r--;
        bool ok=uf.unite(l,r,d);
        if(ok) {
            cnt++;
        }
    }
    if(cnt==m) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }
    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
int n,k;
cin>>n>>k;
ll a =k*pow((k-1),(n-1));
cout<<a<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n, k, q;
    int i;
    int x;
    ll sum = 0;

    cin >> n >> k >> q;

    vector<int> a(n + 1, 0);

    rep(i, 0, q)
    {
        cin >> x;
        a[x]++;
        sum++;
    }

    rep(i, 1, n + 1)
    {
        if (a[i] + k - sum <= 0)
        {
            cout << "No" << endl;
        }
        else
        {
            cout << "Yes" << endl;
        }
    }
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main()
{
    int a,b,c,i,d=0;
    scanf("%d %d %d",&a,&b,&c);
    for(i=a;i<=b;i++){
        if(i%c==0)
        d++;
        
    }
    printf("%d\n",d);

    return 0;
}

Measured memory_bytes: 1724
while True:
    H,W=map(int,input().split())
    
    if H==0 and W==0:
        break
    
    else:
        for i in range(1,H+1):
            for j in range(1,W+1):
                if i%2==1 :
                    if j%2==1 :
                        print("#",end="")
                    else:
                        print(".",end="")
                else:
                    if j%2==1 :
                        print(".",end="")
                    else:
                        print("#",end="")
            print()
        print()


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

int main()
{
    int N;
    cin >> N;
    int p[N];
    for(int i = 0; i < N; i++)
    {
        cin >> p[i];
    }   
    int check = 0;
    for(int i = 0; i < N; i++)
    {
        if(p[i] != i + 1)
        {
            check++;
        }
    }
    if(check == 0 || check == 2)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
# inputs
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]

# solve
dp = [1] * (n+1)

for i in a:
    dp[i] = 0

for i in range(2, n+1):
    if dp[i] != 0:
        dp[i] = (dp[i - 1] + dp[i - 2]) % (10 ** 9 + 7)

print(dp[n])


Measured memory_bytes: 7848