akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

string S;

int main(){
    cin>>S;
    int mini=10000000;
    rep(i,S.length()-2){
        int now = atoi(S.substr(i,3).c_str());
        mini=min(mini,abs(753-now));
    }
    out(mini);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int modulo(1e9 + 7);
const int N(555555);
int a[N], cnt[N], le[N], bt[N], fac[N];
bool vst[N];
int n;
int getSum(int x) {
	int res(0);
	for(int i(x); i; i -= i & -i)
		res += bt[i];
	return res;
}
void inc(int x) {
	for(int i(x); i <= n; i += i & -i)
		bt[i] += 1;
}
int main() {
	cin >> n;
	fac[0] = 1;
	for(int i(1); i <= n; i++) {
		fac[i] = 1ll * i * fac[i - 1] % modulo;
	}
	for(int i(1); i <= n; i++) {
		cin >> a[i];
		cnt[i] = cnt[i - 1];
		if(a[i] == 0) {
			cnt[i]++;
		}else {
			vst[a[i]] = true;
		}
	}
	int sum(0);
	for(int i(1); i <= n; i++) {
		if(!vst[i]) {
			le[i] = 1;
			sum = (sum + i) % modulo;
		}
	}
	for(int i(1); i <= n; i++) {
		le[i] += le[i - 1];
	}
	int ans(0), cur(0);
	for(int i(1); i <= n; i++) {
		if(a[i]) {
			int tmp(0);
			tmp = (tmp + 1ll * (a[i] - 1) * fac[cnt[n]]) % modulo;
			int nu(getSum(a[i]));
			tmp = (tmp - 1ll * fac[cnt[n]] * nu % modulo + modulo) % modulo;
			//k = cnt[i], l = cnt[n] - k, a = le[a[i]]
			if(cnt[i]) {
				tmp = (tmp - 1ll * le[a[i]] * cnt[i] % modulo * fac[cnt[n] - 1] % modulo + modulo) % modulo;
			}
			//printf("tmp[%d] = %d\n", i, tmp);
			ans = (ans + 1ll * fac[n - i] * tmp) % modulo;
			inc(a[i]);
			cur = (cur + (cnt[n] - le[a[i]])) % modulo;
		}else {
			//k = cnt[i], m = cnt[n]
			int tmp(0);
			tmp = (tmp + 1ll * (sum - cnt[n] + modulo) * fac[cnt[n] - 1]) % modulo;

			tmp = (tmp - 1ll * cnt[n] * (cnt[n] - 1) / 2 % modulo * (cnt[i] - 1) % modulo * fac[cnt[n] - 2] % modulo + modulo) % modulo;
			tmp = (tmp - 1ll * cur * fac[cnt[n] - 1] % modulo + modulo) % modulo;
			ans = (ans + 1ll * fac[n - i] * tmp) % modulo;
		}

	}
	cout << (ans + fac[cnt[n]]) % modulo << endl;
}


Measured memory_bytes: 10496
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, ll num=0){
  if(num == 0) num = (ll)v.size();
  cout << endl; cout << "i=  ";for(ll i=0; i<num; i++) cout << i << "   ";cout << endl;  
  cout << "    ";
  if(is_reverse) for(ll i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<"   ";}
  else for(ll i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<"   ";}
  cout << endl;
}

template <typename T>
void print_pairvec(const vector<T> &v, ll num=0){
  if(num == 0) num = (ll)v.size();
  cout << endl; for(ll i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(ll i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(ll i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(ll j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

using LP = pair<ll, int>;
int main(){
  int H, W;
  cin >> H >> W;
  const int NUMS = 10;
  vector<vector<ll>> c(NUMS, vector<ll>(NUMS));
  for(int i=0; i<NUMS; i++){
    for(int j=0; j<NUMS; j++) cin >> c[i][j];
  }
  vector<vector<int>> A(H, vector<int>(W));
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++) cin >> A[i][j];
  }
  
  //ダイクストラで 数字iを1に変える最小コストを求める
  const ll INF = (ll)1 << 60;
  vector<ll> to1(NUMS, INF); to1[1] = 0;
  for(int i=0; i<NUMS; i++){
  // for(int i=8; i<9; i++){
    if(i==1) continue;
    vector<vector<ll>> costs(NUMS, vector<ll>(NUMS, INF));
    for(int i=0; i<NUMS; i++) costs[i][i] = 0;
    priority_queue<LP, vector<LP>, greater<LP>> pri_qu;
    pri_qu.push(LP(0, i));
    while(!pri_qu.empty()){
      ll cost = pri_qu.top().first;
      int num = pri_qu.top().second;
      pri_qu.pop();
      
      for(int j=0; j<NUMS; j++){
        if(j==num) continue;
        if(costs[num][j] <= cost + c[num][j]) continue;
        costs[num][j] = cost + c[num][j];
        pri_qu.push(LP(costs[num][j], j));
        if(j==1) to1[i] = min(to1[i], costs[num][1]);
      }
    }
  }
  ll ans = 0;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(A[i][j] == 1 || A[i][j] == -1) continue;
      int num = A[i][j];
      ans += to1[num];
    }
  }
  cout << ans << endl;
  


  return 0;
}


Measured memory_bytes: 3760
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#include<math.h>
#include<assert.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384
int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int nHr(int a,int b){return nCr(a+b-1,b);}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}
int sankaku(int x){return ((1+x)*x)/2;}
void swap(int *a,int *b){int c;c=(*a);(*a)=(*b);(*b)=c;}


 
int main(void){
    int N,M;
    scanf("%d%d",&N,&M);
    if(N==1&&M==0){
        printf("0");
        return 0;
    }
    int keta[M],vl[M],ans[N];
    for(int i=0;i<M;i++){
        scanf("%d %d",&keta[i],&vl[i]);
    }
    for(int i=0;i<N;i++){
        ans[i]=0;
    }
    for(int i=0;i<M;i++){
        if(N !=1 && keta[i]==1 && vl[i]==0){
            printf("-1");
            return 0;
        }else if(ans[keta[i]-1]==0){
            ans[keta[i]-1]=vl[i];
        }else if(ans[keta[i]-1]!=vl[i]){
            printf("-1");
            return 0;
        }
    }
    if(N!=1 && ans[0]==0)
        ans[0]=1;
    for(int i=0;i<N;i++){
        printf("%d",ans[i]);
    }
    return 0;
}


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

