akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;
// static const ll max_n = 200010;
// 9223372036854775807
static const ll max_l = 4000000000000000000;
static const ll max_o = 9223372036854775807;

int main(){
    // int u, v;
    // bool updated = false;
    ll a,b,c;
    cin >> a >>b >> c;
    ll left = 4*a * b;
    ll right = (c - (a+b));
    // ll small_right = right / 4;
    if(a+b>=c){
        printf("No\n");
    }else{
        right = right * right;
        // cout << right <<endl;
        // cout << left <<endl;
        if(left < right){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }
    
    return 0;

}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  int sum = 0;
  cin >> A[0];
  for (int i = 1; i < N; i++) {
    cin >> A[i];
    sum += abs(A[i-1]-A[i]);
  }
  sum += abs(A[0]) + abs(A[N-1]);
  for (int i = 0; i < N; i++) {
    if (i == 0) cout << sum - abs(A[0]-A[1]) - abs(A[0]) + abs(A[1]) << endl;
    else if (i == N-1) cout << sum - abs(A[N-2]-A[N-1]) - abs(A[N-1]) + abs(A[N-2]) << endl;
    else cout << sum - abs(A[i-1]-A[i]) - abs(A[i]-A[i+1]) + abs(A[i-1]-A[i+1]) << endl;
  }
}


Measured memory_bytes: 3704
#include <iostream>
#include <vector>
#include <string>

using namespace std;


int N;
string X;
vector<string>s;
vector<int> t;

int main()
{


	cin >> N;

	s = vector<string>(N);
	t = vector<int>(N);

	int ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> s[i];
		cin >> t[i];

		ans += t[i];
	}

	cin >> X;

	for (int i = 0; i < N; i++) {
		ans -= t[i];
		if (s[i].compare(X)==0) {
			break;
		}
	}

	cout << ans << endl;

	return 0;
}



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

typedef pair<int,int> P;
const int POINT = 1004*1004;
int H,W;

struct Edge{int to;int cost;};
void Dijk(vector<Edge> G[],int n,int s,int res[POINT]){
	bool vis[POINT]={0};
	fill(res,res+n,-1);
	priority_queue<P,vector<P>,greater<P>> que;
	P p;
	vis[s]=true;
	res[s]=0;
	que.push(P(0,s));
	while(!que.empty()){
		p = que.top();
		que.pop();
		for(Edge e:G[p.second]){
			if(!vis[e.to] || res[e.to]>res[p.second]+e.cost){
				vis[e.to]=true;
				res[e.to]=res[p.second]+e.cost;
				que.push(P(res[e.to],e.to));
			}
		}
	}
}

int id(int i,int j){return i*(W+4)+j;}
int abs(int a){return a>0?a:-a;}

int main(){
	int Ch,Cw,Dh,Dw;
	char s;
	int ans[POINT];
	vector<Edge> G[POINT];
	cin>>H>>W>>Ch>>Cw>>Dh>>Dw;
	bool F[H+4][W+4]={0};
	Ch+=1;
	Cw+=1;
	Dh+=1;
	Dw+=1;
	for(int i=2;i<H+2;i++){
		for(int j=2;j<W+2;j++){
			cin>>s;
			F[i][j]=s=='.';
		}
	}
	for(int i=2;i<H+2;i++){
		for(int j=2;j<W+2;j++){
			for(int ii=i-2;ii<=i+2;ii++)for(int jj=j-2;jj<=j+2;jj++){
				if(F[ii][jj])G[id(i,j)].push_back({id(ii,jj),(abs(i-ii)+abs(j-jj))>=2?1:0});
			}
		}
	}
	Dijk(G,(H+4)*(W+4),id(Ch,Cw),ans);
	cout<<ans[id(Dh,Dw)];
	return 0;
}

Measured memory_bytes: 177016
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,m = readInts()
A = set()
B = set()
for i in range(m):
    a,b = readInts()
    if a == 1:
        A.add(b)
    if b == n:
        B.add(a)
print('POSSIBLE' if A&B else 'IMPOSSIBLE')


