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

int main(){
    int n, i, j;
    double N, dist = 0;
    cin >> n;
    N = n;
    double place[n][2];
    for(i = 0; i < n; i++){
        cin >> place[i][0] >> place[i][1];
    }
    
    for(i = 0; i < N; i++){
        for(j = i+1; j < N; j++){
            dist += sqrt(pow(place[i][0] - place[j][0], 2) + pow(place[i][1] - place[j][1], 2)) * 2;
        }
    }
    dist /= N;
    printf("%.10f\n", dist);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n, x;
    char p;
    int nest = 0;
    bool is_nonzero = true;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> p >> x;
        if (p == '(') {
            nest += x;
        } else {
            nest -= x;
            if (nest < 0) {
                is_nonzero = false;
            }
        }
    }
    if (is_nonzero && nest == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

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

#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
using ll=long long;
using ld=long double;
typedef pair<double,int> P;

#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define INF 100000000
int main()
{
    int h,n;
    cin >> h >> n;
    vector<int> a(n),b(n);
    vector<vector<int>> dp(n+1,vector<int>(h+1));
    rep(i,n)cin >> a[i] >> b[i];
    rep(i,n+1)dp[i][0]=0;
    rep(i,h+1)dp[0][i]=INF;
    rep(i,n){
        rep(j,h){
            if(a[i]>j+1){
                dp[i+1][j+1]=min(dp[i][j+1],dp[i+1][0]+b[i]);
            }else{
                dp[i+1][j+1]=min(dp[i][j+1],dp[i+1][j+1-a[i]]+b[i]);
            }
        }
    }

    cout << dp[n][h] << endl;

}

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

using namespace std;

int main(void){

  int n,m,p;

  while(cin >> n >> m >> p,n|m|p){
    vector<int>cnt(n);
    int sum = 0;
    for(int i=0;i<n;i++){
      cin >> cnt[i];
      sum += cnt[i];
    }
    sum *= 100;
    int ans = sum - sum * p / 100;
    if(cnt[m-1]==0)cout << 0 << endl;
    else cout << ans / cnt[m-1] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 2952
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int n;
	cin>>n;
	int shop[n][10];
	ll profit[n][11];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<10;j++)
			cin>>shop[i][j];
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<11;j++)
			cin>>profit[i][j];
	}
	int freq[n];ll p=-1000000000000;

	for(int i=0;i<n;i++)
		freq[i]=0;
	for(int i=1;i<1<<10;i++)
	{
		ll tp=0;
		for(int j=0;j<10;j++)
		{
			
			if(i&(1<<j))
			{
				for(int l=0;l<n;l++)
				{
					if(shop[l][j]==1)
						freq[l]++;
				}
			}
			

		}
		for(int k=0;k<n;k++)
		{
			tp += profit[k][freq[k]];
		}
		if(tp>p){
			p=tp;
			//cout<<bitset<5>(i)<<"\n";
		}
		for(int k=0;k<n;k++)
			freq[k]=0;
	}
		
		
		cout<<p<<"\n";
}


Measured memory_bytes: 3632
def fib(n):
    if n == 1:
        return 1
    if n == 2:
        return 2
    else:
        a,b = 0,1
        for i in range(n):
            a,b = b,a+b
        return b

n,m = map(int,input().split())
mod = 10**9+7
ans = 1
a = -1
for i in range(m):
    b = int(input())
    if a != -1 and b-a == 1:
        print(0)
        break
    ans *= fib(b-a-2)
    a = b
else:
    ans *= fib(n-a-1)
    print(ans%mod)

Measured memory_bytes: 45288
N=int(input())
A=list(map(int,input().split()))

check=0
for i in range(N):
    check^=A[i]

t=0
for i in range(60):
    if check>>i &1==0:
        t+=2**i

for i in range(N):
    A[i]&=t

A.sort(reverse=True)
base=[]
for i in range(N):
    for b in base:
        t=A[i]^b
        A[i]=min(A[i],t)
    if A[i]!=0:
        base.append(A[i])

new=0
for b in base:
    t=new^b
    new=max(new,t)

print(check+new*2)

Measured memory_bytes: 76832
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <iomanip>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int INT_MAX_SQRT = sqrt(INT_MAX);
int pwi(int x, int p) {
    if (p == 0) return 1;
    if (p == 1) return x;
    int tmp = pwi(x, p / 2);
    if (tmp > INT_MAX_SQRT) return 0;  // overflow
    if (p % 2 == 0)
        return tmp * tmp;
    else
        return tmp * tmp * x;
}

long LONG_MAX_SQRT = sqrt(LONG_MAX);
long pwl(long x, long p) {
    if (p == 0) return 1;
    if (p == 1) return x;
    long tmp = pwl(x, p / 2);
    if (tmp > LONG_MAX_SQRT) return 0;  // overflow
    if (p % 2 == 0)
        return tmp * tmp;
    else
        return tmp * tmp * x;
}

