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

vector<int> rolledDice(char, vector<int>);

int main()
{
    vector<int> dice;

    for (int i = 0; i < 6; i++)
    {
        int label;
        cin >> label;
        dice.push_back(label);
    }

    // for (int i = 0; i < 6; i++)
    // {
    //     cout << dice[i] << " ";
    // }
    // cout << endl;

    string str;
    cin >> str;
    for (int i = 0; i < (int) str.length(); i++) {
        dice = rolledDice(str[i], dice);
    }

    cout << dice[0] << endl;

    return 0;
}

vector<int> rolledDice(char direction, vector<int> olddice)
{
    vector<int> newdice = olddice;
    if (direction == 'N')
    {
        // cout << "rolling to " << direction << endl;
        newdice[0] = olddice[1];
        newdice[1] = olddice[5];
        newdice[5] = olddice[4];
        newdice[4] = olddice[0];
    }
    else if (direction == 'S')
    {
        // cout << "rolling to " << direction << endl;
        newdice[0] = olddice[4];
        newdice[4] = olddice[5];
        newdice[5] = olddice[1];
        newdice[1] = olddice[0];
    }
    else if (direction == 'E')
    {
        // cout << "rolling to " << direction << endl;
        newdice[0] = olddice[3];
        newdice[3] = olddice[5];
        newdice[5] = olddice[2];
        newdice[2] = olddice[0];
    }
    else if (direction == 'W')
    {
        // cout << "rolling to " << direction << endl;
        newdice[0] = olddice[2];
        newdice[2] = olddice[5];
        newdice[5] = olddice[3];
        newdice[3] = olddice[0];
    }
    return newdice;
}



Measured memory_bytes: 3204
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < (up); ++i)
#define repp(i, up) for (ll i = 0; i <= (up); ++i)
#define rrep(i, lo, up) for (ll i = (lo); i < (up); ++i)
#define rrepp(i, lo, up) for (ll i = (lo); i <= (up); ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))
#define feach(it, vec) for (auto it = (vec).begin(); it != (vec).end(); ++it)


ll gcd(ll a, ll b);

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

#endif  // end of use_templates


int main()
{
    ll k;
    cin >> k;
    set<ll> mods;
    for (ll cnt = 1, mod = 7 % k; ; ++cnt) {
        if (mod == 0) {
            cout << cnt << endl;
            return 0;
        }
        else if (mods.find(mod) != mods.end()) {
            cout << "-1" << endl;
            return 0;
        }
        mods.insert(mod);
        mod = (mod * 10 + 7) % k;
    }
    return 0;
}


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

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;




void main() {
    string s, t;
    scan(s);
    scan(t);

    auto n = s.length.to!int;
    auto m = t.length.to!int;

    auto dp = new int[][](26, n + 1);
    fillAll(dp, inf3);

    foreach (i ; 0 .. 26) {
        foreach_reverse (j ; 0 .. n) {
            dp[i][j] = dp[i][j + 1];
            if ((s[j] - 'a') == i) {
                dp[i][j] = j;
            }
        }
    }

    int p;
    long ans;

    foreach (ch ; t) {
        int c = ch - 'a';
        if (dp[c][p] < inf3) {
            ans += dp[c][p] - p + 1;
            p = dp[c][p] + 1;
        }
        else if (dp[c][0] < inf3) {
            ans += (n - p) + dp[c][0] + 1;
            p = dp[c][0] + 1;
        }
        else {
            ans = -1;
            break;
        }

        debug {
            writeln("ans:", ans);
        }
    }

    writeln(ans);
}




















int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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

using namespace std;

int main(){
  int A[3][3];
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> A[i][j];
    }
  }
  
  int N;
  cin >> N;
  
  int b[N];
  for(int k = 0; k < N; k++){
    cin >> b[k];
    for(int i = 0; i < 3; i++){
      for(int j = 0; j < 3; j++){
        if(A[i][j] == b[k]) A[i][j] = -1;
      }
    }
  }
  
  bool bingo = false;
  for(int i = 0; i < 3; i++){
    bool b = true;
    for(int j = 0; j < 3; j++){
      if(A[i][j] > -1){
        b = false;
        break;
      }
    }
    if(b){
      bingo = true;
    }
  }
  
  for(int i = 0; i < 3; i++){
    bool b = true;
    for(int j = 0; j < 3; j++){
      if(A[j][i] > -1){
        b = false;
        break;
      }
    }
    if(b){
      bingo = true;
    }
  }
  
  if(A[0][0] == -1 && A[1][1] == -1 && A[2][2] == -1) bingo = true;
  if(A[2][0] == -1 && A[1][1] == -1 && A[0][2] == -1) bingo = true;
  
  cout << (bingo ? "Yes" : "No") << endl;
  
  return 0;
}

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

#define int long long

