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

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int d = sc.nextInt();
    int t = sc.nextInt();
    int s = sc.nextInt();
    if (d % s == 0) {
      if (d / s <= t) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    } else {
      if ((d / s) + 1 <= t) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    }
  }
}

Measured memory_bytes: 35720
n=int(input())
a=list(map(int,input().split()))
f=[True if a[i]==i+1 else False for i in range(n)]
ans=0
for i in range(n-1):
    if f[i]:
        f[i]=False
        f[i+1]=False
        ans+=1

if f[n-1]:
    ans+=1
print(ans)

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

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

using namespace std;

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

  rep (i, 1, (int)str.size()) {
	if (str[i] == str[i - 1]) {
	  cout << "Bad" << endl;
	  return 0;
	}
  }

  cout << "Good" << endl;
  return 0;
}


Measured memory_bytes: 256
# Problem C - Unification

# input
S = list(input())

# initialization
zero_count = 0
one_count = 0

# count
for s in S:
    if s=='0':
        zero_count += 1
    else:
        one_count += 1

# output
if zero_count==0 or one_count==0:
    print(0)
elif zero_count>=one_count:
    print(one_count * 2)
else:
    print(zero_count * 2)


Measured memory_bytes: 4012
# coding:utf-8

N, A, B = list(input().split())
A_ = int(A)
B_ = int(B)
N_ = int(N)
i_ = "0"

lists = []
for i in range(N_+1):
    i_ = str(i)
    sum_ = 0
    for x in i_:
        sum_ += int(x)
    if sum_ >= A_ and sum_ <= B_:
        lists.append(i)

#print("list = ", lists)
sum_ = 0
for ele in lists:
    sum_ += ele

#print("sum = ",sum_)
print(sum_)



Measured memory_bytes: 3296
L=int(input());S=bin(L)[2:];N=len(S);print(N,2*N+S.count("1")-3)
for i in range(N-1):
 print(i+1,i+2,0);print(i+1,i+2,2**i)
 if S[N-1-i]=="1":L-=2**i;print(i+1,N,L)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

int N, Q;
const int LIM = 300005;
int c[LIM];
int q[LIM];

int main() {
    fill(c, c+LIM, 0);
    cin >> N >> Q;

    for (int j = 0; j < N; ++j) {
        int x; cin >> x;
        c[x] = 1;
    }
    for (int j = 0; j < Q; ++j) {
        cin >> q[j];
    }
    
    // ---

    for (int j = 1; j < LIM; ++j) {
        c[j] += c[j-1];
    }

    for (int j = 0; j < Q; ++j) {
        int ret = 0;
        for (int k = 0; k < (LIM-1) / q[j] + 1; ++k) {
            int ui = min((k+1)*q[j], LIM);
            int* lb = lower_bound(c + k*q[j], c + ui, c[ui-1]);
            ret = max((long)ret, lb - (c + k*q[j]));
        }
        cout << ret << endl;
    }



    return 0;
}

Measured memory_bytes: 4644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  private void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int heapSize = Integer.parseInt(br.readLine());
      String[] keys = br.readLine().split(" ");
      int[] mHeap = new int[heapSize+1];
      mHeap[0] = heapSize;
      for(int i=1; i<=heapSize; i++)
        mHeap[i] = Integer.parseInt( keys[i-1] );

      buildMaxHeap(mHeap);

      StringBuilder buf = new StringBuilder();
      for(int i=1; i<mHeap.length; i++) 
        buf.append(" ").append(mHeap[i]);

      System.out.println(buf);
    } catch(IOException e) {
      System.out.println("IOException!");
    }
  }
  private void buildMaxHeap(int[] heap) {
    for(int i= heap[0]/2; i>0; i--)
      maxHeapify(heap, i);
  }
  private void maxHeapify(int[] heap, int node) {
    int t,left,right,largest;
    left  = node*2;
    right = left+1;

    if( (left <= heap[0]) && (heap[left] > heap[node]) )
      largest = left;
    else
      largest = node;
    if( (right <= heap[0]) && (heap[right] > heap[largest]) )
      largest = right;

    if( largest != node ) {
      t = heap[node]; heap[node] = heap[largest]; heap[largest] = t;

      maxHeapify(heap, largest);
    }
  }
}


Measured memory_bytes: 74840
using System;
using System.Collections.Generic;
using System.Linq;