map<long, long> factorization(long N) {
    map<long, long> res;
    long SQRT_N = ceil(sqrt(N));
    for (long i = 2; i < SQRT_N; i++) {
        while (N % i == 0) {
            if (res.find(i) == res.end()) {
                res[i] = 1;
            } else {
                res[i] += 1;
            }
            N /= i;
        }
    }
    if (N > SQRT_N) res[N] = 1;
    return res;
}

int main() {
    for (int i = 0; i < 5; i++) {
        int x;
        cin >> x;
        if (x == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
/*
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>
#include<stack>
#include<cassert>
#include<functional>
*/
#define int long long int
#define double long double
using namespace std;
#define INT_DMAX 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i,n) for(int (i)=0, i##_len = (n);(i)<i##_len;(i)++)
#define reps(i,x) for(int (i)=1;(i)<=(int)(x);(i)++)
#define rrep(i,x) for(int (i)=((int)(x)-1);(i)>=0;(i)--)
#define rreps(i,x) for(int (i)=((int)(x));(i)>0;(i)--)
#define FOR(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1)<<(n))
#define all(x) (x).begin(),(x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl 

using namespace std;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
typedef pair<int,int> p;
typedef pair<double,double> dop;
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;


signed main()
{
int n;
std::cin >> n;
if(n == 25){
    std::cout << "Christmas" << std::endl;
} else if(n == 24){
    std::cout << "Christmas Eve" << std::endl;

} else if(n == 23){

    std::cout << "Christmas Eve Eve" << std::endl;
} else {

    std::cout << "Christmas Eve Eve Eve" << std::endl;
}
return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<string> s(n);
	map<string,ll> mp;
	rep(i,n) {
		cin >> s[i];
		sort(s[i].begin(),s[i].end());
		mp[s[i]]++;
	}
	ll ans = 0;
	for(auto m: mp){
		ans += (m.second)*(m.second-1)/2;
	}
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> void Max(T &m, const T q) { if (m < q) m = q; }
template<typename T> void Min(T &m, const T q) { if (m > q) m = q; }
template<typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int N;
vector<int> h;

int main()
{
    cin >> N;
    h.resize(N + 1);
    REP(i, N) cin >> h[i + 1];

    lint ans = 0;
    REP(i, N) if (h[i + 1] > h[i]) ans += h[i + 1] - h[i];
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
const int dx4[4] = {1,0,-1,0};
const int dy4[4] = {0,1,0,-1};
const int dx8[8] = {-1,0,1,1,1,0,-1,-1};
const int dy8[8] = {1,1,1,0,-1,-1,-1,0};
typedef long long ll;
const int mod = 1e9+7;

int main(){
  ll h, w;
  cin >> h >> w;
  if(h == 1 || w == 1) cout << 1 << endl;
  else{
    ll ans = (h*w+1) / 2;
    cout << ans << endl;
  }  
}

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

M=3
長さ2
1,2, 1,2 2
1,3 1,3 2
2,3 2,3 2

1,2 1,3 

A={1,2,2}とかはないのか。絶対M以下の違う数が入る
勘違いしてた。
順列だけでいけそうか

M=10 N=5
A=1,2,3,x,x
B=1,2,3,y,y
{1,2,3}=10P3
x,x=10-3 P 5-3
y,yも同じ
i=0~N
mPi * (m-i)P(n-i) * (m-i)P(n-i)

ほうじょ原理
0、全部違う場合は正規
ああ、かぶってんのか
0個同じ、のときにも、実際にはかぶってるものも含んでしまっている。
1個同じ、はNGパターンで、それをひく。
2個同じ、は引きすぎてるから和をとって戻す。
納得できないけどイメージはわかる・・・。
mPiの選び方でmCiか
累積とって逆元か
*/
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;
  }
}

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

ll modpow(ll a, ll n){
  if(n==1) return a%MOD;
  if(n%2==1) return (a*modpow(a,n-1))%MOD;
  else{
    ll t=modpow(a,n/2)%MOD;
    return (t*t)%MOD;
  }
}

int main(){
  COMinit();
  ll N,M,MOD=1e9+7; cin>>N>>M;
  vector<ll> P(M+10,1),Pinv(M+10,1);
  //mPi作る
  for(ll i=1; i<=M; i++) P[i]=(P[i-1]*(M+1-i))%MOD;
  //inv作る
  for(ll i=1; i<=M; i++) Pinv[i]=modpow(P[i],MOD-2);
  ll ans=0,sign=-1;
  rep(i, N+1){
//nCi* mPi * (m-i)P(n-i) * (m-i)P(n-i) *(-1)^i
    ll tmp=COM(N, i);
    (tmp*=P[i])%=MOD;
    (tmp*=(P[N]*Pinv[i])%MOD)%=MOD;
    (tmp*=(P[N]*Pinv[i])%MOD)%=MOD;
    sign*=-1;
    tmp*=sign;
    (ans+=tmp)%=MOD;
//cout<<ans<<endl;    
  }
  (ans+=MOD)%=MOD;
  cout<<ans<<endl;
}


Measured memory_bytes: 22904
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int n, k;
  cin >> n >> k;
  mint sum(0);
  if (k==1) {
    sum += n+1;
  }
  mint upper(2*n-1);
  mint lower(1);
  for (int i=2; i<=n+1; i++) {
    if (i>=k) {
      sum += upper - lower + 1;
    }
    upper += n - i;
    lower += i;
  }
     
  cout << sum << endl;
  
  
  return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>
int N,ll,mm,t1,t2,p[2][4],i;
char *t[3]={"lunch","dinner","midnight"};

int f(int t)
{
	if(660<=t1&&t1<900)
		return 0;
	if(1080<=t1&&t1<1260)
		return 1;
	if(1260<=t1&&t1<1560)
		return 2;
	return 3;
}

int main()
{
	for(;scanf("%d",&N),N;)
	{
		memset(p,0,sizeof(p));
		for(;N--;)
		{
			scanf("%d:%d%d",&ll,&mm,&t2);
			if(ll<11)ll+=24;
			t1=ll*60+mm;
			t2=(mm<=t2?ll:ll+1)*60+t2;
			//printf("%d\n",f(t1));
			if(t2-t1<=8)
				p[1][f(t1)]++;
			p[0][f(t1)]++;
		}
		for(i=0;i<3;i++)
		{
			printf("%s ",t[i]);
			if(p[0][i])printf("%d\n",p[1][i]*100/p[0][i]);
			else puts("no guest");
		}
	}
	return 0;
}

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

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

typedef long long ll;
typedef pair<int, int> point;

const int MAXN = 1e6 + 5, mod = 1e9 + 7;

int bio[MAXN];
int add(int x, int y) {
   x += y;
   if(x >= mod) return x - mod;
   return x;
}
int sub(int x, int y) {
   x -= y;
   if(x < 0) return x + mod;
   return x;
}
int mul(int x, int y) {
  return (ll) x * y % mod;
}

int fact[MAXN], inv[MAXN];

int pot(int x, int exp) {
  if(exp == 1) return x;
  int ret = pot(x, exp / 2);
  if(exp % 2) return mul(mul(ret, ret), x);
  return mul(ret, ret);
}

int povrh(int n, int k) {
  if(k > n) return 0;
  return mul(fact[n], mul(inv[n - k], inv[k]));
}

int a, b;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n; cin >> n;

  fact[0] = 1;
  FOR(i, 1, MAXN)
    fact[i] = mul(fact[i - 1], i);
  FOR(i, 0, MAXN) {
    inv[i] = pot(fact[i], mod - 2);
  }

  REP(i, n + 1) {
    int x; cin >> x;
    if(bio[x]) {
      a = bio[x];
      b = i + 1;
    }
    bio[x] = i + 1;
  }

  REP(i, n + 1) {
    int k = i + 1;
    cout << sub(povrh(n + 1, k), povrh(n - b + a, k - 1)) << "\n";
  }
}


Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
int n,a,k,ma,b;
int main(){
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a;
		if(a>=ma){
			b=ma;
			ma=a;
			k=i;
		}
		else if(a>b)b=a;
	}
	for(int i=1;i<=n;++i){
		if(i!=k)cout<<ma<<endl;
		else cout<<b<<endl;
	}
}

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

int main() {
  int A,B;
  int ans = 0;

  cin >> A >> B;

  //カーテンで隠れない部分を計算
  ans = A - (B * 2);
  if (ans < 0) {
    ans = 0;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b;
	scanf("%d",&a);
	scanf("%d",&b);
	if(a<b){
		printf("a < b\n");
	}else if(a>b){
		printf("a > b\n");
	}else{
		printf("a == b\n");
	}
return 0;
}

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

int main(){
    int n, m, x;
    int MOD = 1000000007;
    cin >> n >> m;
    bool a[n + 1];
    for (int i = 0; i < n + 1; i++) a[i] = true;
    if (m > 0){
        for (int i = 0; i < m; i++){
            cin >> x;
            a[x] = false;
        }
    }
    int dp[n + 1];
    dp[0] = 1;
    if (a[1]) dp[1] = 1; else dp[1] = 0;
    for (int i = 2; i < n + 1; i++){
        dp[i] = 0;
        if (a[i]) dp[i] += dp[i - 1] % MOD + dp[i - 2] % MOD;
        dp[i] %= MOD;
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 768
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 update : [s,t) に xを加算
 query  : [s,t) の　最大(小)値を出力する
 */

/* [0..N-1] */
const ll INIT = 0; // 問題に合わせる
struct SegTree {
    int N;
    ll init_v;
    vector<ll> node, lazy;
    
    SegTree(int _N):init_v(INIT) {
        N = 1;
        while (N < _N) N *= 2;
        node.resize(2 * N - 1, init_v);
        lazy.resize(2 * N - 1, init_v);
    }
    
    ll merge(ll l,ll r){
        return min(l,r);
    }
    
    void lazy_evaluate(int l, int r,int k){
        node[k] += lazy[k];
        if(r - l > 1){
            lazy[2 * k + 1] += lazy[k];
            lazy[2 * k + 2] += lazy[k];
        }
        lazy[k] = 0;
    }
    
    /* [a,b) 引数の範囲に注意!! s~tまでを更新→update(s,t+1,~) */
    void update(int a, int b, ll x) { update(a, b, 0, 0, N, x); }
    void update(int a, int b, int k, int l, int r, ll x) {
        lazy_evaluate(l,r,k);
        if (r <= a || b <= l) return;
        if (a <= l && r <= b) {
            lazy[k] += x;
            lazy_evaluate(l,r,k);
        }
        else {
            update(a, b, 2 * k + 1, l, (l + r) / 2, x);
            update(a, b, 2 * k + 2, (l + r) / 2, r, x);
            node[k] = merge(node[2 * k + 1],node[2 * k + 2]);
        }
    }
    
    /* [a,b) 引数の範囲に注意!! */
    ll query(int a, int b) { return query(a, b, 0, 0, N); }
    ll query(int a, int b, int k, int l, int r) {
        lazy_evaluate(l, r, k);
        if (r <= a || b <= l) return LLONG_MAX; // min : LLONG_MAX , max : LLONG_MIN
        if (a <= l && r <= b) {
            return node[k];
        }
        else {
            ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
            ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
            return merge(vl, vr);
        }
    }
};

int main(){
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n; cin >> n;
    SegTree ST(n);
    int q; cin >> q;
    while(q--){
        int com; cin >> com;
        if(com == 0){
            int s,t,x; cin >> s >> t >> x;
            ST.update(s,t+1,x);
        }else{
            int s,t; cin >> s >> t;
            cout << ST.query(s,t+1) << endl;
        }
    }
}



Measured memory_bytes: 7068
<?php

$b = trim(fgets(STDIN));
$output = '';
if ($b == 'A') {
  $output = 'T';
} elseif ($b == 'T') {
  $output = 'A';
} elseif ($b == 'C') {
  $output = 'G';
} elseif ($b == 'G') {
  $output = 'C';
}
print $output.PHP_EOL;


Measured memory_bytes: 3576
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    import itertools
    
    N,M,X=MI()
    C=[0]*N
    A=[]
    for i in range(N):
        ca=LI()
        C[i]=ca[0]
        A.append(ca[1:])
        
    ans=10**10
    for ite in itertools.product([0,1], repeat=N):
        score=[0]*M
        temp=0
        for i in range(N):
            if ite[i]:
                temp+=C[i]
                for j in range(M):
                    score[j]+=A[i][j]
        if min(score)>=X:
            ans=min(ans,temp)
            
    if ans==10**10:
        ans=-1
    print(ans)
                
            
       

main()


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

int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;++i){
        int k,p;
        scanf("%d %d",&k,&p);
        int ans = k%p;
        if(ans == 0)ans = p;
        printf("%d\n",ans);
    }

    return 0;
}


Measured memory_bytes: 1188
#include<iostream>

using namespace std;

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

    int val = num[ num.size() - 1] - '0';

    if(val == 2 || val == 4 || val == 5 || val == 7 ||val == 9){
        cout<<"hon"<<endl;
    }

    if(val == 0 || val == 1 || val == 6 || val == 8){
        cout<<"pon"<<endl;
    }

    if(val == 3){
        cout<<"bon"<<endl;
    }


    return 0;
}


Measured memory_bytes: 3604
from collections import defaultdict as dd
n = input()
d = dd(int)
n = [int(i) for i in input().split()]
for i in n:
  d[i] += 1

base = 0
for k, v in d.items():
  if v > 1:
    base += v * (v-1)/ 2
    
for i in n:
  tmp = d[i]
  base1 = (tmp) * (tmp-1) /2
  base2 = (tmp - 1) * (tmp-2) /2
  print(int(base - base1 + base2))

Measured memory_bytes: 26780
#include<bits/stdc++.h>
using namespace std;
#define IL inline
#define rep(i,j,k) for(int i=j;i<=k;++i)
#define repd(i,j,k) for(int i=j;i>=k;--i)
#define pb push_back
#define db double
#define mp make_pair
#define mp3(a,b,c) mp(mp(a,b),c)
#define pii pair<int,int>
#define piii pair<pii,int>
#define fr first
#define se second
#define ll long long
#define ull unsigned long long
#define pbc(x) __builtin_popcount(x)
#define clr(x) memset(x,0,sizeof x)
#define SIZE(x) (int)(x.size())
const int mod=1e9+7;
IL int pls(int x,int y){x+=y;return x>=mod?x-mod:x;}
IL int dec(int x,int y){x-=y;return x<0?x+mod:x;}
IL int mul(int x,int y){return 1ll*x*y%mod;}
IL int mul(int x,int y,int z){return mul(mul(x,y),z);}
IL int mul(int x,int y,int z,int p){return mul(mul(x,y),mul(z,p));}
IL void add(int &x,int y){x+=y;x=(x>=mod)?x-mod:x;}
IL int fpw(int x,int y,int r=1){for(;y;y>>=1,x=mul(x,x))if(y&1)r=mul(r,x);return r;}
IL int inv(int x){return fpw(x,mod-2);}
IL int gi(){int x;int _w=scanf("%d",&x);return x;}
IL void gi(int &x){int _w=scanf("%d",&x);}
IL void write(int x){printf("%d\n",x);}
void chkmax(int &x,int y){x=(x>y)?x:y;}
void chkmin(int &x,int y){x=(x<y)?x:y;}
const int INF=0x3f3f3f3f;
template<typename T>IL void debug(T x){cerr<<x;return;}
/* --------------------------------------------------------------------------------------------------------- */
const int maxn=4000+10;
const int LIMIT=4e6;
int f[maxn][maxn],n,k,fac[LIMIT+10],ifac[LIMIT+10];
IL int C(int n,int m){return mul(fac[n],ifac[m],ifac[n-m]);}
int main(){
	n=gi(),k=gi();
	if(k==1)cout<<1<<endl;
	else{
		fac[0]=ifac[0]=1;
		rep(i,1,LIMIT)fac[i]=mul(fac[i-1],i);
		ifac[LIMIT]=inv(fac[LIMIT]);
		repd(i,LIMIT-1,1)ifac[i]=mul(ifac[i+1],i+1);

		f[0][0]=1;
		rep(i,0,n)rep(j,i,n){
			if(i)f[i][j]=pls(f[i][j],f[i-1][j]);
			if(j)f[i][j]=pls(f[i][j],mul(f[i][j-1],C(i+(j-1)*(k-1)+k-2,k-2)));
		}
		cout<<mul(f[n][n],fac[n])<<endl;
	}
	return 0;
}

Measured memory_bytes: 63744
#include <cstdio>

int main() {
	int a, b;
	scanf("%d%d", &a, &b);

	if (a >= b) {
		int i;
		for (i = 0; i < a; i++)
			printf("%d", b);
	} else {
		int i;
		for (i = 0; i < b; i++)
			printf("%d", a);
	}
			printf("\n");
	return 0;
}

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

int main(){
    int N, num;

    cin >> N;
    if(N < 10){
        num = N;
    }else if(N < 100){
        num = 9;
    }else if(N < 1000){
        num = N - 90;
    }else if(N < 10000){
        num = 909;
    }else if(N < 100000){
        num = N - 9090;
    }else{
        num = 90909;
    }
    cout << num << endl;
}


Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto S = "0" ~ readln.chomp;
    auto N = S.length.to!int;

    auto dp = new int[][](N+1, 2);
    foreach (i; 0..N+1) dp[i][] = 1 << 29;
    dp[0][0] = 0;

    foreach (i; 0..N) {
        int d = S[N - i - 1] - '0';
        dp[i+1][0] = min(dp[i][0] + d, d == 9 ? 1 << 29 : dp[i][1] + d + 1);
        dp[i+1][1] = min(d == 0 ? 1 << 29 : dp[i][0] + 10 - d, dp[i][1] + 9 - d);
    }

    dp[N][0].writeln;
}