int32_t main(){

      string s,t;
      cin>>s>>t;

      int n=s.size();
      int m=t.size();

      int dp[n+1][m+1];

      for(int i=0;i<=n;i++){
         for(int j=0;j<=m;j++){
            if(i==0||j==0)
               dp[i][j]=0;
            else if(s[i-1]==t[j-1])
               dp[i][j]=1+dp[i-1][j-1];
            else
               dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
         }
      }

      int ans=dp[n][m];
      int k=1;
      string fin="";
      
      int i=n;
      int j=m;

      while(i>=1&&j>=1){
         if(dp[i][j]==ans&&s[i-1]==t[j-1]){
            fin+=s[i-1];
            ans--;
            i--;
            j--;
         }
         else if(dp[i][j]==dp[i-1][j])
            i--;
         else if(dp[i][j]==dp[i][j-1])
            j--;
      }

      reverse(fin.begin(),fin.end());

      cout<<fin;

   
}


Measured memory_bytes: 70656
#include<bits/stdc++.h>
#define ll long long int
#define vl vector<ll>
#define pl pair<ll,ll>
#define pb push_back
#define F first
#define S second
using namespace std;
ll tako(ll n,ll x,ll t)
{
	if(n<=x)
	{
			//cout << n << " " << " " <<  x << " " << t << "\n";
 
	return t;
	}
	//cout << n << " " << " " <<  x << " " << t << "\n";
	return t+tako(n-x,x,t);
}
int main()
{
	ll t,n,k,x;
	cin >> n >> x >> t;
	cout << tako(n,x,t);
	
	return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;
const int N = 100100;
int dp[N];

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VI yuki(1, 1);
  int cur = 6;
  while (cur < N) {
    yuki.push_back(cur);
    cur *= 6;
  }
  cur = 9;
  while (cur < N) {
    yuki.push_back(cur);
    cur *= 9;
  }
  REP(i, 1, N) {
    dp[i] = 1e8;
  }
  REP(i, 1, N) {
    for (int v: yuki) {
      if (i < v) continue;
      dp[i] = min(dp[i], dp[i - v] + 1);
    }
  }
  cout << dp[n] << endl;
}


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

ll dp[81][20000][3];

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll num = 1000;
  for (int i = 0; i < n-1; i++){
    ll stock = 0;
    if(a[i] < a[i+1]) stock = num / a[i];
    num += (a[i+ 1] - a[i]) * stock; 
  }
  cout << num << endl;
}

Measured memory_bytes: 3632
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
pre_jyanken = [0] * K  # K回前に相手が出した手
ans = 0
for i in range(N):
    if pre_jyanken[i % K] == T[i]:
        pre_jyanken[i % K] = i
    else:
        if T[i] == "r":
            ans += P
        elif T[i] == "s":
            ans += R
        else:
            ans += S
        pre_jyanken[i % K] = T[i]
print(ans)


Measured memory_bytes: 4144
#include <vector> 
#include <list> 
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <complex>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(t,c) for(typeof((c).begin()) t=(c).begin(); t!=(c).end(); ++t)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(t,a,b) for(int t=(a);t<(b);++t)
#define REP(t,n)  FOR(t,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;



const LL mod = 1000000007;

LL gcd(LL a, LL b) { if (a%b == 0) { return b; } else return gcd(b, a%b); }
LL lcm(LL a, LL b) { return a / gcd(a, b)*b; }

#define Yes_ cout<<"Yes"<<endl; return 0;
#define No_ cout<<"No"<<endl; return 0;


#define YES_ cout<<"YES"<<endl; return 0;
#define NO_ cout<<"NO"<<endl; return 0;

#define POSSIBLE cout<<"POSSIBLE"<<endl; return 0;
#define IMPOSSIBLE cout<<"IMPOSSIBLE"<<endl; return 0;



LL conbi2(LL n, LL r) {
	if (r>n || r<0LL)return 0LL;
	LL i;
	LL s = 1LL;
	for (i = 1LL; i <= r; i++)s = s * (n + 1LL - i) / i;
	return s;
}