class B
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var h = Read();
		var n = h[0];
		var es = new int[h[1]].Select(_ => Read()).ToArray();

		var map = Array.ConvertAll(new int[n], _ => new List<int[]>());
		var indeg = new int[n];
		foreach (var e in es)
		{
			map[e[0]].Add(e);
			indeg[e[1]]++;
		}

		var svs = Enumerable.Range(0, n).Where(v => indeg[v] == 0).ToArray();
		var seq = new List<int>();
		var q = new Queue<int>();

		foreach (var sv in svs)
		{
			seq.Add(sv);
			q.Enqueue(sv);

			while (q.Count > 0)
			{
				var v = q.Dequeue();
				foreach (var e in map[v])
				{
					if (--indeg[e[1]] > 0) continue;
					seq.Add(e[1]);
					q.Enqueue(e[1]);
				}
			}
		}
		Console.WriteLine(string.Join("\n", seq));
	}
}



Measured memory_bytes: 26376
#include<stdio.h>

int main(void){
	int i,m,d,temp;
	int mon[13]={0};
	
	temp = 31;
	mon[0] = 0;
	mon[1] = 31;
	for(i=2;i<12;i++){
		if(i==4||i==6||i==9||i==11)
		mon[i]+=temp+30;
		else if(i==2)
		mon[i]+=temp+29;
		else
		mon[i]+=temp+31;
		temp = mon[i];
	}
	while(scanf("%d %d",&m,&d)){
		if(m==0)
		break;
		temp=(mon[m-1]+d)%7;
		if(temp==1)
		printf("Thursday\n");
		else if(temp==2)
		printf("Friday\n");
		else if(temp==3)
		printf("Saturday\n");
		else if(temp==4)
		printf("Sunday\n");
		else if(temp==5)
		printf("Monday\n");
		else if(temp==6)
		printf("Tuesday\n");
		else if(temp==0)
		printf("Wednesday\n");
	}
	return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s1,s2;
	cin >> s1 >> s2;
	int a,b;
	cin >> a >> b;
	string t;
	cin >> t;
	if(t==s1)
	a--;
	else
	b--;
	cout << a << " " << b << endl;
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int N,M,Q,B[200010],C,D;
int A[200010];
std::string S;

int main(){
	int n,a[100010],min=INF;
	vector<P> v;
	cin>>n;
	REP(i,n){
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=n-2;0<=i;i--){
		v.push_back(P(abs((a[n-1]-a[i])-a[i]),a[i]));
	}
	sort(v.begin(),v.end());
	DEB(v[0].second)END
	cout<<a[n-1]<<" "<<v[0].second<<endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int cnt_odd = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        cnt_odd += a % 2;
    }
    cout << (cnt_odd % 2 ? "NO" : "YES") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
#define MOD 1000000007
#define MAXN 200001
#define f(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rf(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);i--)
using namespace std;
 
int main() {
    ll r;
    cin >> r;
    long double pi=3.141592653589793238;
    long double cir=2*pi*r;
    cout << fixed <<setprecision(18)<<cir;
}

Measured memory_bytes: 3764
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto c = new string[](3);
	foreach (i; 0..3)
	{
		c[i] = RD!string;
	}

	writeln([c[0][0], c[1][1], c[2][2]]);
	stdout.flush();
	debug readln();
}


Measured memory_bytes: 256
def main():
  A, B = map(lambda i: int(i), input().split(' '))
  count = 0
  for i in range(A, B + 1):
    nums = list(str(i))
    if nums[0] == nums[4] and nums[1] == nums[3]:
      count += 1
  print(count)

main()


Measured memory_bytes: 2940
def manhattan(n, x, y):
    x2 = [0] * n
    y2 = [0] * n
    for i in range(n):
        x2[i] = x[i] - y[i]
        y2[i] = x[i] + y[i]
    print(max(max(x2) - min(x2), max(y2) - min(y2)))

n = int(input())
x = [0] * n
y = [0] * n
for i in range(n):
    x[i] , y[i] = map(int, input().split())
manhattan(n, x, y)


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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

typedef pair<int, int> P;

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int INFLL = 1e18;
const int MOD = 1e9 + 7;

signed main(){
    int N, M;
    while( cin >> N >> M, N | M ){
        vector<int> p( N + 1 );
        REP( i, N ) cin >> p[i];
        p[N] = 0;

        vector<int> sum( ( N + 1 ) * ( N + 1 ) );
        int size = 0;
        REP( i, N + 1 ){
            REP( j, N + 1 ){
                sum[size++] = p[i] + p[j];
            }
        }

        sort( ALL( sum ) );

        int ans = 0;
        REP( i, ( N + 1 ) * ( N + 1 ) ){
            auto it = lower_bound( ALL( sum ), M - sum[i] );
            if( it != sum.begin() ){
                chmax( ans, sum[i] + *prev( it ) );
            }
        }

        cout << ans << endl;
    }
}



