akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

typedef long long s64;

const int MaxN = 2000;
const int MaxNK = 2000;
const int MaxNL = MaxN * MaxNK;

const int M = 1000000007;

inline int modpow(int a, const int &n)
{
	int res = 1;
	for (int i = n; i; i >>= 1)
	{
		if (i & 1)
			res = (s64)res * a % M;
		a = (s64)a * a % M;
	}
	return res;
}

inline int add(int a, const int &b)
{
	a += b;
	return a >= M ? a - M : a;
}
inline int dec(int a, const int &b)
{
	a -= b;
	return a < 0 ? a + M : a;
}

int n, nK;

int fact[MaxNL];
int rfact[MaxNL];

inline void init_fact(int n)
{
	fact[0] = 1;
	for (int i = 1; i <= n; ++i)
		fact[i] = (s64)fact[i - 1] * i % M;

	rfact[n] = modpow(fact[n], M - 2);
	for (int i = n; i; --i)
		rfact[i - 1] = (s64)rfact[i] * i % M;
}

inline int binom(int n, int m)
{
	return n < 0 || m < 0 ? 0 : (s64)fact[n] * rfact[m] % M * rfact[n - m] % M;
}

int f[MaxN + 1][MaxN + 1];

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

	if (nK == 1)
	{
		cout << 1 << endl;
		return 0;
	}

	init_fact(n * nK - 1);

	f[0][0] = 1;
	for (int i = 1; i <= n; ++i)
		for (int j = 0; j <= i; ++j)
		{
			int a = j ? f[i][j - 1] : 0;
			int b = (s64)f[i - 1][j] * binom(i * (nK - 1) + j - 1, nK - 2) % M;
			f[i][j] = add(a, b);
		}

	cout << (s64)fact[n] * f[n][n] % M << endl;

	return 0;
}

Measured memory_bytes: 46208
(defun Lamps (n k)
    (let* ((readLamps (make-array n ))
        (dousyutuLamps (make-array (1+ n) :initial-element 0))
        (stop t)
        )
 
        (dotimes (i n) 
            (setf (aref readLamps i) (read)))
 
    (loop named main-loop
          for _ below k
          do (progn 
            (loop for i below n
                do (let ((l (max 0 (- i (aref readLamps i))))
                    (r (min (- n 1) (+ i (aref readLamps i)))))
                    (incf (aref dousyutuLamps l))
                    (if (<= (1+ r) n)
                        (decf (aref dousyutuLamps (1+ r)))
                    )
                )                    
            )
            (loop for i from 1 to n
                do (incf (aref dousyutuLamps i) (aref dousyutuLamps (- i 1)))
            )
            (loop for i below n
                 
                do (setf stop (and stop (= (aref dousyutuLamps i) n)))
                do (setf (aref readLamps i) (aref dousyutuLamps i))
                do (setf (aref dousyutuLamps i) 0)
                
            ) 
            
            (if stop
                (return-from main-loop)
                (setf stop t))
        )
    )
        (loop for i below (- n 1)
            do(format t "~A "(aref readLamps i))
        )
        (format t "~A~%" (aref readLamps (- n 1))))
    
)
(Lamps (read) (read))

Measured memory_bytes: 80184
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    if ((a*b)%2==0)
      System.out.println("Even");
    else
      System.out.println("Odd");
  }
}


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