int main() {

	/*int N;
	cin >> N;
	vector<LL> A(N),B,C;
	REP(i, N) { cin >> A[i]; }
	B = A;
	sort(ALL(A));
	LL c = (N) / 2;


	REP(i, N) {

		if (B[i] < A[c]) {
			cout << A[c] << endl;

		}
		else {
			cout << A[c-1] << endl;

		}

	}*/
	int N;
	cin >> N;
	vector<LL> a(N);

	LL max2_ = -1;

	LL max_ = -1;
	REP(i, N) { cin >> a[i]; max_ = max(max_,a[i]); }

	PII ans;
	for (int j = 0; j < N; j++) {
		if (a[j] == max_) { continue; }
		LL comb = min(max_-a[j],a[j]);
		if (comb > max2_) {
			ans.first = max_;
			ans.second = a[j];
			max2_ = comb;
		}
	}

	cout << ans.first << " " << ans.second << endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
using namespace std;
 
int main(void)
{
    static string input[1280];
    int cnt = 0;
     
    while (cin >> input[cnt]) cnt++;
     
    string data[10];
    data[0] = "* = ****";
    data[1] = "* =* ***";
    data[2] = "* =** **";
    data[3] = "* =*** *";
    data[4] = "* =**** ";
    data[5] = " *= ****";
    data[6] = " *=* ***";
    data[7] = " *=** **";
    data[8] = " *=*** *";
    data[9] = " *=**** ";
     
    for (int i = 0; i < cnt; i++){
        char output[10][10];
        string cur = "";
         
        for (int j = 0; j < 10; j++){
            for (int k = 0; k < 10; k++){
                output[j][k] = '\0';
            }
        }
         
        for (int j = 0; j < 5 - input[i].length(); j++){
            cur += '0';
        }
        cur += input[i];
        for (int j = 0; j < cur.length(); j++){
            int p = cur[j] - '0';
            for (int k = 0; k < 8; k++){
                output[k][j] = data[p][k];
            }
        }
        for (int j = 0; j < 8; j++){
            printf("%s\n", output[j]);
        }
        if (i + 1 != cnt) cout << endl;
    }
     
     
    return 0;
}

Measured memory_bytes: 3224
import math
A, B = map(int, input().split())

num = math.ceil(25 / 2 * A)
A_list = []

if A % 2 == 0:
  while num <= math.floor(25 / 2 * (A + 1)):
    A_list.append(num)
    num += 1
else:
  while num < 25 / 2 * (A + 1):
    A_list.append(num)
    num += 1

res = -1
A_list.sort(reverse=True)
for item in A_list:
  if item >= 10 * B and item < 10 * (B + 1):
    res = item

print(res)

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

int main()
{
    int n;scanf("%d",&n);
    vector<int> arr(n);
    set<int> ar;
    ar.insert(0);
    for(int i=0;i<n;i++){
        scanf("%d",&arr[i]);
        auto it=ar.end();
        if(*(--it)==arr[i]-1){ar.insert(arr[i]);}
    }
    if(ar.size()==1){puts("-1");}
    else  printf("%d",n-ar.size()+1);
    return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << '\n'; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << ' ' << val;
            return *this;
        }
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val;
        return {};
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
                first = false;
            }
            cout << x;
        }
    }
};

int main()
{
    input in;
    output out;

    auto N = in.read<int>();
    auto s = in.read<std::string>();

    if (N % 2) {
        out << "No";
        return 0;
    }
    if (s.substr(0, N / 2) == s.substr(N / 2)) {
        out << "Yes";
    } else {
        out << "No";
    }

    return 0;
}


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

int main(void)
{
    int data_num;			/* Count Data Num */
	int dn;					/* Data Num */
    int *pSortBuff;
	int sn = 0;				/* SortNum */
	int minj;				/* MininumNum */
	int i, j;
	int swap;
    
    /* get "Data Num" */
    scanf("%d", &dn);
     
    pSortBuff = (int *)malloc(sizeof(int) * dn);
	
    /* get Name & time */
    while((scanf("%d", &(pSortBuff[data_num])) != EOF) && data_num < dn)
    {
        data_num++;
    }
    
	
    /* get Data Num equal process num */
    if( data_num == dn )
    {
    	for( i=0; i<dn; i++ )
    	{
    		minj = i;
    		for( j=i; j<dn; j++ )
    		{
    			if( pSortBuff[minj] > pSortBuff[j] ) 
    			{
    				minj = j;
    			}
    		}
    		if(minj != i)
    		{
    			swap = pSortBuff[minj];
    			pSortBuff[minj] = pSortBuff[i];
    			pSortBuff[i] = swap;
    			sn++;
    		}
    	}
    }
    else
    {
        /* error input */
    }
	
	for(i=0; i<dn-1; i++)
	{
		printf("%d ", pSortBuff[i]);
	}
	printf("%d\n%d\n", pSortBuff[dn-1], sn);
	
	free(pSortBuff);
    return 0;
}



Measured memory_bytes: 1780
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
    input! {
        x: usize,
    }
    let mut money = 100;
    let mut ans = 0;

    while money < x {
        money += money / 100;
        ans += 1;
    }

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


Measured memory_bytes: 2204
import scala.io.StdIn.{readInt,readLine}

object Main {

  def main(args:Array[String]) = {
    var n = 0
    while( {n=readInt;n} != 0 ){
      val list = for(i<-1 to n) yield {
        val s = readLine.split(" ")
        (s(0), s(2).toDouble/((s(1).toDouble/100)*(s(1).toDouble/100)))
      }
      println(list.sortWith{(x,y) => Math.abs(22.0-x._2) < Math.abs(22.0-y._2)}.take(1)(0)._1)
    }
  }
}

Measured memory_bytes: 46620
#include<queue>
#include<iostream>
#include<math.h>