Measured memory_bytes: 38952
use std::collections::VecDeque;
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let n: usize = read();
    let q: u16 = read();
    let mut time: u32 = 0;
    let mut v = VecDeque::new();
    for _ in 0..n {
        let s: String = read();
        let time: u16 = read();
        v.push_back((s, time))
    }

    while !v.is_empty() {
        let mut process: (String, u16) = v.pop_front().unwrap();
        if process.1 > q {
            time += q as u32;
            process.1 -= q;
            v.push_back(process)
        } else {
            time += process.1 as u32;
            println!("{} {}", process.0, time);
        }
    }
}



Measured memory_bytes: 7060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
using namespace std;

int main(void)
{
	int t;
	string nn;
	for (;;)
	{
		cin >> t >> nn;
		if (!t)break;
		int cal = -1;
		string output = "error";
		for (int f = 0; f < (1 << (nn.size() - 1)); ++f)
		{
			string n = nn;
			int sum = 0;
			vector<string>cash;
			int las = 0, put = 0;
			for (int i = 1; i < nn.size(); ++i)
			{
				++put;
				if (f & (1 << (i - 1)))
				{
					string m = n.substr(0, put);
					for (int k = 0; k < put; ++k)n.erase(n.begin());
					put = 0;
					las = i;
					sum += stoi(m);
					cash.push_back(m);
				}
			}
			if (!n.empty())
			{
				sum += stoi(n);
				cash.push_back(n);
			}
			if (sum <= t)
			{
				if (cal < sum)
				{
					cal = sum;
					output.clear();
					stringstream ss;
					ss << cal;
					ss >> output;
					for (string elm : cash)
					{
						output.append(" "+elm);
					}
				}
				else if (cal == sum)
				{
					output = "rejected";
				}
			}
		}
		cout << output << endl;
	}
	return 0;
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vetcor<ll>
#define vii vector<pii>
#define vll vector<pll>
#define IOS ios_base::sync_with_stdio(false)
using namespace std;
double long pi = 3.14159265;
int main()
{
	double r;
	cin>>r;
	cout<<fixed<<setprecision(10);
	cout<<2 * r * pi<<endl;
}

Measured memory_bytes: 3784
fn main() {
    let n: usize = read();
    let t: f64 = read();
    let a: f64 = read();
    let h: Vec<f64> = (0..n).map(|_| read()).collect();

    let mut pos = 1;
    let mut min = (a - (t - h[0] * 0.006)).abs();
    for i in 1..n {
        let tmp = (a - (t- h[i] * 0.006)).abs();
        if min > tmp {
            min = tmp;
            pos = i + 1;
        }
    }
    println!("{}", pos);
}

fn read<T: std::str::FromStr>() -> T {
    use std::io::prelude::*;

    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))

