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

using namespace std;
typedef long long ll;
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7

template<typename T>
string printVector(const vector <T> &data) {
    stringstream ss;
    ostream_iterator <T> out_it(ss, " ");
    std::copy(data.begin(), data.end(), out_it);
    return ss.str();
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int even = 0, odd = 0;
    vector<int> ans(SIZE(s), 1);
    for (int i = 0; i < SIZE(s) - 1; ++i) {
        if (s[i] == 'R' && s[i + 1] == 'L') {
            if ((i + 1) % 2 == 0) {
                ans[i + 1] += even;
                ans[i] += odd;
            } else {
                ans[i + 1] += odd;
                ans[i] += even;
            }
            odd = 0;
            even = 0;
        } else if (s[i] == 'R') {
            if (i % 2 == 0) {
                even++;
                ans[i]--;
            } else {
                odd++;
                ans[i]--;
            }
        }
    }
    reverse(ALL(s));
    reverse(ALL(ans));
    for (int i = 0; i < SIZE(s) - 1; ++i) {
        if (s[i] == 'L' && s[i + 1] == 'R') {
            if ((i + 1) % 2 == 0) {
                ans[i + 1] += even;
                ans[i] += odd;
            } else {
                ans[i + 1] += odd;
                ans[i] += even;
            }
            odd = 0;
            even = 0;
        } else if (s[i] == 'L') {
            if (i % 2 == 0) {
                even++;
                ans[i]--;
            } else {
                odd++;
                ans[i]--;
            }
        }
    }
    reverse(ALL(ans));
    cout << printVector(ans) << endl;
}


Measured memory_bytes: 1296
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int V=sc.nextInt();//頂点数
			int E=sc.nextInt();//辺の数
			int s;//頂点
			int t;//頂点
			double[][] dist=new double[V+1][V+1];//辺の長さ(st距離)
			double[][] dp=new double[1<<V][V];
			double INF=1e100;
			
			for(int i=0; i<V; i++) {
				for(int j=0; j<V; j++) {
					dist[i][j]=INF;
				}
			}
			
			for(int i=0; i<E; i++) {
				s=sc.nextInt();
				t=sc.nextInt();
				dist[s][t]=sc.nextInt();
			}
			for(int i=0; i<(1<<V); i++) {
				for(int j=0; j<V; j++) {
					dp[i][j]=INF;
				}
			}
			dp[1][0]=0;//頂点0からスタートだから
			
			for(int i=0; i<(1<<V); i++) {
				for(int j=0; j<V; j++) {//現在いる頂点j
					if(dp[i][j]==INF) continue;
					for(int k=0; k<V; k++) {//次の行き先頂点k
						if((1&i>>k)==1) continue;//すでに訪れてるとき
						else if(dist[j][k]==INF) continue;//辺がないとき
						int nexti = i| (1<<k);//bitごとのOR演算(今まで通ってきた頂点に次の頂点を足せる) 
						//System.out.printf("nexti=%d\n", nexti);
						double nextd=dp[i][j]+dist[j][k];
						dp[nexti][k]=Math.min(dp[nexti][k], nextd);
					}
				}
			}
//			for(int i=0; i<(1<<V); i++) {
//				for(int j=0; j<V; j++) {
//					System.out.printf("dp[%d][%d]=%f\n", i, j, dp[i][j]);
//				}
//			}
			int all=(1<<V)-1;//最後の全部bitたっている状態
			double ret=INF;
			for(int i=0; i<V; i++) {//最後頂点0に戻る分の距離を足す
				if(dp[all][i]==INF) {
					continue;
				}
				else if(dist[i][0]==INF) continue;//頂点0にもどれないとき
				double temp = dp[all][i]+dist[i][0];
				ret=Math.min(ret, temp);
			}
			if(ret==INF) {
				ret=-1;
			}//bitが全部たたない
			System.out.println((int)ret);
			

		}
	}
}


Measured memory_bytes: 34440
import copy
N=int(input())
Tn=[int(x) for x in input().split()]
M=int(input())
for _ in range(M):
  P,X=[int(x) for x in input().split()]
  tTn=copy.deepcopy(Tn)
  tTn[P-1]=X
  print(sum(tTn))

Measured memory_bytes: 3444
S=input()
T=input()
n=len(S)
m=len(T)
dp=[[0]*(m+1) for i in range(n+1)]
for i in range(n):
  for j in range(m):
    dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j],dp[i][j]+(S[i]==T[j]))
ans=''
while n>0 and m>0:
  if dp[n][m]==dp[n-1][m]:
    n-=1
  elif dp[n][m]==dp[n][m-1]:
    m-=1
  else:
    n-=1
    m-=1
    ans=S[n]+ans
print(ans)

Measured memory_bytes: 144128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

void Main()
{
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  
  double hd = h * 30.0 + 30 * m / 60.0;
  double md = m * 6.0;
  
  double sa;
  
  double x;
  
  if(abs(hd - md) < 180){
    sa = abs(hd - md);
  }
  else{
    sa = 360 - abs(hd - md);
  }
  x = sqrt(a * a + b * b - 2 * a * b * cos(sa / 180.0 * M_PI));
  
  
  
  std::cout << x << std::endl;
}