int main(){
  int N,L;
  cin>>N>>L;
  vector<string> S(N);
  for(int i=0;i<N;i++){
    cin>>S.at(i);
  }

  bool flag = false;
  for(;;){
    if(flag){
      break;
    }
    string tmp="";
    for(int i=0;i<N-1;i++){
      if(S.at(i)>S.at(i+1)){
        tmp = S.at(i);
        S.at(i) = S.at(i+1);
        S.at(i+1) = tmp;
      }
    }
    if(tmp==""){
      flag = true;
    }
  }

  string out="";
  for(int i=0;i<N;i++){
    out += S.at(i);
  }
  cout<<out<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define DIVCEIL(A,B) ((A+(B-1))/B)
using namespace std;

void solve(long long n, std::vector<std::string> S){
    vector<map<char, long long>> cnts(n);
    
    set<char> cs;
    for(int i=0; i<n; i++)for(auto c:S[i]){
        cnts[i][c]++;
        cs.insert(c);
    }

    vector<string> ans;
    for(auto c: cs){
        auto nrep = (*min_element(cnts.begin(), cnts.end(), [c](auto cnt1, auto cnt2){return cnt1[c] < cnt2[c];}))[c];
        if(nrep>0)ans.emplace_back(string(nrep, c));
    }

    for(auto s:ans)cout << s;
    cout << endl;
}

int main(){
    long long n;
    scanf("%lld",&n);
    std::vector<std::string> S(n);
    for(int i = 0 ; i < n ; i++){
        std::cin >> S[i];
    }
    solve(n, std::move(S));
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <queue>
#include <cmath>

#define REDIRECT(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)
#define CLOSEALL() fclose(stdin), fclose(stdout)

using namespace std;

const int MAXN = 800 + 5;
const int DIRX[] =
{ 1, -1, 0, 0 };
const int DIRY[] =
{ 0, 0, 1, -1 };

int H, W, K;
int stX, stY;
char mz[MAXN][MAXN];
bool vist[MAXN][MAXN];

int answer = 0x7F7F7F7F;

void BFS()
{
	queue<pair<pair<int, int>, int> > Q;
	Q.push(make_pair(make_pair(stX, stY), 0));

	while (!Q.empty())
	{
		pair<pair<int, int>, int> cur = Q.front();
		Q.pop();

		if(vist[cur.first.first][cur.first.second])
			continue;
		vist[cur.first.first][cur.first.second] = true;

		int curAns = min(min(cur.first.first - 1, H - cur.first.first),
				min(cur.first.second - 1, W - cur.first.second));
		curAns = (curAns + K - 1) / K;
		answer = min(answer, curAns + 1);

		if (cur.second >= K)
			continue;

		for (int i = 0; i < 4; i++)
		{
			pair<int, int> newPos = make_pair(cur.first.first + DIRX[i],
					cur.first.second + DIRY[i]);
			if(newPos.first <= 0 || newPos.first > H)
				continue;
			if(newPos.second <= 0 || newPos.second > W)
				continue;
			if(mz[newPos.first][newPos.second] != '#' && !vist[newPos.first][newPos.second])
				Q.push(make_pair(newPos, cur.second + 1));
		}
	}
}

int main()
{

	//REDIRECT("room");

	scanf("%d%d%d", &H, &W, &K);
	for (int i = 1; i <= H; i++)
	{
		scanf("%s", mz[i] + 1);
		for (int j = 1; j <= W; j++)
			if (mz[i][j] == 'S')
				stX = i, stY = j;
	}

	BFS();

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

	CLOSEALL();
	return 0;
}


Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		char[] str = s.toCharArray();

		int num = str[0] + 1;
		char c  = (char)(num);

		System.out.print(c);
 
		sc.close();
 
	}
}

Measured memory_bytes: 21460
n,m=map(int,input().split())
h=list(map(int,input().split()))
good=[True]*n
for i in range(m):
    a,b=map(int,input().split())
    a-=1;b-=1
    if h[a]<h[b]:
        good[a]=False
    elif h[b]<h[a]:
        good[b]=False
    elif h[b]==h[a]:
        good[a]=False
        good[b]=False
print(good.count(True))

Measured memory_bytes: 20112
#include "bits/stdc++.h"
using namespace std;
#define push back pb;
int main(){
int a;scanf("%d",&a);
int L=a/100;
int R=a%100;
if(1<=L&&L<=12){
if(1<=R&&R<=12)printf("AMBIGUOUS\n");
else printf("MMYY\n");
}else{
if(1<=R&&R<=12)printf("YYMM\n");
else printf("NA\n");
}
}

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

int main() {
  int k, n;
  cin >> k >> n;
  vector<int> A(n);
  rep(i, n) { cin >> A[i]; }
  sort(A.begin(), A.end());
  vector<int> D(n);
  rep(i, n) {
    if (i < n - 1) {
      D[i] = abs(A[i] - A[i + 1]);
    } else {
      D[i] = abs(A[i] - k) + A[0];
    }
  }
  sort(D.begin(), D.end());
  D.pop_back();
  int d = 0;
  int n1 = n - 1;
  rep(i, n1) { d += D[i]; }
  cout << d << endl;
  return 0;
}

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