int main() {
    ll k;
    cin >> k;
    string s;
    cin >> s;
    ll d = s.size();
    for (ll i= 0; i < min(k, d); i++) {
        cout << s[i];
    }
    if(k < d) {
        cout << "..." << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define fore(x,a,b) for(int x=a, qwerty=b; x<qwerty; x++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define fst first
#define snd second
using namespace std;
typedef long long ll;

ll ans = 0, n, m;
pair<int,int> pos[4];
set<pair<int,int> > s;
int main(){
    cin >> n >> m;
    pos[0]={0,0};
    pos[1]={0,m-1};
    pos[2]={n-1,0};
    pos[3]={n-1,m-1};
    if(n>=2 && m>=2)
        ans += (n-2LL)*(m-2LL);
    if(n>=2){
        ans += (m>=2?2LL:1LL)*(n-2LL)*((3LL*min(m,2LL))%2);
    }
    if(m>=2){
        ans += (n>=2?2LL:1LL)*(m-2LL)*((3LL*min(n,2LL))%2);
    }
    fore(i,0,4){
            int x=pos[i].fst, y=pos[i].snd;
            if(x<0||x>=n||y<0||y>=m||s.count({x,y}))continue;
            s.insert({x,y});
            int cnt=0;
            for(int xx=-1; xx<=1; xx++)
                for(int yy=-1; yy<=1; yy++)
                    if(x+xx>=0&&x+xx<n && y+yy>=0&&y+yy<m)cnt++;
            ans+=cnt%2;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
get_input(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).


f(S,T) :- 
    string_length(S, L),
    substring(T, 1, L, T2),
    S = T2.


main:-
    get_string(S),
    get_string(T),
    f(S,T) -> writeln('Yes') ; writeln('No').


Measured memory_bytes: 8136
#include <iostream>
#include <sstream>

using namespace std;

int main(void) {
    int num;
    cin >> num;
    
    int data[4][3][10] = {};
    for (int i = 0; i < num; i++) {
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        data[b - 1][f - 1][r - 1] += v;
    }
    
    for (int b = 1; b <= 4; b++) {
        if (b != 1) cout << "####################" << endl;
        
        for (int f = 1; f <= 3; f++) {
            ostringstream oss;
            for (int r = 1; r <= 10; r++) {
                oss << " " << data[b - 1][f - 1][r - 1];
            }
            
            cout << oss.str() << endl;
        }
    }

}

Measured memory_bytes: 3140
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

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

  ll n;
  cin >> n;
  if (n % 2) {
    cout << 0 << endl;
    return 0;
  }
  ll ret = n / 10;
  n /= 10;
  while (n) {
    ret += n / 5;
    n /= 5;
  }
  cout << ret << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i , n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
#include <bits/stdc++.h>
int main() {
    string a , b , c;
    cin >> a >> b >> c;
    if(a[a.size() - 1] == b[0] && c[0] == b[b.size() - 1]){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


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

class Dice{
    vector<int> x;

    void advance_vertical(){ 
        advance(0, 1, 5, 4); // N方向
    }
    
    void advance_horizontal(){ 
        advance(0, 3, 5, 2); // E方向
    }

    void advance(int i, int j, int k, int l){
        int tmp = x[i]; 
        x[i] = x[j];
        x[j] = x[k];
        x[k] = x[l];
        x[l] = tmp;
    }

public:
    Dice(vector<int>& x) : x(x) {}
    
    void roll(const string& command){
        for(const auto c : command){
            if(c == 'E'){
                advance_horizontal();
            }
            else if(c == 'N'){
                advance_vertical();
            }
            else if(c == 'S'){
                for(int i = 0; i < 3; ++i){
                    advance_vertical();
                }
            }
            else{
                for(int i = 0; i < 3; ++i){
                    advance_horizontal();
                }
            }
        }      
    }

    int getNow(){
        return x[0];
    }
};

int main(){

    vector<int> x(6);
    for(int i = 0; i < 6; ++i){
        cin >> x[i];
    }

    Dice dice(x);
    string command;
    cin >> command;

    dice.roll(command);

    cout << dice.getNow() << endl;

    return 0;
}


Measured memory_bytes: 3224
#include <iostream>
#include <string>
#include<iomanip>
#include <algorithm>
#include <map>
#include <vector>
#include<queue>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include <map>
#include<string.h>
#include<sstream>
#include<stack>
#include <iostream>
#define ll long long
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 2e5 + 5, inf = 1e9 + 7;
const double ep = 0.0000000001;
const double pi = 3.14159265359;
ll fact[N], inv[N];
ll fp(ll base, ll exp)
{
	if (exp == 0)
		return 1;
	ll ans = fp(base, exp / 2);
	ans = (ans * ans) % inf;
	if (exp % 2 != 0)
		ans = (ans * (base% inf)) % inf;
	return ans;
}
void calc()
{
	fact[0] = inv[0] = 1;
	for (int i = 1; i < N; i++)
	{
		fact[i] = (fact[i - 1] * i) % inf;
		inv[i] = fp(fact[i], inf - 2) ;
	}
}
ll ncr(ll n, ll r)
{
	return (((fact[n] * inv[n - r]) % inf)*inv[r]) % inf;
}

ll n, arr[1000005], sum1 = 0, k, sum2 = 0, ans;
int main() {
	calc();
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		cin >> arr[i];
	}
	sort(arr, arr + n);
	ll mx, mn;
	for (int i = 0; i < n; i++) {
		if (i < k - 1)
			mx = 0;
		else
		mx = ncr(i, k - 1);
		if (n - i - 1 < k - 1)
			mn = 0;
		else
			mn = ncr(n - i - 1, k - 1);
		ans += ((arr[i] % inf)*(mx - mn) % inf) % inf;
		ans %= inf;
	}
	cout << ans;
	return 0;

}


Measured memory_bytes: 5888
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int taihi;
		for(int i=1;i<=3000;i++) {
			if(x<=0 && y<=10000) {
			}
				if(x>y) {
					taihi=y;
					y=x;
					x=taihi;
			}
				System.out.println(x+" "+y);
			x = sc.nextInt();
			y = sc.nextInt();
			if(x == 0 && y == 0) {
				break;
			}
		}
	}
}

Measured memory_bytes: 36560
a,b,c = map(int,input().split("/"))
if a < 2019:
  print("Heisei")
  exit()
if a == 2019 and b < 4:
  print("Heisei")
  exit()
if a == 2019 and b == 4 and c <= 30:
  print("Heisei")
  exit()
print("TBD")

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

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

using namespace std;

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

	int n=s.length(),ans=0;
	rep(i,n-1) if(s[i]!=s[i+1]) ans++;
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n, m;
    cin >> n >> m;

    const int inf = 1001001001;
    auto d = make_vec<int>(n, n);
    fill_v<int>(d, inf);
    rep(i, n) d[i][i] = 0;
    vector<int> a(m), b(m), c(m);
    rep(i, m) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--; b[i]--;
        d[a[i]][b[i]] = c[i];
        d[b[i]][a[i]] = c[i];
    }

    rep(k, n) rep(i, n) rep(j, n) chmin(d[i][j], d[i][k] + d[k][j]);
    
    int res = m;
    rep(i, m) {
        bool flag = false;
        rep(s, n) if (d[s][a[i]] + c[i] == d[s][b[i]]) flag = true;
        if (flag) res--;
    }

    cout << res << endl;
}


Measured memory_bytes: 3660
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    S = input()
    for i in range(ord("a"), ord("z") + 1):
        if chr(i) not in S:
            print(chr(i))
            return
    print("None")
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 62548
n = int(input())
b_li = [int(i) for i in input().split()]

a_li = [[] for i in range(n)]

for i in range(1,n-1):
    a_li[i] = min(b_li[i],b_li[i-1])
a_li[0] = b_li[0]
a_li[-1] = b_li[-1]
print(sum(a_li))

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

class Main
{
    public static void main (String args[]) throws IOException         //?????????
    {
        InputStreamReader is = new InputStreamReader(System.in);       //?????????
        BufferedReader br = new BufferedReader(is);                    //?????????
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int tmp_min = a;
        int tmp_mid = b;

        if(a > b){
            tmp_min = b;
            tmp_mid = a;
        }
        if(tmp_min > c){
            System.out.println(c + " " + tmp_min + " " + tmp_mid);
        }
        else if(tmp_mid < c){
            System.out.println(tmp_min + " " + tmp_mid + " " + c);
        }
        else{
            System.out.println(tmp_min + " " + c + " " + tmp_mid);
        }
    }
}
    

Measured memory_bytes: 26292
#include<bits/stdc++.h>
#define ll long long
#define fin(x) scanf("%lld",&x)
#define fout(x) printf("%lld\n",x)
#define pll pair<ll,ll>
#define mp(x,y) make_pair(x,y)
#define cases int t;  scanf("%d",&t);   while(t--)
#define MOD 1000000007
#define MAXN 1234567
#define read() freopen("lele.txt","r",stdin)
#define write() freopen("dede.txt","w",stdout)

using namespace std;

int main()
{   
    ll a, b, k;
    fin(a); fin(b); fin(k);
    ll mn = min(a, k);
    a -= mn;
    k -= mn;
    mn = min(b, k);
    b -= mn;
    k -= mn;
    cout << a << " " << b << endl;
    return 0;
}

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

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define FI first
#define SE second
using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
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(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}


int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> h(n);
  cin >> h;
  int maxi = -1;
  int res = 0;
  for(int i = 0; i < n; i++){
    if(maxi <= h[i]){
      res++;
      maxi = h[i];
    }
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			int[] sSort = new int[n];
			for(int i = 0;i < n;i++){
				sSort[i] = scan.nextInt();
			}
			int count = 0;
			for(int i = 0;i < n;i++){
				int min = i;
				for(int j = i+1;j < n;j++){
					if(sSort[min] > sSort[j]){
						min = j;
					}
				}
				if(min != i){
					swap(sSort,i,min);
					count++;
				}
			}
			PrintOut(sSort,n);
			System.out.println(count);
		}
	}
	
	public static void swap(int[] a,int i,int j){
		int t = a[j];a[j] = a[i];a[i] = t;
	}
	
	public static void PrintOut(int[] a,int n){
		for(int i = 0;i < n;i++){
			System.out.print(a[i] + ((i == n-1)?"\n":" "));
		}
	}
}