int main()
{
  std::cout << std::fixed << std::setprecision(15);
  Main();
}



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

   typedef long long ll;
   typedef pair<ll, ll> Pii;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}


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

const ll MAX_N = 2e5;
ll N;
ll a[MAX_N], b[MAX_N + 1], h[MAX_N];

ll monoid(ll x, ll y) {
  return max(x, y);
}

class SegmentTree{
    private:
        ll n;
        vector<ll> dat;
    public:
        //宣言と初期化, 要素数を2べきに.
        SegmentTree(ll N){
            n = 1;
            while (n < N) n *= 2;
            dat.resize(2 * n - 1, 0);
        }
        void update(ll i, ll x){
            //Aiをxに更新する
            i += n - 1;
            dat[i] = x;
            while(i > 0){
                i = (i - 1) / 2;
                dat[i] = monoid(dat[i * 2 + 1], dat[2 * i + 2]);
            }
        }
        ll prod(ll a, ll b, ll k, ll l, ll r){
            //区間[a, b)におけるモノイド積
            if (r <= a || b <= l) return 0;
            if (a <= l && r <= b) return dat[k];
            else{
                ll pl = prod(a, b, k * 2 + 1, l, (l + r) / 2);
                ll pr = prod(a, b, k * 2 + 2, (l + r) / 2, r);
                return monoid(pl, pr);
            }
        }
        ll prod(ll a, ll b) {
            return prod(a, b, 0, 0, n);
        }
};

int main(){
  cin >> N;
  REP(i, N){
    cin >> h[i];
    b[h[i]] = i + 1;
    //ex)h[i] = 3, 1, 4, 2 -> b[i] = 0, 2, 4, 1, 3
  }
  REP(i, N){
    cin >> a[i];
    //ex)a[i] = 10, 20, 30, 40
  }
  SegmentTree t(N);
  REP(i, N){
    t.update(b[i + 1] - 1, t.prod(0, b[i + 1]) + a[b[i + 1] - 1]);
    /*
    REP(j, N){
      printf("t.prod(0, %lld) = %lld\n", j + 1, t.prod(0, j + 1));
    }
    */
  }
  cout << t.prod(0, N) << endl;
}


Measured memory_bytes: 9088
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <functional>
using ll = long long;
using namespace std;
int main() {
	ll n, m, ans = 1;
	cin >> n >> m;
	for (ll i = n; i <= 1000000000000000000;i++)
		if (i * 2 <= m) {
			ans++;
			i *= 2;
			i--;
		}
		else {
			cout << ans << endl;
			return 0;
		}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main()
{
    ll r, D, x;
    cin >> r >> D >> x;

    for (int i = 0; i < 10; ++i) {
        x = r * x - D;
        cout << x << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  std::string S; std::cin >> S;
  for (int i = 1; i <= S.length(); ++i) {
    if (i%2 == 1) {  // odd
      if (S[i-1] == 'L') {
        std::cout << "No" << std::endl;
        return 0;
      }
    } else {  // even
      if (S[i-1] == 'R') {
        std::cout << "No" << std::endl;
        return 0;
      }
    }
  }
  std::cout << "Yes" << std::endl;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}

using comp = std::complex<double>;

signed main(){
    int n, k;
    cin >> n >> k;
    
    vector<comp> center(n);
    vector<int> weight(n);
    REP(i, n){
        double a, b, c;
        cin >> a >> b >> c;
        center[i] = comp(a, b);
        weight[i] = c;
    }

    double ng = 0, ok = 1e7;
    const double eps = 1e-8;

    while(ok - ng > eps){
        double mid = (ok + ng) / 2;
        vector<comp> intersection(center);

        REP(i, n-1){
            FOR(j, i+1, n){
                const comp& c1 = center[i], c2 = center[j];
                comp c12 = c2 - c1;

                double r1 = mid / weight[i], r2 = mid / weight[j];

                double a = abs(c12);
                double d = (a*a + r1*r1 - r2*r2) / (2.0 * a);

                if(r1 + r2 < a - eps || abs(r1 - r2) > a + eps) continue;

                double h = sqrt(r1*r1 - d*d);

                comp c3 = (c12 / a) * d;

                intersection.emplace_back(c1 + c3 + (c12 / a) * comp(0, h));
                intersection.emplace_back(c1 + c3 + (c12 / a) * comp(0, -h));
            }
        }

        bool enclose = false;

        for(const auto& i : intersection) {
            int cnt = 0;
            REP(j, n){
                double r = mid / weight[j];
                cnt += abs(i - center[j]) <= r + eps;
            }
            if(cnt >= k){
                enclose = true;
            }
        }

        if(enclose) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    cout << setprecision(12) << ok << endl;
    
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
int min(int a, int b){
  if (a > b) {
    return b;
  } else {
    return a;
  }
}
int main(void){
  int a[5][20];
  int b[5][10];
  int n,m;
  int point;
  scanf("%d",&n );
  while(n){
    point = 0;
    for (int i = 0; i < 20; i++) {
      for (int j = 0; j < 5; j++) {
        a[j][i] = 0;
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < 5; j++) {
        scanf("%d",&a[j][n-1-i] );
      }
    }
    m = 11;
    while(m > 0){
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < 5; j++) {
          b[j][i] = 0;
        }
      }
      for (int i = 0; i < n; i++) {
        if (a[0][i] == a[1][i] && a[1][i] == a[2][i] && a[0][i] != 0) {
          if (a[2][i] == a[3][i]) {
            if (a[3][i] == a[4][i]) {
              point += a[0][i] * 5;
              for (int j = 0; j < 5; j++) {
                b[j][i] = 1;
              }
            }else{
              point += a[0][i] * 4;
              for (int j = 0; j < 4; j++) {
                b[j][i] = 1;
              }
          }
        }else{
          point += a[0][i] * 3;
            for (int j = 0; j < 3; j++) {
              b[j][i] = 1;
            }
          }
        }else if (a[1][i] == a[2][i] && a[2][i] == a[3][i] && a[1][i] != 0) {
          if (a[3][i] == a[4][i]) {
            point += a[1][i] * 4;
            for (int j = 1; j < 5; j++) {
              b[j][i] = 1;
            }
          }else{
            point += a[1][i] * 3;
            for (int j = 1; j < 4; j++) {
              b[j][i] = 1;
            }
          }
        }else if (a[2][i] == a[3][i] && a[3][i] == a[4][i] && a[2][i] != 0) {
          point += a[2][i] * 3;
          for (int j = 2; j < 5; j++) {
            b[j][i] = 1;
          }
        }
      }
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < 5; j++) {
          if (b[j][i] == 1) {
            a[j][i] = 0;
            b[j][i] = 0;
          }
        }
      }
      for (int e = 0; e < n; e++) {
        
        for (int i = 0; i < n; i++) {
          for (int j = 0; j < 5; j++) {
            if (a[j][i] == 0) {
              for (int l = i; l < 10; l++) {
                a[j][l] = a[j][l+1];
              }
            }
          }
        }
      }
      m--;

      
    }
    printf("%d\n",point );
    scanf("%d",&n );

  }
  return 0;
}