int a[1000][1000], dp[1000][1000];
char b[1000][1000];
int main() {
	int h, w, n;
	while (scanf("%d%d%d", &h, &w, &n), h) {
		rep(i, h)rep(j, w) {
			scanf("%d", &a[i][j]); b[i][j] = a[i][j];
		}
		memset(dp, 0, sizeof(dp));
		dp[0][0] = n - 1;
		rep(i, h)rep(j, w) {
			if (i) {
				if (a[i - 1][j])dp[i][j] += dp[i - 1][j] / 2;
				else dp[i][j] += (dp[i - 1][j] + 1) / 2;
			}
			if (j) {
				if (a[i][j - 1])dp[i][j] += (dp[i][j - 1] + 1) / 2;
				else dp[i][j] += dp[i][j - 1] / 2;
			}
			if (dp[i][j] & 1)b[i][j] = !b[i][j];
		}
		int x = 0, y = 0;
		while (x < h&&y < w) {
			if (b[x][y])y++;
			else x++;
		}
		printf("%d %d\n", x + 1, y + 1);
	}
}

Measured memory_bytes: 11992
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

//ここから編集
template<typename T>
struct LazySegmentTree{
  const int INF = numeric_limits<int>::max();
  int n0;
  vector<T> node, lazy;

  LazySegmentTree(vector<T> &v){
    int n = v.size();
    n0 = 1;
    while(n0 < n) n0 <<= 1;
    node.resize(2*n0-1);
    lazy.assign(2*n0-1, 0);
    for(int i=0; i<n; i++) node[i+n0-1] = v[i];
    for(int i=n0-2; i>=0; i--) node[i] = min(node[i*2+1], node[i*2+2]);
  }

  void eval(int k){
    if(lazy[k] == 0) return;
    node[k] += lazy[k];
    if(k < n0-1){
      lazy[k*2+1] += lazy[k];
      lazy[k*2+2] += lazy[k];
    }
    lazy[k] = 0;
  }

  void update(int a, int b, T x, int k, ll l, ll r){
    eval(k);
    if(a <= l && r <= b){
      lazy[k] += x;
      eval(k);
    }else if(a < r && l < b) {
      update(a, b, x, k*2+1, l, (l+r)/2);
      update(a, b, x, k*2+2, (l+r)/2, r);
      node[k] = min(node[k*2+1], node[k*2+2]);
    }
  }

  void update(int l, int r, T x) { update(l, r, x, 0, 0, n0); }

  T query(int a, int b, int k, ll l, ll r){
    eval(k);
    if(r <= a || b <= l) return INF;
    else if(a <= l && r <= b){
      return node[k];
    }else{
      T vl = query(a, b, k*2+1, l, (l+r)/2);
      T vr = query(a, b, k*2+2, (l+r)/2, r);
      return min(vl, vr);
    }
  }
  T query(int l, int r) { return query(l, r, 0, 0, n0); }

  inline T operator[](int a) { return query(a, a + 1); }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(5);
  
  int N, Q; cin >> N >> Q;
  vector<ll> a(N, 0);
  LazySegmentTree<ll> seg(a);

  REP(i,Q){
    int q; cin >> q;
    if(q == 0){
      int s, t, x;
      cin >> s >> t >> x;
      seg.update(s, t+1, x);
    }else{
      int s, t; cin >> s >> t;
      cout << seg.query(s, t+1) << endl;
    }
    // for(int j=0; j<N; j++){
    //   cout << seg[j] << " ";
    // }
    // cout << endl;
  }

  return 0;
}


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

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

	vector<char> V;
	for (int i = 0; i < S.size(); i++) V.push_back(S[i]);
	
	int A_position = 0;
	for (int j = 0; j < V.size(); j++) {
		if (V.at(j) == 'A') {
			A_position += j;
			break;
		}
	}
	
	reverse(V.begin(), V.end());
	int Z_position = 0;
	for (int k = 0; k < V.size(); k++) {
		if (V.at(k) == 'Z') {
			Z_position += k;
			break;
		}
	}

	cout << (V.size() - Z_position) - A_position << endl;

}

Measured memory_bytes: 772
/*我是萌新*/
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip>
#include<map>
typedef long long ll;
const int mod = 1e9+7;
using namespace std;
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()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    string t;
    while (cin >> t)
    {
        if(t=="ABC")cout<<"ARC\n";
        else cout<<"ABC\n";
    }
}

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

int main(){
    int N;
    cin >> N;
    long long a,b,sum=0,minB=1000000000;
    for(int i=0; i<N; i++){
        cin >> a >> b;
        sum+=a;
        if(a>b && minB>b)
        minB=b;
    }
    if(minB==1000000000)
    cout << 0 << endl;
    else
    cout << sum-minB << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
template<typename tn> void read(tn &a){
    tn x=0,f=1;char c=' ';
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar() ) x=x*10+c-'0';
    a=x*f;
}
template<typename tn> void print(tn a){
    if(a<0) putchar('-'),a=-a;
    if(a>9) print(a/10);
    putchar(a%10+'0');
}
#define ll __int128
const int N=105;
ll n;
ll b[N]; 
ll ans;
int main(){
	read(n);
	for(int i=1;i<n;i++) read(b[i]);
	b[n]=b[0]=1e9;
	for(int i=1;i<=n;i++)
		ans+=min(b[i],b[i-1]);
	print(ans);
	puts("");
	return 0;
} 

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

char m[10][10], t[10][10];
int H, W, K, ans;

inline int check() {
  int ret = 0;
  for (int i = 1; i <= H; ++i)
    for (int j = 1; j <= W; ++j) ret += m[i][j] == 1;
  return ret == K;
}