Measured memory_bytes: 25356
#include<bits/stdc++.h>
using namespace std;
#define N 100005
typedef long long ll;
ll MOD = 1000000007;
vector< ll > G[200005];
ll ans[200005];
ll t[200005];
void dfs(int a , int b , int c){
	ans[a] = c + t[a];
	for(int i = 0 ; i < G[a].size() ; i++){
		if(G[a][i] == b) continue;
		dfs(G[a][i] , a , ans[a]);
	}
}
int main()
{
    int n , q;
    cin >> n >> q;
    for(int i = 0 ; i < n - 1 ; i++){
    	int x , y;
    	cin >> x >> y;
    	x--;
    	y--;
    	G[x].push_back(y);
    	G[y].push_back(x);
    }
    for(int i = 0 ; i < q ; i++){
    	int z , x;
    	cin >> z >> x;
    	z--;
    	t[z] += x;
    }
    dfs(0 , -1 , 0);
    for(int i = 0 ; i < n ; i++){
    	if(i)
    		cout <<" ";
    	cout << ans[i];
    }
    cout << endl;

}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n;
    cin >> n;
    vector<string> s(n);
    REP(i, n) cin >> s[i];

    ll ret = 0;
    map<string, ll> mp;
    REP(i, n) {
        sort(ALL(s[i]));
        if(mp.find(s[i]) != mp.end()) ret += mp[s[i]];
        mp[s[i]]++;
    }
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
#define ii pair<int,int>
#define ll long long
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define sz(x) (int)(x).size()
#define INF 1000000000
bool die[10];
bool can(int x) {
	while(x>0) {
		int y=(x%10);
		if (die[y]) return 0;
		x/=10;
	}
	return 1;
}
int main() {
	int n,k,d;
	scanf("%d%d",&n,&k);
	for (int i=0;i<k;i++) {
		scanf("%d",&d);
		die[d]=1;
	}
	int cur=n;
	while(1) {
		if (can(cur)) {
			printf("%d\n", cur);
			return 0;
		}
		cur++;
	}
	return 0;
}

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

int main() {
	int n;
	int cards[4][13] = {};

	char suit;
	int temp;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> suit;

		switch (suit) {
		case 'S':
			cin >> temp;
			cards[0][temp-1] = 1;
			break;
		case 'H':
			cin >> temp;
			cards[1][temp-1] = 1;
			break;
		case 'C':
			cin >> temp;
			cards[2][temp-1] = 1;
			break;
		case 'D':
			cin >> temp;
			cards[3][temp-1] = 1;
			break;
		}
	}

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			switch (i) {
			case 0:
				if (cards[i][j] != 1) {
					printf("S %d\n", j + 1);
				}
				break;
			case 1:
				if (cards[i][j] != 1) {
					printf("H %d\n", j + 1);
				}
				break;
			case 2:
				if (cards[i][j] != 1) {
					printf("C %d\n", j + 1);
				}
				break;
			case 3:
				if (cards[i][j] != 1) {
					printf("D %d\n", j + 1);
				}
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3200
N = int(input())
c = input()
C = []
for c_i in c:
    C.append(c_i)
count = 0
left = N-1
for i in range(N):
    if i >= left:
        print(count)
        break
    if C[i] == 'W':
        for j in reversed(range(left+1)):
            if i == 1:
                if j == i:
                    C[i] = 'R'
                    left = i
                    break
            else:
                if j == i-1:
                    left = i
                    break
            if C[j] == 'R':
                C[i] = 'R'
                C[j] = 'W'
                left = j
                count += 1
                break

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

int main(){
    int n, m, s = 0;
    int a[100];
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        s += a[i];
    }
    float dk = (float)1/(4*m);
    dk *= s;
    int dem = 0;
    for(int i = 0; i < n; i++)
        if(a[i]>=dk)
            dem++;
    if(dem >= m) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;cin >> N;
	for(ll h=1;h<=3500;++h){
		for(ll n=1;n<=3500;++n){
			if(4*h*n-N*h-N*n<=0) continue;
			if(N*h*n%(4*h*n-N*h-N*n)!=0) continue;
			ll w=N*h*n/(4*h*n-N*h-N*n);
			cout << h << " " << n << " " << w << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
  int n = 0;
  cin >> n;
  vector<vector<int> > kazu(10,vector<int>(10));
  for(int i = 0;i <= 9;i++){
    for(int j = 0;j <= 9;j++){
      kazu[i][j] = 0;
    }
  }
      for(int k = 1;k <= n;k++){
        string moji;
        moji = to_string(k);
        //cout << "mojiの最初" << moji[0] << " i" << i << " mojiの最後" << moji[moji.size() - 1] << " j" << j << endl;
        kazu[moji[0] - '0'][moji[moji.size() - 1] - '0']++;
      }
  long long kotae = 0;
  for(int i = 0;i <= 9;i++){
    for(int j = 0;j <= 9;j++){
      kotae += kazu[i][j] * kazu[j][i]; 
      //cout << kazu[i][j] << " " << kazu[j][i] << endl;
    }
  }
  cout << kotae << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
#define pi acos(-1)
#define faster_io ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

int main()
{
    //freopen("/home/sohel/Documents/my_codes/out.txt", "wt", stdout);
    int n,temp;
    faster_io;
    cin >> n;
    temp = n % 1000;
    if (temp == 0)
    {
        cout << temp << endl;
    }
    else {
        cout << 1000 - temp << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int a,b;cin>>a>>b;
  if(a==1)a=14;
  if(b==1)b=14;
  if(a<b){
    P("Bob");
  }else if(a>b){
    P("Alice");
  }else{
    P("Draw");
  }
  return 0;
}


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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t n;
  cin >> n;
  int64_t val = n;
  string name = "";
  string cur = "";
  do{
    val--;
    cur = (char)(((val)%26)+'a') ;
    name = cur + name;
    if(val<26) break;
    val /= 26;
  }while(val>0);
  cout << name << endl;
  return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;

    vector<vector<int> > num(h+1, vector<int>(w+1, INT_MAX/2));
    num[0][1] = 0;
    for(int i=1; i<=h; ++i){
        for(int j=1; j<=w; ++j){
            char c;
            cin >> c;
            num[i][j] = min(num[i-1][j], num[i][j-1]) + (c - '0');
        }
    }

    cout << num[h][w] << endl;

    return 0;
}

Measured memory_bytes: 0
// https://atcoder.jp/contests/dp/tasks/dp_b

#include <bits/stdc++.h>
using namespace std;
typedef std::pair<int, int> ipair;
#define int long long
#define pb push_back
#define ff first
#define INF INT_MAX
#define ss second
#define rep(i, a) for (int i = 0; i < a; i++)
#define fr(i, j, a) for (int i = j; i < a; i++)
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define mp make_pair
#define mod 1000000007
#define IOS                                                                    \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
void init() {
  int n, K;
  cin >> n >> K;
  vector<int> h(n), dp(n, INT_MAX);
  fr(i, 0, n) cin >> h[i];
  dp[0] = 0;
  /*for(int i=0;i<n;i++){
    for(int k=K;k>=0;k--){
      if(i-k>=0) dp[i]=min(dp[i],dp[i-k]+abs(h[i]-h[i-k]));
    }
  }
  for (int i = 0; i < n; ++i) { // dp[j] - min total cost incurred to reach step
  j for (int j = i + 1; j <= i + K; ++j) { if (j < n) { dp[j] = min(dp[j], dp[i]
  + abs(h[i] - h[j]));
      }
    }
  }*/
  for (int i = 1; i < n; i++) {
    for (int j = 1; j <= K; j++) {
      if (i - j >= 0)
        dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i-j]));
    }
  }
  cout << dp[n - 1] << endl;
}
int32_t main() {
  IOS;
  init();
  return 0;
}