Measured memory_bytes: 11384
#include<iostream>
using namespace std;
using lli = long long int;

lli dfs(int n, int k, int s, int sum = 0, int prev = 0, int depth = 0){
  if(s < sum)return 0;
  if(depth == k) return sum == s;
  lli res = 0;
  for (int i = prev + 1; i <= n; i++) {
    res += dfs(n, k, s, sum + i, i, depth + 1);
  }
  return res;
}

int main(){
  int n, k, s;
  while(std::cin >> n >> k >> s, n){
    std::cout << dfs(n, k, s) << std::endl;
  }
  return 0;
}




Measured memory_bytes: 3108
#include "bits/stdc++.h"
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    int a[1005];
    for (int i =0; i<n; ++i){
        cin >> a[i];
    }
    int res =0;
    sort(a, a + n);
    while (k--){
        res+=a[k];
    }
    cout << res << endl;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

ll a[20][20];
ll dp[1 << 16];  // dp[i]: iの立っているビットを使用したときの組み合わせの数
ll SCORE[1 << 16]; // USE[i]: iで立ってるビットを同じグループとしたときのスコア

int main() {
    int N;
    cin >> N;
    REP(i, N) REP(j, N) cin >> a[i][j];
    
    // useで同じグループになっているもののスコアを先に計算しておく
    for (int use = 0; use < (1 << N); use++) {
        ll score = 0;
        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                if (((use >> i) & 1) and ((use >> j) & 1)) score += a[i][j];
            }
        }
        SCORE[use] = score;
    }

    // DP
    for (int used = 0; used < (1 << N); used++) { // 使用済みのビット
        int unused = used ^ ((1 << N) - 1); // 未使用のビット        
        for (int use = unused; use > 0; use = (use - 1) & unused) { // unusedの部分集合を列挙
            chmax(dp[use | used], dp[used] + SCORE[use]);
        }
    }

    cout << dp[(1 << N) - 1] << endl;

    return 0;
}

Measured memory_bytes: 1280
N = input()
A = [int(p) for p in input().split(' ')]
stools = list()
stools.append(0)
for k in range(1,len(A)):
    if(A[k-1]>A[k]):
        stools.append(A[k-1]-A[k])
        A[k] = A[k-1]
    else:
        stools.append(0)
print(sum(stools))

Measured memory_bytes: 31988
#include <iostream>
#include <string>
#include <sstream>
#include <stack>

using namespace std;

int main()
{
  string s;
  getline(cin, s);
  getline(cin, s);
  stringstream ss(s);
  stack<string> st;

  while (ss.peek() != EOF) {
    uint t;
    ss >> t;
    st.push(to_string(t));
    if (ss.peek() == EOF) break;
    st.push(" ");
  }

  while (!st.empty()) {
    cout << st.top();
    st.pop();
  }
  cout << endl;
}



Measured memory_bytes: 3312
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m,l;
	cin>>n>>m>>l;
	vl k(n), s(m+1,0);
	cin>>k; rep(i,m)cin>>s[i+1];
	partial_sum(all(s),s.begin());

	sort(rall(k));
	vvl dp(n, vl(n, LINF));
	dp[0][1]=dp[1][0]=(s[k[0]]-s[k[1]-1])/l;
	range(len,3,n+1){
		rep(i,len-2){
			ll j=(i+1==len-1 ? max(i-1,0) : len-2);
			chmin(dp[i][len-1], dp[i][j] + (s[k[j]] - s[k[len-1]-1]) / l );
			chmin(dp[len-1][j], dp[i][j] + (s[k[i]] - s[k[len-1]-1]) / l );
			chmin(dp[j][len-1], dp[j][i] + (s[k[i]] - s[k[len-1]-1]) / l );
			chmin(dp[len-1][i], dp[j][i] + (s[k[j]] - s[k[len-1]-1]) / l );
		}
	}
	ll ans=LINF;
	rep(i,n)range(j,i+1,n)if(i==n-1 or j==n-1){
		chmin(ans, dp[i][j]+(s[k[i]] - s[k[j]-1])/l);
	}
	puta(ans);
	return 0;
}


Measured memory_bytes: 35108
n = int(input())
if 1 <= n < 1e1:
  print(n)
elif 1e1 <= n < 1e2:
  print(9)
elif 1e2 <= n < 1e3:
  print(9+(n-99))
elif 1e3 <= n < 1e4:
  print(9+900)
elif 1e4 <= n < 1e5:
  print(9+900+(n-9999))
else:
  print(9+900+90000)

  

Measured memory_bytes: 2940
from collections import Counter