void dfs(int r, int c) {
  if (r == H + 1 && c == W + 1) {
    ans += check();
    return;
  }
  if (r <= H) {
    dfs(r + 1, c);
    for (int i = 1; i <= W; ++i) m[r][i]--;
    dfs(r + 1, c);
    for (int i = 1; i <= W; ++i) m[r][i]++;
  } else {
    dfs(r, c + 1);
    for (int i = 1; i <= H; ++i) m[i][c]--;
    dfs(r, c + 1);
    for (int i = 1; i <= H; ++i) m[i][c]++;
  }
}

int main() {
  // freopen("1.in", "r", stdin);
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  std::cin >> H >> W >> K;
  for (int i = 1; i <= H; ++i) std::cin >> m[i] + 1;
  for (int i = 1; i <= H; ++i)
    for (int j = 1; j <= W; ++j) m[i][j] = m[i][j] == '.' ? 0 : 1;
  dfs(1, 1);
  std::cout << ans;
}

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


int main(){
	int N,T;
	while(cin >> N >> T && N){
		char info[2001];
		double dp[2][2001] = {0.0};
		for(int i = 0 ; i < N ; i++) cin >> info[i];
		for(int i = 0 ; i < N ; i++) if(info[i] == 'R') dp[0][i] = 1.0;
		for(int i = 0 ; i < T ; i++){
			for(int j = 0 ; j < N ; j++) dp[i&1^1][j] = 0.0;
			for(int j = 0 ; j < N ; j++){
				for(int k = 1 ; k <= 6 ; k++){
					dp[i&1^1][((j-k)%N+N)%N] += dp[i&1][j] / 6.0;
				}
			}
		}
		double ans = 0;
		for(int i = 0 ; i < N ; i++){
			ans = max(ans,dp[T&1][i]);
		}
		printf("%.10lf\n",ans);
	}
}

Measured memory_bytes: 940
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
a = nl()

x = [sum(a) - 2 * sum([a[i] for i in range(1, n - 1, 2)])]

for i in range(1, n):
    x.append(2 * a[i-1] - x[i-1])

print(*x)

Measured memory_bytes: 14708
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;

int main(void)
{
    int N;
    cin >> N;
    
    vector<string> S(N);
    map<string, int> mp;
    for (int i = 0; i < N; i ++) {
        cin >> S[i];
        mp[S[i]] ++;
    }
    
    int ans = 0;
    for (int i = 0; i < mp.size(); i ++) {
        if (mp[S[i]] > 0) {
            ans ++;
        }
    }
    
    cout << ans << endl;
    
}

Measured memory_bytes: 25076
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a,b,h[100010],d,ji,ju,ti,num,l,r,mid,k[100010];
int main()
{
	scanf("%lld%lld%lld",&n,&a,&b);
	d=a-b;
	for(ll i=1;i<=n;i++)
	{
		scanf("%lld",&h[i]);
		num+=h[i];
	}
	sort(h+1,h+1+n);
	r=num/b+1;
	while(l<r)
	{
		mid=l+r>>1;
		ji=0;
		for(int i=1;i<=n;i++)
			k[i]=h[i]/b+1*(h[i]%b!=0);
		for(int i=1;i<=n;i++)
			if(k[i]>mid)
				ji+=(h[i]-mid*b+d-1)/d;
		if(ji<=mid)
			r=mid;
		else
			l=mid+1;
	}
	cout<<l;
}

Measured memory_bytes: 1792
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int
#define Vec vector

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	int N,M,C;
	cin >> N >> M >> C;
	Vec<int> B(M);
	Vec<Vec<int>> A(N);
	for(int i=0;i<N;i++) A[i].resize(M);
	for(int i=0;i<M;i++) cin >> B[i];
	for(int i=0;i<N;i++) for(int j=0;j<M;j++) cin >> A[i][j];
	
	int cnt = 0;
	for(int i=0;i<N;i++){
		int v = C;
		for(int j=0;j<M;j++) v += A[i][j] * B[j];
		if(v > 0) cnt++;
	}
	
	cout << cnt << endl;
	
	
	
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

type ListEntry struct {
	prev *ListEntry
	next *ListEntry
	key  int
}

type List struct {
	head    *ListEntry
	tail    *ListEntry
	current *ListEntry
}

func (l List) print() {
	current := l.head.next
	for current != l.tail {
		fmt.Println(current.key)
		// fmt.Printf(" (%v %v %v)", current.prev.key, current.key, current.next.key)
		current = current.next
	}
	// fmt.Print("\n")
}

func newList() *List {
	l := List{}
	l.head = &ListEntry{}
	l.tail = &ListEntry{}
	l.head.next = l.tail
	l.tail.prev = l.head
	l.current = l.tail
	return &l
}

func main() {
	scanner.Split(bufio.ScanWords)

	nQueries := nextInt()
	l := newList()
	for iQuery := 0; iQuery < nQueries; iQuery++ {
		// l.print()
		queryType := nextInt()
		if queryType == 0 { // insert
			x := nextInt()
			newEntry := ListEntry{
				prev: l.current.prev,
				next: l.current,
				key:  x,
			}
			if l.current.prev != nil {
				l.current.prev.next = &newEntry
			}
			l.current = &newEntry
			l.current.next.prev = l.current
		} else if queryType == 1 { // move
			d := nextInt()
			if d > 0 {
				for i := 1; i <= d; i++ {
					l.current = l.current.next
				}
			} else if d < 0 {
				for i := 1; i <= -d; i++ {
					l.current = l.current.prev
				}
			}
		} else if queryType == 2 { // erase
			current := l.current
			l.current.prev.next = current.next
			l.current.next.prev = current.prev
			l.current = current.next
			// fmt.Println(current)
		}
	}
	l.print()
}



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