Measured memory_bytes: 2036
/// Find the maximum product of subsequences  of size k
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pb push_back
#define inf 1000000000000000000
using namespace std;
int main()
{
    ll i,j,k,n,s=0;
    cin>>n;
    cin>>k;
    ll K=k;
    vector<ll>neg,pos,zero;
    vector<pair<ll,ll> >vec;
    ll arr[n];
    for(i=0; i<n; i++)
    {
        cin>>arr[i];
        if(arr[i]>0)
        {
            pos.pb(arr[i]);
            s=1;
        }
        else if(arr[i]<0)
        {
            neg.pb(abs(arr[i]));
            s=-1;
        }
        else
        {
            zero.pb(arr[i]);
            s=1;
        }
        vec.pb(make_pair(abs(arr[i]),s));
    }
    ll idp=(ll)pos.size()-1;
    ll idn=(ll)neg.size()-1;
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());
    sort(vec.begin(),vec.end());
    ll ans=1;
    if(k%2)
    {
        if(pos.size()>0)
        {
            ans=(ans*pos[idp])%mod;
            idp--;
            k--;
        }
    }
    /// as k is even so k will be zero if enough positive or negative pair is present here
    while(k&& (idp>0||idn>0))
    {
        ll a=-inf;
        ll b=-inf;
        if(idp>=1)
            a=pos[idp]*pos[idp-1];
        if(idn>=1)
            b=neg[idn]*neg[idn-1];
        if(a>b)
        {
            ans=(ans%mod*(a%mod+mod)%mod)%mod;
            idp=idp-2;
            k=k-2;
        }
        else
        {
            ans=(ans%mod*(b%mod+mod)%mod)%mod;
            idn=idn-2;
            k=k-2;
        }
    }
    if(k)
    {
        if(zero.size())
            ans=0;
        else
        {
            ans=1;
            for(i=0; i<K; i++)
                ans=(ans%mod*(((vec[i].first*vec[i].second)%mod)+mod)%mod)%mod;
        }
    }
    cout<<ans;
return 0;

}


Measured memory_bytes: 10836
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }
  return 0; }
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return 1; }
  return 0; }

