akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }


signed main()
{
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 1; i <= N; i++)
	{
		int a;
		cin >> a;
		if (i % 2 == 1 && a % 2 == 1)
		{
			ans++;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 3224
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<set>
#include<map>


using namespace std;

#define all(x) (x).begin(),(x).end()
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define y1 Emilia
#define forit(s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

#define N 400400
#define dracarys ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

ll A, B, C;

int main(){
    dracarys
    cin >> A >> B >> C;
    if(C < B){
        cout << C + B << "\n";
        return 0;
    }
    if(C >= A + B + 1)
        cout << A + 2 * B + 1;
    else
        cout << C + B << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <complex>
#include <iterator>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define rtr(c, i) for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define repfn(i, a, cont, next) \
  for(auto i = (a); [=](){return(cont);}(); i = [=](){return(next);}())
#define repby(i, a, b, step) repfn(i, a, i < b, i + step)
#define repab(i, a, b) repby(i, (a), (b), 1)
#define rep(i, n) repab(i, 0, (n))
#define pb push_back
#define sz(c) int((c).size())

int main(int argc, char **argv)
{
  int n;
  vi v;
  typedef tuple<int, int, int, int> ti4;
  set<ti4> accm;

  while (cin >> n) {
    repab (a, 0, 10) {
      repab (b, 0, 10) {
        repab (c, 0, 10) {
          repab (d, 0, 10) {
            if (a + b + c + d == n) {
              accm.insert(ti4(a, b, c, d));
            }
          }
        }
      }
    }
    cout << sz(accm) << endl;
    accm.clear();
  }
  return 0;
}

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

ll rui(ll a, ll n){
    int x=a;
    while(n>1){
        a *=x;
        n--;
    }
    return a;
}

int main(){
    int N,P; cin>>N>>P;
    ll odd=0,even=0;
    
    rep(i,N){
        int x; cin>>x;
        if(x%2==0){
            even++;
        }else{
            odd++;
        }
    }
    
    // 1袋のとき
    if(N==1){
        if(P==1 && odd==1){
            cout << 1 << endl;
        }else if(P==1 && odd==0){
            cout << 0 << endl;
        }
        
        if(P==0 && even==1){
            cout << 1 << endl;
        }else if(P==0 && even==0){
            cout << 0 << endl;
        }
        return 0;
    }
    
    
    if(odd==0 && P==1){
        cout << 0 << endl; return 0;
    }
    if(odd==0 && P==0){
        cout << rui(2,even) << endl; return 0;
    }
    ll ans = rui(2,N-1);
    cout << ans << endl;
    
    /*
    ll ans=0;
    if(P==0){
        ans = pow(2,even)*(pow(2,odd)/2);
    }else if(P==1){
        ans = pow(2,even)*(pow(2,odd)/2);
    }
    
    cout << ans <<endl;
    */
}


Measured memory_bytes: 3560
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll N, K, A[212345], B[212345];

int main() {

	memset(B, 0xff, sizeof(B));
	cin >> N >> K;
	rep(i, N) cin >> A[i];
	rep(i, N) A[i]--;

	ll cur = 0, cnt = 0;

	for (; B[cur] == -1; cnt++) {
		B[cur] = cnt;
		cur = A[cur];
	}

	ll s;
	if (K < B[cur]) s = K;
	else s = (K - B[cur]) % (cnt - B[cur]) + B[cur];

	rep(i, N) {
		if (B[i] == s) {
			cout << i + 1 << endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 6864
package main

import (
	"fmt"
	"sort"
)

type Heap struct {
	data []int
}

func (h *Heap) Len() int           { return len(h.data) }
func (h *Heap) Less(i, j int) bool { return h.data[i] < h.data[j] }
func (h *Heap) Swap(i, j int)      { h.data[i], h.data[j] = h.data[j], h.data[i] }
func (h *Heap) Push(i interface{}) { h.data = append(h.data, i.(int)) }
func (h *Heap) Pop() interface{} {
	i := h.data[len(h.data)-1]
	h.data = h.data[:len(h.data)-1]
	return i
}

type Data struct {
	b, c int
}
type DataSlice struct {
	data []*Data
}

func (s DataSlice) Len() int           { return len(s.data) }
func (s DataSlice) Swap(i, j int)      { s.data[i], s.data[j] = s.data[j], s.data[i] }
func (s DataSlice) Less(i, j int) bool { return s.data[i].c > s.data[j].c }

func main() {
	n, m := oneInt(), oneInt()
	input := scanNums(n)

	dataSlice := &DataSlice{[]*Data{}}
	for i := 0; i < m; i++ {
		b, c := oneInt(), oneInt()
		dataSlice.data = append(dataSlice.data, &Data{b, c})
	}

	ans := calc(input, dataSlice, n)

	fmt.Println(ans)

}

func calc(input []int, dataSlice *DataSlice, n int) int {
	for _, a := range input {
		dataSlice.data = append(dataSlice.data, &Data{1, a})
	}

	sort.Sort(dataSlice)

	count := 0
	sum := 0
	for _, d := range dataSlice.data {
		for i := 0; i < d.b; i++ {
			if count == n {
				return sum
			}
			count++
			sum += d.c
		}
	}
	return sum
}

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}


Measured memory_bytes: 13056
def main():
  ans = [0] *100000
  for i in range(1,  101):
    for j in range(1, 101):
      for k in range(1, 101):
        ans[i**2 + j**2 + k**2 + i*j + j*k + k*i-1] +=1
  n = int(input())
  for i in range(n):
    print(ans[i])
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 10084
#include "bits/stdc++.h"
using namespace std;
#define MODULO 1000000007
#define PI 3.14159265359
typedef long long int ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
     int n,i;
     cin>>n;
     int A[n];
     for(i=0;i<n;++i)
     {
     	cin>>A[i];
	 }
	 int ans=0;
	 for(i=0;i<n;i+=2)
	 {
	 	if(A[i]%2!=0)
	 	ans++;
	 }
	 cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;


int main(int argc, char *argv[]) {

	int N; cin >> N;

	vector<int> X(N,0);
	for (int i = 0; i < N; i++) {
		cin >> X[i];
	}

	int MIN = INF;
	for (int i = 1; i <= 100; i++) {
		int hp = 0;
		for (int j = 0; j < N; j++) {
			hp += (X[j]-i) * (X[j] - i);
		}
		MIN = min (hp,MIN);
	}
	cout << MIN << endl;

	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include<list>
#include<algorithm>
#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repj(a,b,c) for(a=b;a<c;a++)
#define repr for(i=n-1;i>=0;i--)
#define pii pair<ll,ll>
#define pll pair<ll, ll>
#define inf 100000001
const double pie  =3.141592653589793238463;
#define mod 1000000007
#define lb lower_bound
#define up upper_bound
#define rep1 for(i=1;i<=n;i++)
#define vr vector
#define POP(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define ef else if
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(),A.end());
#define REV(A) reverse(A.begin(), A.end());
#define lenth length()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n" 
const ll dx[4] = { -1, 1, 0, 0};
const ll dy[4] = {0, 0, -1, 1};
ll XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
ll YY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
#define precise(x) cout<<fixed<<setprecision(x)
#define t1(x)                cerr<<#x<<": "<<x<<endl
#define t2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define t4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define t5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define t6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
using namespace std;
void SieveOfEratosthenes(ll n) 
{ 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (ll i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // for (ll p=2; p<=n; p++) 
       // if (prime[p]) 
          // cout << p << " "; 
} 

ll power(ll x, ll y) 
{ 
    ll res = 1; 
    while (y > 0) 
    { 
        if (y & 1) 
            res = res * x; 
        y = y >> 1; 
        x = x * x; 
    } 
    return res; 
}
int main()
{
    // fastio
    ll t,i,j,k,l,m,n,a,x,b,y,z,c,h,d,f,e,p,o,nl,np,q,r,g;
    cin>>n>>k;
    ll arr[n];
    ll ans=0;
    rep(i,0,n)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    rep(i,0,k)
    {
        ans+=arr[i];
    }
    cout<<ans<<endl;
}

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

#define FO(i,a,b) for (int i = (a); i < (b); i++)
#define sz(v) int(v.size())

using namespace std;

int n, m, q;
int a[100005];
set<int> seen;
int v[100005];
int iv[100005];
int r;

int nw[100005];

int main() {
    scanf("%d %d %d", &n, &m, &q);
    FO(i,0,q) scanf("%d", a+i);
    reverse(a,a+q);
    FO(i,0,q) {
        if (!seen.count(a[i])) {
            seen.insert(a[i]);
            v[r++] = a[i];
        }
    }
    FO(i,1,m+1) if (!seen.count(i)) {
        v[r++] = i;
    }

    FO(i,0,m) {
        //printf("%d ", v[i]);
        iv[v[i]] = i;
    }
    //printf("\n");

    nw[0] = n;

    FO(i,0,q) {
        int o = iv[a[i]];
        if (nw[o]) {
            nw[o]--;
            nw[o+1]++;
        }
    }

    bool bd = false;
    for (int i = m-2; i >= 0; i--) {
        if (v[i] > v[i+1]) bd = true;
        if (bd && nw[i]) {
            printf("No\n");
            return 0;
        }
    }

    printf("Yes\n");
}



Measured memory_bytes: 6528
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

using ll = long long;
using P = pair<double, double>;

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




int main() {
	int n, c, k;
	cin >> n >> c >> k;

	vector<int> t(n);

	rep(i ,n) {
		cin >> t[i];
	}
	sort(t.begin(), t.end());

	int nt = -1;
	int cc = 0;
	int ans = 0;

	for(int i = 0; i < n; i++) {
		//cout << "i:" << i << " cc:" << cc << " t:" << t[i] << " nt:" << nt << " ans:" << ans << endl; 
		cc++; 
		if (cc >= c) {
			cc = 0;
			ans++;
			nt = -1;
			continue;
		}

		if (nt == -1) {
			nt = t[i] + k;
		}  

		if (i < n - 1 && t[i + 1] > nt) {
			cc = 0;
			ans++;
			nt = -1;
		}
	}
	if (cc > 0) {
		ans++;
	}
	cout << ans << endl;

	return 0;
}


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

using namespace std;

using i64 = int64_t;

int main() {
#ifdef GOLIKOV
  freopen("in", "rt", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int h, w, n;
  cin >> h >> w >> n;
  int const max = h + w;

  int const MOD = (int) 1e9 + 7;
  auto add = [](int& x, int y) -> int& {
    x += y;
    if (x >= MOD) {
      x -= MOD;
    }
    return x;
  };
  auto mul = [](int& x, int y) -> int& {
    return x = (int) ((i64) x * y % MOD);
  };
  auto prod = [&](int x, int y) {
    return mul(x, y);
  };
  auto sub = [](int& x, int y) {
    x -= y;
    if (x < 0) {
      x += MOD;
    }
  };
  auto pw = [&](int x, int d) {
    int r = 1;
    while (d) {
      if (d & 1) {
        mul(r, x);
      }
      mul(x, x);
      d >>= 1;
    }
    return r;
  };
  auto inv = [&](int x) {
    return pw(x, MOD - 2);
  };
  vector<int> fact(max + 1), ifact(max + 1);
  fact[0] = 1;
  for (int i = 0; i < max; ++i) {
    fact[i + 1] = prod(fact[i], i + 1);
  }
  ifact.back() = inv(fact.back());
  for (int i = max - 1; i >= 0; --i) {
    ifact[i] = prod(ifact[i + 1], i + 1);
  }
  auto choose = [&](int n, int k) {
    if (n < 0 || k < 0 || k > n) {
      return 0;
    }
    return prod(fact[n], prod(ifact[k], ifact[n - k]));
  };
  auto npaths = [&](auto x1, auto x2) {
    return choose(x2.first + x2.second - x1.first - x1.second,
            x2.first - x1.first);
  };
  vector<pair<int, int>> a(n);
  for (auto& p : a) {
    cin >> p.first >> p.second;
    --p.first;
    --p.second;
  }
  sort(a.begin(), a.end(), [](auto& x, auto& y) {
    return x.first + x.second < y.first + y.second;
  });
  a.emplace_back(h - 1, w - 1);
  ++n;
  vector<int> dp(n);
  pair<int, int> start{0, 0};
  for (int i = 0; i < n; ++i) {
    dp[i] = npaths(start, a[i]);
    for (int j = 0; j < i; ++j) {
      sub(dp[i], prod(dp[j], npaths(a[j], a[i])));
    }
  }
  cout << dp.back() << '\n';
  return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef long int li;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<double, double>P;
typedef tuple<ll, int, int>T;
#define PI 3.14159265358979
#define MOD (ll)1000000007
typedef vector<ll> vec;
typedef vector<vec> mat;
//A*Bの計算
mat mul(mat &A,mat &B){
  mat C(A.size(),vec(B[0].size()));
  rep(i,C.size()){
    rep(j,C[0].size()){
  	  C[i][j]=0ll;
    }
  }
  for(int i=0;i<A.size();i++){
    for(int k=0;k<B.size();k++){
      for(int j=0;j<B[0].size();j++){
        C[i][j]=(C[i][j]+A[i][k]*B[k][j])%MOD;
      }  
    }
  }
  return C;
}
mat powmul(mat A,ll n){
  mat B(A.size(),vec(A[0].size()));
  for(int i=0;i<A.size();i++){
    B[i][i]=1ll;
  }
  while(n>0){
    if(n>0){
      if(n&1) B=mul(B,A);
      A=mul(A,A);
      n>>=1;
    }
  }
  return B;
}

int main(){
  int N;
  ll K;
  cin>>N>>K;
  mat X(N,vec(N));
  rep(i,N){
    rep(j,N){
      cin>>X[i][j];
    }
  }
   X=powmul(X,K);
  ll ans=0ll;
  rep(i,N){
    rep(j,N){
      ans+=X[i][j];
      ans%=MOD;
    }
  }
  cout<<ans;
}

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

int gcd(int a, int b) {
  if(a < b) return gcd(b, a);
  int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}



int main(){
   int K;
   cin >> K;

   ll sum = 0;
   //three same
   for(int i=1;i<K+1;i++){
      sum += i;
   }

   //two same
   for(int i=1;i<K+1;i++){
      for(int j=i+1;j<K+1;j++){
         sum += gcd(i,j)*6;
      }
   }

   //no same
   for(int i=1;i<K+1;i++){
      for(int j=i+1;j<K+1;j++){
         for(int k=j+1;k<K+1;k++){
            sum += gcd(gcd(i,j),k)*6;
         }
      }
   }
   cout << sum << endl;
   return 0;  
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <string_view>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <sstream>
#include <typeinfo>
#include <algorithm>
#include <numeric>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cmath>

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

using namespace std;

bool isRG(char x, char y){ return (x == 'R' && y == 'G') || (y == 'R' && x == 'G'); }
bool isGB(char x, char y){ return (x == 'G' && y == 'B') || (y == 'G' && x == 'B'); }
bool isBR(char x, char y){ return (x == 'B' && y == 'R') || (y == 'B' && x == 'R'); }

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

    int n;
    string s;
    cin >> n >> s;
    
    uint64_t count_r = 0;
    uint64_t count_g = 0;
    uint64_t count_b = 0;
    
    rep(i,s.size()){
        if(s[i] == 'R'){
            count_r += 1;
        }
        else if(s[i] == 'G'){
            count_g += 1;
        }
        else if(s[i] == 'B'){
            count_b += 1;
        }
    }

    uint64_t count_triple = count_r * count_g * count_b;
    for(int j = 1; j < (int)s.size(); ++j){
        for(int k = j+1; k < (int)s.size(); ++k){
            if(s[k] == s[j]) continue;
            if(isRG(s[j], s[k]) && s[j-(k-j)] == 'B'){
                count_triple -= 1;
            }
            else if(isGB(s[j], s[k]) && s[j-(k-j)] == 'R'){
                count_triple -= 1;
            }
            else if(isBR(s[j], s[k]) && s[j-(k-j)] == 'G'){
                count_triple -= 1;
            }
        }
    }
    cout << count_triple << '\n';

    return 0;
}


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

int s[212345];

int main () {

	int n;
	string str;

	cin >> n >> str;

	for (int i = 1; i <= n; ++i) s[i] = s[i - 1] + (str[i - 1] == '#');

	int ans = n;
	for (int i = 0; i <= n; ++i) {
		int temp = s[i];
		temp += n - i - (s[n] - s[i]);
		ans = min (ans, temp);
	}

	cout << ans << endl;

	return 0;
}

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

const int maxn = 100005;

int n;

int main(){
    int n,s,x;
    int sum=0;
    cin>>n>>s;
    for(int i=1;i<=n;i++){
        cin>>x;
        sum+=x;
        if(sum>s){
            cout<<i<<endl;
            break;
        }
    }
    if(sum<=s)cout<<n+1<<endl;
}


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

int main() {
    string s;
    cin >> s;
    int counter = 0;
    if (s[0] == '1') ++counter;
    if (s[1] == '1') ++counter;
    if (s[2] == '1') ++counter;
    cout << counter << endl;
}

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

int CountOfDigits(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {

  int N;
  cin >> N;
  
  int M = CountOfDigits(N);
  if( N % M == 0 ) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

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

#define MAXN 100001

struct data{
    int a,b;
}c[MAXN];

bool cmp(struct data x, struct data y)
{
    return x.b < y.b;
}

int n,m;

int main()
{
    cin >> n >> m;
    for(int i=0;i<m;++i)
    {
        scanf("%d%d",&c[i].a,&c[i].b);
    }
    sort(c,c+m, cmp);
    int t=0,ans=0;
    for(int i=0;i<m;++i)
    {
        if(c[i].a >= t)
        {
            t = c[i].b;
            ++ans;
        }
    }
    cout << ans << endl;
}


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

using ll = long long;

#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define len(x) int((x).size())

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define randint(n) uniform_int_distribution<int>(1, (n))(rng)

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

	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	int n,k;
	cin>>n>>k;

	vector<int> A;

	for(int i=0; i<n; i++)
	{
		int a;
		cin>>a;
		A.push_back(a);
	}

	int pass=1e9;
	int fail=0;

	while(pass-fail>1)
	{
		int mid = int((pass+fail)/2);
		int cur2 = 0;

		for(int i=0; i<n; i++)
		{
			cur2 += int(A[i]/mid);
			if(A[i]%mid == 0) cur2--;
		}

		if(cur2<=k) pass=mid;
		else fail=mid;
	}

	cout << pass << endl;
}

Measured memory_bytes: 4320
#include <iostream>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long

int main(){
	int n,a[200002];
	ll A=0,B=0,min=0;

	cin >> n;
	FOR(i,0,n){
		cin >> a[i];
		B += a[i];
	}

	A += a[0];
	B -= a[0];
	min = abs(A-B);

	FOR(i,1,n-1){
		A += a[i];
		B -= a[i];
		if(min > abs(A-B)) min = abs(A-B);
	}
	cout << min;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
    int n;
    cin >> n;
    int a[200010] = {};
    for (int i = 1; i < n; ++i) {
        int hoge;
        cin >> hoge;
        ++(a[hoge-1]);
    }
    for (int i = 0; i < n; ++i) {
        cout << a[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4416
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

using namespace std;
using P = pair<int, int>;
using T = tuple<long, long, long>;

long long MOD = 1000000007;
long long dp[100005][4];

int main() {
	int N,M;
	cin >> N >> M;

	vector<T>xyz(N);
	for (int i = 0; i < N;++i) {
		cin >> get<0>(xyz[i]) >> get<1>(xyz[i]) >> get<2>(xyz[i]);
	}

	vector<long long>sum(N);
	long long ans = 0;
	for (int i = 0; i < 8;++i) {
		for (int j = 0; j < N;++j) {
			long long x = ((i >> 0) & 1) ? 1 : -1;
			long long y = ((i >> 1) & 1) ? 1 : -1;
			long long z = ((i >> 2) & 1) ? 1 : -1;
			sum[j] = x * get<0>(xyz[j]) + y * get<1>(xyz[j]) + z * get<2>(xyz[j]);
		}
		sort(sum.begin(),sum.end(), greater<long long>());

		long long currentSum = 0;
		for (int i = 0; i < M;++i) {
			currentSum += sum[i];
		}
		ans = max(ans,currentSum);
	}
	cout << ans << endl;
}


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

int main () {

    int n;
    std::cin >> n;
    std::vector<int> a(n - 1);
    for (int i = 0; i < a.size(); i++) std::cin >> a[i];

    std::vector<int> ans(n, 0);
    for (int i = 0; i < a.size(); i++) ans[a[i] - 1]++;

    for (int i = 0; i < ans.size(); i++) std::cout << ans[i] << std::endl;

    return 0;
}

Measured memory_bytes: 4376
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <map>
#include <iomanip> 
#include <ctime>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

const int INF = 1001001001;
const int MAX_N = 100100;
const double PI = 3.14159265358979323846;



int main(int argc, char *args[]) {
	int n;
	cin >> n;
	if (n % 2 == 1) {
		cout << "No" << endl;
		return 0;
	}
	char s[101];
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	char t[101];
	for (int i = 0; i < n/2; i++) {
		t[i] = s[i];
	}
	for (int i = 0; i < n/2; i++) {
		if (s[i + n / 2] != t[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include <assert.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
#include <climits>
using namespace std;
typedef unsigned long long ull;
#define ll long long int
static const double PI = 3.141592653589793;
const ll INF = 100000000000000;
ll mod = 1000000007;
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s, t;
	ll y = 0;
	cin >> s>>t;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == t[i])y++;
	}
	cout<<y <<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,ac{},wa{},tle{},re{};
    cin>>n;
    fr(i,n){
        string s;
        cin>>s;
        if(s=="AC") ++ac;
        if(s=="WA") ++wa;
        if(s=="TLE") ++tle;
        if(s=="RE") ++re;
    }
    cout<<"AC x "<<ac<<"\nWA x "<<wa<<"\nTLE x "<<tle<<"\nRE x "<<re<<'\n';
}

Measured memory_bytes: 3636
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;
using ll = long long;

int main(void)
{
    int n;
    cin >> n;
    int a[n];
    fill(a, a + n, 0);
    REP(i, n - 1)
    {
        int t;
        cin >> t;
        t--;
        a[t]++;
    }
    REP(i, n)
    {
        cout << a[i] << endl;
    }
}

Measured memory_bytes: 4416
#!/usr/bin/ruby
# encoding: utf-8

N = gets.to_i
T,A = gets.split.map(&:to_i)
H = gets.split.map(&:to_i)

def temp t,x
  return t-x*0.006
end

diff = Array.new(N,0)

(0..N-1).each do |i|
  diff[i] = (A - temp(T,H[i])).abs
end

ans = -1
min = diff[0]
(0..N-1).each do |i|
  if min >= diff[i]
    min = diff[i]
    ans = i + 1
  end
end

p ans


Measured memory_bytes: 1788
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include<deque>
#include<queue>
#include<set>
#include <functional>
#include <cmath>


//マクロ
/*動かない・・・
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
int n;
int a[200000];

//使用する関数
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;
}

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

	cin >> n;
	REP(i,n) {
		cin >> a[i];
	}

	int tar = 1;
	int ans = 0;
	REP(i, n) {
		if (a[i] != tar) {
			ans++;
			continue;
		}
		tar++;
	}
	if (tar == 1) {
		cout << -1 << endl;
	}
	else {
		cout << ans << endl;
	}
}

Measured memory_bytes: 1024
#include <stdio.h>
//選択ソート

//配列の要素を順番に出力
void trace(int A[],int N){
    int i;
    for(i = 0; i < N;i++){
        if(i > 0)printf(" ");//隣の要素の間に一つの空白を出力
        printf("%d",A[i]);
    }
    printf("\n");
}


void selectionSort(int A[], int N){
    int i , j, t;
    int min_j;
    int select_count = 0;

    for(i = 0; i < N; i++){
        min_j = i;
        for(j = i; j < N; j++){
            if(A[j] < A[min_j]) {
                min_j = j;
            }
        }
        t = A[i]; A[i] = A[min_j]; A[min_j] = t;
        if(i != min_j){
            select_count++;
        }
    }
    trace(A,N);
    printf("%d\n", select_count);
}
int main(){
    int N, i, j;
    int A[100];

    scanf("%d",&N);
    for(i = 0;i < N;i++){
        scanf("%d",&A[i]);
    }
    selectionSort(A,N);
    return 0;
}


Measured memory_bytes: 2132
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int x,y; cin >> x >> y;
	int m=GCD(x,y);
	cout << (x+y+1)-m << endl;
}



Measured memory_bytes: 3192
#include <cstdio>
#include <iostream>

using namespace std;

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

	int A[n];
	for (int i = 0; i < n; ++i) {
		int v;
		scanf("%d", &v);
		A[i] = v;
	}
	int length = 1;
	int L[n];
	L[0] = A[0];
	for (int i = 1; i < n; ++i) {
		if (A[i] > L[length - 1]) {
			L[length++] = A[i];
		} else {
			int left = 0;
			int right = length;
			while (left < right) {
				int mid = (left + right) / 2;
				if (L[mid] >= A[i]) {
					right = mid;
				} else {
					left = mid + 1;
				}
			}
			L[right] = A[i];
		}
	}

	cout << length << endl;

	return 0;
}

Measured memory_bytes: 3916
a[200],b[200],c[1000],d[1000],n,m,i,j,k,t;main(){for(;scanf("%d",&n)&&n;){for(i=0;i<n;i++){scanf("%d%d",&a[i],&b[i]);}scanf("%d",&m);for(i=0;i<m;i++){scanf("%d%d",&c[i],&d[i]);}for(i=0;i<m;i++){for(j=1;j<n;j++){for(k=0;k<m;k++){if(a[j]+c[i]-a[0]==c[k]){if(b[j]+d[i]-b[0]==d[k]){t++;break;}}}}if(t==n-1){printf("%d %d\n",c[i]-a[0],d[i]-b[0]);t=0;break;}t=0;}}return 0;} 

Measured memory_bytes: 608
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <vector>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;

using P = tuple<int, int>;

int main() {
  int N, M; cin >> N >> M;
  vector<P> nums(N);
  FOR(n, 1, N + 1) { get<1>(nums[n - 1]) = n; }
  FOR(i, 1, M + 1) {
    int E; cin >> E;
    get<0>(nums[E - 1]) = -i;
  }
  sort(nums.begin(), nums.end());
  for (auto &p : nums) {
    cout << get<1>(p) << endl;
  }
  return 0;
}

Measured memory_bytes: 4408
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node{
  int key;
  Node *right,*left,*parent;
};


Node *root, *NIL;

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }

  z->parent = y;
  if(y == NIL){
    root = z;   
  }
  else{
    if(z->key < y->key){
      y->left = z;
    }
    else{
      y->right = z;
    }
  }
}

void inorder(Node *u){
  if(u == NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u){
  if(u == NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  string com;

  scanf("%d", &n);

  for(i=0;i<n;i++){
    cin >> com;
    if(com == "insert"){
      scanf("%d",&x);
      insert(x);
    }
    else if(com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}  

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

int main() {
	int ans = 0;
	string str;
	cin >> str;
	char run = '2';
	for (int i = 0; i < (int)str.size(); i++) {
		char ch = str[i];
		if (ch == run) {
			ans++;
			if (ch == '0') {
				run = '1';
			}
			else {
				run = '0';
			}
		}
		else {
			if (ch == '0') {
				run = '0';
			}
			else {
				run = '1';
			}
		}
	}
	cout << ans << endl;
}

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

using ll = long long;

ll gcd(ll x, ll y) {
    if (y == 0) return x;
    return gcd(y, x % y);
}

int main() {
    ll A, B;
    cin >> A >> B;
    cout << A / gcd(A, B) * B << endl;
}

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

int main() {
  int x,y=0;
  cin>>x>>y;
  
  rep(i,100){
    rep(j,100){
      if(i+j==x){
        if(i*2+j*4==y){
          cout<<"Yes";
          return 0;
        }
      }
    }
  }
  cout<<"No";
}

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

int main() {
	char s[101], as[256] = {0};
	scanf("%s", s);
	int i;
	for (i=0; i < strlen(s) ;i++) {
		as[s[i]]++;
	}
	for (i=0; i < 256 ;i++) {
		if (as[i] != 0 && as[i] % 2 != 0) {
			break;
		}
	}
	if (i == 256) printf("Yes\n");
	else printf("No\n");
	/*
	int n, i, j, max;
	scanf("%d", &n);
	for (i=1; i <= n ;i++) {
		for (j=1; j <= i ;j++) {
			if (i*j == n) {
				if (i%10+1 <= j%10+1) printf("%d\n", j%10+1);
				else printf("%d\n", i%10+1);
				return 0;
			}
		}
	}
	*/
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <map>
#include <cmath>
using namespace std;

typedef long long i64;
const int MAX_N = 100005;
const i64 LIM = 20000000000LL;

int pr[MAX_N], tot;
i64 S[MAX_N];

void init_prime() {
  static bool vis[MAX_N];
  for (int i = 2; i < MAX_N; ++i) 
    if (!vis[i]) {
      pr[++tot] = i;
      for (int j = i; j < MAX_N; j += i)
	vis[j] = 1;
    }
}

int N;

map<i64, i64> back, NUM;
map<i64, i64>::iterator iter;

bool mul(i64 &x, i64 y) {
  if ((double) LIM / x < y) return false;
  x *= y;
  return true;
}

int main() {
  init_prime();
  
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) scanf("%lld", &S[i]);

  int res = 0;
  
  for (int i = 1; i <= N; ++i) {
    i64 temp = S[i], anti = 1;
    bool flag = 1;
    for (int j = 1; 1LL * pr[j] * pr[j] * pr[j] <= temp; ++j) 
      if (temp % pr[j] == 0) {
	int cnt = 0;
	while (temp % pr[j] == 0) temp /= pr[j], S[i] /= pr[j], cnt++;
	cnt %= 3;
	if (cnt == 1) S[i] *= pr[j], flag &= mul(anti, pr[j] * pr[j]);
	else if (cnt == 2) S[i] *= pr[j] * pr[j], flag &= mul(anti, pr[j]);
      }

    int x = sqrtl(temp);
    if (1LL * x * x == temp) flag &= mul(anti, x);
    else flag &= mul(anti, temp * temp);
    
    if ((1LL * x * x != temp && temp > 1000000000) || !flag) {
      res++;
      continue;
    }
    
    NUM[S[i]]++, back[S[i]] = anti, back[anti] = S[i];
  }

  for (iter = back.begin(); iter != back.end(); ++iter) {
    if (iter->first == 1) {
      res++;
      continue;
    }
    if (iter->first > iter->second) continue;
    res += max(NUM[iter->first], NUM[iter->second]);
  }

  printf("%d\n", res);
  
  return 0;
}


Measured memory_bytes: 21760
#!/usr/bin/env python3
import bisect


def main():
    N = int(input())
    L = sorted(map(int, input().split()))
    ans = 0
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            ans += bisect.bisect_right(L, L[a] + L[b] - 1) - b - 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9360
import java.util.Scanner;
import java.util.stream.Stream;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// Stringをint配列に変換
		int[] S = Stream.of(sc.nextLine().split("")).mapToInt(Integer::parseInt).toArray();

		// 0の回数、1の回数を取得
		int zero_cnt=0;
		int one_cnt=0;
		for(int i=0;i<S.length;i++) {
			if(S[i]==0) zero_cnt++;
			else one_cnt++;
		}
		
		// 0or1で少ない方を取得
		// 回数の取得になる。
		int result = Math.min(zero_cnt, one_cnt);
		
		// 1回で2つ減るので×2をする。
		System.out.println(result*2);
	}
}

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

N, Y = map(int, read().split())

for i in range(N + 1):
    for j in range(N + 1 - i):
        if (i * 10000 + j * 5000 + (N - i - j) * 1000) == Y:
            print(i, j, N - i - j)
            exit(0)

print('-1 -1 -1')


Measured memory_bytes: 2940
#include<iostream>
#define ll long long int
using namespace std;

int main(){
	long long int r, d, x;
  	cin>>r>>d>>x;
  	ll a = x;
  	for( ll i=0; i<10; i++){
    	a = r*a-d;
      	cout<<a<<endl;
    }
}

Measured memory_bytes: 256
#!/mnt/c/Users/moiki/bash/env/bin/python
# N,M = map(int, input().split())
N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]

ans = - 10**10

for i in range(1,1<<10):
    score = 0
    for n in range(N):
        f = "".join(map(str,F[n])) 
        b = "{:010b}".format(i)
        c = [int(f[i]) & int(b[i]) for i in range(10)]
        cnt = len(list(filter( lambda x: x, c)))
        score += P[n][cnt]
    ans = max(ans, score)
print(ans)


Measured memory_bytes: 42716
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    cin>>n;
    vector<ll> v(n,0);
    for(int i = 0;i < n; i++){
        cin>>v[i];
    }
    int max1=0;
    int max2=0;
    int index1=0;
    int index2=0;
    for(int i = 0;i < n; i++){
        if(max1<v[i]) {
            max1=v[i];
            index1=i;
        }
        else if(max2<v[i]){
            max2=v[i];
            index2=i;
        }
    }
    for(int i = 0;i < n; i++){
        if(i==index1) cout<<max2<<endl;
        else cout<<max1<<endl;
    }
    return 0;
}

Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int N = Integer.parseInt(in.nextLine());
        int countDoublets = 0;
        boolean threeConsecutive = false;
        for (int i = 0 ; !threeConsecutive && i < N; i++) {
            String[] read = in.nextLine().split(" ");
            int d1 = Integer.parseInt(read[0]), d2 = Integer.parseInt(read[1]);
            if (d1 == d2) {
                countDoublets++;
                if (countDoublets == 3) {
                    System.out.println("Yes");
                    threeConsecutive = true;
                }
            } else {
                countDoublets = 0;
            }
        }

        if (!threeConsecutive)
            System.out.println("No");

    }
}



Measured memory_bytes: 35740
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  vector<pair<int,int>> point(n);
  for(int i=0;i<n;i++)
    cin>>point.at(i).first>>point.at(i).second;
  double sum = 0;
  for(int i=0;i<n-1;i++){
    for(int j=i+1; j<n;j++){
      int dx=point.at(i).first - point.at(j).first;
      int dy=point.at(i).second - point.at(j).second;
      sum += sqrt(dx*dx +dy*dy);
    }
  }
  double result=2*sum/n;
  printf("%f\8", result);
  return 0;
}
      

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

int main() {
    int N;
    cin >> N;
    vector<long int> a(N), b(N), c(N);
    for (int i = 0; i < N; i++) scanf("%ld", &a[i]);
    for (int i = 0; i < N; i++) scanf("%ld", &b[i]);
    for (int i = 0; i < N; i++) scanf("%ld", &c[i]);
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    long int ans = 0;
    for (int i = 0; i < N; i++) {
        long int t = b[i];
        auto r = lower_bound(a.begin(), a.end(), t);
        long int x = r - a.begin();
        auto l = upper_bound(c.begin(), c.end(), t);
        long int y = c.end() - l;
        ans += x * y;
    }
    cout << ans << "\n";
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, Q;
    cin >> N >> Q;
    vector<int> parent(N + 1);
    parent.at(1) = 1;

    vector<int> ans(N + 1);
    for (int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        parent.at(b) = a;
    }

    for (int i = 0; i < Q; ++i) {
        int p, x;
        cin >> p >> x;
        ans.at(p) += x;
    }

    for (int i = 2; i <= N; ++i) {
        ans.at(i) += ans.at(parent.at(i));
    }

    for (int i = 1; i <= N - 1; ++i) {
        cout << ans.at(i) << " ";
    }
    cout << ans.at(N) << "\n";
    return 0;
}


Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main() {
	int n;
	cin >> n;
	long double e = 6.28318530717958623200;
	output(n * e, 15);
	return 0;
}

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

void solve(long long K, long long A, long long B){
    bool ans = false;
    for (int i = A; i <= B; i++) {
        if (i % K == 0) ans = true;
    }
    if (ans) cout << "OK" << '\n';
    else cout << "NG" << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long K;
    scanf("%lld",&K);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(K, A, B);
    return 0;
}


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

int main() {
  int N,K;
  string S;
  
  cin >> N >> S >> K;
  char C = S.at(K-1);
  
  for( int i = 0 ; i < N ; i++ ){
  	if ( S.at(i) != C )
      S.at(i) = '*';
  }  
  cout << S << endl;  
}

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

typedef long long ll;
typedef vector < int > vi;
typedef pair <int , int > pi;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fr(i,a,b) for(int i=a;i<b;i++)



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

   float r;
   cin>>r;
   float d = (float)44/7*r;
   cout<<d;
    return 0;
}


Measured memory_bytes: 3760
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BC
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  [a, b] <- map readInt . BC.words <$> BC.getLine
  putStrLn $ if solve a b then "Yay!" else ":("

solve :: Int -> Int -> Bool
solve a b = a <= 8 && b <= 8

readInt :: BC.ByteString -> Int
readInt = fst . fromJust . BC.readInt


Measured memory_bytes: 380
#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
#include<string.h>

int main()
{
	int len;
	int count = 0;
	char s[100000];
	char t = 'B';

	scanf("%s", &s);
	len = strlen(s);

	if (s[0] == 'W') t = 'W';

	for (int i = 1; i < len; i++) {
		if (t != s[i]) {
			count++;
			t = s[i];
		}
	}

	printf("%d", count);

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if ( a == b && b !=c )
    printf("Yes\n");
  else if ( b==c && c != a )
    printf("Yes\n");
  else if ( a==c && c != b )
    printf("Yes\n");
  else if ( a==b && b==c )
    printf("No\n");
  else
    printf("No\n");
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(){
    int N;
    int a[100];
    double sum ;
    scanf("%d",&N);

    for(int i=0;i<N;i++){
        scanf("%d",&a[i]);
        
        sum += 1.0 / a[i];
    }

//scanf("%d",&a[0]);
//printf("%d",a[0]);
    printf("%lf",1.0/sum);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int M,D;
	cin >> M >> D;
	int ans = 0;
	rep1(i,M) rep1(d,D){
		int X = d/10, Y = d%10;
		if(X>=2 && Y>=2 && X*Y == i) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> h;
  int p;
  for(int i=0;i<n;i++){
    cin >> p;
    h.push_back(p);
  }
  int cnt = 0,ans = 0;
  for(int i=1;i<n;i++){
    if(h[i-1]<h[i]){
      ans = max(cnt,ans);
      cnt = 0;
    }else{
      cnt++;
    }
  }
  ans = max(cnt,ans);
  cout << ans << endl;
}

Measured memory_bytes: 892
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	ArrayList<ArrayList<Integer>> g = new ArrayList<ArrayList<Integer>>();
	int parent[];
	int prenum[];
	int lowest[];
	boolean visited[];
	int timer=0;
	int root = 1;
	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		parent = new int[n+1];
		prenum = new int[n+1];
		lowest = new int[n+1];
		visited =  new boolean[n+1];
		int m=sc.nextInt();
		for(int i=0; i<n+1; i++) {
			g.add(new ArrayList<Integer>());
		}
		for(int i=0; i<m; i++) {
			int a=sc.nextInt();
			int b=sc.nextInt();
			g.get(a).add(b);
			g.get(b).add(a);
		}

		dfs(root, -1);

		int cnt=0;

		for(int i=root+1; i<n+1; i++) {
			if(prenum[i]==lowest[i]) {
				cnt++;
			}
		}

		System.out.println(cnt);
		sc.close();
	}

	private void dfs(int s, int prev) {
		visited[s]=true;
		prenum[s] = lowest[s] = timer++;

		for(int t : g.get(s)) {
			if(! visited[t]) {
				parent[t]=s;
				dfs(t, s);
				lowest[s] = Math.min(lowest[s], lowest[t]);
			} else if(t != prev) {
				lowest[s] = Math.min(lowest[s], prenum[t]);
			}
		}

	}
}


Measured memory_bytes: 23892