Measured memory_bytes: 19100
from collections import *
import copy
N,v,u=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(N-1)]
data=[[] for i in range(N+1)]
for A,B in AB:
    data[A].append(B)
    data[B].append(A)

stack=deque([[v,0]])
visited=set([v])
while stack:
    a,m=stack.popleft()
    for p in data[a]:
        if p==u:
            K=m+1
        if not p in visited:
            visited.add(p)
            stack.append([p,m+1])


for i in range(len(data)):
    if len(data[i])>1:
        visited=set([i])
        stack=deque([i])
        End=set()
        break

if N==2:
    print(0)
    exit()
while stack:
    a=stack.popleft()
    flag=0
    for p in data[a]:
        if not p in visited:
            visited.add(p)
            stack.append(p)
            flag=1
    if flag==0:
        End.add(a)

Uvisited=set([u])
Vvisited=set([])
if not v in End:
    Vvisited.add(v)
Ustack=deque([[u,0]])
Vstack=deque([[v,0]])
ans=[]
M=1

while Ustack:
    while Vstack:
        a,m=Vstack.popleft()
        if m==M:
            Vstack.append([a,m])
            break
        for p in data[a]:
            if not p in End:
                if p in Uvisited:
                    pass
                    #ans.append(m)
                elif not p in Vvisited:
                    Vvisited.add(p)
                    Vstack.append([p,m+1])
    while Ustack:
        a,m=Ustack.popleft()
        if m==M:

            Ustack.append([a,m])
            break
        for p in data[a]:

            if not p in Uvisited:
                if p in Vvisited:
                    ans.append(m+1)
                Uvisited.add(p)
                Ustack.append([p,m+1])
    M+=1