Measured memory_bytes: 4792
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int a,b;
  cin>>a>>b;
  if(a%3==0||b%3==0||(a+b)%3==0) cout<<"Possible"<<endl;
  else cout<<"Impossible"<<endl;
  return 0;
}


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

using ll = long long;

int main() {
    int n; cin >> n;
    vector<int> p(n);
    ll ans = 0;
    for(int i = 0; i < n; ++i) {
        cin >> p[i];
        ans += p[i];
    }
    sort(begin(p), end(p));
    ans -= p.back() / 2;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vi b(n);
    rep(i, n-1) cin >> b[i];
    
    vi a(n);
    a[0] = b[0];
    a[n-1] = b[n-2];
    for (int i=1;i<n-1;i++){
        a[i] = min(b[i], b[i-1]);
    }
    
    ll ans=0;
    rep(i, n) ans += a[i];
    cout << ans << endl;
}


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

int main(){
 long long  int n,a[200010];
  cin >> n ;
  
  for(int i=0;i<n;i++)
    cin >> a[i];
  
 map<int, int> b;
	for (int i = 0; i < n; i++)
		b[a[i]]++;
 
	int ans = 0;
	for (auto p: b) {
		int x = p.first;
		int n = p.second;
		if (n < x) ans += n;
		else ans += n - x;
	}
  
  cout << ans << endl;
}
    
  
  
  
    
 
 


Measured memory_bytes: 5504
import java.util.*;
//たてH cm よこ W cm の枠を描くプログラム
//H, W がともに 0 のとき、入力の終わり
public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
       Scanner sc = new Scanner(System.in);
        
    while (sc.hasNextLine()) {
        
        int H = sc.nextInt();
        int W = sc.nextInt();
        int i;
        int j;
        
        
if(H == 0 && W == 0){  
          break;
}else{

  for ( i = 0; i < H; i++ ){
    for ( j = 0; j < W; j++ ){
    if( j == 0 || j == W-1 || i == 0 || i == H-1){
        System.out.print("#");
    }else{
        System.out.print(".");
    }
    }        System.out.println("");
  }

}     System.out.println();
}
}
}



