akhauriyash/Code-Regression huggingface dataset:
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

class UnionFindTree {
public:
    this(size_t n) {
        parent = iota(n).array();
        rank = new size_t[](n);
    }
    size_t find(size_t n) {
        if(n == parent[n]) {
            return n;
        } else {
            parent[n] = find(parent[n]);
            return parent[n];
        }
    }
    void unite(size_t n, size_t m) {
        auto p1 = find(n);
        auto p2 = find(m);
        if(n == m) {
            return;
        }
        if(rank[p1] < rank[p2]) {
            swap(p1, p2);
        }
        if(rank[p1] == rank[p2]) {
            ++rank[p1];
        }
        parent[p2] = p1;
    }
private:
    size_t[] parent;
    size_t[] rank;
}
unittest {
    auto uft = new UnionFindTree(10);
    foreach(i; iota(10)) {
        assert(uft.find(i) == i);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0).drop(1)) {
        uft.unite(i, i-3);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0)) {
        assert(uft.find(0) == uft.find(i));
    }
    foreach(i; iota(10).filter!(a => a%3 != 0)) {
        assert(uft.find(0) != uft.find(i));
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

void main(){
    auto n = readLong();
    string[] s;
    foreach(i; iota(n)) {
        s ~= readln().chomp();
    }
    auto c = new long[][](n, 26);
    foreach(i; iota(n)) {
        foreach(ci; s[i]) {
            c[i][ci - 'a']++;
        }
    }
    auto ans = appender!(char[]);
    foreach(i; iota(26)) {
        long mn = long.max;
        foreach(j; iota(n)) {
            mn = min(mn, c[j][i]);
        }
        ans ~= ('a' + i).to!char.repeat(mn);
    }
    writeln(ans.data);
}



Measured memory_bytes: 256
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
LL ans,n,m;
void solve()
{
    cin>>n>>m;
    if(n<m)
    {
        for(int i=0;i<m;i++)
            cout<<n;
    }
    else
    {
        swap(n,m);
        for(int i=0;i<m;i++)
            cout<<n;
    }
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

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

#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1e9)

int main(){
  ll n,q;
  cin >> n >> q;
  string s;
  cin >> s;

  ll dp[100010] = {};
  //まず0文字目からi<=n-1文字目までのACの数を数えてメモ
  dp[0] = 0;
  if(s[0] == 'A' && s[1] == 'C'){
    dp[1] = 1;
  }

  for(ll i=2; i<n; i++){
    if(s[i]!='C'){
      dp[i] = dp[i-1];
    }else{
      if(s[i-1] == 'A'){
        dp[i] = dp[i-1]+1;
      }else{
        dp[i] = dp[i-1];
      }
    }
  }

  ll l,r;
  rep(i,q){
    cin >> l >> r;
    l--;
    r--;//0-indexedに
    if(l!=0){
      if(s[l-1] == 'A' && s[l]== 'C'){
        cout << dp[r]-dp[l-1]-1 << endl;
      }else{
        cout << dp[r]-dp[l-1] << endl;
      }
    }else{
      cout << dp[r] << endl;
    }
  }
}

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

int main(){
	vector<int> v0, v1;
	int n, k, cnt = 0, ans = 0, curr;
	string s;
	cin >> n >> k;

	cin >> s;
	for(int i = 0 ; i < n ; i++){
		if(s[i] == '0') cnt++;
		else if(cnt){
			v0.push_back(cnt);
			cnt = 0;
		}
	}
	if(cnt) v0.push_back(cnt);

	if(s[0] == '0') v1.push_back(0);
	cnt = 0;
	for(int i = 0 ; i < n ; i++){
		if(s[i] == '1') cnt++;
		else if(cnt){               
			ans = max(ans, cnt);
			v1.push_back(cnt);
			cnt = 0;
		}
	}
	v1.push_back(cnt);         
	                           	
	curr = v1[0];
	for(int i = 0 ; i < k && i < v0.size() ; i++) curr += (v0[i] + v1[i+1]);

	ans = curr;
      	for(int i = k ; i < v0.size() ; i++){
		curr -= (v0[i-k]+v1[i-k]);
		curr += (v0[i]+v1[i+1]);
		ans = max(ans, curr);
	}

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

Measured memory_bytes: 1020
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

int main() {
	int m;
	cin >> m;
	cout << 24 + (24 - m) << endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;

using namespace std;

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

    int a,b,c,d,e;
    cin>>a;

    if(a<=111) cout<<111;
    else if(a<=222) cout<<222;
    else if(a<=333) cout<<333;
    else if(a<=444) cout<<444;
    else if(a<=555) cout<<555;
    else if(a<=666) cout<<666;
    else if(a<=777) cout<<777;
    else if(a<=888) cout<<888;
    else cout<<999;

    cout<<'\n';
    return 0;
}


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

using namespace std;
typedef long long llong;

#define MAX 200001
const llong mod = 1000000000 + 7;

int main()
{
  char S[MAX];
  int Q;
  int t, f;
  char c;
  int isReversed = 0;
  scanf("%s", S);

  vector<char> v(S, S + strlen(S));

  scanf("%d", &Q);

  for (int i = 0; i < Q; i++)
  {
    scanf("%d", &t);
    if (t == 2)
    {
      scanf("%d %c", &f, &c);
      if ((f == 1 && !isReversed) || (f == 2 && isReversed))
      {
        v.insert(v.begin(), c);
      }
      else
      {
        v.push_back(c);
      }
    }
    else
    {
      isReversed = isReversed ? 0 : 1;
    }
  }

  if (isReversed)
    reverse(v.begin(), v.end());

  for (auto ch : v)
  {
    printf("%c", ch);
  }

  return 0;
}

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

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

signed main(){
    int n,k; cin >> n>> k;
    cout<<min(n%k,abs(n%k-k))<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int hist[100];

int main() {
  int n, w;
  while (scanf("%d %d", &n, &w), n|w) {
    MEMSET(hist, 0);
    double ans = 0.01;
    double height = 0;
    int right = 0;
    REP(i, n) {
      int v;
      scanf("%d", &v);
      v /= w;
      hist[v]++;
      right = max(right, v);
      height = max(height, (double)hist[v]);
    }
    REP(i, right + 1) {
      ans += (double)hist[i] / (double)height * (double)(right - i) / (double)right;
    }
    printf("%.5lf\n", ans);
  }
}

Measured memory_bytes: 0
def solve(N: int, M: int, V: int, P: int, A: 'list[int]') -> int:
    from itertools import accumulate

    def is_ok(j):
        from math import ceil

        X = A[j]
        always_add = (P - 1) + 1 + j  # この区間は、すべてのjudgeから加算を受ける

        if V <= always_add:
            return A[N - P] <= X + M

        flat_distribute_block = N - always_add  # A[j]+Mを超過しないように分配する区間
        count_per_judge = V - always_add  # 各judgeが加点する問題数

        block_sum = acc[N - P + 1] - acc[j + 1]  # [j+1,N-P](0-indexed)
        without_exceed = A[N - P] * flat_distribute_block - block_sum  # A[N-P]を超過せずに処理できる投票数
        vote_piled_up = M * count_per_judge - without_exceed

        if vote_piled_up <= 0:
            return A[N - P] <= X + M
        else:
            to_add = ceil(vote_piled_up / flat_distribute_block)
            return A[N - P] + to_add <= X + M

    def binary_search():
        ok = N - 1
        ng = -1
        while abs(ok - ng) > 1:
            mid = (ok + ng) // 2
            if is_ok(mid):
                ok = mid
            else:
                ng = mid
        return ok

    *A, = sorted(A)
    acc = (0,) + tuple(accumulate(A))
    return N - binary_search()


def main():
    import sys
    input = sys.stdin.readline

    N, M, V, P = map(int, input().split())
    A = map(int, input().split())
    print(solve(N, M, V, P, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 14296
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int count(int n) {
    int num = 0;
    while(n) {
        num++;
        n /= 10;
    }

    return num % 2;
}

int main(void) {
    int n;
    cin>>n;

    int ans = 0;
    for(int i = 1;i <= n;i++) {
        ans += count(i);
    }

    cout<<ans<<endl;

    return 0;
}




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

int main(){
 int a,b,c,d,e,k;
 cin >> a  >> b >> c >> d >> e;
 cin >> k;
 
  int dis;
  dis = max(a, (b, c, d, e)) - min(a, (b, c, d, e)); 

  if(k >= dis){
  cout << "Yay!" << endl;
  }else{
 cout << ":(" << endl;
  }
                                  
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
cnt = 0
rate_cnt = [0]*8
for i in range(n):
    if a[i] >= 3200:
        cnt += 1
    elif a[i] >= 2800:
        rate_cnt[7] += 1
    elif a[i] >= 2400:
        rate_cnt[6] += 1
    elif a[i] >= 2000:
        rate_cnt[5] += 1
    elif a[i] >= 1600:
        rate_cnt[4] += 1
    elif a[i] >= 1200:
        rate_cnt[3] += 1
    elif a[i] >= 800:
        rate_cnt[2] += 1
    elif a[i] >= 400:
        rate_cnt[1] += 1
    else:
        rate_cnt[0] += 1
for j in range(8):
    if 0 in rate_cnt:
        rate_cnt.remove(0)
    else:
        break
max_ans = len(rate_cnt)+cnt
if len(rate_cnt) == 0:
    min_ans = 1
else:
    min_ans = len(rate_cnt)
print(min_ans, max_ans)

Measured memory_bytes: 3064
#include<stdio.h>

void swap(int *a, int *b)
{
  int temp;

  temp=*a;
  *a=*b;
  *b=temp;
}

int main(void)
{
  int n;
  int i,j;
  int a[210]={};

  scanf("%d", &n);

  for(i=0;i<2*n;i++)
    scanf("%d",&a[i]);

  for(i=0;i<2*n;i++)
    for(j=i+1;j<2*n;j++)
      if(a[i]<a[j])
        swap(&a[i],&a[j]);

  int sum=0;

  for(i=0;i<2*n;i+=2)
    sum+=a[i+1];

  printf("%d\n",sum);

  return 0;
}


Measured memory_bytes: 128
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        int[] p = new int[n];
        int q1=0;
        int q2=0;
        int q3=0;
        
        for(int i=0; i<n; i++){
        	p[i] = sc.nextInt();
        	if(p[i] <= a){
        		q1++;
        	}else if(p[i] > a && p[i] <= b){
        		q2++;
        	}else{
        		q3++;
        	}
        }

        int min=q1;
        if(q2<=min){
        	min =q2;
        }
        if(q3<=min){
        	min =q3;
        }
        System.out.println(min);
 
    }
}


Measured memory_bytes: 21716
package main

import "fmt"

func main(){
  var D, N int
  fmt.Scan(&D, &N)
	ans := 1
	for i := 0; i < D; i++ {
		ans *= 100
	}
  
  	if N == 100 {
		fmt.Println(ans*N + ans)
	} else {
		fmt.Println(ans * N)
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

int main() {
    int X, N;
    cin >> X >> N;
    if (N == 0) {
        cout << X << endl;
        return 0;
    }

    vector<int> p(N, 0);
    for (auto &x: p)
        cin >> x;
    sort(p.begin(), p.end());

    int center = -1;
    for (size_t i=0; i<p.size(); i++) {
        if (p[i] == X) {
            center = i;
            break;
        }
    }
    if (center == -1) {
        cout << X << endl;
        return 0;
    }

    int diff = 1;
    while (true) {
        int xl = p[center] - diff;
        int j = center - diff;
        if (j < 0) {
            cout << xl << endl;
            break;
        }
        if (xl != p[j]) {
            cout << xl << endl;
            break;
        }
        int xr = p[center] + diff;
        j = center + diff;
        if (j >= N) {
            cout << xr << endl;
            break;
        }
        if (xr != p[j]) {
            cout << xr << endl;
            break;
        }
        diff++;
    }
}


Measured memory_bytes: 3636
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [A, B] = input[0].map(Number);

  return A % 3 === 0 || B % 3 === 0 || (A + B) % 3 === 0
    ? "Possible"
    : "Impossible";
};

console.log(main(read()));


Measured memory_bytes: 29620
#include<iostream>
using namespace std;
int main()
{
  int x[100];
  for(int i=1;i<=5;i++)
  {
    cin>>x[i];
  }
  for(int i=1;i<=5;i++)
  {
    if(x[i]==0)
    {
      cout<<i<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3128
s = input()

if s == 'SUN':
  ans = 7
elif s == 'MON':
  ans = 6
elif s == 'TUE':
  ans = 5
elif s == 'WED':
  ans = 4
elif s == 'THU':
  ans = 3
elif s == 'FRI':
  ans = 2
elif s == 'SAT':
  ans = 1
  
print(ans)

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

typedef long long ll;
using namespace std;

#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define _repi(i, s, n) for(ll i = (ll)(s); i < (ll)n; i++)
#define REP(...) _overload(__VA_ARGS__, _repi, _rep,)(__VA_ARGS__)
#define all(v) (v).begin(),(v).end()
#define UNIQUE(v) (v).erase( unique( all(v) ), (v).end() );
#define MOD 1000000007

int main(){
	ll n, k;	cin >> n >> k;
	ll h[n];
	ll sum = 0;
	REP(i, n){
		cin >> h[i];
	}

	sort( h, h + n, greater<ll>() );

	REP(i, k, n){
		sum += h[i];
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 5172
#include <stdio.h>

int M, N;
int A[114514];

int main(void) {
	int i;
	if (scanf("%d%d", &M, &N) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}
	if (M <= 2) {
		int hoge = 0, fuga = 0;
		for (i = 0; i < N; i++) {
			if (A[i] != (i % 2 == 0 ? 1 : 2)) hoge++;
			if (A[i] != (i % 2 == 0 ? 2 : 1)) fuga++;
		}
		printf("%d\n", hoge <= fuga ? hoge : fuga);
	} else {
		int miyukiti = 0;
		for (i = 1; i < N; i++) {
			if (A[i - 1] == A[i]) {
				miyukiti++;
				i++;
			}
		}
		printf("%d\n", miyukiti);
	}
	return 0;
}



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

int main() {
	string S; cin >> S;
	int bf=0, wf=0;
	for(int i=0; i<S.size(); ++i){
	    if(S[i]=='0' ^ i%2==0) ++wf;
	    else ++bf;
	}
	cout << min(wf, bf) << endl;
	return 0;
}


Measured memory_bytes: 512
def main():
  S = input()
  
  if S[0] != 'A':
    print("WA")
    return
  if S[1].isupper() or S[-1].isupper():
    print("WA")
    return
  cnum = 0
  for i in S[1:-1]:
    if i == 'C':
      cnum +=1
    elif i.isupper():
      print("WA")
      return
  if cnum == 1:
    print("AC")
  else:
    print("WA")

main()

Measured memory_bytes: 3060
N,M,C=map(int,input().split())
B=list(map(int,input().split()))

ans=0
K=[0]*M

for i in range(N):
  A=list(map(int,input().split()))
  for j in range(M):
    K[j]=A[j]*B[j]
  if sum(K)+C > 0:
    ans += 1

print(ans)

Measured memory_bytes: 3060
N, K = map(int, input().split())
vals = list(map(int, input().split()))

objs = [None for i in range(K+1)]

objs[0] = -1

for i in range(K+1):
    score = -1
    for a in vals:
        if a <= i:
            score = max(score, -objs[i-a])
    objs[i] = score

if objs[-1] == 1:
    print("First")
else:
    print("Second")


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

int n, m, a;
bool v[10];
bool f(int p) {
	while (p > 0) {
		if (v[p % 10]) return false;
		p /= 10;
	}
	return true;
}
int main()
{
	int i;
	cin >> n >> m;
	while (m--) {
		scanf ("%d", &a);
		v[a] = 1;
	}
	for (i = n; ; i++) {
		if (f(i)) {
			cout << i;
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,cnt;
    
    while(1){
        scanf("%d",&n);
        if(n==0)break;
        
        cnt=0;
        do{
            n/=5;
            cnt+=n;
        }while(n!=0);
        
        printf("%d\n",cnt);
    }
    return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <vector>
#include <tuple>

using namespace std;

typedef tuple<int, int, int> ti;

int l;

int main() {
	scanf("%d", &l);
	int n = 1;
	while ((1 << n) <= l) n++;
	vector<ti> res;
	int w = (1 << (n - 2));
	for (int i = 2; i <= n; i++) {
		res.push_back(ti(i - 1, i, 0));
		res.push_back(ti(i - 1, i, w));
		w >>= 1;
	}
	int add = (1 << (n - 1));
	while (add < l) {
		for (int i = 2; i <= n; i++) {
			if (add + (1 << (n - i)) <= l) {
				res.push_back(ti(1, i, add));
				add += (1 << (n - i));
				break;
			}
		}
	}
	printf("%d %d\n", n, (int)res.size());
	for (int i = 0; i < res.size(); i++)
		printf("%d %d %d\n", get<0>(res[i]), get<1>(res[i]), get<2>(res[i]));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int h,w;
while(1){
cin >> h >> w;
if(h==0 && w==0)break;
for(int i=0; i<h; i++){
for(int j=0; j<w; j++){
if(i==0 || i==h-1 || j==0 || j==w-1)cout << "#";
else cout << ".";
}
cout <<endl;
}
cout <<endl;
}
return 0;
}


Measured memory_bytes: 3136
#include <cstdlib>
#include <cstdio>
#include <cstring>

bool is_kaibun(const char* s, int n){
    for(int i=0;i<n/2;i++)
        if(s[i]!=s[n-i-1]) return false;
    return true;
}

int main()
{
    char S[100];
    scanf("%s",S);
    int N=strlen(S);
    printf("%s\n",is_kaibun(S,N)&&is_kaibun(S,N/2)&&is_kaibun(S+N/2+1,N/2)?"Yes":"No");
}

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

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

using namespace std;

int main(){
  string s;cin>>s;
  cout<<( (s.substr(0,4)=="YAKI")?"Yes" : "No" )<<endl;
  return 0;
}

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

int main() {
  string s;
  cin >> s;
   if (s == "RRR")
     cout << 3 << endl;
  else if (s == "RRS" || s == "SRR")
    cout << 2 << endl;
  else if (s == "SSS")
    cout << 0 << endl;
  else
    cout << 1 << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
#define INF 10000000000
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

vector<ll> dist(100005);
vector<int> visit(100005);
vector<vector<pair<int,int>>> edge(100005);

void dfs(int v,ll d){
    dist[v]=d;
    visit[v]=1;
    for(int i=0;i<edge[v].size();i++){
        if(visit[edge[v][i].first]==0) dfs(edge[v][i].first,d+edge[v][i].second);   
    }
}

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        edge[a].push_back({b,c});
        edge[b].push_back({a,c});
    }
    int q,k;
    cin>>q>>k;
    k--;
    vector<pair<int,int>> que(q+5);
    for(int i=0;i<q;i++){
        int x,y;
        cin>>x>>y;
        x--;y--;
        que[i]={x,y};
    }
    dfs(k,0);
    for(int i=0;i<q;i++) cout<<dist[que[i].first]+dist[que[i].second]<<endl;
    return 0;
}

Measured memory_bytes: 12416
MAX = 10**9 + 7
 
 
H, N = map(int, input().split())
damage_costs = [tuple(map(int, input().split())) for _ in range(N)]

dp = [MAX] * (H + 1 + max(damage_costs, key=lambda x: x[0])[0])
dp[0] = 0

for (ai, bi) in damage_costs:
    for i, dp_i in enumerate(dp):
        if i >= ai:
            dp[i] = min(dp_i, dp[i - ai] + bi)

print(min(dp[H:]))


Measured memory_bytes: 42348
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define endl "\n"
#define cv(c) (int)(c-'a')
#define db(x) cerr << #x << ": " << x << " "
#define db2(x, y) cerr << #x << ": " << x << " " << #y << ": " << y << " "
#define bn() cerr << endl
#define sep() cerr << "-------" << endl

using namespace std;
typedef long long ll;
typedef long double ld;

int v[102];
int main(){
    ios::sync_with_stdio(false);
    int k, t;
    cin >> k >> t;

    for (int i = 0; i < t; i++){
        cin >> v[i];
    }
    sort(v, v + t);

    int acum = v[t - 1];
    for (int i = t - 2; i >= 0; i--){
        acum = abs(acum - v[i]);
    }
    cout << max(0, acum - 1) << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
int n;
cin>>n;
vector<int> a(n);
int s1 = 0,s2 =0 ;
for(int i=0;i<n;i++){
	cin>>a[i];
	s1+=a[i];
}
int res = s1;
for(int i=0;i<n;i++){
	s1 -= a[i];
	s2 += a[i];
	res = min(res,abs(s1-s2) );
}

	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,p;
	int age[7];
	while(1){
		cin >> n;
		if(n == 0) return 0;
		for(int i=0; i<7; i++) age[i]=0;
		for(int i=0; i<n; i++){
			cin >> p;
			if(p < 10)
				age[0]++;
			if(p >= 10 && p < 20)
				age[1]++;
			if(p >= 20 && p < 30)
				age[2]++;
			if(p >= 30 && p < 40)
				age[3]++;
			if(p >= 40 && p < 50)
				age[4]++;
			if(p >= 50 && p < 60)
				age[5]++;
			if(p >= 60)
				age[6]++;
		}
	for(int i=0; i<7; i++)
		cout << age[i] << endl;
	}
	return 0;
}

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

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

typedef long long unsigned int ll;

int n;
vector<int> vc;


int main(){
  cin >> n;
  string res = "Yes";
  rep(i, n){
    int a;
    cin >> a;
    vc.push_back(a);
  }
  reverse(vc.begin(), vc.end());
  rep(i, n-1){
    if(vc[i] >= vc[i+1]){
      //何もしない
    }else if(vc[i] + 1 ==vc[i+1]){
      vc[i+1] -= 1;
    }else{
      res = "No";
      break;
    }
  }
  cout << res << endl;
}

// int main(){
//   cin >> n;
//   int a, b, c;
//   if(n == 1){
//     cin >> a;
//     cout << "Yes" << endl;
//     return 0;
//   }
//   else if(n == 2){
//     cin >> a;
//     cin >> b;
//     // cout << a << " " << b << endl;
//     // cout << (a == b) << endl;
//     if(a < b || a == b || a == b+1){
//       cout << "Yes" << endl;
//       return 0;
//     }else{
//       cout << "No" << endl;
//       return 0;
//     }
//   }
//   int x[n];
//   rep(i, n){
//     cin >> x[i];
//   }

//   rep(i, n-2){
//     if(i == 0){
//       cin >> a;
//       cin >> b;
//       cin >> c;
//     }else{
//       a = b;
//       b = c;
//       cin >> c;
//     }
//     if(a > c + 1){
//         // if(i == n-3){
//         //   continue;
//         // }
//         cout << "No" << endl;
//         return 0;
//       }
//   }

//   if(b - 1 <= c){
   
//   }else{
//     cout << "No" << endl;
//     return 0;
//   }

//   cout << "Yes" << endl;
// }

Measured memory_bytes: 892
import sys, math
from collections import deque
from collections import Counter

readline = sys.stdin.readline

N = int(readline())
S = [readline().rstrip() for i in range(N)]

S = [''.join(sorted(s)) for s in S]

c = Counter(S)

count = 0
for x in c.values():
    count += x * (x - 1) // 2

print(count)

Measured memory_bytes: 71260
#include <bits/stdc++.h>
 
using namespace std;
 
#define INPUT_OUTPUT { \
	freopen("input.txt", "r", stdin); \
	freopen("output.txt", "w", stdout); \
}
#define ll long long
#define Pi acos(-1)
 
int main()
{
	//INPUT_OUTPUT;
	int n;
	cin >> n;
	cout << (n*n) << endl;
	return 0;
}

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

int main() {

	int a, b, c;
	cin >> a >> b >> c;

	if (a == b && b == c) {
		cout << "1" << endl;
	}
	else if (a != b && b != c && c != a) {
		cout << "3" << endl;
	}
	else {
		cout << "2" << endl;
	}

	return 0;
}
//*/

Measured memory_bytes: 256
n, m = map(int, input().split())
As = [[] for i in range(8)]
for i in range(n):
    x,y,z = map(int, input().split())
    As[0].append(-x-y-z)
    As[1].append(-x-y+z)
    As[2].append(-x+y-z)
    As[3].append(-x+y+z)
    As[4].append(x-y-z)
    As[5].append(x-y+z)
    As[6].append(x+y-z)
    As[7].append(x+y+z)

ans = 0
for a in As:
    a.sort(reverse=True)
    s = sum(a[:m])
    ans = max(ans,s)
print(ans)

Measured memory_bytes: 9452
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        //static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var Mod = 998244353L;
            var N = Sarray()[0];
            var Ai = Sarray();
            var dct = new Dictionary<long, long>();
            if (Ai[0] != 0)
            {
                WriteLine(0);
                return;
            }
            for (var i = 0; i < N; ++i)
            {
                if (!dct.ContainsKey(Ai[i])) dct[Ai[i]] = 0;
                ++dct[Ai[i]];
            }
            if ( 1 != dct[0])
            {
                WriteLine(0);
                return;
            }
            var max = Ai.Max();
            var ans = 1L;
            for (var i = 1; i <= max; ++i)
            {
                if (!dct.ContainsKey(i))
                {
                    WriteLine(0);
                    return;
                }
                var t = modpow(dct[i - 1], dct[i], Mod);
                ans = (ans * t) % Mod;
            }
            WriteLine(ans % Mod);
            //Out.Flush();
        }
        static long modpow(long a, long n, long mod)
        {
            var res = 1L;
            if (0 < n)
            {
                res = modpow(a, n / 2, mod);
                res = res * res % mod;
                if (0 != n % 2) res = res * a % mod;
            }
            return res;
        }
    }
}

Measured memory_bytes: 26464
#include <bits/stdc++.h>
#define double long double
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
  int n,k;
  cin>>n>>k;
  int sum=0;
  rep(i,n) {
    int a;
    cin>>a;
    sum+=2*min(a,k-a);
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
// #define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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;
}
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;
const int M = 1000000;
vector<int> dp(M+10);
vector<int> dpodd(M+10);
vector<int> num;
vector<int> numodd;
/*----------------------------------------------------------------*/
signed main(){

	for(int i = 1;;i++){
		int x = i*(i+1)*(i+2)/6;
		if(x > M)break;
		num.pb(x);
		if(x%2 == 1)numodd.pb(x);
	}
	rep(i,M)dp[i+1] = dpodd[i+1] = INTINF;
	rep(i,M){
		for(auto x:num){
			if(i+x > M)break;
			chmin(dp[i+x],dp[i]+1);
		}
		for(auto x:numodd){
			if(i+x > M)break;
			chmin(dpodd[i+x],dpodd[i]+1);
		}
	}
	
    while(1){
		int n;
		cin >> n;
		if(n == 0)return 0;
		cout << dp[n] << " " << dpodd[n] << endl;
	}

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_d


Measured memory_bytes: 10488
w,h,n=map(int,input().split())
xya=[list(map(int,input().split())) for i in range(n)]

My=h
Mx=w
my=0
mx=0
for x,y,a in xya:
    if a==1 and mx<x:mx=x
    if a==2 and Mx>x:Mx=x
    if a==3 and my<y:my=y
    if a==4 and My>y:My=y

if Mx-mx<=0 or My-my<=0:print(0)
else:print((Mx-mx)*(My-my))

Measured memory_bytes: 3064
n,k = list(map(int, input().split()))
a=list(map(int, input().split()))
x=0
ans = 0
for i in range(45,-1,-1):
  c=0
  for p in a:
    if (p >> i) & 1:
      c += 1
  if n - c > c and x + (1<<i) <= k:
    ans += (n-c) * (1<<i)
    x += 1<<i
  else:
    ans += c * (1<<i)
print(ans)

Measured memory_bytes: 14620
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const double PI = acos(-1.0);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

struct RandomNumberGenerator {
  mt19937 mt;

  RandomNumberGenerator() : mt(chrono::steady_clock::now().time_since_epoch().count()) {}

  int operator()(int a, int b) { // [a, b)
    uniform_int_distribution< int > dist(a, b - 1);
    return dist(mt);
  }

  int operator()(int b) { // [0, b)
    return (*this)(0, b);
  }
};

RandomNumberGenerator RNG;
const unsigned long long base = RNG(10,1<<30);

template <typename S>
struct RollingHash {
    typedef unsigned long long ull;

    const ull MASK30 = (1ull << 30) - 1;
    const ull MASK31 = (1ull << 31) - 1;
    const ull mod = (1ull << 61) - 1;
    const ull POSITIVIZER = mod * 3;

    vector<ull> hash,power;

    RollingHash(const S &s) {
        int sz = s.size();
        hash.assign(sz + 1,0);
        power.assign(sz + 1,1);
        for (int i = 0; i < sz; i++) {
            power[i+1] = CalcMod(Mul(power[i],base));
            hash[i+1] = CalcMod(Mul(hash[i],base) + s[i]);
        }
    }

    ull get(int l, int r) { // [l,r) (0-indexed)
        ull res;
        res = CalcMod(hash[r] + POSITIVIZER - Mul(hash[l],power[r-l]));
        return res;
    }

	int LCP(RollingHash &b, int l1, int r1, int l2, int r2) {
		int len = min(r1 - l1, r2 - l2);
    	int low = -1, high = len + 1;
    	while(high - low > 1) {
      		int mid = (low + high) / 2;
      		if(get(l1, l1 + mid) == b.get(l2, l2 + mid)) low = mid;
      		else high = mid;
    	}
    	return (low);
	}

    ull Mul (ull a, ull b) {
        ull au = a >> 31;
        ull ad = a & MASK31;
        ull bu = b >> 31;
        ull bd = b & MASK31;
        ull mid = ad * bu + au * bd;
        ull midu = mid >> 30;
        ull midd = mid & MASK30;
        return (au * bu * 2 + midu + (midd << 31) + ad * bd);
    }

    ull CalcMod(ull val) {
        val = (val & mod) + (val >> 61);
        if (val > mod) val -= mod;
        return val;
    }
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> A(N),B(N);
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];

    vector<ll> P(2*N),Q(N);
    rep(i,2*N) P[i] = A[i%N]^A[(i+1)%N];
    rep(i,N) Q[i] = B[i%N]^B[(i+1)%N];
    RollingHash<vector<ll>> RHA(P),RHB(Q);
    vector<pll> ans;
    rep(i,N) {
        if (RHA.get(i,i+N)==RHB.get(0,N)) {
            ans.emplace_back(i,A[i]^B[0]);
        }
    }

    for (auto i : ans) cout << i.first << " " << i.second << ln;
}


Measured memory_bytes: 24044
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define pob pop_back
#define vi vector<ll>
#define mp make_pair
#define sz size()
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define maxx 100005
#define edge pair<ll,ll>
#define mod 1000000007
using namespace std;
 
 
// ¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++¦¦¦++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++¦¦¦¦¦¦¦¦¦¦+++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++¦¦¦¦¦+++++++¦++¦¦
// ¦¦¦¦¦¦¦¦++¦¦¦¦¦¦++++++¦¦¦¦+++++++++++++¦
// ¦¦¦¦¦¦¦++++++¦¦¦++++++¦¦++++++++++++++¦¦
// ¦¦¦¦¦¦¦+++++++¦¦¦+++++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++¦¦¦¦¦¦¦¦¦++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++¦¦¦¦¦¦¦¦+++++++¦ 
// ¦¦¦¦¦¦¦¦¦¦++¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦++++¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦ 
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++¦¦+¦++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++¦¦+++++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+¦¦¦¦+++¦¦¦¦++++++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++¦¦+¦¦¦¦¦+++++++¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++++++¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+¦¦¦+++++++++++¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++¦¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++¦¦¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++¦¦¦¦¦¦¦¦¦¦¦¦

//ll dp[maxx];
//ll par[maxx];


int main()
{
	
	fast;
	ll n;
	string s;
	float m;
	cin>>n>>m;
	ll a[n];
	ll i;
	for(i=0;i<n;i++) cin>>a[i];
	float sum=0;
	
	
	
	
	for(i=0;i<n;i++)
	{
		sum+=a[i];
	}

	ll cnt=0;
	
for(i=0;i<n;i++){
        float tmp1 = float(sum)/float(4*m);
        float tmp2 = float(a[i]);
        if(tmp2>=tmp1){
            cnt++;
        }
    }
	if(cnt>=m)
	cout<<"Yes"<<endl;
	else
	{
		cout<<"No"<<endl;
	}
	
	return 0;
}
//cout<<"YES"<<endl;

//cout<<"NO"<<endl;


Measured memory_bytes: 256
N, L = map(int, input().split())
apple_list = [L + i for i in range(N)]
tmp = 0

if 0 in apple_list:
    print(sum(apple_list))

else:
    for i in range(1, N):
        if abs(apple_list[i]) < abs(apple_list[tmp]):
            tmp = i

    apple_list.remove(apple_list[tmp])
    print(sum(apple_list))

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

int main()
{
    int n, m, x, a[110] = {};
    cin >> n >> m >> x;
    for (int i = 0; i < m; i++) cin >> a[i];

    sort(a, a + m);
    int ans = 0, cnt = 0;
    for (int i = 0; i < m; i++) {
        if (a[i] < x) ans++;
        else cnt++;
    }
    ans = min(ans, cnt);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

//===
// nCr mod p
// p is prime
// 1 <= k <= n <= 1e7

void init_comb(long long modulus);
void init_comb(void);
long long combination(long long n, long long k);
long long pow_mod(long long n, long long m);

long long _modulus = (long long)1e9 + 7;
long long fact[10000007];
long long fact_inv[10000007];

void init_comb(long long modulus) {_modulus = modulus; }
void init_comb(void) {
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    for (int i = 2; i <= 10000; i++) {
        fact[i] = fact[i - 1] * i % _modulus;
        fact_inv[i] = pow_mod(fact[i], _modulus - 2);
    }
}

long long combination(long long n, long long k) {
    static long long f;

    if (f != _modulus) f = _modulus, init_comb();

    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;

    return fact[n] * (fact_inv[k] * fact_inv[n - k] % _modulus) % _modulus;
}

long long pow_mod(long long n, long long m) {
    //n ** m;
    long long ret = 1;

    while (m) {
        if (m & 1) {
            ret = ret * n % _modulus;
        }

        n = n * n % _modulus;
        m = m >> 1;
    }

    return ret;
}
//===

llong n, k;

int main() {
    cin >> n >> k;

    llong red = n - k;
    llong blue = k;

    for (int i = 1; i <= k; i++) {
        llong a = combination(red + 1, i);
        llong b = combination(blue - 1, i - 1);

        cout << a * b % ((llong)(1e9) + 7) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <algorithm>
#include <cmath>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <cstring>
#include <climits>
#include <iomanip>

#define EPS 1e-7
#define LLMAX 9223372036854775807
#define INTMAX 2147483647
#define ULLMAX 18446744073709551615
#define precision(n) cout << setprecision(n) << fixed
#define forn(i, n) for (int i = 0; i<(int)n; ++i)
#define forr(i, t, n) for (int i = t; i<n; ++i)
#define rforr(i, t, n) (int i = n-1; i>=t; --i)
#define rfor(i, n) for (int i = n-1; i>=0; --i)
#define rmod(x, y) (((x%y)+y)%y)
#define pb push_back
#define emp emplace_back
using namespace std;
typedef vector<int>::iterator vit;
typedef unsigned int uint;
typedef unsigned short ushort;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int MAXN = 1024;

//STRUCTS


//OPERATORS


//GLOBALS


//FUNCTIONS


//PROBLEM: 
//LINK: 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	#ifndef ONLINE_JUDGE
	//	freopen("_input.txt", "r", stdin);
	//	freopen("_output.txt", "w", stdout);
	#endif
		int n;
		cin >> n;
		cout << n*n*n;




	return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
        int color[] = new int[8];
        int free = 0;
        for(int i = 0; i < n; i++){
        	int num = sc.nextInt();
            if(num <= 399){
            	color[0] = 1;
            }else if(num <= 799){
            	color[1] = 1;
            }else if(num <= 1199){
            	color[2] = 1;
            }else if(num <= 1599){
            	color[3] = 1;
            }else if(num <= 1999){
            	color[4] = 1;
            }else if(num <= 2399){
            	color[5] = 1;
            }else if(num <= 2799){
            	color[6] = 1;
            }else if(num <= 3199){
            	color[7] = 1;
            }else{
            	free++;
            }
        }
        int count = 0;
        for(int i = 0; i < 8; i++){
        	count += color[i];
        }
        int max = count + free;
        int min = count;
        if(count == 0){
            min = 1;
        }
        System.out.println(min + " " + max);
    }
}

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

int main() {
 int n,cnt=0;cin >> n;
 vector<int> p(n);
 for(int i=0;i<n;i++){
   cin >> p[i];
 }
 vector<int> num(3);
   for(int i=1;i<n-1;i++){
    num[0]=p[i-1];
    num[1]=p[i];
    num[2]=p[i+1];
    sort(num.begin(),num.end());

    if(num[1]==p[i])cnt++;
   }
   cout << cnt << endl;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);



int main(){
  FAST_IO  
  
  LL a, b; cin >> a >> b;
  
  int min = 1, max = 65, possible = -1;

  auto ok = [&](int len){
    LL factor = (1LL << (len - 1));
    if((__int128)a * factor <= b) return true;
    return false;
  };

  while(min <= max){
    int mid = min + (max - min) / 2;
    if(ok(mid)){
      possible = mid;
      min = mid + 1;
    }else{
      max = mid - 1;
    }
  }

  cout << possible << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

int main() {
    int n; cin >> n;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        sum += a - 1;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7


def resolve():
    N, M = map(int, input().split())

    broken = [False] * (N + 1)
    dp = [0 for _ in range(N + 1)]
    dp[0] = 1

    for _ in range(M):
        broken[int(input())] = True

    for i in range(1, N + 1):
        if broken[i]:
            continue

        if i == 1:
            dp[i] = dp[i - 1]
        else:
            dp[i] = dp[i - 1] + dp[i - 2]
            dp[i] %= MOD

    print(dp[N])


resolve()


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

using namespace std;

typedef long long ll;

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    string o,e;
    cin >> o >> e;
    int so=0,se=0;
    int lo = o.size(),le = e.size();
    for(int i=1;i<=lo+le;i++){
    	if(i%2!=0 && so<lo){
    		cout << o[so++];
		}
		else if(i%2==0 && se<le){
			cout << e[se++];
		}
	}
    //aattccooddeerrbreeggiunlnaerrccoonntteesstt
    //aattccooddeerrbreeggiunlnaerrccoonntteesstt
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	int N, M;
	cin >> N >> M;
	vector<int>s(M), c(M);
	vector<int>v(N, INF);
	bool isOK = true;
	if (N == 1 && M == 0) {
		cout << 0;
		return 0;
	}
	rep(i, M) {
		cin >> s[i] >> c[i];
		if (N != 1) {
			if (s[i] == 1 && c[i] == 0)isOK = false;
		}
		if (v[s[i] - 1] == INF)v[s[i] - 1] = c[i];
		else if (v[s[i] - 1] == c[i])continue;
		else isOK = false;
	}
	if (!isOK) {
		cout << -1;
		return 0;
	}
	string S;
	rep(i, N) {
		if (!i)S.push_back('1');
		else S.push_back('0');
	}
	rep(i, M) {
		char tmp = '0' + c[i];
		S[s[i] - 1] = tmp;
	}
	rep(i, N)cout << S[i];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;


int main(void) {
    int n;
    cin >> n;
    
    vector<bool> f(n+1, false);
    
    f[1] = true;
    repeat_from_to (i, 2, sqrt(n)) {
        int t = i * i;
        while (t <= n) {
            f[t] = true;
            t *= i;
        }
    }
    
    repeat_reverse_from_to (i, n, 1) {
        if (!f[i]) continue;
        cout << i << endl;
        break;
    }
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <functional>
using namespace std;
int main() {
	int N;
	while (cin >> N, N) {
		vector<double> p(N);
		vector<vector<int> > g(N), rg(N);
		for (int i = 0; i < N; ++i) {
			int l;
			cin >> p[i] >> l;
			for (int j = 0; j < l; ++j) {
				int u;
				cin >> u; --u;
				g[i].push_back(u);
				rg[u].push_back(i);
			}
		}
		vector<bool> vis(N);
		vector<int> ord(N, -1), invord(N, -1);
		int cnt = 0;
		function<void(int)> dfs1 = [&](int pos) {
			vis[pos] = true;
			for (int i : g[pos]) {
				if (!vis[i]) dfs1(i);
			}
			ord[pos] = cnt;
			invord[cnt] = pos;
			++cnt;
		};
		for (int i = 0; i < N; ++i) {
			if (ord[i] == -1) {
				dfs1(i);
			}
		}
		cnt = 0;
		vector<int> col(N, -1);
		vector<int> vlist;
		function<bool(int)> dfs2 = [&](int pos) {
			col[pos] = cnt;
			vlist.push_back(pos);
			bool ans = true;
			for (int i : rg[pos]) {
				if (col[i] == -1) ans = ans && dfs2(i);
				else if (col[i] != cnt) ans = false;
			}
			return ans;
		};
		double ans = 1.0;
		for (int i = N - 1; i >= 0; --i) {
			if (col[invord[i]] != -1) continue;
			vlist.clear();
			bool res = dfs2(invord[i]);
			if (res) {
				double mul = 1.0;
				for (int j : vlist) mul *= p[j];
				ans *= 1.0 - mul;
			}
			++cnt;
		}
		cout.precision(15);
		cout << fixed << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3372