int main(void){
  ll n; cin >> n;
  ll k = n;
  ll sum = 0;
  ll i = 2;
  while(1){
    if(i*i > k) break;
    ll count = 0;
    while(1){
      if(n % i != 0){
        break;
      }
      else{
        n /= i;
        count++;
      }
    }
    for(ll j = 1; j <= 11; j++){
      if(count - j < 0) break;
      else{
        count = count - j;
        sum++;
      }
    }
    i++;
  }
  if(n != 1 && k != 1){
    sum++;
  }
  if(k != 1) cout << sum << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 3672
use std::io;

fn main() {
    let mut input_string = String::new();
    io::stdin().read_line(&mut input_string).expect("Error");
    let s = input_string.trim();
    let mut result = String::new();
    for i in s.chars() {
        if i == 'B' {
            result.pop();
            continue;
        }
        result.push(i);
    }
    println!("{}", result);
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>

typedef struct{
    char name;
    int num, id;
}card;

void swap(card* A, card* B){
    card tmp = *A;
    *A = *B;
    *B = tmp;

}

int partition(card* A, int p, int r){
    int x = A[r].num, i = p-1;
    for(int j=p ; j<r ; j++){
        if(A[j].num <= x){
            i++;
            swap(&A[i], &A[j]);
        }
    }
    swap(&A[i+1], &A[r]);
    return i+1;
}

void quicksort(card* A, int p, int r){
    if(p<r){
        int q = partition(A, p, r);
        quicksort(A, p, q-1);
        quicksort(A, q+1, r);
    }
}

int checkstable(card* A, int n){
    for(int i=0 ; i<n-1 ; i++)
        if(A[i].num == A[i+1].num && A[i].id > A[i+1].id)
            return 1;
    
    return 0;
}

int main(void){
    int n;
    scanf("%d", &n);
    card A[n];
    for(int i=0 ; i<n ; i++){
        scanf("%s %d", &A[i].name, &A[i].num);
        A[i].id = i;
    }

    quicksort(A, 0, n-1);
    checkstable(A, n) == 1 ? printf("Not stable\n") : printf("Stable\n");

    for(int i=0 ; i<n ; i++)
        printf("%c %d\n", A[i].name, A[i].num);

    return 0;
}




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

ll euler_phi(ll n) {
    ll ret = n;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            ret -= ret / i;
            while (n % i == 0)
                n /= i;
        }
    }
    if (n > 1)
        ret -= ret / n;
    return ret;
}

int main() {

    int N;
    cin >> N;

    cout << euler_phi(N) << endl;

    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string A,B,C;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>A>>B>>C;
	if(A.back()==B[0] && B.back()==C[0]) _P("YES\n");
	else _P("NO\n");
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  vector<double> P(N);
  for (int i = 0; i < N; i++) {
    double p;
    cin >> p;
    P[i] = (p + 1) / 2;
  }
  vector<double> Q(N + 1, 0);
  for (int i = 0; i < N; i++) {
    Q[i + 1] = Q[i] + P[i];
  }
  double res = 0;
  for (int i = 0; i + K - 1 < N; i++) {
    res = max(res, Q[i + K] - Q[i]);
  }
  cout << fixed << setprecision(10) << res << '\n';
  return 0;
}


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

int main()
{
    string s;
    string t;
    cin >> s >> t;
    int ans = 1000000;
    for(int i = 0; i < s.size(); i++)
    {
        int temp = 0;
        for(int j = 0; j < t.size(); j++)
        {
            if(i+j >= s.size())
            {
                temp = 10000;
                continue;
            }
            if(s[i+j] != t[j])
                temp++;
        }
        ans =min(ans,temp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3592
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	long double a, b;
	scanf("%Lf %Lf", &a, &b);
	printf("%Lf\n", a/b);
	return 0;
}


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

int main(void){
    int n;
    cin >> n;

    map<string,int> point;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        if(point.count(s)){
            point.at(s)++;
        }else{
            point[s] = 1;
        }
    }

    int m;
    cin >> m;
    for(int i=0;i<m;i++){
        string s;
        cin >> s;
        if(point.count(s)){
            point.at(s)--;
        }else{
            point[s] = -1;
        }
    }

    int maxvalue = 0;
    for(auto p: point){
        maxvalue = max(maxvalue,p.second);
    }

    cout << maxvalue << endl;

}

Measured memory_bytes: 256
a, b, k = gets.split.map &:to_i
if b - a < k
  (a..b).each do |i|
    puts i
  end
  exit
end
r = []
for i in 0...k
  r << a + i
  r << b - i
end
r.sort.uniq.each do |i|
  puts i
end

Measured memory_bytes: 14360
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
using namespace std;

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if((a * 100 + b * 10 + c) % 4 == 0) cout << "YES";
	else cout << "NO";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using Weight = int;
using Capacity = int;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

class lca {
public:
    int n, segn;
    std::vector<int> path, depth, in_order;
    std::vector<std::pair<int,int>> dat;
    const std::pair<int,int> INF = std::make_pair(1000000000, 1000000000);

    lca(const Graph &g, int root)
        : n(g.size()),
          path(n * 2 - 1),
          depth(n * 2 - 1),
          in_order(n) {
        int k = 0;
        dfs(g, root, -1, 0, k);
        for (segn = 1; segn < n * 2 - 1; segn <<= 1);
        dat.assign(segn * 2, INF);
        for (int i = 0; i < (int)depth.size(); ++i)
            dat[segn + i] = std::make_pair(depth[i], i);
        for (int i = segn - 1; i >= 1; --i)
            dat[i] = min(dat[i * 2], dat[i * 2 + 1]);
    }

    int get(int u, int v) {
        int l = std::min(in_order[u], in_order[v]);
        int r = std::max(in_order[u], in_order[v]) + 1;
        auto res = range_min(1, segn, l, r);
        return path[res.second];
    }

    void dfs(const Graph &g, int v, int p, int d, int &k) {
        in_order[v] = k;
        path[k] = v;
        depth[k++] = d;
        for (auto &e : g[v]) {
            if (e.dst != p) {
                dfs(g, e.dst, v, d + 1, k);
                path[k] = v;
                depth[k++] = d;
            }
        }
    }

    std::pair<int,int> range_min(int v, int w, int l, int r) const {
        if (r <= l || w == 0) return INF;
        if (r - l == w) return dat[v];
        int m = w / 2;
        auto rmin = range_min(v * 2, m, l, std::min(r, m));
        auto lmin = range_min(v * 2 + 1, m, std::max(0, l - m), r - m);
        return min(rmin, lmin);
    }
};


using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    Graph g(n);
    for(int i = 0; i < n; ++i) {
        int k;
        cin >> k;
        for(int j = 0; j < k; ++j) {
            int c;
            cin >> c;
            g[i].emplace_back(i, c, 1);
        }
    }
    lca l(g, 0);
    int q;
    cin >> q;
    for(int i = 0; i < q; ++i) {
        int u, v;
        cin >> u >> v;
        cout << l.get(u, v) << '\n';
    }
}

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