int main(){
	string str, str_copy;
	
	while(getline(cin, str)){
		for(int i = 0; i < 26; i++){
			for(int j = 0; j < str.size(); j++){
				if(str[j] >= 'a' && str[j] <= 'z'){
					str[j] = (str[j] == 'z')? 'a' : str[j] + 1;
				}
			}
			if(str.find("the") != string::npos
			 || str.find("this") != string::npos
			  || str.find("that") != string::npos){
				cout << str << endl;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 1176
#include <stdio.h>

int main()
{
    int i, j, k;

    int num_people[4][3][10]; //num_people[bldg][floor][room]
    for (i = 0; i < 4; i++) {
        for (j = 0; j < 3; j++) {
            for (k = 0; k < 10; k++) {
                num_people[i][j][k] = 0;
            }
        }
    }

    int num_data;
    scanf("%d", &num_data);
    for (i = 1; i <= num_data; i++) {
        int bldg, floor, room, people;
        scanf("%d %d %d %d", &bldg, &floor, &room, &people);
        num_people[bldg - 1][floor - 1][room - 1] += people;
    }

    for (i = 0; i < 4; i++) {
        if (i != 0) {
            printf("####################\n");
        }
        for (j = 0; j < 3; j++) {
            for (k = 0; k < 10; k++) {
                printf(" %d", num_people[i][j][k]);
            }
            printf("\n");
        }
    }

    return 0;
}

Measured memory_bytes: 612
#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 allR(x) (x).rbegin(), (x).rend()
using ll = long long;
using P = pair<int, int>;
const int INF = 2'000'000'000;

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

  int x = N[N.length()-1] - '0';

  string ans;
  if (x == 3) {
    ans = "bon";
  } else if (x == 0 || x ==1 || x==6|| x==8) {
    ans = "pon";
  }
  else {
    ans = "hon";
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3592
<?php

while (($line = trim(fgets(STDIN)))) {
    sscanf($line, '%d %d', $H, $W);
    if ($H === 0 && $W === 0) {
        break;
    }

    for ($i = 0; $i < $H; $i++) {
        $flg = $i % 2 === 0;
        for ($j = 0; $j < $W; $j++) {
            if ($flg) {
                echo $j % 2 === 0 ? '#' : '.';
            } else {
                echo $j % 2 === 0 ? '.' : '#';
            }
        }
        echo PHP_EOL;
    }
    echo PHP_EOL;
}

Measured memory_bytes: 6572
#include <stdio.h>

int main(void){
  unsigned int i;
  unsigned long int sum = 0;
  unsigned int input;
  
  scanf("%u",&input);
  for(i = 1;i <= input;i++){
    if((i % 3 != 0) && (i % 5 != 0)){
      sum += i;
    }
  }
  printf("%lu",sum);
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

using P = pair<int, PII>;

/* -----  2017/09/20  Problem: ACPC2017_day3_e  / Link:   ----- */
/* ------??????------



-----?????????????????§----- */
/* -----?§£??¬???-----



----?§£??¬???????????§---- */

LL N;
struct BIT2D {
	int _H, _W;
	VVI data;
	BIT2D(int h, int w) {
		_H = h; _W = w;
		data = VVI(_W + 1, VI(_H + 1, 0));
	}
	void add(int a, int b, int val) {
		for (int x = a; x <= _W; x += x&-x) {
			for (int y = b; y <= _H; y += y&-y) {
				data[x][y] += val;
			}
		}
	}
	int _sum(int a, int b) {
		int ret = 0;
		for (int x = a; x > 0; x -= x & -x) {
			for (int y = b; y > 0; y -= y & -y) {
				ret += data[x][y];
			}
		}
		return ret;
	}
	int sum(int lx, int ly, int rx, int ry) {
		return _sum(rx, ry) - _sum(lx - 1, ry) - _sum(rx, ly - 1) + _sum(lx - 1, ly - 1);
	}
};

LL ans = 0LL;
int H, W, T, Q;

int main() {

	scanf("%d%d%d%d", &H, &W, &T, &Q);
	BIT2D yet(max(W, H), max(W, H) );// 1index
	BIT2D done(max(W, H) , max(W, H) );// 1index


	queue<P> que;
	FOR(i, 0, Q) {
		int t, c, h1, w1, h2, w2;
		scanf("%d%d%d%d", &t, &c, &h1, &w1);

		while (!que.empty()) {
			P p = que.front();
			if (p.first + T <= t) {
				que.pop();
				int Y = p.second.first, X = p.second.second;
				yet.add(Y, X, -1);
				done.add(Y, X, 1);
			}
			else break;

		}

		if (c != 2) {
			if (c == 0) {
				if (yet.sum(h1, w1, h1, w1) == 0 && done.sum(h1, w1, h1, w1) == 0) {
					yet.add(h1, w1, 1);
					que.push({ t,PII(h1,w1) });
				}
			}
			else {//c ==1
				if (done.sum(h1, w1, h1, w1) == 1) {
					done.add(h1, w1, -1);
				}
			}
		}
		else {
			scanf("%d%d", &h2, &w2);
			printf("%d %d\n", done.sum(h1, w1, h2, w2), yet.sum(h1, w1, h2, w2));
		}

	}



	return 0;
}

Measured memory_bytes: 35548
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

i64 nined(i64 N) {
    i64 res = 0;
    i64 v = 9;
    while (v <= N) {
        res = v;
        v = v * 10 + 9;
    }
    return res;
}

void Main() {
    i64 N;
    cin >> N;
    if (N % 2 == 1) {
        cout << 0 << endl;
        return;
    }
    i64 ans = 0;
    i64 c = 10;
    while (c <= N) {
        ans += N / c;
        c *= 5;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

ll dp[310][310][310];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,K;
    cin >> n >> K;
    vi h(n);
    cin >> h;
    if(K == n) {
        cout << 0 << endl;
        return 0;
    }
    int mn = *min_element(all(h));
    rep(i,n) h[i] -= mn;
    vi prs;
    rep(i,n) prs.pb(h[i]);
    sort(all(prs));
    prs.erase(unique(all(prs)),prs.end());
    rep(i,310) rep(j,310) rep(k, 310) dp[i][j][k] = linf;
    dp[0][0][0] = 0;
    rep(i,n) rep(j,K+1) rep(k,prs.size()) {
        int now = lower_bound(all(prs),h[i])-prs.begin();
        chmin(dp[i+1][j][now],dp[i][j][k]+max(0,prs[now]-prs[k]));
        if(j < K) chmin(dp[i+1][j+1][k],dp[i][j][k]);
    }
    ll ans = linf;
    rep(i,310) rep(j,310) chmin(ans,dp[n][i][j]);
    cout << ans+mn << endl;
}


Measured memory_bytes: 232960
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>P(N);
  for(int i=0;i<N;i++){
    cin>>P.at(i);
  }
  int count=0;
  vector<int>minlist(N);
  minlist.at(0)=P.at(0);
  for(int i=1;i<N;i++){
    minlist.at(i)=min(minlist.at(i-1),P.at(i));
  }
  for(int i=0;i<N;i++){
    if(P.at(i)==minlist.at(i)){
      count=count+1;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <string>

using namespace std;

int main(int argc, const char * argv[]) {
    
    // source code
    int A,B,S;

    scanf("%d%d%d", &A, &B, &S);
	int count = A;
  	int sum_ = 0;
  	while (count <= S){
    	sum_ += B;
      	count += A;
    }
    printf("%d\n", sum_);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  string str;
  cin >> str;

  str.at(3) = '8';
  cout << str << endl;
}


Measured memory_bytes: 3580
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N;
	cin>>N;
	vector<int> a(100010);
	int nax = -1;
	rep(i,N){
		int t;
		cin>>t;
		a[t]++;
		nax = max(nax, t);
	}
	int ans = 0;
	for(int i = 1; i<100010; i++){
		ans = max(a[i] + a[i-1] + a[i+1], ans);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
S = input()
N = len(S)
n = N // 2
ans = 'Yes'
for i in range(n):
    p = S[2*i]
    q = S[2*i+1]
    if p == 'L':
        ans = 'No'
    if q == 'R':
        ans = 'No'
if N % 2 == 1:
    if S[N-1] == 'L':
        ans = 'No'
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i, a, j) for(int i = a; i < j; i++)
#define dia(i, j) i * i + j* j
#define all(i) i.begin(), i.end()
using namespace std;
struct dat_st { int h, w, num; };
bool compare(dat_st &t0, dat_st &t1)
{
	if (t0.num == t1.num)
	{
		return t0.h < t1.h;
	}
	return t0.num < t1.num;
}
int num(int x, int y)
{
	int num = x * x + y * y;
	return num;
}
int main()
{
	vector<dat_st> cul(0);
	rep(h, 1, 151) rep(w, 1, 151)
	{
		if (h < w && h != w) { cul.push_back({ h, w, dia(h, w) }); }
	}
	sort(all(cul), compare);
	int h, w; while (cin >> h >> w, h, w)
	{
		rep(i, 0, (int)cul.size())
		{
			if (cul[i].h == h && cul[i].w == w)
			{
				printf("%d %d\n", cul[i + 1].h, cul[i + 1].w);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3320
import numpy as np
def main():
    n,s=map(int,input().split())
    A=list(map(int,input().split()))
    dp=np.array([0 for i in range(min(3001,s+1))])
    dp[0]=1
    for ai in A:
        tmp=dp[:-ai].copy()
        #print(tmp)
        dp*=2
        dp[ai:]+=tmp
        dp%=998244353
    print(dp[s])
    

if __name__=="__main__":
    main()

        

    

Measured memory_bytes: 27556
#include <algorithm>
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <string>
#include <vector>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#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()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> p(n), q(n);
  rep(i, n) cin >> p[i];
  string ps = "", qs = "";
  rep(i, n) cin >> q[i];

  rep(i, n) ps += to_string(p[i]);
  rep(i, n) qs += to_string(q[i]);


  vector<int> v(n);
  rep(i, n) v[i] = i + 1;

  vector<string> res;
  do {
    string tmp  = "";
    for (int i = 0; i < n; i++) {
      tmp += to_string(v[i]);
    }
    res.push_back(tmp);
  } while (next_permutation(ALL(v)));

  int a, b;
  for (int i = 0; i < int(res.size()); i++) {
    if(ps == res[i]) a = i;
    if(qs == res[i]) b = i;
  }
  cout << abs(a-b) << endl;
}


Measured memory_bytes: 2424
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;
  auto p = readln.chomp.split.to!(int[]);
  int cnt;
  foreach (i; 1..p.length-1) {
    if (p[i-1] < p[i] && p[i] < p[i+1]
    ||  p[i-1] > p[i] && p[i] > p[i+1]) {
      cnt++;
    }
  }

  cnt.writeln;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <iomanip>
#include <algorithm>

using namespace std;

int main(){
	int a = 0;
	int b = 0;
	scanf("%d",&a);
	scanf("%d",&b);
	
	int array1[3] = {0,0,0};
	array1[0] = a + b;
	array1[1] = a - b;
	array1[2] = a * b;
	sort(array1,array1+3);
	
	cout<< array1[2]<<endl;
	
	
	
	return 0;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
    int a, b;

    cin >> a >> b;

    a += b;
    if (a >= 24) {
        a -= 24;
    }
    cout << a << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	int a;
	cin >> a;
	if (a == 7 || a == 5 || a == 3)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 2e5 + 5;
const ll MOD = 1e9+7;
 
int parent[N];
 
int gcd(int a, int b) { 
    if (a == 0) 
        return b;  
    return gcd(b%a, a);  
} 
   
int lcm(int a, int b) {  
    return (a*b)/gcd(a,b);  
} 
 
ll pow(ll x, ll y, ll p) {
    if(y == 0) return 1;
    ll res = 1;
    x %= p;
    if(x == 0) return 0LL;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y >>= 1;
        x = (x*x) % p;
    }
    return res;
}
 
int find(int x) {
    return x == parent[x] ? x : parent[x] = find(parent[x]);
}
 
void Union(int x, int y) {
    int xPar = find(x), yPar = find(y);
    if(xPar != yPar) parent[xPar] = yPar;
}
 
ll nCr(ll n, ll r) {
    ll res = 1;
    for(ll i=1;i<=r;i++) {
        res = res * (n - r + i) / i;
        // is different from
        // res *= (n -r + i) / i;
    }
    return res;
}
 
int ask(int i, int j) {
    cout << "? " << i + 1 << ' ' << j + 1 << endl;
    int v;
    cin >> v;
    return v;
}

void solve() {
    int n, x, t;
    cin >> n >> x >> t;
    cout << (int)(ceil)(n / (double)x) * t << endl;
    return;
} 
 
int main()
{
    IOS
    //int t;
    //cin >> t;
    //while(t--) 
    solve();
    return 0; 
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define maxn 200005 
using namespace std;
int a[maxn];
int main(){
	int n,k;
	cin>>k>>n;
	cin>>a[0];
	
	int maxx=-1,sum=0;
	
	for(int i=1;i<n;i++){
		cin>>a[i];
		sum+=abs(a[i]-a[i-1]);
		maxx=max(maxx,a[i]-a[i-1]);

	}
	sum+=abs(abs(a[n-1]-k)+a[0]);
	maxx=max(maxx,abs(abs(a[n-1]-k)+a[0]));
	cout <<sum-maxx<<endl;
	
}

Measured memory_bytes: 1024
"""
unioufind
集合の中で、直接の友達 と直接のブロックを引く
TLE

bfsで集合をまず見ておく
"""
from collections import deque
from collections import defaultdict
N,M,K = map(int, input().split())

# 木構造を作る
G = defaultdict(list)
for i in range(M):
    # グラフに頂点を追加(距離があるときは,u,vの後に入れる)
    u,v = map(int,input().split())
    G[u-1].append((v-1))
    G[v-1].append((u-1))

tomodachi_group = defaultdict(int)
used = [False] * N
parent = [-1] * N
group_cnt = {}
for i in range(N):
    if used[i]: continue
    used[i] = True
    parent[i] = i
    q = deque([])
    q.append(i)
    cnt = 0
    while len(q) > 0:
        a = q.popleft()
        Vs = G[a]
        for u in Vs:
            if not used[u]:
                q.append(u)
                parent[u] = i
                used[u] = True
                cnt += 1
    group_cnt[i] = cnt

block = defaultdict(int)
for i in range(K):
    c,d = map(int, input().split())
    c -= 1
    d -= 1
    # 友達グループじゃないと無意味
    if parent[c] != parent[d] :continue
    block[c] += 1
    block[d] += 1

ans = []
for i in range(N):
    cnt = group_cnt[parent[i]] - len(G[i]) - block[i]
    ans.append(cnt)
print(*ans)

Measured memory_bytes: 109400
import sys
import heapq

n = int(input())
ab = []
for i in range(n):
  tmp = list(map(int, input().split()))
  job = (tmp[1], tmp[0])
  heapq.heappush(ab, job)

today = 0
for i in range(n):
  tmp = heapq.heappop(ab)
  today += tmp[1]
#  print(today)
  if today > tmp[0]:
#    print (-tmp[0])
    print('No')
    sys.exit()

print('Yes')

Measured memory_bytes: 73816
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char[] c = str.toCharArray();
        int n = c.length;
        
        boolean ok = false;
        for (int i = 0; i < n; i++) {
            for (int j = i; j < n; j++) {
                String tmp1 = str.substring(0, i);
                String tmp2 = str.substring(j, n);
                
                String tmp = tmp1 + tmp2;
                if (tmp.equals("keyence")) ok = true;
            }
        }
        
        if (ok) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 40312
import heapq

n, m = map(int, input().split())
items = [int(x) for x in input().split()]

class Heapq:
    def __init__(self, arr, desc=False):
        if desc:
            arr = [-a for a in arr]
        self.sign = -1 if desc else 1
        self.hq = arr
        heapq.heapify(self.hq)
 
    def pop(self):
        return heapq.heappop(self.hq) * self.sign
 
    def push(self, a):
        heapq.heappush(self.hq, a * self.sign)
 
    def top(self):
        return self.hq[0] * self.sign
    
    def qsum(self):
        return -sum(self.hq)

q = Heapq(items, True)

for i in range(m):
    max_price = q.pop()
    max_price = max_price // 2
    q.push(max_price)

print(q.qsum())

Measured memory_bytes: 14180
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define MOD(x) ((x)%mod)
long long n,a,b;
long long h[100005];
bool check(long long x)
{
	long long num=0;
	for(int i=1;i<=n;i++)
	{
		if(h[i]<=x*b) continue;
		long long tmp;
		tmp=(h[i]-x*b)/a;
		if(tmp*a!=h[i]-x*b) tmp++;
		num+=tmp;
	}
	if(num>x) return 0;
	return 1;
}
int main()
{
	scanf("%lld%lld%lld",&n,&a,&b);
	a-=b;
	for(int i=1;i<=n;i++)
		scanf("%lld",&h[i]);
	long long l=1,r=1e9;
	long long m;
	while(l<r)
	{
		m=(l+r)/2;
		if(check(m)) r=m;
		else l=m+1;
	}
	printf("%lld",l);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(void)
{
    int A, B, C, tmp, answer;
    cin >> A >> B >> C;
    tmp = A - B;
    answer = C - tmp;
    if (answer < 0)
    {
        cout << "0" << endl;
    }
    else
    {
        cout << answer << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define endl "\n"
#define pb push_back
#define arrinp(v) for(auto &i:v) cin>>i;
#define arrout(v) for(auto &i:v) cout<<i<<" ";
#define newline cout<<endl;
using namespace std;
const int mod=1e9+7;
int power(int x, int y) 
{ 
    int res = 1;     // Initialize result 
    for(int i=0;i<y;i++){
    	res=res*x%mod;
    }
    return res; 
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t=1;
    // cin >> t;
    while (t--) {
        int n;
        cin>>n;
        int ans=power(10,n)-power(9,n)-power(9,n)+power(8,n);
        ans%=mod;
        ans=(ans+mod)%mod;
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;


ll trans(ll a) {
	for (ll i = 0; i < 32; i++) {
		if (i % 2 == 0) continue;
		if ((a >> i) & 1) a += (1LL << (i + 1));
	}
	return a;
}

int main() {
	ll n; cin >> n;
    if (n == 0) {
      cout << 0 << endl;
      return 0;
    }
	ll a = trans(n);
	string ans;
	while (a > 0) {
		ans += a & 1 ? '1' : '0';
		a /= 2;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys
sys.setrecursion = 10000000


def solve(): 
  n = int(input())
  print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][n-1])

solve()

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

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

}


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

int main() {
  std::string word; std::cin >> word;
  
  if ((word[0] == word[1]) &&
      (word[2] == word[3]) &&
      (word[0] != word[2])) {
    std::cout << "Yes" << std::endl;
  } else if ((word[0] == word[2]) &&
             (word[1] == word[3]) &&
             (word[0] != word[1])) {
    std::cout << "Yes" << std::endl;
  } else if ((word[0] == word[3]) &&
             (word[1] == word[2]) &&
             (word[0] != word[1])) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream> 
#include <algorithm>
using namespace std;
int main(){
  int64_t a,b;
  cin>>a>>b;
  if(a==1||b==1) cout<<1;
  else if(a%2==1&&b%2==1) cout<<a*b/2+1;
  else  cout<<a*b/2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){ 
int N; 
cin >> N; 
int A[30] = {100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100}; 
for (int i = 0; i < N; ++i) {
string S; 
cin >> S; 
int B[30] = {0}; 
for(int j = 0; j < S.size(); ++j){
B[S.at(j) - 'a'] ++; 
}
for(int k=0; k < 26; k++){
A[k] = min(A[k], B[k]); 
}
}
for(char c = 'a'; c <= 'z'; ++c){
for(int j = 0; j < A[c - 'a'] ; ++j){
cout << c; 
}
}
cout << endl; 
}

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

using namespace std;

int main(){

  string s;
  string a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  
  cin >> s;

  int now = 0;
  int cnt = 0;
  
  for(int i = 0;i < s.size();++i){
	for(int j = 0;j < 26;++j){
	  if(s[i] == a[j]){
		if(now - j >= 0)
		  cnt++;
		now = j;
		break;
	  }
	}
  }

  cout << cnt << endl;

}



Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


// range sum query using fenwick tree
// note index starts at 1

class fenwick_tree {
	vector<long long> t;
	long size;
public:
	fenwick_tree(long long n) {
		t.assign(n + 1, 0);
		size = n + 1;
	}

	long long LSOne(long long k) {	// least significant 1-bit
		return k & (-k);
	}

	void update(long long index, long long val) {	// can go up or go down
		for (; index < size; index += LSOne(index)) t[index] += val;
	}

	long long query_full(long long a, long long b) {		// range query
		return query(b) - ((a <= 1) ? 0 : query(a - 1));
	}

	long long query(long long b) {	// range query 1..b
		if (b < 1) return 0;

		long long sum = 0;
		for (; b; b -= LSOne(b)) sum += t[b];
		return sum;
	}
};



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

	long long n, k, i, j, ans, x, b, MOD = 1000000007;
	cin >> n >> k;
	vector<long long> a(n);
	for (i = 0; i < n; i++) cin >> a[i];

	fenwick_tree st(k + 10);
	vector<long long> dp(k + 1, 0);
	dp[k] = 1;
	st.update(k + 1, 1);

	for (i = 0; i < n; i++) {
		for (j = 0; j <= k; j++) {
			b = min(k, j + a[i]);
			x = st.query_full(j + 1, b + 1) % MOD;
			st.update(j + 1, x - dp[j]);
			dp[j] = x;
		}
	}

	ans = dp[0] % MOD;
	cout << ans << "\n";

	return 0;
}





Measured memory_bytes: 1792
#include <iostream>
#include <cmath>

using namespace std;

bool isPrime(int x){

    if(x == 2){
        return true;
    }

    if(x <= 1 || x % 2 == 0){
        return false;
    }

    double xSqrt = sqrt(x);

    for(int i=3; i<=xSqrt; i+=2){
        if(x % i == 0){
            return false;
        }
    }

    return true;
}

int main(){
    int n;
    int a[10000];
    int count = 0;
    cin >> n;

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

    //入力値に対して判定・出力
    for(int i=0; i<n; i++){
        if(isPrime(a[i])){
            count++;
        }
    }

    cout << count << endl;
    
    return 0;
}



Measured memory_bytes: 3144
#include <stdio.h>

int map[50][50] = {};
int vec[] = { -1, 0, 1 };
int w,h;

void search(int x,int y){
    int i,j;
    if(map[y][x]!=0){
        map[y][x]=0;

        for(i = 0; i < 3; i++){
            for(j = 0; j < 3; j++){
                if((y+vec[i] >=0 && y+vec[i] < h) && (x+vec[j] >= 0 && x+vec[j] < w)){
                    search(x+vec[j],y+vec[i]);
                }
            }
        }
    }
}

int input(){
    int i,j;
    scanf("%d %d",&w,&h);
    if(w == h && w == 0)
        return 0;
    for(i = 0; i < h; i ++){
        for(j = 0; j < w; j ++)
            scanf("%d",&map[i][j]);
    }
    return 1;
}

int main(void){
    int i,j;
    int n;
    while(input()){
        n = 0;
        for(i = 0; i < h; i ++){
            for(j = 0; j < w; j ++){
                if(map[i][j] == 1){
                    n ++;
                    search(j,i);
                }
            }
        }
        printf("%d\n",n);
    }
    return 0;
}


Measured memory_bytes: 1860
// C - Welcome to AtCoder
#include <bits/stdc++.h>
using namespace std;

int wa_count[100000];

int main(){
	int n,m,p,ac=0,wa=0;
	char s[3];
	scanf("%d%d",&n,&m);
	while(m--){
		scanf("%d%s",&p,s); --p;
		if(wa_count[p] < 0) continue;// ac
		else{//not ac
			if(s[0] == 'W') wa_count[p]++;
			else{
				ac++;
				wa += wa_count[p];
				wa_count[p] = -1;// ac flag on
			}
		}
	}
	printf("%d %d\n",ac,wa);
}

Measured memory_bytes: 640
from collections import defaultdict

def prime_sieve(start, end):
    assert end > 1
    is_prime = [True for i in range(end)]
    is_prime[0], is_prime[1] = False, False
    primes = list()
    for i in range(2,end):
        if is_prime[i]:
            if i >= start:  
                primes.append(i)
            for j in range(2 * i, end, i):
                is_prime[j] = False
    return primes

def prime_factorize(n,primes):
  res = []
  for i in primes:
    tmp = 0
    while not (n%i):
      n //= i
      tmp += 1
    res.append(tmp%3)
  res.append(n)
  return tuple(res)


n = int(input())
s = [int(input()) for i in range(n)]
primes = prime_sieve(1,315)
factorized = defaultdict(int)
square = dict()
for i in range(1,100001):
  square[i**2] = i
cubic = set([i**3 for i in range(1,4000)])
mid_primes = prime_sieve(315,5500)
rev_mid_primes = dict()
for i in mid_primes:
  for j in mid_primes:
    if i == j:
      continue
    rev_mid_primes[i**2*j] = j**2*i
    
    
for i in s:
  t = prime_factorize(i,primes)
  factorized[t] += 1
ans = n
f = factorized.items()
for k,v in f:
  rem = k[-1]
  another = [(3-i) % 3 for i in k[:-1]]
  if rem in cubic:
    another.append(1)
  elif rem in square:
    another.append(square[rem])
  elif rem in rev_mid_primes:
    another.append(rev_mid_primes[rem])
  else:
    another.append(rem**2)
  another = tuple(another)
  if k == another:
    ans -= factorized[k] - 1
    continue
  if another in factorized:
    if factorized[k] <= factorized[another]:
      ans -= factorized[k]
      factorized[k] = 0
    else:
      ans -= factorized[another]
      factorized[another] = 0
print(ans)

Measured memory_bytes: 243192
#include<stdio.h>
#include<string.h>
int main() {
	char s1[15]; char s2[15]; char s3[15];
	int a,b;
	
	scanf("%s", s1);
	scanf("%s", s2);
	scanf("%d%d", &a, &b);
	scanf("%s", s3);
	if (strcmp(s1,s3)==0)printf("%d %d\n", a-1,b);
	else printf("%d %d\n", a,b-1);
	return 0;

}

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

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int n,m;
    int ans=0;
    cin>>n>>m;
    if(m<n)
        cout<<n-1;
    else
        cout<<n;
    cout<<endl;

    return 0;
}

Measured memory_bytes: 256
<?php
// Your code here!

    $input_line = intval(trim(fgets(STDIN)));
    
    $flg=0;
    
    for($i=1;$i<=$input_line;$i++){
        $x=$i;
        //３の倍数かどうか
        if($x%3==0 && $flg==0){
            echo " $i";
            continue;
        }
        
        do{
            //10で割った時に3余るかどうか１３とか２３
            if($x%10==3){
                echo " $i";
                $flg=0;
                break;
            }elseif($x>13){
                $x=floor($x/10);
                $flg=1;
            }else{
                $flg=0;
                break;
            }

        }while(1);
        
    }
    echo "\n";
?>


Measured memory_bytes: 9232
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;

int main(){
	ios::sync_with_stdio(false);
	ll n,ans=0,ans2=0;
	cin>>n;
	priority_queue<ll> L,L2;
	priority_queue<ll,vector<ll>,greater<ll>> S,S2;
	for(int i=0;i<n;i++){
		ll a;
		cin>>a;
		L.push(a);
		S.push(a);
		L2.push(a);
		S2.push(a);
	}
	ll a=S.top(),b=S.top();
	S.pop();
	for(int i=0;i<n/2;i++){
		if(i%2==0){
			ans+=abs(L.top()-b);
			b=L.top();
			L.pop();

			ans+=abs(L.top()-a);
			a=L.top();
			L.pop();
		}else{
			ans+=abs(S.top()-a);
			a=S.top();
			S.pop();

			ans+=abs(S.top()-b);
			b=S.top();
			S.pop();
		}
	}
	ll a2=L2.top(),b2=L2.top();
	L2.pop();
	for(int i=0;i<n/2;i++){
		if(i%2==0){
			ans2+=abs(S2.top()-b2);
			b2=S2.top();
			S2.pop();

			ans2+=abs(S2.top()-a2);
			a2=S2.top();
			S2.pop();
		}else{
			ans2+=abs(L2.top()-a2);
			a2=L2.top();
			L2.pop();

			ans2+=abs(L2.top()-b2);
			b2=L2.top();
			L2.pop();
		}
	}
	cout<<max(ans,ans2)<<endl;
	return 0;
}

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

typedef long long ll;
typedef vector<ll> V;
typedef pair<ll,ll> P;
typedef map<ll,ll> M;

#define REP(i, n) for(ll (i) = 0; (i) < (n); ++(i))
#define FOR(i, j, n) for(ll (i) = (j); (i) < (n); ++(i))
#define REPR(i, n) for(ll (i) = (n); (i) >= 0; --(i))

const ll MOD = 1e9+7;

signed main(){
    int n;
    cin >> n;
    vector<string> s(n);
    for(auto& xx : s)cin >> xx;
    vector<V> edges(n);
    vector<V> rev(n);
    V cou(n, 0);
    REP(i, n-1){
        int a,b;
        cin >> a >> b;
        --a;--b;
        edges[a].push_back(b);
        ++cou[a];
        rev[b].push_back(a);
    }
    V dp(n, 0);
    queue<int> que;
    REP(i,n)if(!cou[i])que.push(i);
    while(!que.empty()){
        int pos = que.front();
        que.pop();

        bool option = (s[pos].size() != 1);

        ll patcou = 0;

        if(s[pos][0] == 'E'){
            ll num = 1;
            for(auto x : edges[pos]){
                num *= dp[x];
                num %= MOD;
            }
            patcou = (num + option) % MOD;
        }
        else if(s[pos][0] == 'A'){
            // alt
            ll num = 0;
            for(auto x : edges[pos]){
                num += dp[x];
                num %= MOD;
            }
            patcou = (num + option) % MOD;

        }
        else if(s[pos][0] == 'R'){
            // or
            ll num = 0;
            FOR(i,1, 1<<(edges[pos].size())){
                ll numnum = 1;
                REP(j,edges[pos].size()){
                    if(i & (1<<j)){
                        numnum *= dp[edges[pos][j]];
                        numnum %= MOD;
                    }
                }
                num += numnum;
                num %= MOD;
            }
            patcou = (num + option) % MOD;

        }

        dp[pos] = patcou;

        for(auto x : rev[pos])
            if(--cou[x] == 0)
                que.push(x);
    }
    cout << dp[0] << endl;

    return 0;
}



Measured memory_bytes: 3340
l, r = map(int, input().split())

l0 = l % 2019
l1 = l // 2019
r0 = r % 2019
r1 = r // 2019

if l1 != r1:
    res = 0
else:
    amari = 2019
    for i in range(l0, r0+1):
        for j in range(i+1, r0+1):
            amari = min(amari, (i * j) % 2019)

    res = amari

print(res)


Measured memory_bytes: 42092
N = int(input())
S = [input() for i in range(N)]
L = [[0 for i in range(N)] for i in range(26)]
for i in range(N):
    for j in S[i]:
        L[ord(j)-97][i]+=1
R = [min(L[i]) for i in range(26)]
T = ""
for i in range(26):
    T += chr(i+97)*R[i]
print(T)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 87;
int n, a[N], ans[N];
vector<int> t = {0};
vector<int> g[N];
void dfs(int u, int p)
{
    int pb = 0, pj = -1, x;
    if (a[u] > t.back()) {
        t.push_back(a[u]);
        pb = 1;
    } else {
        pj = lower_bound(t.begin(), t.end(), a[u]) - t.begin();
        x = t[pj];
        t[pj] = a[u];
    }
    ans[u] = t.size() - 1;
    for (int v : g[u])
        if (v != p)
            dfs(v, u);
    if (pb)
        t.pop_back();
    else
        t[pj] = x;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1, 1);
    for (int i = 1; i <= n; ++i)
        cout << ans[i] << '\n';
}


Measured memory_bytes: 30480
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

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

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 long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[110][110];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}


int main() {
	cin >> n;
	map<ll, ll> mpd;
	map<ll, ll> mpt;
	rep(i, n) {
		ll d;
		cin >> d;
		mpd[d]++;
	}
	ll m;
	cin >> m;
	rep(i, m) {
		ll t;
		cin >> t;
		mpt[t]++;
	}
	for (auto i = mpt.begin(); i != mpt.end(); i++) {
		if (mpd[i->first] < i->second) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 25216
#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#include <cstdio>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<LL,LL> P;
int read()
{
    int x=0,flag=1; char c=getchar();
    while((c>'9' || c<'0') && c!='-') c=getchar();
    if(c=='-') flag=0,c=getchar();
    while(c<='9' && c>='0') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return flag?x:-x;
}

#define chl k<<1
#define chr k<<1|1

const int maxn=5e5+5;
int a[maxn],book[2*maxn],n,m,tree[maxn*3],t,ans[maxn];
struct node {int l,r,bianhao;};
node h[maxn];

bool cmp(node &a,node &b)
{
    return a.r<b.r;
}

void add(int k,int l,int r,int j,int v)
{
    if(j<l || j>r) return;
    if(l==r && l==j) {tree[k]+=v;return;}
    tree[k]+=v;
    int mid=(l+r)>>1;
    add(chl,l,mid,j,v);
    add(chr,mid+1,r,j,v);
}

int sum(int k,int l,int r,int ll,int rr)
{
    if(rr<l || ll>r) return 0;
    if(l>=ll && r<=rr) return tree[k];
    int mid=(l+r)>>1;
    return sum(chl,l,mid,ll,rr)+sum(chr,mid+1,r,ll,rr);
}

int main()
{
    n=read(); m=read();
    for(int i=1;i<=n;i++) a[i]=read();
    for(int i=0;i<m;i++) h[i].l=read(),h[i].r=read(),h[i].bianhao=i;
    sort(h,h+m,cmp);

    for(int i=0;i<m;i++)
    {
        int l=h[i].l,r=h[i].r;
        for(int j=t+1;j<=r;j++)
        {
            if(!book[a[j]]) book[a[j]]=j,add(1,1,n,j,1);
            else
            {
                add(1,1,n,book[a[j]],-1);
                book[a[j]]=j;
                add(1,1,n,j,1);
            }
        }
        t=r;
        ans[h[i].bianhao]=sum(1,1,n,l,r);
    }
    for(int i=0;i<m;i++)
        printf("%d\n",ans[i]);

	return 0;
}


Measured memory_bytes: 19596
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    vector<string> x(3);
    rep(i,3) cin >> x[i];
    vector<int> y(3,0);
    int flag = 0;
    while(true){
        if(y[flag]==x[flag].size()){
            if(flag==0) cout << 'A' << endl;
            else if(flag==1) cout << 'B' << endl;
            else cout << 'C' << endl;
            return 0;
        }
        y[flag]++;
        flag = x[flag][y[flag]-1] -'a';
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true) {
            int n = sc.nextInt();
            if(n == 0) break;
            int i;
            int ave=0;
            int score[] = new int[n];
            for(i=0;i<n;i++){
                score[i] = sc.nextInt();
            }
            Arrays.sort(score);
            for(i=1;i<n-1;i++){
                ave += score[i];
            }
            ave /= n-2;
            System.out.println(ave);
        }
    }
}



Measured memory_bytes: 29360
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_128
{
    class F
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            long[] ss = ReadLongs();
            long res = 0;
            for (int i = 1; i < n / 2; i++)
            {
                long sum = 0;
                var useSet = new HashSet<long>();
                for (int j = 1; i * (j + 1) < n - 1; j++)
                {
                    long other = n - i * j - 1;
                    useSet.Add(i * j);
                    if (useSet.Contains(other)) break;

                    sum += ss[i * j] + ss[other];
                    res = Max(res, sum);
                }
            }
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

int main() {
  double W,H,x,y;
  cin>>W>>H>>x>>y;
  double ans=W*H/2;
  cout<<ans<<' ';
  if(x*2==W&&y*2==H)cout<<1;
  else cout<<0;
  return 0;
}

Measured memory_bytes: 256