akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include <string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>

#define ok printf("ok\n");
#define MAX 1000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define pb push_back

using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

int main()
{
	int a,b,c;
	string s,t;
	vi v,w;
	cin >> s >> t;
	rep(i,s.size()){
		a = (int)s[i];
		v.pb(a);
	}
	rep(i,t.size()){
		a = (int)t[i];
		w.pb(a);
	}
	sort(all(v));
	sort(w.rbegin(), w.rend());
	b = a;
	rep(i,s.size())
	{
		if(v[i] != w[i])
		{
			a = i;
			break;
		}
	}
	if(a == b)
	{
		if(s.size()<t.size())
			cout << "Yes";
		else
			cout << "No";
	}
	else{
	//cout << v[a] << w[a];
	if(v[a] < w[a])
		cout <<"Yes";
	else
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[10][10];
int main(){
	int n,m,k,S,ans=0;scanf("%d%d%d",&n,&m,&k),S=1<<(n+m);
	for(int i=0;i<n;i++)scanf("%s",s+i);
	for(int i=0;i<S;i++){
		int w=0;
		for(int j=0;j<n;j++)for(int l=0;l<m;l++)
			if(s[j][l]=='#'&&(i&(1<<j))==0&&(i&(1<<(l+n)))==0)w++;
		ans+=w==k;
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int n, q;
  cin >> n >> q;
  string s = "a";
  string ss;

  cin >> ss;
  s += ss;
  s += "a";

  int left = 0;
  int right = n+1;

  vector<char> t(q), L(q);
  rep(i, q){
    cin >> t[i] >> L[i];
  }

  for(int i = q-1; i >= 0; i--){

    // rightの処理
    if(L[i] == 'L' && s[right] == t[i]){
      right = min(n+1, right+1);
    }
    if(L[i] == 'R' && s[right-1] == t[i]){
      right = max(1, right-1);
    }

    if(L[i] == 'L' && s[left+1] == t[i]){
      left = min(n, left+1);
    }

    if(L[i] == 'R' && s[left] == t[i]){
      left = max(0, left - 1);
    }

  }

  if(right <= left){
    cout << 0 << endl;
  }else{
    cout << right - left - 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 1172
//0042 A Thief
//vñFibvTbNâè
//Ql http://algorithms.blog55.fc2.com/blog-category-6.html

#include<iostream>
#include<cstdlib>
#include<algorithm>
using namespace std;

int main(void)
{

	const int MAX_WEIGHT = 1000 + 1;
	const int MAX_OBJECT = 1000 + 1;
	const int MAX_SCORE = 10000;

	int caseNum = 1;
	while(1)
	{
		int totalWeight, totalN;
		int i, j;
		static int c[MAX_OBJECT][MAX_WEIGHT];	//X^bNÉæçÈ¢ÌÅÃIÌæÉu­
		for(i = 0; i < MAX_OBJECT; i++)
			for(j = 0; j < MAX_WEIGHT; j++)
				c[i][j] = 0;
		char dummy;

		cin >> totalWeight;
		if(totalWeight == 0)
			break;
		cin >> totalN;

		int score, w;
		for(i = 0; i < totalN; i++)
		{
			cin >> score >> dummy >> w;

			//eÊjÌibvTbNÉüé©AüéÈçAüêéÆ«üêÈ¢Æ«ÇÁ¿ª¢©
			for(j = 0; j <= totalWeight; j++)
			{
				//ibvTbNÉüèÜ·@©ÂAüê½Æ«ÍüêÈ¢Æ«æè¾µÜ·
				if(w<=j && c[i][j-w]+score > c[i][j])
				{
					c[i+1][j] = c[i][j-w] + score;
				}
				//»ÌiÍgíÈ¢
				else
				{
					c[i+1][j] = c[i][j];
				}
			}
		}

		cout << "Case " << caseNum << ":" << endl;
		caseNum++;


		w = totalWeight;
		//¯¶¿lÅæèy¢àÌª é©²×é
		while(1)
		{
			if(c[totalN][totalWeight] == c[totalN][w-1])
				w--;
			else
				break;
		}
		cout << c[totalN][totalWeight] << endl << w << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for (int i=(a); i<(b); i++)
#define per(i,a,b) for (int i=(b-1); i>=(a); i--)
#define de(x) cout << #x << " => " << x << endl
using namespace std;

#define fi first
#define se second
#define mp make_pair
typedef pair<int,int> pii;

#define pb push_back
typedef vector<int> vi;

typedef long long ll;
typedef long double ld;

///----------------------------------------------

int main() {
	vi v; v.resize(3);
	rep(i, 0, 3) scanf("%d", &v[i]);
	sort(all(v));
	printf("%d", v[0] == v[1] ? v[2] : v[0]);
}


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

int main() {
	int N,M,X,r=INF;
	cin >> N >> M >> X;
	vector<int> C(N);
	vector<vector<int>> A(N, vector<int>(M));

	rep(i,N) {
		cin >> C.at(i);
		rep(j,M)
			cin >> A.at(i).at(j);
	}

	rep(i,1<<N) {
		vector<int> al(M,0);
		int t = 0;
		bool ok = 1;

		rep(j,N)
			if(i & 1<<j) {
				t += C.at(j);
				rep(k,M)
					al.at(k) += A.at(j).at(k);
			}

		rep(j,M)
			if(al.at(j) < X)
				ok = 0;
		if(ok)
			r = min(r, t);
	}

	if(r == INF)
		cout << -1;
	else
		cout << r;
	cout << endl;
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    if(N%10==3){
        cout << "bon";
    }else if(N%10==0 || N%10==1 || N%10==6 || N%10==8){
        cout << "pon";
    }else{
        cout << "hon";
    }
}


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

int main(){
	int n;
	cin>>n;
	vector<double> ans(40000,200);
	
	vector<int> t(n);
	vector<int> v(n);
	int maxt=0;
	for(int i=0;i<n;i++){
		cin>>t[i];
		maxt+=t[i];
	}
	for(int i=0;i<n;i++)cin>>v[i];
	
	double speed=0;
	int time=0;
	int ttime=0;
	for(int i=0;i<n;i++){
		ttime=0;
		while(ttime<t[i]*2){
			ttime+=1;
			if(speed<v[i]){
				speed+=0.5;
			}else if(speed>v[i]){
				speed=v[i];
			}
			ans[time+ttime]=speed;
		}
		time+=ttime;
	}
	
	speed=0;
	time=maxt*2;
	ttime=0;
	for(int i=n-1;i>=0;i--){
		ttime=0;
		while(ttime<t[i]*2){
			ttime+=1;
			if(speed<v[i]){
				speed+=0.5;
			}else if(speed>v[i]){
				speed=v[i];
			}
			ans[time-ttime]=min(ans[time-ttime],speed);
		}
		time-=ttime;
	}
	double sum=0;
	for(int i=1;i<maxt*2;i++)sum+=ans[i];
	cout<< fixed << setprecision(3) <<sum/2<<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ppi = pair<pii, int>;

#define INF (ll)1e18

struct edge{
  ll to, a, b;
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  ll n, m, s;
  cin >> n >> m >> s;
  vector<vector<edge>> edges(n);
  vector<ll> c(n), d(n);
  ll max_a = 0;
  for(int i = 0; i < m; i++){
    ll u, v, a, b;
    cin >> u >> v >> a >> b;
    u--, v--;
    edges[u].push_back({v, a, b});
    edges[v].push_back({u, a, b});
    max_a = max(max_a, (ll)a);
  }
  for(int i = 0; i < n; i++){
    cin >> c[i] >> d[i];
  }

  priority_queue<
    pair<pll, pll>,
    vector<pair<pll, pll>>,
    greater<pair<pll, pll>>
  > q;

  q.push({{0, 0}, {0, min((ll)max_a*(n-1), s)}});
  ll t, cost, point, silver;
  bool f;
  vector<ll> ans(n, INF);
  vector<vector<ll>> used(n, vector<ll>(max_a*(n-1)+1, INF));
  while(!q.empty()){
    // auto now = q.top(); q.pop();
    // t = now.first.first;
    // cost = now.first.second;
    // point = now.second.first;
    // silver = now.second.second;
    tie(t, cost) = q.top().first;
    tie(point, silver) = q.top().second;
    q.pop();
    if(used[point][silver] <= t) continue;
    used[point][silver] = t;
    ans[point] = min(ans[point], t);
    // cout << t << ' ' << point << ' ' << silver << ' ' << q.size() << endl;
    if(used[point][min(max_a*(n-1), silver + c[point])] > t + d[point])
      q.push({{t + d[point], cost}, {point, min(max_a*(n-1), silver + c[point])}});
    for(auto e : edges[point]){
      if(silver >= e.a && used[e.to][silver - e.a] > t + e.b)
        q.push({{t + e.b, cost + e.a}, {e.to, min(max_a*(n-1), silver - e.a)}});
    }
  }

  for(int i = 1; i < n; i++){
    cout << ans[i] << endl;
  }

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 12540
#include <bits/stdc++.h>
using namespace std;
#include <string>
int main() {

int n,m;
cin >> n >> m ;
vector <int> s(m+1);
vector <char> c(m+1);
string kekka;

if(n==1)
{kekka="0";}
if(n==2)
{kekka="10";}
if(n==3)
{kekka="100";}


for (size_t i = 0; i < m; i++)
{
  cin >> s.at(i)>>c.at(i);
  int a=s.at(i);


  /*if(a>n)
  {kekka="-1"; }*/
  for (size_t j = 0; j < i; j++)
  {
   if(a==s.at(j)&&c.at(i)!=c.at(j))
   {kekka="-1"; }  
   }

}


if(kekka!="-1")
{ 
  for (size_t i = 0; i < m; i++)
  {
  kekka.at(s.at(i)-1)=c.at(i);
  }
}

if(kekka!="-1" && n!=1){
  if( kekka.at(0)=='0')
    {kekka="-1";}
}

cout << kekka << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=100+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("A.in","r",stdin);
	freopen("A.out","w",stdout);
#endif
}
int n,a[N],x;
ll sum[N];
void input()
{
	n=read<int>();x=read<int>();
	For(i,1,n)a[i]=read<int>();
}
void work()
{
	sort(a+1,a+n+1);
	For(i,1,n)sum[i]=sum[i-1]+a[i];
	int pos=0;
	for(;pos<n&&sum[pos+1]<=x;pos++);
	if(sum[pos]==x)write(pos,'\n');
	else
	{
		if(pos==n)pos--;
		write(pos,'\n');
	}
}
int main()
{
//	file();
	input();
	work();
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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();

		boolean can = false;

		for (int i = 1; i <= k; i++) {
			if (a >= b) {
				b *= 2;
			} else if (b >= c) {
				c *= 2;
			}

		}

		if (a < b && b < c) {
			can = true;
		}

		if (can) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}


		sc.close();
	}

}


Measured memory_bytes: 35712
s=str(input())
n=len(s)

k=(n-1)//2
l=(n+3)//2
if s==s[::-1]:
    if(s[:k]==s[:k][::-1]):#s[:k][::-1]0からkまでスライスして逆順に並べる
        if(s[l-1:n]==s[l-1:n][::-1]):
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")

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

int main()
{
    long n; cin>>n;
    long res=0;
    for(long i=1; i*i<=n; ++i) {
        if ((n-i)%i>0) continue;
        auto m=(n-i)/i;
        if (m>0 and n/m==n%m) res+=m;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_B&lang=jp
# Selection Sort: python3
#  2018.12.09 yonezawa

import sys
input = sys.stdin.readline


def selectionSort(l):
    cnt= min_i= 0
    for i in range(len(l)-1):
        min_i = i
        flg = False
        for j in range(i+1,len(l)):
            if l[min_i] > l[j]:
                min_i = j
                flg = True
        if flg == True:
            cnt += 1
            #print (l[i],l[min_i])
            (l[i],l[min_i]) = (l[min_i],l[i]) 
    return l,cnt

def main():
    n = int(input())
    l = list(map(int,input().split()))
    (ans,cnt) = selectionSort(l)
    print (*ans)
    print (cnt)
if __name__ == '__main__':
    main()



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

int main() {

  int H, W;

  for(;;) {
    std::cin >> H >> W;
    if( H == 0 && W == 0 ) {
      break;
    }
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
	std::cout << "#";
      }
      std::cout << std::endl;
    }
    std::cout << std::endl;
  }
  
  
  
  return 0;
}

Measured memory_bytes: 1152
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  998244353;
const ll inf = 1e18;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}



signed main() {
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> a(n), b(n);
  REP(i, n) cin >> a[i];
  REP(i, n) cin >> b[i];
  using Node = pair<ll, int>;
  priority_queue<Node> q;
  REP(i, n) {
    if(a[i] < b[i]) {
      q.emplace(b[i], i);
    }
  }
  ll ans = 0;
  while(q.size()) {
    auto c = q.top();q.pop();
    ll cnt = (c.first - a[c.second]) / (b[(c.second+1) % n] + b[(n+c.second-1) % n]);
    ll nv = c.first - cnt * (b[(c.second+1) % n] + b[(n+c.second-1) % n]);
    if(cnt == 0) {
      cout << -1 << endl;
      return 0;
    }
    else if(nv > a[c.second]) {
      q.emplace(nv, c.second);
    }
    b[c.second] = nv;
    ans += cnt;
  }
  cout << ans << endl;
  return 0; 
}


Measured memory_bytes: 9584
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}


//cout<<" "<<endl;
int main(){
  vvi A(3 ,vi (3));
  rep(i,3){
    rep(j,3)cin>>A[i][j];
  }
  int N;cin>>N;
  vi b(N);rep(i,N)cin>>b[i];
  rep(k,N){
    rep(i,3){
      rep(j,3){
        if(A[i][j]==b[k])A[i][j]=0;
      }
    }
  }
  bool ok=false;
  rep(i,3)if(A[i][1]==A[i][0] &&A[i][0]==A[i][2])ok=true;
  rep(j,3)if(A[0][j]==A[1][j] &&A[0][j]==A[2][j])ok=true;
  if(A[0][0]==A[1][1]&&A[0][0]==A[2][2])ok=true;
  if(A[0][2]==A[1][1]&&A[0][2]==A[2][0])ok=true;
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;
int main()
{
    // 文字列の入力
    int N;
	cin >> N;
	
	static int A[100001];
	int B, C;
	static long long S[100001];
	int tempA;
	for(int i = 0; i < N; i++) {
		cin >> tempA;
		A[tempA]++;
		S[0] += tempA;
	}
	
	int Q;
	cin >> Q;
	for(int i = 1; i <= Q; i++) {
		cin >> B >> C;
		
		long long sum = 0;
		sum = S[i - 1] + (C - B) * A[B];
		int tempB = A[B];
		A[B] = 0;
		A[C] += tempB;
		
		printf("%lld\n", sum);
		S[i] = sum;
	}
	
    return 0;
}


Measured memory_bytes: 4824
from sys import setrecursionlimit, stdin

setrecursionlimit(10 ** 9)

def input():
    return stdin.readline()

n, q = map(int, input().split())
root = [[] for _ in range(n)]
ans = [0 for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    root[a - 1].append(b - 1)
    root[b - 1].append(a - 1)
for _ in range(q):
    p, x = map(int, input().split())
    ans[p - 1] += x
    
def dfs(pos, before):
    for next_pos in root[pos]:
        if next_pos == before:
            continue
        ans[next_pos] += ans[pos]
        dfs(next_pos, pos)

dfs(0, -1)

for i in range(n):
    print(ans[i], end=" ")

Measured memory_bytes: 227844
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
//#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

class CumulativeSum{
public:
  vector<double> sum;
  CumulativeSum(){}
  CumulativeSum(vector<double> A){
    int n = A.size();
    sum.resize(n+1,0);
    for(int i=1;i<=n;i++) sum[i] += sum[i-1] + A[i-1];
  }
  double get(int l,int r){assert(l>=0 && r<=(int)sum.size());return sum[r] - sum[l];} //[l,r)
};


int n;
int m;
vector<double> A;
CumulativeSum sum;

double mem[510][510];
int used[510][510];

double dfs(int pos,int cnt){
  
  if(pos == n) return cnt == m? 0:-INF;;
  if(used[pos][cnt]++) return mem[pos][cnt];

  double res = -INF;
  for(int i=pos;i<n;i++){
    double a = sum.get(pos,i+1) / (i+1-pos);
    Max(res,a + dfs(i+1,cnt+1));
  }
  return mem[pos][cnt] = res;
}

signed main(){

  cin>>n;
  cin>>m;
  A.resize(n);
  cin>>A;
  sum = CumulativeSum(A);
  
  double ans = dfs(0,0);
  printf("%.10lf\n",ans);
  return 0;
}



Measured memory_bytes: 7312
#include<bits/stdc++.h>
#define N 200005
#define M 100005
using namespace std;
int n,m,e[M],used[N];
vector<int> ans;

int main(){
  cin>>n>>m;
  for(int i=0;i<m;i++)
    cin>>e[i];
  for(int i=m-1;i>=0;i--)
    if(!used[e[i]]){
      used[e[i]]=true;
      ans.push_back(e[i]);
    }
  for(int i=1;i<=n;i++)
    if(!used[i])ans.push_back(i);
  for(int i=0;i<ans.size();i++)
    cout<<ans[i]<<endl;
  return 0;
}

Measured memory_bytes: 4976
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abcdef
{
    public class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            //Input integer
            int n = int.Parse(Console.ReadLine());

            //Input int array
            int[] a = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            var ans = 0;
            for (int i = 0; i < n; i++)
            {
                if (i % 2 == 0 && a[i] % 2 == 1) 
                {
                    ans++;
                }
            }
            Console.WriteLine(ans.ToString());

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28168
N,K=gets.split.map(&:to_i)
A=gets.split.map(&:to_i)
h=Hash.new{0}
A.each{|a|
    h[a]+=1
}
k=h.keys.sort_by{|k|h[k]}
r=0
(k.size-K).times{|i|
    r+=h[k[i]]
}
puts r


Measured memory_bytes: 40232
#include<stdio.h>
#include<math.h>
 
int main()
{
    double a,b,C,d;
    double S,L,h;
     
    scanf("%lf%lf%lf",&a,&b,&C);
     
    h = b*sin(C*M_PI/180);
    S = a*h/2;
    d = (a*a+b*b) - 2*a*b*cos(C*M_PI/180);
    d = sqrt(d);
    L = a+b+d;
     
    printf("%f\n%f\n%f\n",S,L,h);
     
    return 0;
}

Measured memory_bytes: 648
n, *a = map(int, open(0).read().split())
max_a = max(a)
money = 1000
stock = 0
for i in range(n-1):
    if a[i] < a[i+1]:
        stock = money // a[i]
        money += (a[i+1] - a[i]) * stock
print(money)

Measured memory_bytes: 9172
H,W,K=map(int,input().split())
K-=1
P=10**9+7
dp=[[0 for j in range(W)] for i in range(H+1)]
dp[0][0]=1
F=[1,1,2,3,5,8,13,21,34,55,89,144,233]
for i in range(H):
    for j in range(W):
        dp[i+1][j]+=dp[i][j]*F[j]*F[W-j-1]
        dp[i+1][j]%=P
        if j!=W-1:
            dp[i+1][j]+=dp[i][j+1]*F[j]*F[W-j-2]
            dp[i+1][j]%=P
        if j!=0:
            dp[i+1][j]+=dp[i][j-1]*F[j-1]*F[W-j-1]
            dp[i+1][j]%=P
print(dp[H][K])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

//BIT
//計算量 初期化:O(N)、クエリ:O(log(N))

template<typename T>
struct Binary_Indexed_Tree{
    vector<T> bit;
    const int n;
    
    Binary_Indexed_Tree(int N) : n(N){
        bit.assign(N+1, 0);
    }
    
    void add(int i, const T &x){
        for(i++; i <= n; i += (i & -i)) bit[i] += x;
    }
    
    T sum(int i){
        T ret = 0;
        for(; i > 0; i -= (i & -i)) ret += bit[i];
        return ret;
    }
    
    T query(int l, int r){
        return sum(r) - sum(l);
    }

    int lower_bound(T x){
        int ret = 0;
        for(int k = 31-__builtin_clz(n); k >= 0; k--){
            if(ret+(1<<k) <= n && bit[ret+(1<<k)] < x) x -= bit[ret += (1<<k)]; 
        }
        return ret;
    }

    int upper_bound(T x){
        int ret = 0;
        for(int k = 31-__builtin_clz(n); k >= 0; k--){
            if(ret+(1<<k) <= n && bit[ret+(1<<k)] <= x) x -= bit[ret += (1<<k)];
        }
        return ret;
    }
    
    void clear(){
        fill(bit.begin(), bit.end(), 0);
    }
};

//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_B

int main(){
    int N, Q;
    cin >> N >> Q;
    Binary_Indexed_Tree<int> bit(N);
    while(Q--){
        int q, x, y; cin >> q >> x >> y; x--;
        if(q == 0) bit.add(x, y);
        else cout << bit.query(x, y) << endl;
    }
}


Measured memory_bytes: 3132
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int n,l[110],r[110];
int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d%d" ,&l[i],&r[i]);
    for(int i=1;i<=n-2;i++)
        if(l[i]==r[i]&&l[i+1]==r[i+1]&&l[i+2]==r[i+2]) {
            puts("Yes");
            return 0;
        }
    puts("No");
}

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

int main() {
  int N, mod=1000000007;
  cin >> N;
  long long S=1, T=2, U=1;
  
  for (int i=0; i<N; i++) {
    S*=10;
    S=S-S/mod*mod;
  }
  
  for (int i=0; i<N; i++) {
    T*=9;
    T=T-T/mod*mod;
  }
  
  for (int i=0; i<N; i++) {
    U*=8;
    U=U-U/mod*mod;
  }
  
  long long P=S-T;
  P+=mod;
  P=P-P/mod*mod;
  P=P+U;
  P=P-P/mod*mod;
  cout << P << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
char s[13000];
int main()
{
	cin>>s;
	int len=strlen(s);
	long long ans=0;
	for(int i=0;i<(1<<(len-1));i++)
	{
		long long num=s[0]-'0';
		for(int j=0;j<len-1;j++)
		{
			if(i&(1<<j))
			{
				ans=ans+num;
				num=0;
			}
			num=num*10+s[j+1]-'0';
		}
		ans=ans+num;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define mod 1000000007
#define bitcount __builtin_popcountll
#define ll long long
#define pb push_back
#define pi pair<int,int>
#define pii pair<pi,int>
#define mp make_pair
int arr[100005][35];
map<double,int>m;
int main()
{
	int i,j,k,l;
	int n,c;
	sd(n);
	sd(c);
	for(i=1;i<=n;i++)
	{
		sd(l);
		sd(j);
		sd(k);
		arr[l][k]++;
		arr[j][k]--;
	}
	for(i=1;i<=c;i++)
	{
		for(j=1;j<=100000;j++)
			arr[j][i]+=arr[j-1][i];
	}
	for(i=1;i<=c;i++)
	{
		for(j=1;j<=100000;j++)
		{
			if(arr[j-1][i]==0&&arr[j][i]==1)
				m[(double)j-0.5]++;
			else if(arr[j-1][i]==1&&arr[j][i]==0)
				m[(double)j-0.1]--;
		}
	}
	map<double,int>::iterator it,it1;
	it=m.begin();
	it1=it;
	it1++;
	int ans=it->second;
	while(it1!=m.end())
	{
		(it1->second)+=(it->second);
		ans=max(ans,(it1->second));
		it++;
		it1++;
	}
	printf("%d\n",ans );
	return 0;
}

Measured memory_bytes: 22016
import sys
for s in sys.stdin.readlines():
    st = []
    for c in s.strip().split():
        if c=='+':
            st.append(st.pop()+st.pop())
        elif c=='-':
            st.append(-st.pop()+st.pop())
        elif c=='*':
            st.append(st.pop()*st.pop())
        elif c=='/':
            st.append(1/st.pop()*st.pop())
        else:
            st.append(float(c))
    print st.pop()

Measured memory_bytes: 4228
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
#define int long long 
using namespace std;
int n,A[li][5],dp[li][5];
int dfs(int node,int pre){
	int cev=-inf;
	if(node==n+1) return 0;
	if(~dp[node][pre]) return dp[node][pre];
	for(int i=1;i<=3;i++){
		if(i==pre) continue;
		cev=max(cev,dfs(node+1,i)+A[node][i]);
	}
	return dp[node][pre]=cev;
}
main(){
	memset(dp,-1,sizeof(dp));
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) scanf("%lld %lld %lld",&A[i][1],&A[i][2],&A[i][3]);
	int ty=dfs(1,0);
	printf("%lld\n",ty);
	return 0;
}




Measured memory_bytes: 14336
#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 a, b, c, n;
    cin >> a >> b >> c >> n;
    int aa, bb, cc;

    
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n-i; j++) {
            for (int k = 0; k <= n-i-j; k++) {
                aa = a;
                bb = b;
                cc = c;
                
                if (i != 0) aa = a * pow(2, i);
                if (j != 0) bb = b * pow(2, j);
                if (k != 0) cc = c * pow(2, k);
                // cout << "red=" << aa << " green=" << bb << " blue=" << cc << endl;
                if (bb > aa && cc > bb ) {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 4004
#include<iostream>

using namespace std;


int x0,x1,x2,x3,x4,y0,y1,y2,y3;
int n;


int solve(int ax,int ay,int bx,int by,int cx,int cy,int dx,int dy){
    int a1=ax-bx, b1=ay-by,a2=cx-dx,b2=cy-dy;
    double naiseki,gaiseki;
    gaiseki = a1*b2-b1*a2;
    naiseki = a1*a2 + b1*b2;
    if(naiseki == 0 ) return 1;
    if(gaiseki == 0) return 2;
    return 0;
}

int main(){
    cin>>n;

    for(int i=0;i<n;i++){
        cin>>x0>>y0>>x1>>y1>>x2>>y2>>x3>>y3;

        cout<<solve(x0,y0,x1,y1,x2,y2,x3,y3)<<endl;
    
    }
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <math.h>
using namespace std;
void doIt3();

int main(){
doIt3();
}

void doIt3(){
	int n;
	cin >> n;
	while(n != 0){
		if(n == 1){
			cout << "deficient number" << endl;
			cin >> n;
			continue;
		}
		double rt = sqrt(n);
		//まず1の処理
		int sum = 1;
		int i;
		for(i = 2; i < rt; i++){
			if(n % i == 0){
				sum += i;
				sum += n / i;
			}
		}
		if((double)i == rt){
			sum += i;
		}
		if(sum == n){
			cout << "perfect number" << endl;
		}
		else if(sum > n){
			cout << "abundant number" << endl;
		}
		else{
			cout << "deficient number" << endl;
		}
		//cout << sum << endl;
		cin >> n;
	}
	
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll MOD;

const int SZ = 5005;
ll inv[SZ];
ll fact[SZ];
ll fact_inv[SZ];
ll choose(int n, int r) {
  if (n < 0 || r < 0 || n < r) return 0;
  return fact[n] * fact_inv[n-r] % MOD * fact_inv[r] % MOD;
}

ll mod_pow(ll a, ll b, ll p) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % p;
    a = (a * a) % p;
    b >>= 1;
  }
  return res;
}

const int MAX_N = 5010;
ll dp[MAX_N][MAX_N];

ll ways(int N, int i) {

  ll res = 0;
  for (int j = 0; j <= i; j++) {
    res += dp[i][j] * mod_pow(2, (N-i)*j, MOD);
    res %= MOD;
    // cout << "ways2(" << j << ")" << res << endl;
  }

  ll mm = 1;
  REP(p, N-i) mm = (mm * 2) % (MOD - 1);
  res *= mod_pow(2, mm, MOD);
  res %= MOD;

  // cout << "ways(" << N << "," << i << ")=" << res << endl;
  return res;
}


int main2() {
  int N; cin >> N;
  cin >> MOD;

  inv[1] = 1;
  for (int i = 2; i < SZ; i++) inv[i] = inv[(int) (MOD % i)] * (MOD - MOD / i) % MOD;
  fact[0] = 1;
  for (int i = 1; i < SZ; i++) fact[i] = fact[i-1] * i % MOD;
  fact_inv[0] = 1;
  for (int i = 1; i < SZ; i++) fact_inv[i] = fact_inv[i-1] * inv[i] % MOD;

  CLR(dp, 0);

  for (int i = 0; i <= N; i++) dp[i][0] = 1;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= i; j++) {
      dp[i][j] = ((j+1) * dp[i-1][j] + dp[i-1][j-1]) % MOD;
    }
  }

  ll ans = 0;
  for (int i = 0; i <= N; i++) {
    ll sub_i = choose(N, i) * ways(N, i);
    ans += (i % 2 == 0 ? +1 : -1) * sub_i;
    ans = (ans % MOD + MOD) % MOD;
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 196480
import java.util.*;
import java.io.*;
public class Main{
	static BufferedReader br;
    static PrintWriter out;
    static StringTokenizer st;
	public static void main(String[] args) throws IOException{
	    br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(new OutputStreamWriter(System.out));
        int A = readInt(), B = readInt(), C = readInt(), X = readInt(), Y = readInt();
        int op1 = A*X + B*Y;
        int min = Math.min(X, Y);
        int op2 = min*C*2 + A*(X-min) + B*(Y-min);
        int op3 = Math.max(X,Y)*C*2;
        int Best = Math.min(Math.min(op1, op2), op3);
        System.out.println(Best);
	}
	static String next () throws IOException {
	    while (st == null || !st.hasMoreTokens())
	    st = new StringTokenizer(br.readLine().trim());
	    return st.nextToken();
	}

	static long readLong () throws IOException {
	    return Long.parseLong(next());
	}

	static int readInt () throws IOException {
	    return Integer.parseInt(next());
	}

	static double readDouble () throws IOException {
	    return Double.parseDouble(next());
	}

	static char readCharacter () throws IOException {
	    return next().charAt(0);
	}

	static String readLine () throws IOException {
	    return br.readLine().trim();
	}
}



Measured memory_bytes: 32888
using System;

namespace ConsoleApp8
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
         
            Console.WriteLine("{0} {1}", a * b, 2*(a + b));
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 9172
#include <stdio.h>
#include <string.h>
void bubble_sort(int C[], int value[], int length) {
  int i,j,tmp;
  for(i = 1; i <= length; ++i) {
    for(j = length; j >= i+1; --j) {
      if(value[C[j]] < value[C[j-1]]) {
        tmp = C[j];
        C[j] = C[j-1];
        C[j-1] = tmp;
      }
    }
  }
}

void select_sort(int C[], int value[], int length) {
  int i,j,mini,tmp;
  for(i = 1; i <= length; ++i) {
    mini = i;
    for(j = i; j <= length; ++j) {
      if(value[C[j]] < value[C[mini]] ){
        mini = j;
      }
    }
    tmp = C[i];
    C[i] = C[mini];
    C[mini] = tmp;
  }
}

void make_str(char str[], int C[], int value[], char mark[], int length) {
  int i,j,k;
  k = 0;
  for(i = 1; i <= 9; ++i) {
    for(j = 1; j <= length; ++j) {
      if(value[C[j]] == i) str[k++] = mark[C[j]];
    }
  }
  str[k] = '\0';
}

void show(int C[], int value[], char mark[], int length, int isNotStable) {
  int i;
  for(i = 1; i <= length; ++i) {
    if(i != 1) printf(" ");
    printf("%c%d", mark[C[i]], value[C[i]]);
  }
  printf("\n");
  printf("%s\n",isNotStable==0?"Stable":"Not stable");
}

int main() {
  int length;
  int value[37];
  char mark[37];

  int C[37],C1[37],C2[37];
  char S[37],S1[37],S2[37];
  int i,j,k;

  scanf("%d", &length);
  for(i = 1; i <= length; ++i) {
    scanf(" %c%d", &mark[i], &value[i]);
  }
  for(i = 1; i <= length; ++i) {
    C[i] = C1[i] = C2[i] = i;
  }

  bubble_sort(C1,value,length);
  select_sort(C2,value,length);

  make_str(S,C,value,mark,length);
  make_str(S1,C1,value,mark,length);
  make_str(S2,C2,value,mark,length);
  show(C1,value,mark,length,strcmp(S,S1));
  show(C2,value,mark,length,strcmp(S,S2));

  return 0;
}

Measured memory_bytes: 0
n=int(input())
l=[[-1 for i in range(n)] for j in range(n)]
for i in range(n):
  a=int(input())
  for j in range(a):
    x,y = map(int,input().split())
    l[i][x-1]=y

ans=0
for i in range(2**n):
  d=[0 for x in range(n)]
  for j in range(n):
    if i>>j & 1:
      d[j]=1

  flag=1

  for j in range(n):
    for s in range(n):
      if d[j]==1:
        if l[j][s]==-1:
          continue
        
        if l[j][s]!=d[s]:
          flag=0
          break
          
  if flag:
    ans=max(ans,sum(d))

print(ans)

Measured memory_bytes: 9252
#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = read().rstrip()

bl = S[2] == S[3] and S[4] == S[5]
answer = 'Yes' if bl else 'No'
print(answer)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}

void END(){cout << 0 << endl; exit(0);}


int main()
{
 cin.tie(0);
 ios::sync_with_stdio(false);
 int m1, m2, d1, d2;
 cin >> m1 >> d1 >> m2 >> d2;
 if (m1 != m2) cout << 1 << endl;
 else cout << 0 << endl;

 return 0;
}

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


class BIT():
    """区間加算、一点取得クエリをそれぞれO(logN)で答える"""
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)

    def _add(self, i, val):
        while i > 0:
            self.bit[i] += val
            i -= i & -i

    def get_val(self, i):
        """i番目の値を求める"""
        i = i + 1
        s = 0
        while i <= self.n:
            s += self.bit[i]
            i += i & -i
        return s

    def add(self, l, r, val):
        """区間[l, r)にvalを加える"""
        self._add(r, val)
        self._add(l, -val)


def compress(array):
    """座標圧縮したリストを返す"""
    array2 = sorted(set(array))
    memo = {value: index for index, value in enumerate(array2)}
    return memo

n, d, a = map(int, input().split())
info = [list(map(int, input().split())) for i in range(n)]

info = sorted(info)
b = [info[i][0] for i in range(n)]
memo = compress([info[i][0] for i in range(n)])
bit = BIT(n)

for i in range(n):
    ind, val = info[i]
    bit.add(memo[ind], memo[ind] + 1, val)

ans = 0
for i in range(n):
    tmp = bit.get_val(i)
    if tmp <= 0:
        continue
    ans += -((-tmp) // a)
    nxt_ind = b[i] + 2 * d
    ii = bisect.bisect_right(b, nxt_ind)
    bit.add(i, ii, ((-tmp) // a) * a)
print(ans)

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

#define read(a) cin >> a
#define out(a)  cout << a
#define ull unsigned long long
#define ll long long
#define FOR(i, l, r) for (ll i = l; i <= r; i++)
#define FOD(i, l, r) for (ll i = l; i >= r; i--)
#define fast ios_base::sync_with_stdio(false);
#define mod 1000000007
#define ll long long

int main()
{
   float d, t, s;
   cin >> d >> t >> s;
   if (d / s <= t) cout << "Yes";
   else cout << "No";
}


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

int main(void){
	long i,n,min=1,ans=0,a;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a;
		if(a==min){
			min++;
			continue;
		}
		ans+=(a-1)/min;
if(i==0) min++;
	}
	cout << ans;
	return 0;
}

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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
const long long INF  = 1e18;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s.back()=='s')
        s += "es";
    else 
        s += "s";
        cout<<s;
}
//https://www.youtube.com/watch?v=ZQqccia8bVo

Measured memory_bytes: 3600
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define ALL(v) v.begin(), v.end()
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
	int N; cin >> N;
	string S; cin >> S;
	int ans = 0;
	rep(i, N-2) if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C') ++ans;
	cout << ans << endl;
}

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

int N,Q,M,Date,ans,mem;
map<int,int> cnt;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> N >> Q,N){
        cnt.clear();
        for (int i=0;i<N;++i){
            cin >> M;
            for (int j=0;j<M;++j){
                cin >> Date;
                ++cnt[Date];
            }
        }
        ans=mem=0;
        for (auto p:cnt) if (Q<=p.second){
            if (mem<p.second) ans=p.first,mem=p.second;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3224
using System;
using System.Linq;

namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    int a=int.Parse(Console.ReadLine());
    string s=Console.ReadLine();
      if(a>=3200){
        Console.WriteLine(s);
      }else{
        Console.WriteLine("red");
    }
    }
    
  }

}

Measured memory_bytes: 27336
#include "bits/stdc++.h"
#include<assert.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define MRE assert(0);
const int inf = 1e17;
const int mod = 998244353;
typedef pair<int, int> P;
struct edge {
	int to, dir;
};
int n; 
vector<string>ans;
void dfs(string now, int val) {
	if (now.size() == n) {
		ans.push_back(now);
		return;
	}
	for(int i=1;i<=val+1;i++) {
		now.push_back('a' + i-1);
		dfs(now, max(i, val));
		now.pop_back();
	}
}
signed main(){
	cin >> n;
	dfs("", 0);
	sort(ans.begin(), ans.end());
	for (string s : ans)cout << s << endl;
}

Measured memory_bytes: 9332
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();
		int powk = ((int) Math.pow(2, k));
		int answer = 0;

		if (a > b && a > c) {
			answer = a * powk + b + c;
		} else if (b > a && b > c) {
			answer = b * powk + a + c;
		} else {
			answer = c * powk + a + b;
		}

		System.out.println(answer);
  }
}


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

using namespace std;
const int maxn=1e5+500;
double b[maxn];

int main()
{
	int n;
	cin>>n;
	double h,a;
	cin>>h>>a;
	int flag=0;
	for(int i=0;i<n;i++){
		cin>>b[i];
		b[i]=h-b[i]*0.006;
		b[i]=fabs(b[i]-a);
	}
	cout<<(min_element(b,b+n)-b)+1;
} 

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>

#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using namespace boost::multiprecision;

cpp_int power(int p, int q){
    cpp_int ret = p;
    for(int i=1;i<q;i++){
        ret *= p;
    }
    return ret;
}

int main(void){
	int n = 0;
    cin >> n;
    cpp_int pow = 1;
    for(int i=1;i<=n;i++){
        pow *= i;
    }
    cout << pow % (7 + power(10,9)) << endl;
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

int main()
{
	ull n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	vector<ll> vec0, vec1;

	auto pu = [&vec0, &vec1]( char p, ll x )
	{
		if( p == '0' ) vec0.push_back(x);
		else vec1.push_back(x);
	};

	ll sum = 0;
	char p = s[0];
	pu( p, 0 );
	REP(i,n)
	{
		if( s[i] == p ) continue;
		p = s[i];
		pu( p, i );
		if( p == '0' )
		{
			sum = max( sum, vec0[vec0.size()-1] - vec1[vec1.size()-1] );
		}
	}

	if( k >= vec0.size()  ) sum = n;
	else
	{
		REP(i, vec0.size() - k + 1)
		{
			int j = i + k - 1;
			ll s,e;
			if( vec1.size() < 1 ) {e = n; s = 0;}
			else
			{
				if( i == 0 ) s = 0;
				else s = vec1[ vec0[0] < vec1[0] ? i - 1 : i];
				if( j == vec0.size() - 1 ) e = n;
				else e = vec0[j + 1];
			}
			sum = max( sum, e - s );
		}
	}
	
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1404
#include<stdio.h>
#define MAX 500000

void maxHeapify(int);

int n,num[MAX+1];

int main() {

  int i;

  scanf("%d",&n);
  for(i=1;i<=n;i++) scanf("%d",&num[i]);

  for(i=n/2;i>=1;i--) maxHeapify(i);

  for(i=1;i<=n;i++) printf(" %d",num[i]);
  printf("\n");

  return 0;

}

void maxHeapify(int i) {

  int l,r,largest;
  int a;
  l = 2*i;
  r = 2*i+1;
  
  if(l<=n && num[l]>num[i]) largest = l;
  else largest = i;
  if(r<=n && num[r]>num[largest]) largest = r;
  
  if(largest != i) {
    a = num[i]; num[i] = num[largest]; num[largest] = a;
    maxHeapify(largest);
  }
}


Measured memory_bytes: 3652
N=int(input())
W=list(map(int,input().split()))
sumw=sum(W)
half=sumw/2
kei=0
cnt=0
i=0
while kei<half:
    kei=kei+W[i]
    i+=1
keis=kei-W[i-1]

kotae=min(abs(sumw-2*kei),abs(sumw-2*keis))
print(kotae)

Measured memory_bytes: 3064
data_num = int(input())
data = [int(n) for n in input().split(' ')]
changed = 0

for i in range(0, data_num):
    minj = i
    for j in range(i, data_num):
        if data[j] < data[minj]:
            minj = j
    data[i], data[minj] = data[minj], data[i]
    if i != minj:
        changed += 1

print(' '.join([str(i) for i in data]))
print(changed)

Measured memory_bytes: 7708