using namespace std;

queue<long long int> A;

int main(){
    long long int n,k,key,x;
    cin >> k ;

    int i=0;
    while(i < k){
        if ( i<9 ){
            A.push(i+1);
            x = i+1;
            i++;
            continue;
        }

        key =  A.front();
        if (key % 10 != 0){
            x = 10*key + key % 10 -1;
            A.push(x);
            if ( ++i >= k) break;
        } 

        x = 10*key + key % 10;
        A.push(x);
        if ( ++i >= k) break;

        if (key % 10 != 9){
            x = 10*key + key % 10 +1;
            A.push(x);
            if ( ++i >= k) break;
        }
        A.pop();
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  vector<char>a(s.size());
  for(int i=0;i<s.size();i++){
    a.at(i)='x';
  }
  for(int i=0;i<s.size();i++){
    cout << a.at(i);
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int vis[100001], dp[100001];
vector<int>ar[100001];
int c;
void dfs(int node)
{
	vis[node]=1;
	dp[node]=0;
	for(int i:ar[node])
	{
		if(vis[i]==0)
		dfs(i);
		dp[node]=max(dp[node],1+dp[i]);
	}
}
int main() 
{
	int n,m,x,y;
	cin>>n>>m;
	while(m--)
	{
		cin>>x>>y;
		ar[x].push_back(y);
	}
	for(int i=1;i<=n;i++)
	{
		if(vis[i]==0)
		dfs(i);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	ans=max(dp[i],ans);
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 12612
#include <stdio.h>

// min
int main(void){
  int n = 0;
  int a[101];
  double sum = 0;
  double ans = 0;

  scanf("%d", &n);

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

  //逆数の総和の逆数を求める
  //まず逆数の総和を求める
  
  for(int i = 0; i < n; i++){
    sum += 1.0 / a[i];
  }

  ans = 1.0 / sum;

  printf("%f\n", ans);

  return 0;

}


Measured memory_bytes: 128
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, fractions
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

A=list(map(int,input().split()))
a=b=0
for ai in A:
    if ai==5:
        a+=1
    elif ai==7:
        b+=1
if a==2 and b==1:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 64492
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[3],b;
  cin>>a[0]>>a[1]>>a[2]>>b;
  sort(a,a+3);
  for(int i=0;i<b;i++)a[2]*=2;
  cout<<a[2]+a[1]+a[0]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <set>
#include <map>

using namespace std;

int N;
int d[100];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> d[i];
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < i; j++){
            ans += d[i]*d[j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 888
#include <stdio.h>
 
int main(void){
  int N, i, ans = 0;
  char S[1000000],before_c;
  
  scanf("%d", &N);
  scanf("%s", S);
  
  for(i = 0; i < N; i++){
    if(i == 0 ||before_c != S[i]){
      before_c = S[i];
      ans++;
    }
  }
  
  printf("%d\n", ans);
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mp make_pair
#define S second
#define F first
ll mod=1e9+7;
#define input_from_file  freopen("input.txt", "r", stdin);

int main()
{
  //input_from_file;
  ll n,k,m,u,v;cin>>n>>m;
  vector<vector<char>> vec(n,vector<char>(m,'a'));
  for(ll i=0;i<n;i++){
    for(ll j=0;j<m;j++) cin>>vec[i][j];
  }
  vector<vector<ll>> dp(n,vector<ll>(m,0));
  for(ll i=0;i<n;i++){
    if(vec[i][0]=='.')  dp[i][0]=1;
    else break;
  }
  for(ll i=0;i<m;i++){
    if(vec[0][i]=='.')  dp[0][i]=1;
    else break;
  }
  for(ll i=1;i<n;i++){
    for(ll j=1;j<m;j++){
      if(vec[i][j]=='.')  dp[i][j]=( dp[i-1][j] + dp[i][j-1] ) %mod;
    }
  }
  cout<<dp[n-1][m-1]%mod;
  return 0;

}

Measured memory_bytes: 9088
"use strict";

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }

function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

function main(input) {
  var lines = input.split('\n');

  var _splitNum = splitNum(lines[0]),
      _splitNum2 = _slicedToArray(_splitNum, 3),
      N = _splitNum2[0],
      H = _splitNum2[1],
      W = _splitNum2[2];

  var res = 0;
  var _iteratorNormalCompletion = true;
  var _didIteratorError = false;
  var _iteratorError = undefined;

  try {
    for (var _iterator = lines.slice(1, N + 1)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
      var line = _step.value;

      var _splitNum3 = splitNum(line),
          _splitNum4 = _slicedToArray(_splitNum3, 2),
          h = _splitNum4[0],
          w = _splitNum4[1];

      if (h >= H && w >= W) {
        res++;
      }
    }
  } catch (err) {
    _didIteratorError = true;
    _iteratorError = err;
  } finally {
    try {
      if (!_iteratorNormalCompletion && _iterator.return != null) {
        _iterator.return();
      }
    } finally {
      if (_didIteratorError) {
        throw _iteratorError;
      }
    }
  }

  console.log(res);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function splitNum(line) {
  return line.split(/\s+/).map(function (n) {
    return parseInt(n);
  });
}


Measured memory_bytes: 22332
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;
char a[1005],b[1005];
int n,m;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> a+1 >> b+1; n = strlen(a+1), m = strlen(b+1);
    int ans = 1e9;
    for(int i = 1;i <= n-m+1;i++) {
        int cnt = 0;
        for(int j = i;j < i+m;j++) {
            if(a[j] != b[j-i+1]) cnt++;
        }
        ans = min(ans,cnt);
    }
    cout << ans;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
    int n,m;
    cin>>n>>m;
    vector<int> p(m);
    vector<string> s(m);
    vector<bool> ac(n,false);
    vector<int> wa(n,0);
    for(int i=0; i<m; i++){
        int P;
        cin>>P>>s[i];
        P--;
        p[i]=P;
    }
    int a=0,w=0;
    for(int i=0; i<m; i++){
        if(s[i]=="WA" && !ac[p[i]]) wa[p[i]]++;
        else if(s[i]=="AC" && !ac[p[i]]) ac[p[i]]=true;
    }
    for(int i=0; i<n; i++){
        if(ac[i]){
            a++;
            w+=wa[i];
        }
    }
    cout<<a<<" "<<w<<endl;
}


Measured memory_bytes: 6528
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	int n,temp,temp1;
	char ctemp;
	
	while(scanf("%d",&n)){
		if(n==0)
		break;
		string s,st,st1;
		cin.ignore();
		getline(cin,s);
		ctemp = s[0];
		for(int i=0;i<n;i++){
			for(int j=0;j<s.size();){
				temp = j+1;
				while(s[temp]==ctemp) temp++;
				temp1 = temp-j;
				st1 = to_string(temp1);
				st+=st1;
				st.push_back(ctemp);
				j=temp;
				ctemp=s[j];
			}
			s.clear();
			s+=st;
			st.clear();
			ctemp=s[0];
		}
		printf("%s\n",s.c_str());
	}
}

Measured memory_bytes: 3296
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0
for i in range(n):
    if b[i] <= a[i]:
        ans += b[i]
    else:
        ans += a[i]
        b[i] -= a[i]
        if b[i] <= a[i+1]:
            a[i+1] -= b[i]
            ans += b[i]
        else:
            ans += a[i+1]
            a[i+1] = 0

print(ans)


Measured memory_bytes: 18624
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
const int mx=1e3+10;
const ld inf=1e16;
double x[mx],y[mx],r[mx];
vector<int>g[mx];
vector<ld>w[mx];
ld ds[mx];
struct node{
  int u;
  ld w;
  node(int u,ld w):u(u),w(w){}
  bool operator <(node n)const{
    return w>n.w;
  }
};
void dij(int u){
  fill(ds,ds+mx,inf);
  priority_queue<node>q;
  q.push(node(u,0ll));
  ds[u]=0;
  while(!q.empty()){
    u=q.top().u;
    ld wu=q.top().w;
    q.pop();
    if(ds[u]!=wu)continue;
    for(int i=0;i<int(g[u].size());i++){
      int v=g[u][i];
      ld bet=wu+w[u][i];
      if(bet<ds[v]){
        ds[v]=bet;
        q.push(node(v,bet));
      }
    }
  }
}

int main(){
  int n;
  double xs,ys,xt,yt;
  scanf("%lf %lf %lf %lf %d",&xs,&ys,&xt,&yt,&n);
  for(int i=0;i<n;i++)
    scanf("%lf %lf %lf",x+i,y+i,r+i);  
  int s=n,t=n+1;
  x[s]=xs,y[s]=ys,r[s]=0;
  x[t]=xt,y[t]=yt,r[t]=0;
  for(int i=0;i<n+2;i++){
    for(int j=i+1;j<n+2;j++){
      ld d2=powl(x[i]-x[j],2)+powl(y[i]-y[j],2);
      ld d=sqrtl(d2);
      if(d2>powl(r[i]+r[j],2))d-=r[i]+r[j];      
      else d=0;
      g[i].push_back(j);
      g[j].push_back(i);
      w[i].push_back(d);
      w[j].push_back(d);
    }    
  }
  dij(s);
  cout<<setprecision(15)<<fixed<<ds[t]<<endl;
  return 0;
}


Measured memory_bytes: 29292
using System;

class Program
{
    static void Main()
    {
        var s = Console.ReadLine();
        int a = -1;
        int z = 0;
        for (int i = 0; i < s.Length; i++)
        {
            if (a == -1 && s[i] == 'A') a = i;
            if (s[i] == 'Z') z = i;
        }
        Console.WriteLine(z - a + 1);
    }
}

Measured memory_bytes: 13140
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner Ent = new Scanner(System.in);
        int n =  Ent.nextInt();
        if(n < 1200){
            System.out.println("ABC");
        }else if(n<2800){
            System.out.println("ARC");
        }else{
            System.out.println("AGC");
        }
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const int MOD = 1e9 +7;
const int MAX_N =1<<18;


template<class T>
struct BIT {
    int n;
    vector<T> bit;

    // 各要素の初期値は 0
    BIT(int num) : bit(num+1, 0) { n = num; }

    // a_i += w
    void add(int i, T w) {
        for (int x = i; x <= n; x += x & -x) {
            bit[x] += w;
        }
    }
    // [1, i] の和を計算.
    T sum(int i) {
        T ret = 0;
        for (int x = i; x > 0; x -= x & -x) {
            ret += bit[x];
        }
        return ret;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    int b[n];
    for(int i=0;i<n;i++) b[i]=a[i];
    sort(b,b+n);
    map<int,int> m;
    for(int i=0;i<n;i++) m[b[i]]=i+1;
    BIT<int> bit(n);
    ll ans=0;
    for (int j = 0; j < n; j++) {
        ans += j - bit.sum(m[a[j]]);
        bit.add(m[a[j]], 1);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 14460
def get_count(n,x):
    count = 0
    for i in range(0,n-2):
        for j in range(i+1,n-1):
            for k in range(j+1,n):
                if (i+j+k+3) == x:
                    count += 1
    return count

if __name__ == "__main__":
    while True:
        n,x = map(int,input().split())
        if n==0 and x == 0:
            exit()
        else:
            print(get_count(n,x))


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

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) c.begin(),c.end()
static const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
static const int MOD = (int)(1e9 + 7);

//????????????
class Dice {
private:
	map<char, string> mp;
public:
	//string d = "UFRLBD";
	string d = "RENSWL";
	vector<int> v; //UFRLBD:123456
	Dice() {
		init();
		v.resize(6);
	};
	Dice(vector<int> v) :v(v) {
		init();
	};
	void init(){
		mp[d[0]] = "2354";
		mp[d[1]] = "1463";
		mp[d[2]] = "1265";
		mp[d[3]] = "1562";
		mp[d[4]] = "1364";
		mp[d[5]] = "2453";
	}
	void input() { rep(i, 0, 6) { cin >> v[i]; } }
	void roll(char c) { roll(mp[c]); }
	void roll(string s) {
		int tmp = v[s[0] - '1'];
		rep(i, 1, s.size())v[s[i - 1] - '1'] = v[s[i] - '1'];
		v[s[s.size() - 1] - '1'] = tmp;
	}
	bool operator==(const Dice &D)const { return v == D.v; }
};

signed main() {
	int n; cin >> n;
	vector<Dice> D(n); rep(i, 0, n) { D[i].input(); }
	rep(i, 0, n) {
		rep(j, i + 1, n) {
			rep(k, 0, 30) {
				if (D[i] == D[j]) {
					cout << "No" << endl;
					return 0;
				}
				D[j].roll( D[j].d[rand() % 6] );
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

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

    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if (u == s)
        --a;
    else
        --b;
    cout << a << ' '<<b << endl;

    return 0;
}

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

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

int main()
{
    ll n, q;
    cin >> n >> q;
    vector<vector<ll>> a(2, vector<ll>(n, n - 2));
    ll b[2] = { n - 1, n - 1 };
    ll ans = (n - 2) * (n - 2);
    REP(i, q)
    {
        ll c, d;
        cin >> c >> d;
        c--;
        d--;
        if (d < b[c]) {
            ans -= b[(c + 1) % 2] - 1;
            FOR(j, d + 1, b[c])
            {
                a[c][j] = b[(c + 1) % 2] - 1;
            }
            b[c] = d;
        } else {
            ans -= a[c][d];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 8008
# 2253~
# 解法2259
# 1 素数のリストを作って，そのリストにおいてXより大きくなる最初の要素のインデックスを計算する
# 2 Xから増やしていって，素数かどうかの判定をする.最初に素数となるものを出力する.
# 1のほうがわかりやすいよね．素数のリストを作って，ソートする（勝手になっている）．残った素数に対してbisectで要素を見つけ出す
# 2313. ギブです．エラトステネスの古いがかけない．Pから減らしていくがpの要素を減らすので
# generatorとしてPを使うと途中でPの形が変わるのが問題になると思う

# 実装．エラトステネスの篩を実装すればいいことはわかるけどめんどくさい．
X=int(input())

MAX = X+10000
P = [2]
Rest = set(list(range(3,MAX,2)))
import math
MAX_ind = int(math.sqrt(X)) + 1

for i in range(3,MAX_ind+1,2):
    if i in Rest:
        P.append(i)
        for j in range(i,MAX,i):
            if j in Rest:
                Rest.remove(j)
# 残ったRestとPを合体させて，
Rest = list(Rest)
Rest.sort()

P = P + Rest

import bisect
# すでにsortされているので，それによってうまくいく.
ind = bisect.bisect_left(P,X)
print(P[ind])



Measured memory_bytes: 7792
a,b,n,m[17][17],x,y,DP[17][17];
main(){
	for(;scanf("%d%d%d",&a,&b,&n),a;){
		memset(m,0,sizeof(m));
		for(;n--;){
			scanf("%d%d",&x,&y);
			m[x][y]=1;
		}
		for(x=1;x<=a;x++){
			for(y=1;y<=b;y++){
				if(m[x][y])
					DP[x][y]=0;
				else if(x==1&&y==1)
					DP[x][y]=1;
				else
					DP[x][y]=(x>1?DP[x-1][y]:0)+(y>1?DP[x][y-1]:0);
			}
		}
		printf("%d\n",DP[a][b]);
	}
	exit(0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	long long int h;
	cin >> h;
	h = h | (h >> 1);
	h = h | (h >> 2);
	h = h | (h >> 4);
	h = h | (h >> 8);
	h = h | (h >> 16);
	h = h | (h >> 32);
	cout << h << endl;
	return 0;
}

Measured memory_bytes: 256
// https://onlinejudge.u-aizu.ac.jp/courses/lesson/8/ITP2/1/ITP2_1_C
#include <iostream>
#include <list>

int main()
{
    std::list<int> List;

    int q, m, x, d;
    auto itr = List.end();

    std::cin >> q;
    for (int i = 0; i < q; i++)
    {
        std::cin >> m;
        if (m == 0)
        {
            std::cin >> x;
            itr = List.insert(itr, x);
        }
        else if (m == 1)
        {
            std::cin >> d;
            itr = next(itr, d);
        }
        else if (m == 2)
        {
            itr = List.erase(itr);
        }

        // std::cout << m << " " << x << " " << d << std::endl;
        // for (auto &x : List)
        // {
        //     std::cout << x;
        // }
        // std::cout << " " << *itr << std::endl;
    }

    for (auto &x : List)
    {
        std::cout << x << std::endl;
    }

    return 0;
}



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

int main(){
  int N; cin >> N;
  vector<int> MY(N);
  int MAX=0;
  int now=0;
  for(int i=0;i<N;i++){
    cin >> MY.at(i);
  }
  for(int i=0;i<N;i++){
    if(MAX<MY.at(i)){
      MAX=MY.at(i);
      now=i;
    }
  }
  sort(MY.begin(), MY.end());
  for(int i=0;i<N;i++){
    if(i==now){
      cout << MY.at(N-2) << endl;
    }
    else cout << MY.at(N-1) << endl;
  }
}




Measured memory_bytes: 2432
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
s = rr()
max_cnt = 0
for i in range(1, n-1):
  x = set(s[:i])
  y = set(s[i:])
  max_cnt = max(len(x & y), max_cnt)
print(max_cnt)















Measured memory_bytes: 27140
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}

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

    VI wpfront(n+2);
    VI wpback(n+2);
    VI wp;
    rep(i,s.length()) {
        if(s[i] == 'o') {
            wp.push_back(i+1);
        }
    }

    int cnt = 0;
    int prev = 0;
    rep(i,s.length()) {
        if(s[i]=='o' && i>=prev) {
            cnt++;
            wpfront[i+1] = cnt;
            prev = i+c+1;
        } else {
            wpfront[i+1] = cnt;
        }
    }
    prev = s.length();
    cnt = 0;
    for(int i = s.length()-1;i>=0;i--) {
        if(s[i] == 'o' && i <= prev) {
            cnt++;
            wpback[i+1] = cnt;
            prev = i - c -1;
        } else {
            wpback[i+1] = cnt;
        }
    }

    VI ans;
    for(auto i:wp) {
        if(wpfront[i-1] + wpback[i+1] < k) {
            ans.push_back(i);
        }
    }

    for(auto i:ans) {
        cout << i << endl;
    }

}


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

using namespace std;

const int maxn = 112345;
int main()
{

    long long n;
    cin>>n;
    for(long long a=n;a>0;a--)
    {
        for(long long b=1;b<=3500;b++)
        {
            if(4*a*b-a*n-b*n<=0)continue;
            if(n*a*b%(4*a*b-a*n-b*n)==0)
            {
                long long c=n*a*b/(4*a*b-a*n-b*n);
                cout<<a<<' '<<b<<' '<<c<<endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <functional>
#include <set>


using namespace std;

int main(){
    int N, max = 0, ans=1;
    cin >> N;
    set<int> mochis;
    for(int i=0;i<N;++i){
        int mochi;
        cin >> mochi;
        mochis.insert(mochi);
        if(mochi > max) max = mochi;
    }
    auto itr = mochis.end();
    int layer = *itr;
    //cout << layer << endl;
    do{
        itr--;
        if(layer > *itr) ++ans;
        layer = *itr;
        //cout << layer << endl;
    }while(itr != mochis.begin());
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>
int main()
{
    int k;
    char s[100],i=0;
    gets(s);
    k=strlen(s);
    printf("%c",s[0]-32);
   for(i;i<k;i++)
   {
     if(s[i]==' ')
      printf("%c",s[i+1]-32);
   }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#define int long long

using namespace std;

int N;

signed main()
{
    cin >> N;

    if (N % 1000 == 0)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << 1000 - N % 1000 << endl;
    }
}

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

int main() {
  int n;
  cin >> n;
  string answer = "No";
  for (int i = 0; i <= n / 4; i++) {//cake4ドル * i個
    if ((n - 4 * i) % 7 == 0) {
      answer = "Yes";
      break;
    }
  }
  cout << answer;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define x first
#define y second
using namespace std;
int main()
{
	string s;
	cin>>s;
	for (int i=0;i<s.size();i++)
	{
		if (s[i]=='1') cout<<9;
		else if (s[i]=='9') cout<<1;
	}
    return 0;
}

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

int main(){
  int32_t N;
  cin >> N;
  vector<int64_t> vec(N+1);
  vec.at(0) = 2LL;
  vec.at(1) = 1LL;
  for(int32_t i = 2; i <= N; i++){
    vec.at(i) = vec.at(i-1) + vec.at(i-2);
  }
  cout << vec.at(N) << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}   

void solve(){
    int n;
    cin >> n;
    vector<int>v(n+5);
    FOR(i,1,n+1)cin >> v[i];
    sort(v.begin()+1,v.begin()+n+1);
    int sum = v[n],totake = n-2;
    RFOR(i,n-1,0){
        int take = min(totake,2LL);
        sum += take*v[i];
        totake -= take;
    }
    cout << sum << "\n";
}

signed main()
{
    showoff;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...#include <bits/stdc++.h>
 


Measured memory_bytes: 4824
#include <cstdio>
#include <vector>
#include <set>
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 200'009;

vector<int> g[N];
int pa[N];

void dfs0(int x) {
  for (int y : g[x]) {
    if (y == pa[x]) {
      continue;
    }
    pa[y] = x;
    dfs0(y);
  }
}

int p[N];
set<int> s[N];

void merge(int x, int y) {
  if ((int)s[p[y]].size() > (int)s[p[x]].size()) {
    swap(p[x], p[y]);
  }
  for (int e : s[p[y]]) {
    s[p[x]].insert(e);
  }
}

void del(int x, set<int> &cur) {
  cur.erase(-x);
  for (int y : g[x]) {
    if (y == pa[x] || cur.count(-y) == 0) {
      continue;
    }
    del(y, cur);
  }
}

int f[N][2];

void dfs1(int x, int mx) {
  for (int y : g[x]) {
    if (y == pa[x]) {
      continue;
    }
    dfs1(y, max(mx, x));
    while (!s[p[y]].empty()) {
      int ver = -(*s[p[y]].begin());
      if (ver < mx) {
        break;
      }
      del(ver, s[p[y]]);
    }
    f[y][1] = (int)s[p[y]].size();
  }
  s[p[x]].insert(-x);
  for (int y : g[x]) {
    if (y == pa[x]) {
      continue;
    }
    merge(x, y);
  }
  f[x][0] = (int)s[p[x]].size();
}

int ans[N];

void dfs2(int x, int v) {
  ans[x] = f[x][0] + v;
  for (int y : g[x]) {
    if (y == pa[x]) {
      continue;
    }
    dfs2(y, v + f[x][0] - f[y][1]);
  }
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    g[i].clear();
  }
  for (int i = 0; i < n - 1; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    --x;
    --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  pa[0] = 0;
  dfs0(0);
  for (int i = 0; i < n; ++i) {
    s[i].clear();
    p[i] = i;
  }
  dfs1(0, -1);
  dfs2(0, 0);
  for (int i = 1; i < n; ++i) {
    if (i > 1) {
      putchar(' ');
    }
    printf("%d", ans[i] - 1);
  }
  putchar('\n');
}


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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int N; cin >> N;
	vi res(N+1,0);
	forn(x,1,100+1){
		forn(y,1,100+1){
			forn(z,1,100+1){
				int tmp = x*x+y*y+z*z+x*y+y*z+z*x;
				if(tmp <= N)res[tmp]++;
			}
		}
	}
	forn(i,1,N+1)cout << res[i] << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


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

int main() {
    long int N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;

    long int min_through, max_wait;

    min_through = min(A, min(B, min(C, min(D, E))));

    long int five = 5;

    if ( min_through == 1 ) {
      max_wait = N / min_through + five - 1;
    } else {
      max_wait = N / min_through + five;
    }

    // 出力
    cout << max_wait << endl;
}

Measured memory_bytes: 256