Measured memory_bytes: 32892
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
double T, X;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> T >> X;

  cout << (T / X) << endl;
}


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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        int a = in.ni(), b = in.ni(), c = in.ni(), k = in.ni();
        if(k<=a){
            out.println(k);
        }else{
            k -= a;
            if(k<=b) {
                out.println(a);
            }else{
                k -= b;
                if(k<=c)out.println(a-k);
                else{
                    out.println(a-c);
                }
            }
        }
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 32892
#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() {
  int N;
  string c;
  cin >> N >> c;
  int ans = 0;
  int cnt = 0;
  
  rep(i, N){
   if(c.at(i) == 'R') cnt++;
  }
  rep(i, cnt){
   if(c.at(i) == 'W') ans++; 
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3756
// #include C {
#include<cstring>
#include<cassert>
#include<cstdio>
#include<cctype>
#include<cmath>
// }

// #include C++ {
#include<functional>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<map>
#include<set>
// }

using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef DEBUG_MODE

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 205
#define MAX_M 100005
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
//  WF("output.txt");
	DF("err.txt");
	
	char str[MAX_N];
	scanf("%s", str);
	int n = strlen(str);
	int res = 0;
	for (int i = 0; i < n; i++)
		res += str[i] == '1';
	printf("%d\n", res);
}

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


int main() {
	long long K, N;
	long long A;

	cin >> N >> K;

	for (int i = 0; i < N; ++i) {
		cin >> A;
	}
	int res = 0;
	if ((N - 1) % (K - 1) != 0) {
		++res;
	}

	cout << (N - 1) / (K - 1) + res  << endl;
}


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

int main() {
	int A , B ;
    cin >> A >> B ;
  	int kaibunsu = 0;
    for(int i = A; i <= B; i++){
        if(i / 10000 == i % 10 && i % 10000 / 1000 == i % 100 / 10){
        	kaibunsu++;
        }
    }
    cout << kaibunsu << endl;
}


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

int main()
{
    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    vector<bool> p_bool(101, false);
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
        p_bool[p[i]] = true;
    }
    int ans = 1000000;

    if (p_bool[x] == false)
    {
        ans = x;
    }
    else
    {
        int i = 1;
        while (true)
        {
            if (p_bool[x - i] == false)
            {
                ans = x - i;
                break;
            }
            if (p_bool[x + i] == false)
            {
                ans = x + i;
                break;
            }
            i++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
/*        ~ABC 171~
 *    code by kazalika   */
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int N = 1e5 + 5;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  ll sm = 0;
  vector<ll> a(n), cnt(N);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    cnt[a[i]]++;
    sm += a[i];
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    ll b, c;
    cin >> b >> c;
    sm -= cnt[b] * b;
    sm += cnt[b] * c;
    cnt[c] += cnt[b];
    cnt[b] = 0;
    cout << sm << '\n';
  }
}

Measured memory_bytes: 4780
#include<iostream>
#include<string>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
// #define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)
#define min(a,b) (a>b?b:a)
#define max(a,b) (a>b?a:b)
#define yn(f) (f?"Yes":"No")
#define YN(f) (f?"YES":"NO")

vector<pair<int,int>> xx[201000];
vector<int> temp;
int huga[201000];
signed main(){
	int n, m , p, y, count = 1, size = 0;
	vector<pair<int,pair<int,int>>> hoge;
	cin>>n>>m;
	
	for(int i = 1; i <= m; i++){
		cin>>p>>y;
		xx[p].push_back(make_pair(y,i));
		if(huga[p] == 0)temp.push_back(p);
		huga[p] = 1;
	}
	for(int yy : temp){//cout<<y<<endl;
		sort(xx[yy].begin(), xx[yy].end());
		int count = 1;
		for(pair<int,int> z : xx[yy]){
			hoge.push_back(make_pair(z.second,make_pair(yy,count++)));
		}
	}

	sort(hoge.begin(), hoge.end());
	for(int i = 0; i < m; i++){
		// if(to_string(hoge[i].second.first).size() <= 6){
			// printf("%06d", hoge[i].second.first);
		// } else {
			// printf("%6d", hoge[i].second.first);
		// }
		// if(to_string(hoge[i].second.second).size() <= 6){
			// printf("%06d\n", hoge[i].second.second);
		// } else {
			// printf("%6d\n", hoge[i].second.second);
		// }
		
		printf("%06d%06d\n", hoge[i].second.first, hoge[i].second.second);
	}
	
	return 0;
}