int main(void){
    int A, B, K;
    bool result{false};
    cin >> K >> A >> B;

    if(A%K == 0){
        result = true;
    }
    else if((A/K+1)*K<=B){
        result = true;
    }

    if(result){
        cout << "OK" << endl;
    }
    else{
        cout << "NG" << endl;
    }

}


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

int a, b, w;

int main(){
	scanf("%d%d%d", &w, &a, &b);
	if (a + w < b){
		return printf("%d\n", b - a - w), 0;
	}
	if (b + w < a){
		return printf("%d\n", a - b - w), 0;
	}
	return printf("0\n"), 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    //REP(i, N) cout << A[i] - i << endl;

    map<ll, ll> mp;
    ll res = 0;
    REP(i, N){
        res += mp[A[i]-i];
        mp[-A[i]-i]++;
    }   
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 27384
def resolve():
    N, K = map(int, input().split())
    A = tuple(map(int, input().split()))
    path = [1]
    for i in range(2*N):
        cur = A[path[-1]-1]
        path.append(cur)

    if K < N:
        print(path[K])
        exit()

    end = N
    si = N-1
    while path[si] != path[end]:
        si -= 1
    dist = end - si
    K = K % dist
    while K < N:
        K += dist

    print(path[K])

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 32380
main = do
  [w,h,n] <- map read . words <$> getLine :: IO [Int]
  input <- map (map read . words) . lines <$> getContents :: IO [[Int]]
  let (l, r, b, t) = solve (0, w, 0, h) input
      s = (r - l) * (t - b)
  print $ if r > l && t > b then s else 0

solve :: (Int, Int, Int, Int) -> [[Int]] -> (Int, Int, Int, Int)
solve (l, r, b, t) [] = (l, r, b, t)
solve (l, r, b, t) ([x, y, a]:s)
  | a == 1 && l < x = solve (x, r, b, t) s
  | a == 2 && x < r = solve (l, x, b, t) s
  | a == 3 && b < y = solve (l, r, y, t) s
  | a == 4 && y < t = solve (l, r, b, y) s
  | otherwise       = solve (l, r, b, t) s


Measured memory_bytes: 1020
n = int(input())

cnt = 0
while 1:
    if cnt == n:
        break

    runner = [0] * 3
    score = 0
    outcount = 0
    while outcount != 3:
        event = input()
        if event == "HIT":
            if runner[2]:
                score += 1
                runner[2] = 0
            if runner[1]:
                runner[2] = 1
                runner[1] = 0
            if runner[0]:
                runner[1] = 1
            runner[0] = 1

        elif event == "HOMERUN":
            runners = runner.count(1)
            score += runners + 1
            runner = [0] * 3

        else:
            outcount += 1

        if outcount == 3:
            break

    print(score)
    cnt += 1



Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  
  if ( a >= 13){
    cout << b << endl;
  }
  else if ( a <= 12 && a >= 6){
    cout << b/2 << endl;
  }
  else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=[i for i in A if i%2==0]
C=[i for i in B if i%3==0]
D=[i for i in B if i%5==0]
E=[i for i in B if i%15==0]
if len(B)==len(C)+len(D)-len(E):
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3064
//AGC 044 A - Pay to Win
//题目地址：https://atcoder.jp/contests/agc044/tasks/agc044_a
//题解：https://img.atcoder.jp/agc044/editorial.pdf
 
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;

LL A, B, C, D;
map<LL, LL> memo;

LL solve(LL N) {
    if (N == 0) return 0;
    if (N == 1) return D;
    
	if (memo.count(N)) return memo[N];     //记忆化搜索 
    
	LL l2 = (N/2)*2;
    LL r2 = ((N+1)/2)*2;
    LL l3 = (N/3)*3;
    LL r3 = ((N+2)/3)*3;
    LL l5 = (N/5)*5;
    LL r5 = ((N+4)/5)*5;

    LL res = 1e18;
    if (N < res/D) res = N*D;
    
    res = min(res, llabs(l2-N)*D + A + solve(l2/2));
    res = min(res, llabs(r2-N)*D + A + solve(r2/2));

    res = min(res, llabs(l3-N)*D + B + solve(l3/3));
    res = min(res, llabs(r3-N)*D + B + solve(r3/3));

    res = min(res, llabs(l5-N)*D + C + solve(l5/5));
    res = min(res, llabs(r5-N)*D + C + solve(r5/5));

    memo[N] = res;

    return res;
}

int main() {
    int T;
    cin >> T;
    for (int t = 0; t < T; t++) {
        memo.clear();
        LL N;
        cin >> N;
        cin >> A >> B >> C >> D;
        cout << solve(N) << "\n";
    }
}



Measured memory_bytes: 4404
#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<lint> A, B;

int main()
{
    cin >> N;
    A.resize(N);
    B.resize(N);
    REP(i, N) cin >> A[i] >> B[i];

    lint ans = 0;
    IREP(i, N) ans += (B[i] - (A[i] + ans) % B[i]) % B[i];
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

ll fnc(ll l) {
	ll ret = l % 4;
	switch (ret)
	{
	case 0:
		ret = l;
		break;
	case 1:
		ret = 1;
		break;
	case 2:
		ret = l + 1;
		break;
	default:
		ret = 0;
		break;
	}
	return ret;
}

int main() {
	ll a, b, ans;



	in(a);
	in(b);

	a = fnc(a-1);
	b = fnc(b);
	ans = a ^ b;
	outn(ans);



	return 0;


}


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

int N, M;
std::vector<std::vector<int>> T;
int ans = 0;

void sol (int cur, std::set<int> list, std::string str){
  if ( list.size() == 0 ) {
    ans++;
    return;
  }

  for(auto itr = list.begin(); itr != list.end(); ++itr){
    if ( T[cur][*itr] == 1 ) {
      auto l = list;
      l.erase(*itr); sol(*itr, l, str+"-"+std::to_string(*itr));
      continue;
    }
  }
  return;
}

int main (void) {

  std::cin >> N >> M;
  T.resize(N); for(int i=0; i<N; i++) T[i].assign(N,0);

  for(int i=0; i<M; i++){
    int a, b; std::cin >> a >> b;
    T[a-1][b-1] = 1;
    T[b-1][a-1] = 1;
  }

  std::set<int> list;
  for(int i=1; i<N; i++) list.insert(i);
  sol(0, list, "0"); std::cout << ans << std::endl;

  return 0;
}

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

int ch(int k){
	if(k>0){
		if(k%2==0) return k/2;
		else return (k+4)/2;
	}
	else return -k;
}

int main(){
  int i,j;
  int a,b,c;
  cin>>a>>b>>c;
  int ans=9999;
  int m=max(a,max(b,c));
  for(i=0;i<=m+1;i++){
	ans=min(ans,ch(i-a)+ch(i-b)+ch(i-c));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  double v[N];
  for(int i = 0; i < N; i++) cin >> v[i];
  sort(v, v + N);

  double ans = v[0];
  for(int i = 1; i < N; i++){
    ans = (ans + v[i]) / 2.0;
  }

  printf("%.7f\n", ans);
  return 0;
}


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

using namespace std;

int main(){
    string S;
    unsigned long long K;
    cin >> S >> K;
    for (int i = 0; i < K; ++i) {
        if(S.at(i) != '1' || i + 1 == K){
            cout << S.at(i) << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip.split())
def main():
    n = S()
    n = list(n)
    n = list(map(int,n))
    s = sum(n)
    if s%9 == 0:
        print("Yes")
    else:
        print("No")
main()

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

int gcd(int a, int b){ return b ? gcd(b, a%b) : a; }
int main(){
    int n, temp;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }

    temp = a[0];
    for(int i=1; i<n; i++){
        temp = gcd(temp, a[i]);    
    }
    cout << temp << endl;
    return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    ll N, K, roop=0, md;

    cin >> N >> K;

    vector<int> A(N);
    vector<int> cont(N,0);

    rep(i,N) {
        cin >> A[i];
    }

    ll tmp = 0;
    cont[tmp]++;

    while(cont[tmp]<2) {
        tmp = A[tmp]-1;      
        cont[tmp]++;
        K--;
        if(K==0) {
            cout << tmp+1 << endl;
            return 0;
        }
    }

    while(cont[tmp]<3) {
        roop++;
        tmp = A[tmp]-1;      
        cont[tmp]++;
    }

    md = (K+roop) % roop;

    rep(i, md) {
        tmp = A[tmp]-1;
    }

    cout << tmp+1 << endl;

    return 0;
    
}

Measured memory_bytes: 4824
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
int main()
{
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;

    char c1 = s1[0] - 'a' + 'A';
    char c2 = s2[0] - 'a' + 'A';
    char c3 = s3[0] - 'a' + 'A';

    cout << c1 << c2 << c3 << endl;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

k, q = [int(item) for item in input().split()]
d = [int(item) for item in input().split()]
nxm = []
for _ in range(q):
    n, x, m = [int(item) for item in input().split()]
    nxm.append((n, x, m))

for n, x, m in nxm:
    n -= 1
    newd = []
    is_zero = []
    sum_newd = 0
    for item in d:
        sum_newd += item % m
        newd.append(item % m)
        is_zero.append(item % m == 0)
    loop = n // k
    rest = n % k
    total = loop * (sum_newd) + (x % m) 
    zeros = loop * sum(is_zero)
    total += sum(newd[:rest])
    zeros += sum(is_zero[:rest])
    rollover = total // m
    ret = n - rollover - zeros
    print(ret)

Measured memory_bytes: 93916
# 挿入ソート　トランプの時によく使う。
#
#
#
#

cnt = int(input())
numbers = list(map(int, input().split(' ')))


def insertionsort(A, N):
    '''
    :param A: N個の要素を含む０オリジンの配列
    :param N: Aの要素数
    :return:
    '''
    print(' '.join(map(str, A)))

    for i in range(1, N):
        # ずらすために一時保存しておく変数
        v = A[i]
        # ソート済み部分のindex
        j = i - 1
        # 探索 jが-1になったとき か 自分よりソート済みが小さい場合
        while j >= 0 and A[j] > v:
            # ソート済み部分を右に１個ずらす
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v

        print(' '.join(map(str, A)))

insertionsort(numbers, cnt)



Measured memory_bytes: 5616
from collections import defaultdict
N = int(input())
XYH = [list(map(int,input().split())) for _ in range(N)]
XYH.sort(key=lambda x: x[2],reverse=True)

for cx in range(0,101):
    for cy in range(0,101):
        flag = True
        H = XYH[0][2] + abs(XYH[0][0]-cx) + abs(XYH[0][1]-cy)
        for x,y,h in XYH:
            if h != max(H-abs(x-cx)-abs(y-cy),0):
                flag = False
                break

        if flag:
            print(cx,cy,H)
            exit()



Measured memory_bytes: 3316
#include <stdio.h>
#define H 500000
void maxHeapify(int *A,int i);
void buildMaxHeap(int *A);
int n;

int main(){
  int i;
  int N[H];

  scanf("%d",&n);
  for(i=1;i<n+1;i++){
    scanf("%d",&N[i]);
    
  }buildMaxHeap(N);
  
  for(i=1;i<n+1;i++){
    printf(" %d",N[i]);
  }
  printf("\n");
    
  return 0;
}
void buildMaxHeap(int *A){
  int i;
  for(i=n/2;i>0;i--){
    maxHeapify(A,i);
  }
}

void maxHeapify(int *A,int i){
  int l,r,largest,tmp;
  
  l = 2*i;
  r = 2*i+1;

  if(l <= n && A[l] > A[i]) largest = l;
  else largest =i;
  if(r <= n && A[r] > A[largest]) largest = r;
  if(largest != i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(A,largest);
  }
}



Measured memory_bytes: 3684
#include<stdio.h>
   
int main(void){
int a[10000];
int n;
int i;
long s=0;
int h,l;
   
scanf("%d",&n);
   
for(i =0; i<n; i++){
scanf("%d",&a[i]);
s += a[i];
}
   
l =1000001;
h=-1000001;
   
for(i=0;i<n;i++){
if(l>a[i])l = a[i];
if(h<a[i])h = a[i];
}
   
printf("%d %d %ld\n",l, h,s);
   
return 0;
}

Measured memory_bytes: 640
N = int(input())
A = [int(i) for i in input().strip().split(" ")]

from collections import defaultdict

count = defaultdict(int)
for i in A:
    count[i] += 1

diff = {}
total = 0
for i in count.keys():
    tmp = count[i] * (count[i]-1) // 2
    if tmp == 0:
        diff[i] = 0
    else:
        diff[i] = tmp - (count[i]-1) * (count[i]-2) // 2
    total += tmp

prnt = 0
for i in A:
    prnt = total
    prnt -= diff[i]
    print(prnt)


Measured memory_bytes: 32892
#include<bits/stdc++.h>
#include<math.h>
#include<vector>
#include <iostream>
//#include <algorithm>
#include <limits>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
vector<vector<vector<double>>> dp;
//cout <<fixed << setprecision(10)<< ans;で、小数精度10桁にできる
/*void printdp(int N,ll Vmax){
	rep(i,N+1){
		for(ll j=0;j<Vmax+1;j++){
			if(dp[i][j]==llMAX)continue;
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}
	cout << endl;
	return;
}*/
double culc(int a1,int a2,int a3){
	if(dp[a1][a2][a3]!=-1){
		return dp[a1][a2][a3];
	}
	double result = 0;
	if(a1>0){
		result += culc(a1-1,a2,a3)*a1;
	}
	if(a2>0){
		result += culc(a1+1,a2-1,a3)*a2;
	}
	if(a3>0){
		result+= culc(a1,a2+1,a3-1)*a3;
	}
	//result +=N;
	result /=(a1+a2+a3);
	//dp[a1][a2][a3] = (culc(a1-1,a2,a3)*a1+culc(a1+1,a2-1,a3)*a2+culc(a1,a2+1,a3-1)*a3+N)*(1/(a1+a2+a3));
	dp[a1][a2][a3] = result;
	return result;
}
int main(void){
	int N,K;
	cin >> N >> K;
	int a[N];
	rep(i,N){
		cin >> a[i];
	}
	int dp[100009];
	rep(k,K+1){
		int lose=0,cnt=0;
		rep(i,N){
			if(0<=k-a[i]){
				cnt++;
				if(!dp[k-a[i]])lose++;
			}
		}
        if (cnt == 0) dp[k] = 0;
        else if (0 < lose) dp[k] = 1;
        else dp[k] = 0;
	}
	if (dp[K]) printf("First\n");
    else printf("Second\n");
	return 0;
}

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

int main(void){
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); ++i){
		if(s[i] == s[i+1]){
			cout << i+1 << " " << i+2 << endl;
			return 0;
		}
		if(s[i] == s[i+2]){
			cout << i+1 << " " << i+3 << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 760
n=int(input())
A=sorted(list(map(int,input().split())))
B=[0]*(1+A[-1])
for i in A:
    B[i]+=1
    if B[i]==1:
        for j in range(2*i,A[-1]+1,i):
            B[j]+=1
    else:
        continue
ans=0
for i in A:
  if B[i]==1: ans+=1

print(ans)

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

int main() {
	int d[7], g;
	cin >> d[1] >> d[2] >> d[3] >> d[4] >> d[5] >> d[6] >> g;
	for (int i = 0; i < g; i++) {
	    int x, y; cin >> x >> y;
        if (x != d[1]) {
            if (x == d[2]) {
                int t = d[2];
                d[2] = d[6];
                d[6] = d[5];
                d[5] = d[1];
                d[1] = t;
            } else if (x == d[3]) {
                int t = d[3];
                d[3] = d[6];
                d[6] = d[4];
                d[4] = d[1];
                d[1] = t;
            } else if (x == d[4]) {
                int t = d[4];
                d[4] = d[6];
                d[6] = d[3];
                d[3] = d[1];
                d[1] = t;
            } else if (x == d[5]) {
                int t = d[5];
                d[5] = d[6];
                d[6] = d[2];
                d[2] = d[1];
                d[1] = t;
            } else {
                int t = d[6];
                d[6] = d[1];
                int u = d[2];
                d[2] = d[5];
                d[5] = u;
                d[1] = t;
            }
        }
        if (y != d[2]) {
            if (y == d[3]) {
                int t = d[3];
                d[3] = d[5];
                d[5] = d[4];
                d[4] = d[2];
                d[2] = t;
            } else if (y == d[4]) {
                int t = d[4];
                d[4] = d[5];
                d[5] = d[3];
                d[3] = d[2];
                d[2] = t;
            } else {
	            int t = d[5];
                int u = d[4];
                d[5] = d[2];
                d[2] = t;
                d[4] = d[3];
                d[3] = u;
                }
	    }
	    cout << d[3] << endl;
	}
}



Measured memory_bytes: 3004
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

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

	auto maxA = *a.rbegin();
	auto mid = maxA / 2;

	auto left = 0;
	while (left < n - 2 && a[left] < mid)
	{
		++left;
	}

	auto ans = left;
	if (left > 0)
	{
		if (abs(a[left] - mid) > abs(a[left - 1] - mid))
		{
			ans = left - 1;
		}
	}
	cout << (int)maxA << " " << (int)a[ans] << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;


int main(void) {
    int n;
    cin >> n;
    
    vector<string> goods;
    
    string s;
    for (int i = 0; i < n; i++) {
        cin >> s;
        goods.push_back(s);
    }
    sort(goods.begin(), goods.end());
    goods.erase(unique(goods.begin(), goods.end()), goods.end());
    
    cout << goods.size() << endl;
    
    return 0;
}

Measured memory_bytes: 11600
use proconio::input;

fn main() {
    input! {
        x: u128,
    }
    let mut deposit = 100;
    let mut years = 0;

    let ans = loop {
        years+=1;
        deposit = deposit * 101 / 100;
        //println!("{}", deposit);
        if deposit >= x {
            break years;
        }
    };

    println!("{}", ans);
}


Measured memory_bytes: 2148