def main():
    N = int(input())
    S = [input() for _ in range(N)]
    cnt = list(Counter(S).items())
    cnt.sort(reverse=True, key=lambda x: x[1])
    ans = list(filter(lambda x: x[1] == cnt[0][1], cnt))
    ans.sort()
    for s, c in ans:
        print(s)


if __name__ == "__main__":
    main()


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll N,L,ans;
  cin >> N >> L;
  if(1-L<=0){
    ans = N*(L-1)+N*(N+1)/2-L;
    cout << ans << endl;
  }else{
    if(1-L <= N){
      ans = N*(L-1)+N*(N+1)/2;
      cout << ans <<endl;
    }else{
      ans = N*(L-1)+N*(N+1)/2-(L+N-1);
      cout << ans <<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a, const void *b)
{
  return *(int*)b - *(int*)a;
}

int main(void)
{
  int n,i,ans;
  int odd,even;
  int odd_max, even_max;
  int odd_max_num, even_max_num;
  int odd_scnd, even_scnd;
  int odd_scnd_num, even_scnd_num;
  int count_odd_sort[100001]={0};
  int count_even_sort[100001]={0};
  int count_odd_origin[100001]={0};
  int count_even_origin[100001]={0};

  scanf("%d",&n);
  for(i=0;i<n/2;i++){
    scanf("%d %d",&odd,&even);
    count_odd_sort[odd]++;
    count_even_sort[even]++;
    count_odd_origin[odd]++;
    count_even_origin[even]++;
  }
  qsort(count_odd_sort,100001,sizeof(int),cmp);
  qsort(count_even_sort,100001,sizeof(int),cmp);
  for(i=1;i<100001;i++){
    if(count_odd_origin[i]==count_odd_sort[0]){
      odd_max = count_odd_sort[0];
      odd_max_num = i;
    }
    if(count_odd_origin[i]==count_odd_sort[1]){
      odd_scnd = count_odd_sort[1];
      odd_scnd_num = i;
    }
    if(count_even_origin[i]==count_even_sort[0]){
      even_max = count_even_sort[0];
      even_max_num = i;
    }
    if(count_even_origin[i]==count_even_sort[1]){
      even_scnd = count_even_sort[1];
      even_scnd_num = i;
    }
  }

  if(odd_max_num != even_max_num){
    ans = n - odd_max - even_max;
  }else{
    if(odd_max+even_scnd < even_max + odd_scnd){
      ans = n - even_max - odd_scnd;
    }else{
      ans = n - odd_max - even_scnd;
    }
  }
/*****************************************
  printf("%d %d\n",odd_max,odd_max_num);
  printf("%d %d\n",even_max,even_max_num);
  printf("%d %d\n",odd_scnd,odd_scnd_num);
  printf("%d %d\n",even_scnd,even_scnd_num);
*********************************************/
  printf("%d",ans);

  return 0;
}


Measured memory_bytes: 2172
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t H,W;
  cin>>H>>W;
  int64_t ans=100000000000;
  for(int i=0;i<=H;i++){
  int64_t a=W*i;int64_t b=((H-i)/2)*W;
    int64_t c=(H-i-((H-i)/2))*W;
    int64_t A=max(a,max(b,c));
    int64_t B=min(a,min(b,c));
    if(A-B<=ans)ans=A-B;
    int64_t d=(W/2)*(H-i);
    int64_t e=(W-(W/2))*(H-i);
    A=max(a,max(d,e));
    B=min(a,min(d,e));
    if(A-B<=ans)ans=A-B;
   }swap(H,W);
  for(int i=0;i<=H;i++){
  int64_t a=W*i;int64_t b=((H-i)/2)*W;
    int64_t c=(H-i-((H-i)/2))*W;
    int64_t A=max(a,max(b,c));
    int64_t B=min(a,min(b,c));
    if(A-B<=ans)ans=A-B;
    int64_t d=(W/2)*(H-i);
    int64_t e=(W-(W/2))*(H-i);
    A=max(a,max(d,e));
    B=min(a,min(d,e));
    if(A-B<=ans)ans=A-B;
   }cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3620
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

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

			ArrayList<Integer> stateList = new ArrayList<Integer>();
					
			for (int i = 0; i < 3;i ++ ){
				// 整数の入力
				// スペース区切りの整数の入力
				stateList.add(sc.nextInt());
			}
			 
			Collections.sort(stateList);
			
			int sum = 0;
			sum = stateList.get(0) + stateList.get(1);

			// 出力
			System.out.println(sum);
		}
}