Measured memory_bytes: 11632
(defun solve ()
  (let* ((n (read))
         (v (make-array n :element-type '(cons fixnum fixnum))))
    (dotimes (i n)
      (setf (aref v i) (cons (read) (read))))
    (sort v (lambda (c1 c2) (> (cdr c1) (cdr c2))))
    (let ((x (cdr (aref v 0))))
      (dotimes (i n)
        (setf x (- (min x (cdr (aref v i))) (car (aref v i)))))
      (if (< x 0)
          "No"
          "Yes"))))
(format t "~A~%" (solve))

Measured memory_bytes: 63908
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int K = sc.nextInt();
		System.out.println(Math.min(K, A)- Math.max(0, K-A-B));

		sc.close();
	}
}


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

public class Main {
    public static void main(String... args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();

        int[] okashi = new int[N];

        for (int i = 0; i < K; i++) {
            int d = scanner.nextInt();
            for (int j = 0; j < d; j++) {
                int A = scanner.nextInt();
                okashi[A-1]++;
            }
        }

        System.out.println(Arrays.stream(okashi).filter(i -> i == 0).count());
    }
}


Measured memory_bytes: 40808
#include <iostream>
#include <map>
#include <cstring>

using namespace std;

char group[2][100] = {
	"qwertasdfgzxcvb",
	"yuiophjklnm",
};

int main() {
	map<char, int> m;
	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < strlen(group[i]); ++j) {
			m[group[i][j]] = i;
		}
	}
	string str;
	while ( cin >> str, str != "#" ) {
		int bid = -1;
		int ans = 0;
		for (int i = 0; i < str.size(); ++i) {
			int g = m[str[i]];
			if (bid != -1 && g != bid) {
				++ans;
			}
			bid = g;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1188
n=int(input())
m=int(n**0.5)
li=[0]*(10**4)
c=0
for i in range(1,m):
  for j in range(1,m):
    for k in range(1,m):
      if i*i+j*j+k*k+i*j+k*j+k*i<=n:
        li[i*i+j*j+k*k+i*j+k*j+k*i-1]+=1
for i in range(n):
  print(li[i])


Measured memory_bytes: 9724
#include <bits/stdc++.h>
#define fi first
#define se second
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;



int main() {
  int n;
  scanf("%d",&n);
  vi a(n);
  cin>>a;
  ll ans = 0;
  int pre = 0;
  drep(i,n) {
    if (a[i] < pre-1) dame;
    if (a[i] != pre-1) ans += a[i];
    pre = a[i];
  }
  if (pre != 0) dame;
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

void inp_str(int*);

int main(void) {

    char str1[16];
    char str2[16];
    scanf("%s %s", str1, str2);

int A,P;

A=atoi(str1);
P=atoi(str2);

//printf("N=%d\n",N);
//printf("M=%d\n",M);

int ans;

ans=A*3+P;
ans=ans/2;

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


    return 0;

}


void inp_str(int instr[]){
char *ptr;
int z,i,count;
char str[100]={'\0'};
char *ln;

fgets(str, 100, stdin); // 入力："123456\n"
ln = strchr(str, '\n'); /* 改行文字を検索 */
if (ln != NULL) { /* 改行が読み取られていたかどうか */
   *ln = '\0';    /* 改行文字を終端文字に置き換える */
}
else {            /* 入力ストリーム上に文字が残ってる場合 */
   while (1) {    /* 改行文字が読み取られるまで空読みする */
       z = getchar();
      if (z == '\n' || z == EOF) break;
   }
}
	count=0;
    ptr = strtok(str, " ");
    i = atoi(ptr);
    instr[count]=i;
    count=count+1;
    // 2回目以降
    while(ptr != NULL) {
        // strtok関数により変更されたNULLのポインタが先頭
        ptr = strtok(NULL, " ");
        // ptrがNULLの場合エラーが発生するので対処
        if(ptr != NULL) {
		    i = atoi(ptr);
    instr[count]=i;
    		count=count+1;
        }
    }
}



Measured memory_bytes: 128
#include <stdio.h>


int main(void)
{
	char op[2];
	int a,b;
	scanf("%d%s%d",&a,op,&b);
	if(op[0] != '-')
		{
		int add=a+b;
		printf("%d",add);
		}
	else
		{
		int sub=a-b;
		printf("%d",sub);
		}
	return 0;
}


Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules! invec {
    ( $t:ty ) => {{
        let mut s = String::new();
        match std::io::stdin().read_line(&mut s) {
            Ok(0) => Vec::<$t>::new(),
            Ok(n) => s.trim().split_whitespace().map(|s| s.parse::<$t>().unwrap()).collect::<Vec<$t>>(),
            Err(_) => Vec::<$t>::new(),
        }
    }}
}

#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (n,) = input!(usize);
    let mut arr = invec!(u32);

    arr.sort();

    let middle_1 = arr[(arr.len() / 2) - 1];
    let middle_2 = arr[arr.len() / 2];

    println!("{}", middle_2 - middle_1);
}

fn main() {
    solve();
}


Measured memory_bytes: 4352
#include<iostream>
int A, B;
int main(){
    std::cin >> A >> B;
    if(A<=B){
        for(int i=0; i<B; i++){
            std::cout << A;
        }
        std::cout <<"\n";
    }else{
        for(int i=0; i<A; i++){
            std::cout << B;
        }
        std::cout <<"\n";
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var a string
	fmt.Scan(&a)

	strs := strings.Split(a, "")
	var x, y string
	x = strs[0]
	for i := 1; i < len(strs); i++ {
		if x != strs[i] {
			y = strs[i]
			break
		}
	}

	n, m := 0, 0
	for i := 0; i < len(strs); i++ {
		if x == strs[i] {
			n++
		} else if y == strs[i] {
			m++
		}
	}

	if n == 2 && m == 2 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

#define FOR(i, l, r) for (int i = (l); i <= (r); ++i)

typedef long long LL;
const LL mod = 1000000007;
LL n, k;
LL pow(LL x, LL n) {
    LL ret = 1;
    while(n) {
        if (n & 1) {ret *= x; ret %= mod;}
        x *= x; x %= mod; n >>= 1;
    }
    return ret;
}

LL inv(LL x) {
    return pow(x, mod - 2);
}

LL C(int n, int k) {
    if (k < 0 || k > n) return 0;
    if (k == 0) return 1;
    if (k == 1) return n;
    LL ret = n;
    for (int i = 2; i <= k; ++i) {
        ret *= (n - i + 1); ret %= mod;
        ret *= inv(i); ret %= mod;
    }
    return ret;
}

LL Cnext(LL n, LL k, LL Cnkm1) {
    LL ret = Cnkm1 * (n - k + 1); ret %= mod;
    ret *= inv(k); ret %= mod;
    return ret;
}

const int maxn = 200005;
LL a[maxn], b[maxn];

int main() {
#ifdef __APPLE__
    freopen("main.in", "r", stdin);
#endif
    cin >> n >> k;
    if (k == 1) {
        cout << n << endl;
        return 0;
    }
    if (k >= n) k = n - 1;
    /*a[0] = 1;
    for (int i = 1; i <= k; ++i) {
        LL next = Cnext(n - 1 + i - 1, i, a[i - 1]);
        a[i] = (a[i - 1] + next) % mod;
    }
    LL ans = 0;
    for (int i = 0; i <= k; ++i) {
        ans += a[i]; ans %= mod;
    }
    cout << ans << endl;*/

    a[0] = 1;
    for (int i = 1; i <= n - 1; ++i) {
        a[i] = Cnext(n - 1, i, a[i - 1]);
    }

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


Measured memory_bytes: 3456
// abc092-b.scala
object Main extends App {
  val n = io.StdIn.readInt
  val Array(d,x) = io.StdIn.readLine.split(" ").map(_.toDouble)
  val as = for (_ <- 1 to n) yield io.StdIn.readInt

  val result = x + as.map(ai => (d/ai).ceil).sum
  println(result.toInt)
}

Measured memory_bytes: 55024
#include <iostream>

using namespace std;

int main() {
  int a, b;
  while (cin >> a >> b) {
    int sum = a + b;
    int digit = 0;
    while (sum != 0) {
      sum /= 10;
      digit++;
    }
    cout << digit << endl;
  }
  return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <set>

using namespace std;
 
int main() {
    int n,m,temp;
    cin >> n >> m;
    multiset<int> a;
    for(int i=0;i<n;i++){
        cin >> temp;
        a.insert(temp);
    }
    for(int i=0;i<m;i++){
        auto a_itr = a.end();
        a_itr--;
        temp = *a_itr;
        a.erase(a_itr);
        temp/=2;
        a.insert(temp);
    }
    unsigned long result=0;
    for (auto itr=a.begin(); itr!=a.end(); itr++){
        result+=(*itr);
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define all(v) v.begin(), v.end()
#define lint long long
auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;};
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail){
  std::cerr << " " << head;
  debug_impl(tail...);
}
#define debug(...)\
  std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
  debug_impl(__VA_ARGS__);\
  std::cerr << std::noboolalpha;

template <typename T>
std::istream& operator>> (std::istream& is, std::vector<T>& v) {
  for (auto & x : v) is >> x;
  return is;
}

template <typename T>
std::ostream& operator<< (std::ostream& os, const std::vector<T>& v) {
  auto n = v.size();
  os << "{";
  for (size_t i = 0; i < n; i++)
    {os << (i > 0 ? "," : "") << v.at(i);}
  return os << "}";
}

template <typename... Args, std::size_t ... Inds>
std::ostream& tuple_output_impl(
  std::ostream& os,
  const std::tuple<Args...>& tuple,
  std::integer_sequence<std::size_t, Inds...>
)
{
  os << "(";
  (void)std::initializer_list<int>{(
    (void)(os << (Inds > 0 ? "," : "") << std::get<Inds>(tuple)), 0
  )...};
  return os << ")";
}
template <typename... Args>
std::ostream& operator<< (std::ostream& os, const std::tuple<Args...>& tuple)
 { return tuple_output_impl(os, tuple, std::index_sequence_for<Args...>()); }

template <typename... Args, std::size_t ... Inds>
std::istream& tuple_input_impl(
  std::istream& is,
  std::tuple<Args...>& tuple,
  std::integer_sequence<std::size_t, Inds...>
)
{
  (void)std::initializer_list<int>{(
    (void)(is >> std::get<Inds>(tuple)), 0
  )...};
  return is;
}
template <typename... Args>
std::istream& operator>> (std::istream& is, std::tuple<Args...>& tuple)
  { return tuple_input_impl(is, tuple, std::index_sequence_for<Args...>()); }

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n, c; std::cin >> n >> c;
  // time, rl, channel
  auto events = std::vector< std::tuple< int, int, int > >{};
  auto max = 0;
  loop(n) {
    int l, r, c;
    std::cin >> l >> r >> c;
    l--, r--, c--;
    cmx(max, r);
    events.emplace_back(l, 1, c);
    events.emplace_back(r, 0, c);
  }
  std::sort(all(events));
  std::reverse(all(events));
  auto ret = 0;
  auto prv = std::vector< int >(c, false);
  auto crr = std::vector< int >(c, false);
  rep(i, 0, max + 1) {
    while (!events.empty()) {
      int time, rl, c;
      std::tie(time, rl, c) = events.back();
      if (i < time) break;
      events.pop_back();
      if (rl == 0) {
        // assert(crr.at(c) == true);
        crr.at(c) = false;
      } else {
        // assert(crr.at(c) == false);
        crr.at(c) = true;
      }
    }
    auto now = 0;
    rep(i, 0, c)
      { now += prv.at(i) || crr.at(i); }
    cmx(ret, now);
    prv = crr;
  }
  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 4980
def compare(num):
    count=0
    d=list(range(1,num+1,2))
    return len(d)
# スペース区切りの整数の入力
b, c = map(int, input().split())
answer=compare(b)
#print(answer)
if answer>=c:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3064
#include <stdio.h>
#define N 1000000


int A[N];
int count=0;

/* Merge */
void Merge(int A[],int l,int m,int r){
    int n1,n2;
    int i,j,k;
    int L[N],R[N];
    
    n1=m-l;
    n2=r-m;
    
    for(i=0;i<n1;i++)L[i]=A[l+i];
    for(j=0;j<n2;j++)R[j]=A[m+j];
    
    L[n1] = 2147483647;
    R[n2] = 2147483647;
    
    i=0;
    j=0;
    
    for(k=l;k<r;k++){
        if(L[i]<=R[j]){
            A[k]=L[i];
            count++;
            i++;
        }else{
            A[k]=R[j];
            count++;
            j++;
        }
    }
    
}

/* Merge Sort */
void Merge_Sort(int A[],int left,int right){
    int mid;
    if(left+1<right){
        mid = (left + right)/2;
        Merge_Sort(A,left,mid);
        Merge_Sort(A,mid,right);
        Merge(A,left,mid,right);
    }
}// End Merge-Sort







int main(int argc , char *argv[]){
    int n,i;
    
    
 /* INCERT　SERIES */
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    
 /* -------------- */
    
 /* INCERT FUNCTION */
    
    
    Merge_Sort(A,0,n);
    
 /* -------------- */
    
    
   for(i=0;i<n-1;i++){
        printf("%d ",A[i]);
    }
    printf("%d\n",A[n-1]);
    printf("%d\n",count);
    return 0;
    
}

Measured memory_bytes: 5580
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include<cmath>
#include <queue>
#include <numeric>
#include <cassert>
#include<map>
#include<bitset>

using lli = long long int;
lli inf = 1000000007;
using namespace std;


void solve() {
	string S;
	cin >> S;

	int N = S.length();
	int box[200010] = {};
	int x = 1;
	int num = 0;
	for (int i = 0; i < N; i++) {
		num = S[N - i - 1] - '0';
		box[i + 1] = (num * x + box[i]) % 2019;
		x *= 10;
		x %= 2019;
	}
	map<int, int> counter;
	for (int i = 0; i <= N; i++) {
		counter[box[i]]++;
	}
	lli ans = 0;
	for (auto kv : counter) {
		if (kv.second > 1) {
			ans += (kv.second * (kv.second - 1)) / 2;
		}
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 4476
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int n;
 
void compute(int depth,double x1,double y1,double x2,double y2){
  double si60 = sqrt(3.0)/2.0;
  double co60 = 0.5;
   
  double sx = (x1+x1+x2)/3.0;
  double sy = (y1+y1+y2)/3.0;
  double tx = (x1+x2+x2)/3.0;
  double ty = (y1+y2+y2)/3.0;
   
  double vx = tx-sx;
  double vy = ty-sy;
   
  double ux = sx + co60*vx - si60*vy;
  double uy = sy + si60*vx + co60*vy;
   
  if(depth>=n)return;
   
  compute(depth+1,x1,y1,sx,sy);
  printf("%.8f %.8f\n",sx,sy); 
  compute(depth+1,sx,sy,ux,uy);
  printf("%.8f %.8f\n",ux,uy);
  compute(depth+1,ux,uy,tx,ty);
  printf("%.8f %.8f\n",tx,ty);   
  compute(depth+1,tx,ty,x2,y2);
 
   
}
 
int main(){
  cin>>n;
  printf("%.8f %.8f\n",0.0,0.0);
  compute(0,0.0,0.0,100.0,0.0);
  printf("%.8f %.8f\n",100.0,0.0);
  return 0;
}



Measured memory_bytes: 3212
import sys
import  math
import fractions
from collections import defaultdict
from functools import reduce
stdin = sys.stdin
         
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
     
INF=10**18
mod=10**9+7
N=int(input())
A=nl()
ans=0
min_bai=1
for i in range(N):#最大公倍数
    min_bai=min_bai*A[i]//fractions.gcd(min_bai,A[i])

#lcm = reduce(lambda x,y: x//fractions.gcd(x,y)*y, A)
 
for i in range(N):
    ans+=min_bai//A[i]

#ans = sum(lcm//x for x in A)
print(ans%mod)
    

Measured memory_bytes: 6136
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n,k = LI()
    a = LI()
    d = defaultdict(lambda:0)
    for i in a:
        d[i] += 1
    d = list(d.values())
    d.sort()
    ans = 0
    for i in range(len(d)-k):
        ans += d[i]
    print(ans)
    return

#B
def B():
    n,z,w = LI()
    a = LI()
    if n == 1:
        print(abs(a[0]-w))
        return
    ans = max(abs(a[-1]-w),abs(a[-2]-a[-1]))
    print(ans)
    return

#C
def C():
    n = I()
    s1 = S()
    s2 = S()
    dp = [[[0]*3 for j in range(3)] for i in range(n+1)]
    if s1[0] == s2[0]:
        dp[1] = [[1 if i == j else 0 for j in range(3)] for i in range(3)]
    else:
        dp[1] = [[0 if i == j else 1 for j in range(3)] for i in range(3)]
    for i in range(1,n):
        ni = i+1
        if s1[i] == s2[i]:
            for j in range(3):
                for k in range(3):
                    if k == j:continue
                    for l in range(3):
                        if l == j:continue
                        dp[ni][j][j] += dp[i][k][l]
        else:
            if i and s1[i] == s1[i-1]:
                for j in range(3):
                    for k in range(3):
                        dp[ni][j][k] = dp[i][j][k]
            else:
                for j in range(3):
                    for k in range(3):
                        if k == j:continue
                        for l in range(3):
                            if l == j:continue
                            for m in range(3):
                                if m == k:continue
                                dp[ni][j][k] += dp[i][l][m]
    ans = 0
    for i in range(3):
        for j in range(3):
            ans += dp[n][i][j]
    print(ans%mod)
    return

#D
def D():
    def comb(a,b):
        return fact[a]*inv[b]*inv[a-b]%mod
    n = I()
    a = LI()
    d = defaultdict(lambda : 0)
    for i in range(n+1):
        if d[a[i]]:
            l = d[a[i]]-1
            r = n-i
            break
        d[a[i]] = i+1
    fact = [1]
    m = 100001
    for i in range(m):
        fact.append(fact[-1]*(i+1)%mod)
    inv = [1]*(m+1)
    inv[m] = pow(fact[m],mod-2,mod)
    for i in range(m)[::-1]:
        inv[i] = inv[i+1]*(i+1)%mod
    for i in range(1,n+2):
        ans = comb(n+1,i)
        if l+r >= i-1:
            ans -= comb(l+r,i-1)
            ans %= mod
        print(ans)
    return

#E
def E():

    return

#Solve
if __name__ == "__main__":
    D()


Measured memory_bytes: 67484
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, start, end) for(int i = start; i < (int)(end); ++i)
int a[100001];
int main(){
    int n;
    cin >> n;
    rep(i,1,n + 1){
        int tmp;
        cin >> tmp;
        a[tmp] = i;
    }
    rep(i,1,n){
        cout << a[i] << " ";
    }
    cout << a[n] << endl;
    return 0;
}

Measured memory_bytes: 1152
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let k: i32 = read();
    let mut ans = 0;
    for i in 0..n {
        let x: i32 = read();
        ans += std::cmp::min(x, k - x);
    }
    println!("{}", ans * 2);
}


Measured memory_bytes: 4352