akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <type_traits>
using namespace std;

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	os << "{";
	rep(i, (int)v.size()) {
		if (i)
			os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
	for (auto val : array)
		std::cout << val << ", ";
	std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

	int n; std::cin >> n;
	vi a(n);
	rep(i, n) std::cin >> a[i];
	int ans = inf;
	for (int y = -100; y <= 100; y++) {
		int tmp = 0;
		rep(i, n) {
			int cost = abs(a[i] - y);
			tmp += cost * cost;
		}
		chmin(ans, tmp);
	}
	std::cout << ans << "\n";
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        long n = stdIn.nextLong();
        long count = 0;
        count = (n-1) * (1+n-1);
        count /= 2;
        System.out.println(count);
    }
}

Measured memory_bytes: 21844
s = input()
l = len(s)
s3 = ""
if l%2 == 0:
    s1=s[:l//2]
    s2=s[l//2:]
else:
    s1=s[:l//2]
    s2=s[l//2+1:]
hug = 0
for i in range(l//2):
    if s1[-i-1] != s2[i]:
        hug += 1
print(hug)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

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

bool judge(string s) {
  set<string> se;
  int start = 0;
//  cout << s << endl;
  REP(i, s.size()) {
    if (s[i] == '&') {
      start = i+1;
    } else if (isalpha(s[i])) {
      string ss = s.substr(start, i-start+1);
      if (ss.size()==2) {
        if (se.count(ss.substr(1))) {
          return 0;
        }
      } else {
        if (se.count("~"+ss)) {
          return 0;
        }
      }
      se.insert(ss);
    }
  }
  return 1;
}

bool solve(string s) {
  int start = 0;
  bool f = 0;
  REP(i, s.size()) {
    if (s[i] == '(') {
      start = i+1;
      f = 1;
    }
    if (f&&s[i]==')') {
      f = 0;
      if (judge(s.substr(start,i-start)))
        return 1;
    }
  }
  return 0;
}

int main() {
  string s;
  while(cin >> s, s!="#") {
    if (solve(s))
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
  
}

Measured memory_bytes: 904
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int digit_sum(int n) {
  int sum=n%10;
  while(n!=0) {
    n/=10;
    sum+=n%10;
  }
  return sum;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}

int main() {
  int n;
  cin >> n;
  int f=digit_sum(n);
  if(n%f==0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3580
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8

typedef tuple<int,int,int> ti3;

LL calc(vector<ti3> v, vector<ti3> w){
	LL ret = 0;
	int p = 0;
	vector<int> used(v.size());
	while(!v.empty()){
		ti3 t = v.back();
		v.pop_back();
		if(used[get<0>(t)]++){ continue; }
		int l = get<1>(t), r = get<2>(t);
		int np;
		if(l <= p && p <= r){ np = p; }
		else if(p < l){ np = l; }
		else{ np = r; }
		ret += abs(p - np);
		p = np;
		v.swap(w);
	}
	ret += abs(p);
	return ret;
}

void mainmain(){
	int n;
	scanf("%d", &n);
	vector<ti3> v;
	for(int i = 0; i < n; ++i){
		int l, r;
		scanf("%d%d", &l, &r);
		v.emplace_back(i, l, r);
	}
	auto w = v;
	sort(ALL(v), [](const ti3 &a, const ti3 &b){ return get<1>(a) < get<1>(b); });
	sort(ALL(w), [](const ti3 &a, const ti3 &b){ return get<2>(a) > get<2>(b); });
	LL res1 = calc(v, w);
	LL res2 = calc(w, v);
	LL ans = max(res1, res2);
	printf("%lld\n", ans);
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


Measured memory_bytes: 5364
'''
参考
https://www.hamayanhamayan.com/entry/2019/12/29/032305
https://qiita.com/c-yan/items/4724d67c171d82a2366a

パターン1：A,Bともに偶数またはA,Bともに奇数の場合
⇒そのままお互いに近づく…(B-A)/2
パターン2：A,Bのいずれかが奇数の場合
⇒左端（Aに近いほう）か、右端（Bに近いほう）のいずれかで1ターン待機後、お互いに近づく
'''
N, A, B = map(int, input().split())

def approach(x, y):
    return (B-A)//2

ans = 0

if A % 2 == B % 2:
    ans = approach(A, B)
else:
    if A <= (N-B):
        ans += A
        A = 1
        B -= ans
    else:
        ans += N - B + 1
        B = N
        A += ans
    ans += approach(A, B)

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cctype>
#include <bits/stdc++.h>
#include <queue>

using namespace std;
// for loop
#define F(i, L, R) for(long i = L; i < R; i++)
#define FE(i, L, R) for(long i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(long i = L; i > R; i--)
#define FRE(i, L, R) for(long i = L; i >= R; i--)

// data types
#define Int long
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]
#define pb push_back
#define InputV(a, n) F(i,0,n){long l; cin >> l; a.pb(l);}

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323


#define TST 0

int main() {
#if TST==1
    ifstream in ("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int K;
    cin >> K;
    if(K % 2 == 0){
        cout << "-1" << endl;
        return 0;
    }
    unsigned int L = 7;
    for(int i = 0;i < 1000001;i++){
        if(L % K == 0){
            //cout << "ans" << endl;
            cout << i+1 << endl;
            return 0;
        }
        L = (10 * L + 7) % K;
        //cout << L << endl;
    }
    cout << "-1" << endl;

#if TST==1

#endif
}



Measured memory_bytes: 3588
#include<deque>
#include<cstdio>
#include<cstdlib>

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

using namespace std;

const int INF=1<<29;
const int dx[7]={0,1,1,0,-1,-1,0},dy[2][7]={{1,0,-1,-1,-1,0,0},{1,1,0,-1,0,1,0}};

struct state{
	int t,x,y;
	state(int t,int x,int y):t(t),x(x),y(y){}
};

int main(){
	int sx,sy,gx,gy,n; scanf("%d%d%d%d%d",&sx,&sy,&gx,&gy,&n);
	bool kagu[201][201]={};
	rep(i,n){
		int x,y; scanf("%d%d",&x,&y);
		kagu[y+100][x+100]=true;
	}
	int lx,ly; scanf("%d%d",&lx,&ly);

	// お姉さんが指示する方向は時刻について周期 6
	static int dp[6][201][201]; // dp[t][i][j] := ( 時刻 t (mod 6) にマス (i-100, j-100) にいるときの最小コスト )
	rep(t,6) rep(i,201) rep(j,201) dp[t][i][j]=INF;
	dp[0][sy+100][sx+100]=0;

	int ans=-1;
	deque<state> Q; Q.push_back(state(0,sx,sy));
	while(!Q.empty()){
		int t=Q.front().t,x=Q.front().x,y=Q.front().y; Q.pop_front();
		int cost=dp[t][y+100][x+100];

		if(x==gx && y==gy){ ans=cost; break; }

		int ok=abs(x*y*t)%6;
		rep(k,7){
			int xx=x+dx[k],yy=y+dy[abs(x)%2][k];
			if(-lx<=xx && xx<=lx && -ly<=yy && yy<=ly && !kagu[yy+100][xx+100]){
				if(k==ok){
					if(dp[(t+1)%6][yy+100][xx+100]>cost){
						dp[(t+1)%6][yy+100][xx+100]=cost;
						Q.push_front(state((t+1)%6,xx,yy));
					}
				}
				else{
					if(dp[(t+1)%6][yy+100][xx+100]>cost+1){
						dp[(t+1)%6][yy+100][xx+100]=cost+1;
						Q.push_back(state((t+1)%6,xx,yy));
					}
				}
			}
		}
	}

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

	return 0;
}

Measured memory_bytes: 2148
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    ll n, m;
    cin >> n >> m;
    if(2*n >= m){
        cout << m / 2 << endl;
    }else{
        cout << n + (m - 2 * n) / 4 << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
 
int main(){
  	ll N;
  	ll D[2];
  	int count = 0;
  	cin >> N;
  	rep(i, N){
      cin >> D[0];
      cin >> D[1];
      if(D[0] == D[1]){
        count++;
        if(count >= 3) break;
      }
      else count = 0;
    }
  	if(count >= 3) cout << "Yes";
  	else cout << "No";
  	return 0;
}

Measured memory_bytes: 3644
#include <cstdio>
#include <map>

//#define scanf scanf_s

const int kMaxSquare = 64;

int roulette[4];

typedef struct{
	int type;
	int value;
} BoardState;

BoardState board[kMaxSquare];

int bp(int X, int Y){
	std::map<int, double> bp[kMaxSquare];
	double prob = 1.0f / static_cast<double>(X);

	bp[0][0] = 1.0f;
	for (int n = 0; n < Y; n++){
		for (std::map<int, double>::iterator it = bp[n].begin(); it != bp[n].end(); it++){
			for (int k = 0; k < X; k++){
				int pos = (n + roulette[k] < Y) ? n + roulette[k] : Y;
				if (board[pos].type == 1)
					bp[(pos + board[pos].value < Y) ? pos + board[pos].value : Y][it->first] 
						+= it->second * prob;
				else if (board[pos].type == 2)
					bp[pos][it->first + board[pos].value] += it->second * prob;
				else if (board[pos].type == 3)
					bp[pos][(it->first - board[pos].value > 0) ? it->first - board[pos].value : 0] 
						+= it->second * prob;
				else
					bp[pos][it->first] += it->second * prob;				
			}
		}
	}

	double res = 0.0f;
	for (std::map<int, double>::iterator it = bp[Y].begin(); it != bp[Y].end(); it++)
		res += static_cast<double>(it->first) * it->second;
	return static_cast<int>(res);
}

int main(){
	while (1){
		int X, Y, Z; //X:????????¬?????????????????°, Y: ??????????????°(???: ????????????), Z: ???????????????????????°
		scanf("%d %d %d", &X, &Y, &Z);
		if (X == 0) return 0;
		for (int i = 0; i < X; i++)
			scanf("%d", &roulette[i]);
		for (int i = 0; i < kMaxSquare; i++)
			board[i] = { 0, 0 };
		for (; Z > 0; Z--){
			int N, E, A; //N: ?????????, E: ??????????¨????, A: ??????????????§????????° or ?¢????????????????
			scanf("%d %d %d", &N, &E, &A);
			board[N] = { E, A };
		}
		printf("%d\n", bp(X, Y));
	}
}

Measured memory_bytes: 2212
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
 
static const double EPS = 1e-8;

static const int tx[] = {+0,+1,+1,+1,+0,-1,-1,-1,+0};
static const int ty[] = {-1,-1,+0,+1,+1,+1,+0,-1,+0};

struct Cafe {
  int x,y,v;
  Cafe(int x,int y,int v)
    : x(x),y(y),v(v) {}
};

double compute_cost(const vector<Cafe>& cafes, double x, double y){
  double max_cost = 0.0;
  for(int cafe_i = 0; cafe_i < cafes.size(); cafe_i++){
    max_cost = max(max_cost,
                   sqrt((double)(cafes[cafe_i].x - x) * (double)(cafes[cafe_i].x - x)
                        + (double)(cafes[cafe_i].y - y) * (double)(cafes[cafe_i].y - y))
                   / (double)cafes[cafe_i].v);
  }
  return max_cost;
}

double compute_cost(const vector<Cafe>& cafes, double x){
  double upper_y = 100.0;
  double lower_y = 0.0;
  for(int round = 0; round < 50; round++){
    double mid1 = lower_y + (upper_y - lower_y) / 3.0;
    double mid2 = lower_y + 2.0 * (upper_y - lower_y) / 3.0;
    if(compute_cost(cafes,x,mid1) < compute_cost(cafes,x,mid2)){
      upper_y = mid2;
    }
    else{
      lower_y = mid1;
    }
  }
  return compute_cost(cafes,x,lower_y);
}

double compute_cost(const vector<Cafe>& cafes){
  double upper_x = 100.0;
  double lower_x = 0.0;
  for(int round = 0; round < 50; round++){
    double mid1 = lower_x + (upper_x - lower_x) / 3.0;
    double mid2 = lower_x + 2.0 * (upper_x - lower_x) / 3.0;
    if(compute_cost(cafes,mid1) < compute_cost(cafes,mid2)){
      upper_x = mid2;
    }
    else{
      lower_x = mid1;
    }
  }

  return compute_cost(cafes,lower_x);
}


int main(){
  int num_of_cafes;
  while(~scanf("%d",&num_of_cafes)){
    if(num_of_cafes == 0) break;
    vector<Cafe> cafes;
    for(int cafe_i = 0; cafe_i < num_of_cafes; cafe_i++){
      int x,y,v;
      scanf("%d %d %d",&x,&y,&v);
      cafes.push_back(Cafe(x,y,v));
    }
    
    printf("%lf\n",compute_cost(cafes));
  }
}

Measured memory_bytes: 1224
# 問題文
# 3個の整数 A1, A2, A3が与えられます。

# A1+A2+A3 が 22 以上なら bust、
# 21以下なら win を出力してください。

# 制約
# 1≤Ai≤13  (i=1,2,3)
# 入力中のすべての値は整数である。

# 入力
# 入力は以下の形式で標準入力から与えられる。
# A1 A2 A3


# 出力

# A1+A2+A3 が 22 以上なら bust、
# 21 以下なら win を出力せよ。

A1, A2, A3 = map(int, input().split())

if A1 + A2 + A3 >= 22:
    print('bust')
else:
    print('win')

Measured memory_bytes: 2940
#include<iostream>
#include<stack>
#include<string>
using namespace std;
int main() {
	string s;
	while (getline(cin, s)) {
		if (s == ".")return 0;
		bool b = true;
		stack<char>l;
		for (int i = 0; i != s.size(); i++) {
			if (s[i] == '(' || s[i] == '[') {
				l.push(s[i]);
			}
			else if (s[i] == ')') {
				if (l.size() == 0)b = false;
				else if (l.top() == '(') {
					l.pop();
				}
				else b = false;
			}
			else if (s[i] == ']') {
				if (l.size() == 0)b = false;
				else if (l.top() == '[') {
					l.pop();
				}
				else b = false;
			}
		}
		if (l.size() != 0)b = false;
		if (b)cout << "yes\n";
		else cout << "no\n";
	}
}

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

#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int ketasum(int x){
  int sum=0;
  while(x>0){
    sum+=x%10;
    x=x/10;
  }
  return sum;
}

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  int sum=0;
  FOR(i,1,n+1){
    int x=ketasum(i);
    if(x<=b && a<=x){
      sum+=i;
    }
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"
#include "atcoder/fenwicktree.hpp"
using namespace std;
using namespace atcoder;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,q; cin>>n>>q;
    fenwick_tree<ll> bit{n};
    rep(i,n){
        int a; cin>>a;
        bit.add(i,a);
    }
    rep(_,q){
        int t,l,r; cin>>t>>l>>r;
        if(t==0){
            bit.add(l,r);
        }
        else{
            printf("%lld\n",bit.sum(l,r));
        }
    }
}


Measured memory_bytes: 8204
import java.util.Scanner;

public class Main {

	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int m=scan.nextInt();
		int l=0;
		int r=n;
		for(int i=0;i<m;i++)
		{
			int a=scan.nextInt();
			int b=scan.nextInt();
			if(a>l)
			{
				l=a;
			}
			if(b<r) {
				r=b;
			}
			if(b<l || a>r) {
				System.out.println(0);
				return;
			}
		}
		System.out.println(r-l+1);
	}
}


Measured memory_bytes: 64400
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, a) for (ll i = a; i >= 0; --i)
#define all(obj) begin(obj), end(obj)
#define rall(obj) rbegin(obj), rend(obj)
#define pb push_back
#define fst first
#define snd second

ll solve(ll X, ll Y, ll ans) {
    if (X > Y) return ans;
    return solve(X * 2, Y, ans + 1);
}


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll N;
    cin >> N;
    map<ll, ll> A;
    rep (i, N) {
        ll a;
        cin >> a;
        ++A[a];
    }
    ll ans = 0;
    for (auto it : A) {
        if (it.first > it.second) {
            ans += it.second;
        } else {
            ans += it.second - it.first;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 6272
import java.util.*;
//import java.math.BigInteger;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //String str = sc.next();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = 0;
        //int[] m = new int[N];
        
        for(int i=1; i<=b-a; i++){
            ans += i;
        }

        System.out.println(ans-b);
    }
}


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

int main() {
  char c;
  cin >> c;
  if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}


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

int main()
{
  string a, b, c;
  cin >> a >> b >> c;
  char s = a[0];
  a.erase(0, 1);
  if (a.length() == 0)
  {
    cout << 'A' << endl;
    return 0;
  }

  while (1)
  {
    if (s == 'a')
    {
      if (a.length() == 0)
      {
        cout << 'A' << endl;
        break;
      }
      s = a[0];
      a.erase(0, 1);
    }
    else if (s == 'b')
    {
      if (b.length() == 0)
      {
        cout << 'B' << endl;
        break;
      }
      s = b[0];
      b.erase(0, 1);
    }
    else if (s == 'c')
    {
      if (c.length() == 0)
      {
        cout << 'C' << endl;
        break;
      }
      s = c[0];
      c.erase(0, 1);
    }
  }
}


Measured memory_bytes: 3580
arr = gets.strip.split(" ").map!(&:to_i)
l = gets.strip.split(" ").map!(&:to_i)
n = arr[0]
x = arr[1]
sum = 0
count = 1
n.times do |i|
  sum += l[i]
  if(sum > x) then
    puts count
    exit
  end
  count += 1
end
puts count


Measured memory_bytes: 1788
#include <bits/stdc++.h>
        using namespace std;
    	typedef long long int ll; 
    	
    	ll gcd(ll a, ll b){
    	    if(b==0){
    	        return a;
    	    }
    	    return gcd(b,a%b); 
    	}
         
        int main() {
            int N;
            cin >> N;
            vector<ll> A(N);
            
            for (int i = 0; i < N; i++) { 
           		 cin >> A.at(i); 
            }
            ll answer = A.at(0);
            for (int i = 1; i < N; i++) { 
           	   answer  = gcd(answer, A.at(i));
            }   
            cout<< answer; 
     
       }

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

int main(){
	int a, b; cin >> a >> b;
	string s(b, '0'+a);
	string t(a, '0'+b);
	cout << min(s,t) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <map>

using namespace std;
char S[3];
int main(){

cin>>S;
  if(S[0]=='A'&&S[1]=='B'&&S[2]=='C'){cout<<"ARC"<<endl;}
  else{cout<<"ABC"<<endl;}

}


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

int main(){
  vector<int> vec(5);
  for(int i=0; i<5; i++){
    cin >> vec.at(i);
  }
  vector<int> vecX(5);
  for(int j=0; j<5; j++){
    vecX.at(j) = vec.at(j) %10;
  }
  
  int last = 100;
  int last_num = 100;
  for(int k=0; k<5; k++){
    if(vecX.at(k) == 0){
      continue;
    }
    if(last > vecX.at(k)){
      last = vecX.at(k);
      last_num = k;
    }
  }
  int ans = 0;
  for(int l=0; l<5; l++){
    if(l == last_num){
      ans = ans + vec.at(l);
    }
    else if(vec.at(l) %10 == 0){
      ans = ans + vec.at(l);
    }
    else if(vec.at(l) %10 != 0){
      ans = ans + (vec.at(l) / 10 + 1)*10;
    }
  }
  cout << ans << endl;
}

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

int main() {
	int N; cin >> N;
	string S;
	int Snum[26], mini[26];
	for(int i=0; i<26; ++i) mini[i]=60;
	for(int i=0; i<N; ++i){
	    cin >> S;
	    for(int j=0; j<26; ++j) Snum[j]=0;
	    for(int j=0; j<S.size(); ++j) ++Snum[S[j]-'a'];
	    for(int j=0; j<26; ++j) mini[j]=min(mini[j], Snum[j]);
	}
	for(int i=0; i<26; ++i){
	    char ch='a'+i;
	    for(int j=0; j<mini[i]; ++j) cout << ch;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long int;
#define int int64
#define debug(x) cerr<<#x<<" "<<x<<endl;

signed main() {
  int n,q;cin>>n>>q;
  string s;cin>>s;
  vector<char> t(q),d(q);
  for(int i=0;i<q;++i){
    cin>>t[i]>>d[i];
  }
  auto check = [=](int id){
                 for(int i=0;i<q;++i){
                   if(s[id] != t[i]) continue;
                   if(d[i] == 'L'){
                     --id;
                   }else{
                     ++id;
                   }
                   if(id < 0) return -1;
                   if(id > n-1) return 1;
                 }
                 return 0;
               };
    
  int lb_ng = 0,lb_ok = n;
  while(lb_ok-lb_ng > 1){
    int mid = (lb_ok+lb_ng)>>1;
    (check(mid)<0 ? lb_ng : lb_ok) = mid;
  }

  int ub_ng = n,ub_ok = 0;
  while(ub_ng-ub_ok > 1){
    int mid = (ub_ok+ub_ng)>>1;
    (check(mid)>0 ? ub_ng : ub_ok) = mid;
  }
 
  int ans = ub_ok-lb_ok+1;
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 1412
#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)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
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(){
	double W,H,x,y;
	cin>>W>>H>>x>>y;
	double mx = W/2;
	double my = H/2;
	bool ans = false;
	if(x == mx && y == my)ans = true;
	cout<<fixed<<setprecision(10)<<H*W/2<<' ';
	cout<<((ans)?"1":"0")<<endl;
	return 0;
}

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  string tmp;
  cin >> tmp;
  long a, b, c, d;
  a = stol(to_string(tmp.at(0) - '0'));
  b = stol(to_string(tmp.at(1) - '0'));
  c = stol(to_string(tmp.at(2) - '0'));
  d = stol(to_string(tmp.at(3) - '0'));

  long n = 3;
  vector<char> op(n);

  for (long bit = 0; bit < (1 << n); bit++) {
    for (long iflag = 0; iflag < n; iflag++) {
      if (bit & (1 << iflag)) {
        op.at(iflag) = '+';
      } else {
        op.at(iflag) = '-';
      }
    }

    long val = a;
    if (op.at(0) == '+') {
      val += b;
    } else {
      val -= b;
    }
    if (op.at(1) == '+') {
      val += c;
    } else {
      val -= c;
    }
    if (op.at(2) == '+') {
      val += d;
    } else {
      val -= d;
    }
    if (val == 7) {
      cout << a << op.at(0) << b << op.at(1) << c << op.at(2) << d << "=7"
           << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << setprecision(20);
	ll a, b = 0; cin >> a;
	char c; cin >> c;
	b += (c - '0') * 100;
	cin >> c >> c;
	b += (c - '0') * 10;
	cin >> c;
	b += c - '0';
	cout << (a * b)/100;

	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
// 1 <= a <= n
// 1 <= b <= n
// a % b >= K
// a - [a / b] * b >= K
// b
// [a / b]
// min(n, [a / b] * b + K) <= a < min(n, ([a / b] + 1) * b)
ll n, k, ans;

int main() {
    scanf("%lld%lld", &n, &k);
    if (k == 0) ans = n * n;
    else {
        for (ll b = k + 1; b <= n; b++) {
            ans += (n / b) * (b - k);
            if (n % b >= k) ans += n % b - k + 1;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


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

int main(){
  int k,a,b;
  cin >> k >> a >> b;
  for(int i = a;i <= b;i++){
    if(i % k == 0){
      cout << "OK\n";
      return 0;
    }
  }
  cout << "NG\n";
  return 0;
}
      

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

int main(){
  int H,W;cin>>H>>W;
  int N;cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++) cin>>a[i];
  vector<vector<int> > fields(H,vector<int>(W));
  int i=0,j=0;
  for(int k=0;k<N;k++){
    int h=0;
    while(true){
      if(h==a[k]) break;
      fields[i][j]=k+1;
      j++;
      if(j==W){
        i++;
        j=0;
      }
      h++;
    }
  }
  for(int i=0;i<H;i++){
    if(!(i&1)){
      for(auto it=fields[i].begin();it!=fields[i].end();it++){
        cout<<*it<<((it==fields[i].end()-1)?'\n':' ');
      }
    }else{
      for(auto it=fields[i].rbegin();it!=fields[i].rend();it++){
        cout<<*it<<((it==fields[i].rend()-1)?'\n':' ');
      }
    }
  }
  return 0;
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 15;
int N;
int A[MAX_N];
vector<II> X[MAX_N];

signed main()
{
  cin >> N;
  REP(n,N) {
    cin >> A[n];
    REP(i,A[n]) {
      int x,y; cin >> x >> y; x--;
      X[n].push_back(II(x,y));
    }
  }

  int ans = 0;
  REP(S,(1 << N)) {
    bool flag = true;
    int cnt = 0;
    REP(i,N) {
      if((S >> i) & 1) {
        cnt++;
        for(II xy : X[i]) {
          if(xy.second == 1 && !((S >> xy.first) & 1)) {
            flag = false;
          }
          if(xy.second == 0 && ((S >> xy.first) & 1)) {
            flag = false;
          }
          if(!flag) break;
        }
      }
      if(!flag) break;
    }
    if(flag) {
      ans = max(ans, cnt);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int Inf = (1<<30);
ll inf = (1LL<<60);
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main(){
	int n;
	cin >> n;
	vector<int> up(n);
	vector<int> cen(n);
	vector<int> down(n);
	int i;
	for (i = 0; i < n; i++) {
		cin >> up[i];
	}
	for (i = 0; i < n; i++) {
		cin >> cen[i];
	}
	for (i = 0; i < n; i++) {
		cin >> down[i];
	}
	sort(up.begin(), up.end());
	sort(cen.begin(), cen.end());
	sort(down.begin(), down.end());
	ll ans = 0;
	for (i = 0; i < n; i++) {
		auto itr = lower_bound(up.begin(), up.end(), cen[i]); // 使えない
		ll tmp = distance(itr,up.end());
		ll tmp1 = n - tmp;
		auto itr2 = upper_bound(down.begin(), down.end(), cen[i]); // 使える
		ll tmp2 = distance(itr2,down.end());
		if (tmp2 == 1) if (cen[i] >= down[n - 1]) tmp2--;
		ans += tmp1 * tmp2;
	}
	cout << ans;
	return(0);
}

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

using namespace std;
using ll = long long;

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

  ll n, m, k;
  cin >> n >> m >> k;
  vector<ll> a(n);
  vector<ll> b(m);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = 0; i < m; i++)
    cin >> b[i];

  vector<ll> acc1;
  {
    ll sum = 0ll;
    acc1.push_back(0ll);
    for (int i = 0; i < n; i++) {
      sum += a[i];
      acc1.push_back(sum);
    }
  }
  vector<ll> acc2;
  {
    ll sum = 0ll;
    acc2.push_back(0ll);
    for (int i = 0; i < m; i++) {
      sum += b[i];
      acc2.push_back(sum);
    }
  }

  ll ans = 0;
  for (ll i = 0; i <= n; i++) {
    ll left = k - acc1[i];
    if (left < 0) {
      break;
    }
    auto it = upper_bound(acc2.begin(), acc2.end(), left);
    ll sum = i;
    if (it != acc2.begin()) {
      sum += distance(acc2.begin(), it) - 1;
    }
    ans = max(ans, sum);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 11064
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

int32_t next_steps[][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

bool IsValidPosition(const Pair &position, const int32_t N) {
  return position.first >= 0 && position.first <= 100000 && position.second >= 0 && position.second <= 100000;
}

int32_t CanReachWithinTime(const Pair &position, const Pair &target, const int32_t time_limit) {
  const int32_t distance = abs(position.first - target.first) + abs(position.second - target.second);
  return (distance <= time_limit && (time_limit - distance) % 2 == 0);
}

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

  int32_t N;
  cin >> N;
  int32_t previous_time = 0;
  Pair previous_position = Pair(0, 0);
  bool is_okay = true;
  for (int32_t step = 0; step < N; ++step) {
    int32_t taraget_t;
    Pair target_pos;
    cin >> taraget_t >> target_pos.first >> target_pos.second;
    const int32_t dt = taraget_t - previous_time;

    if (!CanReachWithinTime(previous_position, target_pos, dt)) {
      is_okay = false;
    }

    previous_time = taraget_t;
    previous_position = target_pos;
  }
  if (is_okay) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
H=list(map(int,input().split()))
AB=[]
for i in range(M):
    AB.append(list(map(int,input().split())))

J=[0]*N
for i in range(M):
    if H[AB[i][0]-1]<H[AB[i][1]-1]:
        J[AB[i][0]-1]+=1
    elif H[AB[i][0]-1]==H[AB[i][1]-1]:
        J[AB[i][0]-1]+=1
        J[AB[i][1]-1]+=1    
    else:
        J[AB[i][1]-1]+=1
c=0
for i in J:
    if i == 0:
        c+=1

print(c)

Measured memory_bytes: 31948
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;
string yes = "Yes\n";
string no = "No\n";

int  main()
{
	int n; cin >> n;
	if (n < 1200)
		cout << "ABC\n";
	else
		cout << "ARC\n";
	return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(2e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

ll n, T, S, a[3005], b[3005], dp[3005][3005];

int main() {
    cin >> n >> T >> S;
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
    }
    for(int i=0; i<n; i++){
        for(int j=0;j<=S;j++){
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            dp[i][j+1] = max(dp[i][j+1], dp[i][j]);
            if(j+b[i] <= S) dp[i+1][j+b[i]] = max(dp[i+1][j+b[i]], dp[i][j] + a[i]);
        }
    }
    for(int i=0; i<n; i++){
        for(int j=S;j<=T;j++){
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            dp[i][j+1] = max(dp[i][j+1], dp[i][j]);
            if(j+b[i] <= T) dp[i+1][j+b[i]] = max(dp[i+1][j+b[i]], dp[i][j] + a[i]);
        }
    }

    cout << dp[n][T] << endl;
    return 0;
}



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

using namespace std;

#define N 4000
#define BASE 2001
#define MOD 1000000007

int n, a[200005], b[200005], fac[2 * N + 5], facinv[2 * N + 5], f[2 * BASE + 5][2 * BASE + 5], ans;

int fpow(int x, int p) {
    int ret = 1;
    while (p) {
        if (p & 1) ret = 1LL * ret * x % MOD;
        x = 1LL * x * x % MOD;
        p >>= 1;
    }
    return ret;
}

int C(int n, int m) {
    return 1LL * fac[n] * facinv[m] % MOD * facinv[n - m] % MOD;
}

int main() {
    scanf("%d", &n);
    fac[0] = 1;
    for (int i = 1; i <= 2 * N; ++i)
        fac[i] = 1LL * fac[i - 1] * i % MOD;
    facinv[2 * N] = fpow(fac[2 * N], MOD - 2);
    for (int i = 2 * N; i >= 1; --i)
        facinv[i - 1] = 1LL * facinv[i] * i % MOD;
    for (int i = 1; i <= n; ++i) {
        scanf("%d%d", &a[i], &b[i]);
        ans = (ans - C(2 * a[i] + 2 * b[i], 2 * a[i]) + MOD) % MOD;
        f[BASE - a[i]][BASE - b[i]]++;
    }
    for (int i = 1; i <= 2 * BASE; ++i)
        for (int j = 1; j <= 2 * BASE; ++j)
            f[i][j] = (f[i][j] + (f[i - 1][j] + f[i][j - 1]) % MOD) % MOD;
    for (int i = 1; i <= n; ++i)
        ans = (ans + f[a[i] + BASE][b[i] + BASE]) % MOD;
    ans = 1LL * ans * fpow(2, MOD - 2) % MOD;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 64640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int mxn = 2e6 + 1;
ll fac[mxn], inv[mxn];
ll power(ll x, ll y) {
    ll r = 1;
    while (y) {
        if (y & 1)
            r = (r * x) % mod;
        x = (x * x) % mod;
        y >>= 1;
    }
    return r;
}
ll C(int n, int k) {
    if (k < 0 || k > n)
        return 0;
    return ((fac[n] * inv[k]) % mod * inv[n - k]) % mod;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    fac[0] = 1;
    for (int i = 1; i < mxn; i++)
        fac[i] = fac[i - 1] * i % mod;
    inv[mxn - 1] = power(fac[mxn - 1], mod - 2);
    for (int i = mxn - 1; i > 0; i--) {
        inv[i - 1] = inv[i] * (i) % mod;
    }
    int n, k;
    string s;
    cin >> k >> s;
    n = s.size();
    ll ans = 0;
    for (int i = n; i <= k + n; i++) {
        ans = (ans + C(k + n, i) * power(25, k + n - i)) % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35520
#include<stdio.h>

int main(){
	int a[12],b[12];
	int c;
	while(1){
		scanf("%d",&c);
		if(c==0)break;
		for(int i=0;i<12;i++)scanf("%d%d",&a[i],&b[i]);
		int d=0;
		for(int i=0;i<12;i++){
			d+=a[i]-b[i];
			if(d>=c){
				printf("%d\n",i+1);
				break;
			}else if(i==11)printf("NA\n");
		}
	}
}

Measured memory_bytes: 0
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
 
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
#define ll long long
const int mod=1e9+7;
ll n,k,a[100100];
ll F[1<<17],I[1<<17];
ll C(ll a,ll b){return F[a]*I[b]%mod*I[a-b]%mod;}
ll P(ll a,ll b){return b?P(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
int main(){
    int n,k,a[100100];
    cin>>n>>k;
    REP(i,n)cin>>a[i];

    F[0]=1;
    for(int i=1;i<=n;i++)F[i]=F[i-1]*i%mod;

    I[n]=P(F[n],mod-2);
    for(int i=n-1;i>=0;i--)I[i]=I[i+1]*(i+1)%mod;

    sort(a,a+n);

    ll ans=0;
    for(int i=k-1;i<n;i++)
    {
        ans=(ans+a[i]*C(i,k-1))%mod;
        ans=(ans-a[n-i-1]*C(i,k-1))%mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2304
#include <stdio.h>
#define MAX 2000000
#define INF 2147483647

void maxHeapify(int *,int);
int heapExtractMax(int *);
void maxHeapInsert(int *,int);
void heapIncreaseKey(int *,int,int);
void temp(int *,int *);

int j=0;

int main(){
  int i,k,S[MAX];
  char order[8];

  for(i=1;i<MAX;i++){
    scanf("%s",order);
    if(strcmp("insert",order)==0){
      scanf("%d",&k);
      maxHeapInsert(S,k);
    }

    else if(strcmp("extract",order)==0) printf("%d\n",heapExtractMax(S));

    else break;
  }
  return 0;
}

void maxHeapify(int *A,int i){
  int l,r,largest;

  l=i*2;
  r=i*2+1;

  if(l<=j&&A[l]>A[i])
    largest=l;
  else largest=i;

  if(r<=j&&A[r]>A[largest])
    largest=r;

  if(largest!=i){
    temp(&A[i],&A[largest]);
    maxHeapify(A,largest);
  }
}

int heapExtractMax(int *A){
  int max;

  max=A[1];
  A[1]=A[j];
  j--;
  maxHeapify(A,1);
  return max;
}

void maxHeapInsert(int *A,int key){
  j++;
  A[j]=-INF;
  heapIncreaseKey(A,j,key);
}

void heapIncreaseKey(int *A,int i,int key){  
  A[i]=key;

  while(i>1&&A[i/2]<A[i]){
    temp(&A[i],&A[i/2]);
    i=i/2;
  }
}
  
void temp(int *a,int *b){
  int temp;

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

Measured memory_bytes: 5860
#include <stdio.h>
#include <string.h>
int main() {
	char S[201];
	scanf("%s", S);
	int i, j, len = strlen(S), flag = 0;
	for (i = len -1; i >= 0; i--) {
		int half = i / 2;
		for (j = 0; j < half; j++) {
			if (S[j] == S[half + j]) {
				flag = 1;
			} else {
				flag = 0;
				break;
			}
		}
		if (flag) {
			printf("%d\n", i - 1);
			break;
		}
	}
	return 0;
}


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

int main() {
    ll n;
    cin >> n;
    int cnt = to_string(n).length();
    for (ll i=1; i*i<=n; i++) {
        if (n % i == 0) {
            ll a = i;
            ll b = n / i;
            int val = max(to_string(a).length(), to_string(b).length());
            cnt = min(val, cnt);
        }
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll=long long;  
using pLL = std::pair<ll, ll>;
ll N,P;

#define SORT(v) std::sort(v.begin(), v.end())
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N >>P;
  
    if(P==1){
        cout << 1 << endl;
        return 0;
    }else if(N==1){
        cout << P <<endl;
        return 0;
    }
    map<int,int> mp;
    int j=2;
    while(P%j==0){
        P/=j;
        mp[2]++;
        
    }
    for(ll j=3;j*j<=P;j+=2){
        while(P%j==0){
            P/=j;
            mp[j]++;
            
        }
    }
    int ans=1;
    for(auto i=mp.begin();i!=mp.end();++i){
        if(i->second>=N){
            for(int j=0;j<(i->second/N);j++)
            ans*=i->first;
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,abm,mmx,avx,avx2,popcnt,tune=native")
//#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#pragma comment(linker, "/STACK:36777216")

#define _CRT_SECURE_NO_WARNINGS
#include <chrono>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
#include <iomanip>
#include <numeric>
#include <time.h>//////////////
#include <ctime>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
#define endl '\n'
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define queuel queue<long long>
#define sqr(a) ((a) * (a))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pin(p) cin >> p.first >> p.second;
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define rev(v) reverse(v.begin(), v.end());
#define sout(s, c) for (auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for (int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for (int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define fastio() ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); srand(time(NULL))
#define sp system("pause")
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const ld EPS = 1e-4;
const int inf = 1e9;
const ld PI = acos(-1);
int mod = (int)998244353;
const int MOD7 = 1000000007;
const int MOD9 = 1000000009;
const int a228 = 18;
const ll kekmod = 1791791791;
const ll bestmod = 1148822869;
const ll secmod = (int) 1e9 + 113;
vector<ll> mods = { kekmod,bestmod,mod,MOD9,1000000007 };
vector<ll> hashpows = { 29,31,37,43,47,53,179,229 };
const int MAXN = 1e5 + 229;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count() + 228 + 'i' + 'q' + 1337 + 1488);
ll MOD = mods[rnd() % mods.size()];
ll hashpow = hashpows[rand() % hashpows.size()];

signed main()
{
	fastio();
	int a, b;
	cin >> a >> b;
	cout << (a ^ b ^ 1 ^ 2 ^ 3);
	sp;
}

Measured memory_bytes: 504