print(max(ans))


Measured memory_bytes: 120280
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 整数の入力
		int n = sc.nextInt();
		String s = sc.next();
		String[] S = s.split("");
		int k = sc.nextInt();

		// 文字列の抽出
		String str = S[k-1];

		for(int num=0;num<n;num++){
			if(!(S[num].equals(str)))S[num]="*";
		}

		// 出力
		for(String sss:S)System.out.print(sss);
	}
}

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

#define int long long

auto main() -> signed {
    int a, b, c;
    cin >> a >> b >> c;
    for(int i=1; i<1000000; ++i) {
        if(a*i%b==c) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define intt long long int
#define pb push_back
#define ff first
#define ss second
int mod =1000000007;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	int n;cin>>n;
	int temp=n%10;
	if(temp==2 || temp==4|| temp==7|| temp==9|| temp==5)
		cout << "hon" <<"\n";
	else if(temp==0 || temp==1|| temp==6|| temp==8)
		cout << "pon" <<"\n";
	else
		cout << "bon" <<"\n";
}

Measured memory_bytes: 3588
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
bool graph[8][8];
int dfs(int v, int N, bool visited[8]) {
	bool all_visited = true;
	int i, j, k, res;
	res = 0;
	for (i = 0; i < N; i++) {
		if (visited[i] == false) {
			all_visited = false;
		}
	}
	if (all_visited) {
		return 1;
	}
	for (i = 0; i < N; i++) {
		if (graph[v][i]==false) continue;
		if (visited[i]) continue;
		visited[i] = true;
		res += dfs(i, N, visited);
		visited[i] = false;
	}
	return res;
}
int main()
{
	int i,N,M,j,k,v,a,b;
	bool visited[8];
	cin >> N >> M;
	for (i = 0; i < N; i++) {
		visited[i] = false;
	}
	
	for (i = 0; i < M; i++) {
		cin >> a >> b;
		graph[a - 1][b - 1] = graph[b - 1][a - 1] = true;
	}
	visited[0] = true;
	cout << dfs(0, N, visited) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    ll n;cin>>n;
    string s[n];rep(i,0,n-1)cin>>s[i];
    sort(s,s+n);
    ll ans=1;
    if(n==1){
        cout<<1<<endl;
        return 0;
    }
    rep(i,1,n-1){
        if(s[i]!=s[i-1]){
            ans++;
        }
    }
    cout<<ans<<endl;
    
    
    return 0;
    
    
    
}


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

int main()
{
	string N;
	cin >> N;
	if((N[0] == '7')||(N[1] == '7')||(N[2] == '7'))
	cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;

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

typedef long long ll;

void Main()
{
	int n, d; cin >> n >> d;
	int res = n / (2 * d + 1) + (n % (2 * d + 1) == 0 ? 0 : 1);
	cout << res << endl;
}

int main()
{
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	Main();
}


Measured memory_bytes: 256