int main(){
long long n;cin >> n;
vector<long long> v;
long long sum =0;

for(long long i=0;i<n;i++){
  long long c;
  cin >> c;
  v.push_back(c);
}

sort(v.begin(),v.end());

for(int i=0;i<n-1;i++){
  int s = (i+1)/2;

  sum += v[n-1-s];
}

cout << sum << endl;

}


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

int main () {
	int N, h0, h1;
	cin >> N;
	cin >> h0;
	bool flag = true, dec=false;
	for (int i=1; i<N; i++) {
		cin >> h1;
		if (h0 > h1+1)
			flag = false;
		else if (h0>h1 && dec)
			flag = false;
		else if (h0>h1) 
			dec = true;
		else if (h0<h1)
			dec = false;
		h0 = h1;
	}
	cout << (flag?"Yes":"No") << endl;
	return 0;
}

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

const int maxn = 1e5 + 5;
int a[4][maxn], dp[4][maxn];

int main() {
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= 3; ++j) scanf("%d", &a[j][i]);
    } 
    dp[0][0] = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= 3; ++j) {
            for (int k = 0; k <= 3; ++k) {
                if (j == k) continue;
                dp[j][i] = max(dp[j][i], dp[k][i - 1] + a[j][i]);
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= 3; ++i) ans = max(ans, dp[i][n]);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

vector<bool> enum_prime(int N) {
  vector<bool> is_prime(N+1, true);
  is_prime[0] = false, is_prime[1] = false;
  for (int i = 2; i <= N; ++i) {
    if (!is_prime[i]) continue;
    for (int j = 2; i * j <= N; ++j) {
      is_prime[i*j] = false;
    }
  }
  return is_prime;
}

int main() {
  auto b = enum_prime(1e5);
  vector<LL> S(1e5 + 1); S[0] = 0, S[1] = 0, S[2] = 0;
  for (int i = 3; i < 1e5 + 1; ++i) {
    if (i % 2 == 0) S[i] = S[i-1];
    else if (b[i] && b[(i + 1)/2]) S[i] = S[i-1] + 1;
    else    S[i] = S[i-1];
  }

  int Q; cin >> Q;
  for (int i = 0; i < Q; ++i) {
    int l, r; cin >> l >> r;
    cout << S[r] - S[l-1] << endl;
  }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int a, b;
  cin >> a >> b;
  cout << (a*b%2!=0 ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]

def dfs(u, c):
    color[u] = c
    for v in graph[u]:
        if color[v] == c:
            return False
        if color[v] == 0 and not dfs(v, -c):
            return False
        
    return True

graph = [[] for _ in range(N)]
for a, b in X:
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)

color = [0] * N
if dfs(0, 1):
    c = sum(v == 1 for v in color)
    print(c * (N - c) - M)
else:
    print(N * (N - 1) // 2 - M)


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

bool isEven(const int n){
    if(n%2==0){
        return true;
    }else{
        return false;
    }
}
int min(const vector<int>& vec){
    int min=vec[0];
    for(int i=1; i<vec.size(); i++){
        if(min>vec[i]){
            min=vec[i];
        }
    }
    return min;
}
int numOf2in(int x){
    int n=0;
    while(isEven(x)){
        x/=2;
        n++;
    }
    return n;
}
vector<int> numOf2in(const vector<int>& vec_in){
    vector<int> vec_out(vec_in.size());
    for(int i=0; i<vec_in.size(); i++){
        vec_out[i] = numOf2in(vec_in[i]);
    }
    return vec_out;
}

int main(){
    int N; cin >> N;
    vector<int> A(N);
    for(int i=0; i<A.size(); i++){
        cin >> A[i];
    }
    
    A = numOf2in(A);
    int a = min(A);
    cout << a;
    
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;typedef long long lint;typedef vector<lint> liv;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(),v.end()
#define linf 1152921504606846976
#define MAXN 100010

int main(){
	lint n;cin>>n;
	lint a,b;cin>>a>>b;
	if((n==1&&a!=b)||a>b){ cout<<0<<endl;return 0; }
	if(n==1){ cout<<1<<endl;return 0; }
	lint mn=b+(n-1)*a,mx=a+(n-1)*b;
	cout<<mx-mn+1<<endl;
}

//sub-EOF


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<queue>
#define f(x,k) 3*(x-1)+k+1
std::vector<int> a[300005];
int n,m,s,t,dis[300005];
void add(int x,int y){a[x].push_back(y);}
void bfs(int s)
{
	std::queue<int> q;
	for (int i=1;i<=3*n;i++) dis[i]=1000000000;
	dis[s]=0;q.push(s);
	while (!q.empty())
	{
		int v=q.front();q.pop();
		for (int i=0;i<a[v].size();i++)
		{
			int u=a[v][i];
			if (dis[v]+1<dis[u]) dis[u]=dis[v]+1,q.push(u);
	    }
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		add(f(x,0),f(y,1));
		add(f(x,1),f(y,2));
		add(f(x,2),f(y,0));
	}
	scanf("%d%d",&s,&t);
	bfs(f(s,0));
	printf("%d\n",dis[f(t,0)]!=1000000000?dis[f(t,0)]/3:-1);
}

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

int main() {
	int N;
  	cin >> N;
    bool check = false;
    string s;
  	for(int i = 0; i < N ; i++){
    	cin >> s;
      	if(s == "Y"){
        	check = true;
        }
    }
  	if(check == true){
    	cout << "Four" << endl;
    }else{
    	cout << "Three" << endl;
    }
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>

using namespace std;

int main(){
  vector<int> h,w;
  int _h,_w;
  while(1){
    cin >> _h >> _w;
    if(_h == 0 && _w == 0){
      break;
    }
    h.push_back(_h);
    w.push_back(_w);
  }
  for(int i=0;i<h.size();i++){
    for(int h_i=0;h_i<h[i];h_i++){
      for(int w_i=0;w_i<w[i];w_i++){
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}

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

int G[105][105], J[105][105];
int N, M;

priority_queue<tuple<int, int, int>> Q, Qs;
vector<int> Ret(105, 0), Rets(105, 0), bz, bzs;

void dijk(int s, int g) {
	Ret = Rets;
	Q = Qs;
	bz = bzs;
	Q.push(make_tuple(0, s, -1));
	int a, b, c, x, y = INT32_MIN;
	while (!Q.empty()) {
		tie(a, b, c) = Q.top();
		Q.pop();

		if (a < y)break;
		if (b == g) {
			J[b][c] = 1;
			J[c][b] = 1;
			bz.push_back(c);
			x = b;
			y = a;
			continue;
		}
		if (Ret[b])continue;
		Ret[b] = c;

		for (int i = 1;i <= N;i++) {
			if (G[b][i] < 0)continue;
			Q.push(make_tuple(a - G[b][i], i, b));
		}
	}
	for (int i : bz) {
		while (Ret[i] >= 0) {
			J[i][Ret[i]] = 1;
			J[Ret[i]][i] = 1;
			i = Ret[i];
		}
	}
}

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

	for (int i = 0;i < 105;i++) {
		for (int j = 0;j < 105;j++) {
			G[i][j] = -1;
			J[i][j] = 0;
		}
	}

	for (int i = 0;i < M;i++) {
		cin >> a >> b >> c;
		G[a][b] = c;
		G[b][a] = c;
	}

	for (int i = 1;i <= N;i++) {
		for (int j = i + 1;j <= N;j++) {
			dijk(i, j);
		}
	}
	int ans = 0;
	for (int i = 1;i <= N;i++)
		for (int j = i + 1;j <= N;j++)
			ans += J[i][j];
	cout << M - ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
#include <bitset>
#include <string>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define ALL(x) (x).begin(),(x).end()
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

int main() {
  string S; cin >> S;
  int cnt = 0;
  rep(i,S.size()){
    if(S[i]=='o') cnt++;
  }
  if(15-S.size()+cnt>=8){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  


  return 0;
}


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

int main() {
  int N, M, price = 0, tmp = 1;
  string s;

  cin >> N;
  vector<string> blue(N);
  for(int i = 0; i < N; i++){
    cin >> s;
    blue.at(i) = s;
  }
  
  cin >> M;
  vector<string> red(M);
  for(int i = 0; i < M; i++){
    cin >> s;
    red.at(i) = s;
  }
  
  for(int i = 0; i < N; i++){
    for(int j = 1; j < N; j++){
      if (blue.at(i) == blue.at(j) && i != j) tmp++;
    }
    for(int k = 0; k < M; k++){
      if (blue.at(i) == red.at(k)) tmp--;
    }
    if (tmp > price) price = tmp;
    tmp = 1;
  }
  
  if (price >= 0) cout << price << endl;
  else cout << 0 << endl;
  
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n,m;
double l[22],a[22],b[22];

int main(){
	cin.sync_with_stdio(false);
	cin>>n>>m;
	rep(i,n)cin>>l[i]>>a[i]>>b[i];
	double res=0;
	rep(i,1<<n){
		if(bcnt(i)!=m)continue;
		double sum=0;
		rep(j,n){
			if(!((i>>j)&1))continue;
			repl(k,j+1,n){
				if(!((i>>k)&1))continue;
				sum+=pow(l[j]-l[k],2);
				sum+=pow(a[j]-a[k],2);
				sum+=pow(b[j]-b[k],2);
			}
		}
		maxch(res,sum);
	}
	printf("%.10f\n", res);
	return 0;
}

Measured memory_bytes: 3304
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

struct P{
    int x, y;
};

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

int ans;
int w, h;

void solve(vector<vector<int>> m, P p, int n){
    /*
    rep(i,h){
        rep(j,w){
            if(i == p.y && j == p.x) cout << '@';
            else cout << m[i][j];
        }
        cout << endl;
    }
    cout << endl;
    */


    if(n == 10) return;

    rep(i,4){
        int ny = p.y + dy[i];
        int nx = p.x + dx[i];
        if(ny >= h || ny < 0 || nx >= w || nx < 0) continue;
        if(m[ny][nx] != 1){
            rep(j,INF){
                int nny = p.y + dy[i] * j;
                int nnx = p.x + dx[i] * j;
                if(nny >= h || nny < 0 || nnx >= w || nnx < 0) break;
                if(m[nny][nnx] == 1){
                    m[nny][nnx] = 0;
                    P temp;
                    temp.y = nny - dy[i];
                    temp.x = nnx - dx[i];
                    solve(m, temp, n + 1);
                    m[nny][nnx] = 1;
                    break;
                }else if(m[nny][nnx] == 3){
                    ans = min(ans, n);
                    return;
                }
            }
        }
    }
}

int main(){
    while(cin >> w >> h, w||h){
        ans = INF;
        P start;
        vector<vector<int>> v(20);
        rep(i,h){
            rep(j,w){
                int inp;
                cin >> inp;
                v[i].emplace_back(inp);
                if(inp == 2){
                    start.x = j;
                    start.y = i;
                }
            }
        }
        solve(v, start, 0);
        if(ans == INF) cout << -1 << endl;
        else cout << ans + 1 << endl;
    }
}

Measured memory_bytes: 3152
<?php
// Your code here!
// fscanf(STDIN, "%d %d %d", $a,$r,$n);
$w = trim(fgets(STDIN));

$array = [];
while(true){
    $stdin = trim(fgets(STDIN));
    if($stdin == ""){
        break;
    }
    $array[] = explode(" ", $stdin);    
}
// var_dump($array);
$newarr = array_reduce($array, 'array_merge', array());
$ans = 0;
foreach($newarr as $v){
    if(strcasecmp($v, $w) == 0){
        $ans++;
    }
}
// var_dump($newarr);
echo $ans,PHP_EOL;

?>


Measured memory_bytes: 9376
/*
    talk is cheap
    feelings fade

    love is real
    but so is change
*/

#include<bits/stdc++.h>
using namespace std;
#define int long long

const int mod = 1000 * 1000 * 1000 + 7;
 
int power(int x, int y)
{
    x %= mod;
    int res = 1;
    while(y)
    {
        if(y & 1)
            res = (res * x) % mod;
        y >>= 1;
        x = (x * x) % mod;
    }
    return res;
}

int fac[100005];

int ncr(int n, int r)
{
    if(r > n || r < 0 || n == 0)
        return 0;
    int ans = fac[n] * power(fac[r], mod - 2) % mod * power(fac[n-r], mod-2) % mod;
    return ans;
}

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

    fac[0] = 1;
    for(int i=1;i<100005;i++)
        fac[i] = (fac[i-1] * i) % mod;
    
    //int t=1 ; cin>>t ; while(t--)
    {
        int n, k;
        cin >> n >> k;
        int a[n];
        for(int i=0;i<n;i++)
            cin >> a[i];

        sort(a,a+n);
        int ans = 0;

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

        cout << ans << '\n';

        
    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

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

    cout << string(s.size(), 'x') << endl;
    return 0;
}

Measured memory_bytes: 256
N, A, B, C = map(int, input().split())
Ln = [int(input()) for _ in range(N)]

INF = 10**9


def dfs(cur, a, b, c):
    if cur == N:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a, b, c) > 0 else INF

    ret0 = dfs(cur+1, a, b, c)
    ret1 = dfs(cur+1, a+Ln[cur], b, c) + 10
    ret2 = dfs(cur+1, a, b+Ln[cur], c) + 10
    ret3 = dfs(cur+1, a, b, c+Ln[cur]) + 10

    return min(ret0, ret1, ret2, ret3)


print(dfs(0, 0, 0, 0))


Measured memory_bytes: 3064
n = int(input())
tmp = []
isOK = True
for i in range(n):
    s = str(input())
    if len(tmp)!=0:
        if s in tmp:
            #print(s,tmp)
            isOK = False
            break
        if end!=s[0]:
            #print(end,s)
            isOK = False
            break
    end = s[-1]
    tmp.append(s)

if isOK:
    print('Yes')
else:
    print('No')

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(void){
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    COMinit();
    int N; cin >> N;
    int cnt[N+1] = {};
    int fst, snd;
    int A[N+1];
    rep(i, N+1){
        int a; cin >> a;
        cnt[a]++;
        A[i] = a;
        if(cnt[a] == 2){
            snd = i;
            rep(j, i) if(A[j] == A[i]) fst = j; 
        }
    }

    for(int k = 1; k <= N+1; k++){
        ll res = COM(N+1, k);
        //fstの左側と右側から合わせてk-1個取る
        ll choice = fst + (N - snd);
        res = (res - COM(choice, k-1)) % MOD;
        if(res < 0) res += MOD;
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 13952
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
  ll ans = 0;
  int n;
  cin >> n;
  vector<ll> a(n);
  ll pre = 0;
  REP(i, n){
    cin >> a[i];
   	if(pre == 1 && a[i] > 0){
      ans++;
      a[i]--;
    }
    ans += a[i] / 2;
    pre = a[i] % 2;
  }
  cout << ans << endl;
}


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

typedef long long ll;
const ll MOD = 1e9+7;

int main(){
	int n,k;
	cin >> n >> k;
	
	vector<ll> a(n);
	for(int i=0; i<n; i++) cin >> a[i];
	sort(a.begin(),a.end());

	ll ans = 1, f = 0;
	int l = 0, r = n-1;

	if(k%2){
		ans = a[r];
		r--;
		--k;
		if (ans<0) f = 1;
	}

	while(k){
		ll two = a[l]*a[l+1];
		ll one = a[r]*a[r-1];

		if(f){
			if(two>=one){
				ans = one%MOD*ans%MOD;
				r -= 2;
			}

			else{
				ans = two%MOD*ans%MOD;
				l += 2;
			}
		}

		else{
			if(two<=one){
                                ans = one%MOD*ans%MOD;
                                r -= 2;
                        }

                        else{
                                ans = two%MOD*ans%MOD;
                                l += 2;
                        }
                }

		k -= 2;
	}

	cout << (ans+MOD)%MOD << endl;

	return 0;
}

Measured memory_bytes: 4816
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    
    char c[3][3];
    rep(i, 3) {
        rep(j, 3) {
            cin >> c[i][j];
        }
    }

    rep(i, 3) {
        cout << c[i][i];
    }

    cout << endl;
    re0;
}

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

using namespace std;

void bubble(int A[], int n)
{
  for(int i = 0; i < n; i++)
  {
    for(int j = n-1; j >= i+1; j--)
      if(A[j] > A[j-1]) swap(A[j], A[j-1]);
  }
}

int main() 
{
  int n, a[100], sum = 0;
  cin >> n;
  for(int i = 0; i < n; i++) cin >> a[i];
  
  bubble(a,n);
  for(int i = 0; i < n; i++)
  {
    if(i%2 == 0) sum += a[i];
    else sum -= a[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 3544
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<21)

bool chk(char x,char y){
	return x>='1' && x <= '6' && y >= '1' && y <= '5';
}
string table[5] =
{
	"afkpuz",
	"bglqv.",
	"chmrw?",
	"dinsx!",
	"ejoty "
};
char get(char x,char y){
	x -= '1' , y -= '1';
	return table[y][x];
}
int main(){
	string str;
	while(cin >> str){
		bool f = 1;
		if(str.size() % 2) f = 0;
		for(int i=0;i<str.size();i+=2)
			f &= chk(str[i],str[i+1]);
		if(f){
			for(int i=0;i<str.size();i+=2)
				cout << get(str[i],str[i+1]);
			cout << endl;
		}else{
			cout << "NA" << endl;
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
 ll n;cin>>n;
  if(n%1000==0)cout<<"0";
  else{
  ll p=n/1000;
    p++;
    p*=1000;
    cout<<p-n;
  }
  return 0;
}

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

int main()
{
  int total = 0;
  int num = 0;
  char c;
  cin >> total;
  vector<vector<int>> data(4, vector<int>(13, 0));
  vector<char> cdata = {'S', 'H', 'C', 'D'};
  for(int i = 0; i < total; i++)
  {
    cin >> c >> num;
    //cout << c << ':' << num << endl;
    if(c == 'S')
    {
      data.at(0).at(num - 1) = 1;
    }
    if(c == 'H')
    {
      data.at(1).at(num - 1) = 1;
    }
    if(c == 'C')
    {
      data.at(2).at(num - 1) = 1;
    }
    if(c == 'D')
    {
      data.at(3).at(num - 1) = 1;
    }
  }
  //cout << endl;
  for(int i = 0; i < 4; i++)
  {
    for(int j = 0; j < 13; j++)
    {
      if(data.at(i).at(j) == 0)
      {
        cout << cdata.at(i) << ' '<< j + 1 << endl;
      }
    }
  }
  
}


Measured memory_bytes: 3160
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll unsigned long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
ll ans[505][505];
int n;
bool f[2][505],p[64][2][505];
void out(){
	cout<<-1;exit(0);
}
void solve(int now){
	int a[505][505];bool cnt[2][505]={};
	V<int> v[2];
	FILL(a,-1);
	FOR(i,1,n){
		if(p[now][1][i]){
			if(f[1][i])v[1].PB(i);
			else FOR(j,1,n)a[j][i]=1;
		}else{
			if(!f[1][i])v[0].PB(i);
			else FOR(j,1,n)a[j][i]=0;
		}
	}
	bool anf;
	int last[2]={};
	FOR(i,1,n){
		if(p[now][0][i]){
			if(f[0][i]){
				anf=1;
				FOR(j,1,n){
					if(a[i][j]==1){
						anf=0;break;
					}
				}
				if(anf){
					if(!v[1].empty())a[i][v[1].back()]=1;
					else if(!v[0].empty()){
						a[i][v[0][last[0]]]=1;
						last[0]++;
						if(last[0]==v[0].size())last[0]=0;
					}else out();
				}
			}else{
				FOR(j,1,n){
					if(a[i][j]==0)out();
					a[i][j]=1;
				}
			}
		}else{
			if(!f[0][i]){
				anf=1;
				FOR(j,1,n){
					if(a[i][j]==0){
						anf=0;break;
					}
				}
				if(anf){
					if(!v[0].empty())a[i][v[0].back()]=0;
					else if(!v[1].empty()){
						a[i][v[1][last[1]]]=0;
						last[1]++;
						if(last[1]==v[1].size())last[1]=0;
					}else out();
				}
			}else{
				FOR(j,1,n){
					if(a[i][j]==1)out();
					a[i][j]=0;
				}
			}
		}
	}
	FOR(k,0,1){
	for(auto u:v[k]){
		FOR(i,1,n){
			if(a[i][u]==-1)a[i][u]=k;
		}
		bool anf=0;
		FOR(i,1,n){
			if(a[i][u]==k){
				anf=1;break;
			}
		}
		if(!anf)out();
	}
	}
	FOR(i,1,n)FOR(j,1,n)ans[i][j]=ans[i][j]+(1ull<<now)*a[i][j];
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	FOR(i,1,n)cin>>f[0][i];
	FOR(i,1,n)cin>>f[1][i];
	ll x,t;
	FOR(i,1,n){
		cin>>x;
		FOR(j,0,63){
			if(!j)t=1;
			else t=t*2;
			if(x&t)p[j][0][i]=1;
		}
	}
	FOR(i,1,n){
		cin>>x;
		FOR(j,0,63){
			if(!j)t=1;
			else t=t*2;
			if(x&t)p[j][1][i]=1;
		}
	}
	FOR(i,0,63)solve(i);
	FOR(i,1,n){
		FOR(j,1,n)cout<<ans[i][j]<<' ';
		cout<<'\n';
	}
	RE 0;
}




Measured memory_bytes: 8632
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = x/500;
        int b = (x%500) /5;
        System.out.println(a*1000 + b*5);
        sc.close();

    }

}


Measured memory_bytes: 23764
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int cnt[26] = {};
    rep(i, S.length()) cnt[S[i]- 'a']++;
    int cnt2[26] = {};
    string T;
    if (S.length() < 26) {
        rep(i, S.length()) {
            cnt2[S[i]- 'a']++;
            if (S[i] - 'a' == i) {
                T += S[i];
                continue;
            }
            else {
                rep(i, 26) {
                    if (cnt[i] == 0) {
                        cout << S << (char)(i + 'a') << endl;
                        return 0;
                    }
                }
            } 
        }
        rep(i, 26) {
            if (cnt[i] == 0) {
                cout << S << (char)(i + 'a') << endl;
                return 0;
            }
        }
    }
    vector<char> v;
    rep(i, 26) v.push_back(S[i]);
    next_permutation(v.begin(), v.end());
    if (v[0] < S[0]) {
        cout << -1 << endl;
        return 0;
    }
    int c = 0;
    while(S[c] == v[c]) c++;
    c++;
    rep(i, c) cout << v[i];
    cout << endl;

    return 0;
}


Measured memory_bytes: 256