Measured memory_bytes: 20820
#include<stdio.h>
int main(void) {
   int a, b[10], c[10], n, B, C, i;
   scanf("%d", &n);
   while ( n ) {
       scanf("%d", &a);
       B = 0; C = 0;
       b[B] = a;
       c[C] = 0;
       for ( i = 1; i < 10; i++ ) {
           scanf("%d", &a);
           if ( a > b[B] && a < c[C]) {B++; b[B] = a; /*printf("b%d c%d a\n", b[B], c[C - 1]);*/}
           else if ( a < b[B] && a > c[C] ) {C++; c[C] = a;/*printf("b%d c%d b\n", b[B], c[C - 1]);*/}
           else if ( a > b[B] && a > c[C] ) {
               if ( b[B] > c[C] ) {B++; b[B] = a; /*printf("b%d c%d c\n", b[B], c[C - 1]);*/}
               else {C++; c[C] = a; /*printf("b%d c%d d\n", b[B], c[C - 1]);*/} 
           } else break;
       }
       if ( i == 10 ) printf("YES\n");
       else printf("NO\n");
       n--;
   }

   return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main()
{
    rep(i, 5) {
        int x;
        cin >> x;
        if(x == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100//000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;
 
vector<vector<int> > s;
vector<int> c;

int score(vector<int> held,int k){
    vector<int> ld(26,0);
    int ans=0;

    rep(i,held.size()){
        int t=held[i];
        ld[t]=i+1;
        ans+=s[i][t];
        rep(j,26){
            ans-=c[j]*(i+1-ld[j]);
        }
    }

    rep(i,26){
        ans-=c[i]*(held.size()+k*(1+k)+1-ld[i]);
    }

    return ans;
}

int main(){
    int d; cin >> d;
    vector<int> cc(26);
    c=cc;
    rep(i,26) cin >> c[i];
    vector<vector<int> > ss(d);
    s=ss;
    rep(i,d)rep(j,26){
        int a; cin >> a;
        s[i].push_back(a);
    }
 
    //vector<int> ld(26,0);
    vector<vector<int> > ds(26);
    vector<int> days(0);

    rep(i,d){
        int now=-INF;
        int whatday;
        rep(j,26){
            vector<int> tmp=days;
            tmp.push_back(j);
            int sc=score(tmp,9);
            if(sc>now){
                whatday=j;
                now=sc;
            }
        }
        days.push_back(whatday);
    }
    rep(i,d) cout << days[i]+1 << endl;
return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define mo 974711
#define MAXN 300005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        res = res * 10 + c - '0';
        c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
        out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,K;
int a[MAXN];
void Solve() {
    read(K);read(N);
    if(K % 2 == 0) {
        out(K / 2);space;
        for(int i = 2 ; i <= N ; ++i) {
            out(K);space;
        }
        enter;
    }
    else {
        for(int i = 1 ; i <= N ; ++i) a[i] = (K + 1) / 2;
        int t = N / 2;
        int p = N;
        while(t--) {
            --a[p];
            if(a[p] != 0) {
                for(int i = p + 1 ; i <= N ; i++) a[i] = K;
                p = N;
            }
            if(a[p] == 0) --p;
        }
        for(int i = 1 ; i <= N ; ++i) {
            if(a[i] != 0) {
                out(a[i]);space;
            }
        }
        enter;
    }

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

Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <algorithm>

void upstair(int *danger, int goal, long long *memo)
{
    memo[0]=1;
    memo[1]=1*danger[1];
    if(goal>=2){
    for(int i=2; i<=goal; i++){
        memo[i]=(memo[i-1]*danger[i]+memo[i-2]*danger[i])%1000000007;
    }
    }
}


int main()
{
    long long memo[100000]={};
    int danger[100000];
    int N,M;
    std::vector<long> a;
    std::cin >> N >> M;
    for(int i=0; i<N+1; i++){
        danger[i]=1;
    }
    for(int i=0; i<M;i++){
        int temp;
        std::cin >> temp;
        danger[temp]=0;
    }
    upstair(danger,N,memo);
    std::cout << memo[N]<< std::endl;
    return 0;
}

Measured memory_bytes: 1408
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   bitcount(x)  (int)__builtin_popcount(x) 
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    map <int,int>  cnt, store ; 
    int  n, x, m, ans = 0 ; 
    cin >> n >> x >> m ; 
    int cur = x ; 
    ans = x ; 
    store[1] = x ; 
    for (int i=2;i<=n;i++){
        cur = (cur*cur%m) ; 
        if (cur) {
            if (cnt[cur]){
                int k = i-cnt[cur];
                int r = n-i+1;
                ans += r/k * ( store[i-1] - store[cnt[cur]-1] ) ; 
                r = r%k;
                ans += store[cnt[cur]+r-1] - store[cnt[cur]-1] ; 
                break;
            }
            else ans += cur; 
        }
        else break ; 
        cnt[cur] = i ; 
        store[i] = ans ; 
     }
    co ( ans ) ; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 9704
import math
import sys

def main():
    s = input()
    a = [(ch) for ch in s]

    ans = 0

    for i in range(1, len(a)):
        if a[i] == a[i - 1]:
            ans += 1
            a[i] = ('1' if a[i] == '0' else '0')

    print(ans)

if __name__ == '__main__':
    sys.exit(main())

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

#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

string s,t;
string ans;
int tmp[222222];


void solve(){
    cin>>s>>t;
    ans=string();
    reverse(all(s));reverse(all(t));
    if(s.size()<t.size())s+=string(t.size()-s.size(),'0');
    if(t.size()<s.size())t+=string(s.size()-t.size(),'0');

    memset(tmp,0,sizeof(tmp));
    rep(i,s.size()){
        tmp[i]+=s[i]-'0'+t[i]-'0';
        tmp[i+1]+=tmp[i]/10;
        tmp[i]%=10;
    }

    rep(i,s.size()){
        ans+=string(1,'0'+tmp[i]);
    }
    if(tmp[s.size()])ans+=string(1,'0'+tmp[s.size()]);
    reverse(all(ans));

    if(ans.size()>80)cout<<"overflow"<<endl;
    else cout<<ans<<endl;
}

signed main(){
    int T;cin>>T;
    while(T--)solve();
}

Measured memory_bytes: 2952
import numpy as np

X, Y, A, B, C = map(int, input().split())

p_l = list(map(int, input().split()))
q_l = list(map(int, input().split()))
r_l = list(map(int, input().split()))

p_l = sorted(p_l)[::-1]
q_l = sorted(q_l)[::-1]
r_l = sorted(r_l)[::-1]

p_X = p_l[:X]
q_Y = q_l[:Y]

all_l = p_X + q_Y + r_l

ans = np.sum(sorted(all_l)[::-1][:X+Y])

print(ans)


Measured memory_bytes: 34336
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	string a;
	cin >> a;
	int ans = INF;
	for (int i = 0; i < a.size() - 2; i++) {
		string b = a.substr(i,3);
		int c = stoi(b);
		if (ans > abs(753 - c))ans = abs(753 - c);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// #include<deque>
// #include<multiset>
// #include<bitset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

const int N = 1e5;
std::vector<std::vector<int>> g;
int n, m;
int s, t;
ll dist[N][3];

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  cin >> n >> m;
  g.resize(n);
  for(int i = 0; i < m; i++) {
    int a, b; std::cin >> a >> b;
    a--; b--;
    g[a].emplace_back(b);
  }
  cin >> s >> t;
  s--, t--;

  using P = tuple<int, int, int>;
  priority_queue<P, vector<P>, greater<P>> pq;

  ll inf = 1e18;
  for(int i = 0; i < n; i++) dist[i][0] = dist[i][1] = dist[i][2] = inf;
  pq.emplace(0, 0, s);
  dist[s][0] = 0;

  while(pq.size()) {
    int v; ll di; int m;
    tie(di, m, v) = pq.top();
    pq.pop();

    for(auto j : g[v]) {
      if(dist[j][(m + 1) % 3] > di + 1) {
        dist[j][(m + 1) % 3] = di + 1;
        pq.emplace(di + 1, (m + 1) % 3, j);
      }
    }
  }

  if(dist[t][0] == inf) dist[t][0] = -3;
  cout << dist[t][0] / 3 << endl;

  return 0;
}


Measured memory_bytes: 8064
#include <stdio.h>          // printf(), scanf()

int
main(int argc, char **argv)
{
	double a;
	int i;

	while (scanf("%lf", &a) != EOF)
	{
		double sum = a;
		for (i = 2; i <= 10; ++i)
		{
			if (i & 1)
				a /= 3.0;
			else
				a *= 2.0;
			sum += a;
		}

		printf("%.8f\n", sum);
	}

	return 0;
}

Measured memory_bytes: 652
import java.util.*;
import java.io.*;

public class Main {	

	private static void solve(){
		//Implement solution here.
		int N = ni();
		int[] A = na(N - 1);
		int[] result = new int[N];
		for(int i:A)result[i - 1]++;
		Arrays.stream(result).forEach(v -> System.out.println(v));
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

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

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;
SINT32 dfs(SINT32 posi,SINT32 data,vector<SINT32> CHECK);

SINT32 N = 0;
int main() {

	SINT32 ANS = 0;

	cin >> N;

	vector<SINT32> CHECK(3);
	ANS = dfs(0,0,CHECK);

	cout << ANS << endl;
	return 0;
}

SINT32 dfs(SINT32 posi, SINT32 data, vector<SINT32> CHECK) {
	SINT32 count = 0;
	vector<SINT32> BUF(3);

	if (data + pow(10,posi)*7 <= N) {
		BUF = CHECK;
		BUF[2] = 1;
		count += dfs(posi+1,data + pow(10,posi)*7,BUF);
		if ((BUF[0] == 1) && (BUF[1] == 1) && (BUF[2] == 1)) {
			count++;
		}
	}

	if (data + pow(10,posi)*5 <= N) {
		BUF = CHECK;
		BUF[1] = 1;
		count += dfs(posi+1,data + pow(10,posi)*5,BUF);
		if ((BUF[0] == 1) && (BUF[1] == 1) && (BUF[2] == 1)) {
			count++;
		}
	}

	if (data + pow(10,posi)*3 <= N) {
		BUF = CHECK;
		BUF[0] = 1;
		count += dfs(posi+1,data + pow(10,posi)*3,BUF);
		if ((BUF[0] == 1) && (BUF[1] == 1) && (BUF[2] == 1)) {
			count++;
		}
	}

	return count;

	
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();

Measured memory_bytes: 256
def binary(s,num):
    left=0
    right=len(s)-1
    while left<=right:
        m=(left+right)//2
        if s[m]==num:
            return 1
        elif s[m]>num:
            right=m-1
        else:
            left=m+1
    return 0


n=int(input())
s=list(map(int,input().split()))
q=int(input())
t=list(map(int,input().split()))
cnt=0
for i in range(q):
    cnt+=binary(s,t[i])
print(cnt)


Measured memory_bytes: 16708
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5, mod = 1e9 +7;
int n,m;

int fac[N];

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n>>m;
    
    if(abs(n-m)>1){
        cout<<0<<endl;
        return 0;
    }
    
    fac[0] = 1;
    for(int i = 1; i <= max(n,m); ++i)fac[i]=(long long)fac[i-1]*i%mod;
    
    
    int ans = (long long) fac[n]*fac[m]%mod;
    if(abs(n-m)==0)ans = (long long) ans *2 %mod;
    cout<<ans<<endl;
    
    
    
    
    
    
    
    return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<',';hr;})
using namespace std;
typedef long long ll;
const int N = 1e4+10, P = 924844033, G = 5, Gi = 554906420;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}

int lim,l,A[N],B[N],R[N];
void init(int n) {
    for (lim=1,l=0; lim<=n; lim<<=1,++l) ;
    REP(i,0,lim-1) R[i]=(R[i>>1]>>1)|((i&1)<<(l-1));
}

void NTT(int *J, int tp=1) {
    REP(i,0,lim-1) if (i<R[i]) swap(J[i],J[R[i]]);
    for (int j=1; j<lim; j<<=1) {
        ll T = qpow(tp==1?G:Gi,(P-1)/(j<<1));
        for (int k=0; k<lim; k+=j<<1) {
            ll t = 1;
            for (int l=0; l<j; ++l,t=t*T%P) {
                int y = t*J[k+j+l]%P;
                J[k+j+l] = (J[k+l]-y)%P;
                J[k+l] = (J[k+l]+y)%P;
            }
        }
    }
    if (tp==-1) {
        ll inv = qpow(lim, P-2);
        REP(i,0,lim-1) J[i]=(ll)inv*J[i]%P;
    }
}

int n,k,fac[N],ifac[N],a[N],b[N];
int C(int n, int m) {
	if (m>n) return 0;
	return (ll)fac[n]*ifac[m]%P*ifac[n-m]%P;
}

int main() {
	fac[0] = 1;
	REP(i,1,N-1) fac[i] = (ll)fac[i-1]*i%P;
	ifac[N-1] = inv(fac[N-1]);
	PER(i,0,N-2) ifac[i]=(ll)ifac[i+1]*(i+1)%P;
	scanf("%d%d", &n, &k);
	REP(i,0,n) a[i]=C(n/k-i,i),b[i]=C(n/k+1-i,i);
	init(2*n);
	NTT(a),NTT(b);
	REP(i,0,lim-1) a[i]=qpow(a[i],(k-n%k)*2)*qpow(b[i],n%k*2)%P;
	NTT(a,-1);
	int ans = 0;
	REP(i,0,n) {
		if (i&1) ans=(ans-(ll)a[i]*fac[n-i])%P;
		else ans=(ans+(ll)a[i]*fac[n-i])%P;
	}
	if (ans<0) ans += P;
	printf("%d\n", ans);
}

Measured memory_bytes: 384
n,m=gets.split.map(&:to_i)
p=gets.split.map(&:to_i)
index = 0
a = Array.new(n)
b = {}
m.times do |i|
  x, y = gets.split.map{|e| e.to_i - 1}

  if a[x].nil? && a[y].nil?
    a[x] = a[y] = index
    b[index] = [x, y]
    index += 1
  elsif a[y].nil?
    a[y] = a[x]
    b[a[x]] << y
  elsif a[x].nil?
    a[x] = a[y]
    b[a[y]] << x
  elsif a[x] != a[y]
    # _i = a[y]
    _y, _x = [x, y].sort_by{|e| b[a[e]].size }
    b[a[_x]] += b[a[_y]]
    b[a[_y]].each do |e|
      a[e] = a[_x]
    end
    # b.delete(_i)
  end
end

res = 0
n.times do |i|
  if p[i] == i+1 || (!a[i].nil? && a[i] == a[p[i]-1])
    res += 1
  end
end

puts res


Measured memory_bytes: 164820
import scala.io.StdIn._
object Main {
  val dp = Array.ofDim[Long](10, 10001)
  dp(0)(0) = 1
  for(i <- 0  until  101) {
    for(j <- 8 to 0 by -1) {
      for(k <- 0 until 1001 
          if i + j <= 1000) {
        dp(j + 1)(i + k) += dp(j)(k)
      }
    }
  }
  def main(args:Array[String]) = {
    var n  = readLine.split(" ").map(_.toInt)
    while((n(1) | n(0)) != 0) {
      println(dp(n(0))(n(1)))
     n  = readLine.split(" ").map(_.toInt)
    }
  }
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }



int main()
{
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    
    string S;
    cin >> S;
    if(S=="Sunny") cout << "Cloudy" << endl;
    else if(S=="Cloudy") cout << "Rainy" << endl;
    else if(S=="Rainy") cout << "Sunny" << endl;
    return 0;


}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#define INF 2e9
#define rep(i,m) for(int i=0;i<m;i++)
#define repn(i,n,m) for(int i=n;i<m;i++)

using namespace std;

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

	while (1)
	{
		c -= b;
		if(c<=0)
		{ 
			cout << "Yes" << endl;
			break;
		}
		a -= d;
		if (a <= 0)
		{
			cout << "No" << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3636
using System;

namespace A___AtCoder_Crackers
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var n = int.Parse(input[0]);
            var k = int.Parse(input[1]);
            if (n % k == 0)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(1);
            }
        }
    }
}

Measured memory_bytes: 13140
#include<stdio.h>
#include<stdlib.h>
double area(double(*)[2], int);
main()
{
        int i, n;
        double (*a)[2];
        scanf("%d", &n);
        a = (double(*)[2])malloc(sizeof(double) * 2 * n);
        for(i = 0; i < n; i++){
                scanf("%lf %lf", &a[i][0], &a[i][1]);
        }
        printf("%.1f\n", area(a, n));
        free(a);
}
double area(double (*a)[2], int n)
{
        int i;
        double sum = 0;
        for(i = 0; i < n; i++){
                sum += a[i][0] * a[(i + 1) % n][1] - a[i][1] * a[(i + 1) % n][0];
        }
        return sum / 2;
}

Measured memory_bytes: 1856
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
	int n, ans = 1;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	a.erase(unique(begin(a), end(a)), end(a));
	for(int i = 2; i < a.size(); i++){
		int b, c;
		b = a[i - 2] - a[i - 1];
		c = a[i - 1] - a[i];
		if((b > 0 && c < 0) || (b < 0 && c > 0)){
			ans++;
			i++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

const int MAX_D = 61;
const int MAX_N = 200005;
int to[MAX_D][MAX_N];


int main(){
	ll n, k;
	cin >> n >> k;
	for(int i = 0; i < n; i++) {
		cin >> to[0][i];
		to[0][i]--;
	}
	rep(i,MAX_D-1)rep(j,n) to[i+1][j] = to[i][to[i][j]];

	int v = 0;
	for(int i = MAX_D-1; i >= 0; i--){
		ll l = 1ll<<i;
		if(l <= k) {
			v = to[i][v];
			k -= l;
		}
	}
	cout << v+1 << endl;
	return 0; 
}

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

 int main() {

int N,kai;
cin >> N;

int i = 0;
while(true){
               if(std::pow(2, i) <= N) {
                        kai = std::pow(2, i);
                        i++;
                        }
               else break;
                }
cout << kai <<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

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; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    long double L;
    cin >> L;
    cout << (L * L * L) / 27.0 << endl;
}

Measured memory_bytes: 256