akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
    int a[1000];
    int mn = 1000;
    cin >> a[0];
    for (int i=0; i<1000; ++i){
        if (a[i]%2==0) a[i+1]=a[i]/2;
        else a[i+1]=3*a[i]+1;
    }
    for (int i=0; i<1000; ++i){
        for (int j=i+1; j<1000; ++j){
            if (a[j]==a[i]){
                 mn = min(j,mn);
                 break;
            }
        } 
    }
    cout << mn+1 << endl;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair< ll, ll > P;
typedef pair< int, P > PP;

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

int f(int m, int d) {
    if(m == 0) return 0;
    int res = 0;
    res += f(m / d, d) + m % d;
    return res;
}

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

    int n;
    cin >> n;
    int ans = INF;
    REP(i, n + 1) {
        ans = min(ans, f(i, 6) + f(n - i, 9));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define Ma7moud_7amdy                 \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define Open_Sesame Open()
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define clr(arr, x) memset(arr, x, sizeof arr)
#define endl "\n"
#define Accepted 0
#define watch(x) cout << #x << " = " << x << endl;
#define RT(x) return cout << (x), 0;
#define sc(a) scanf("%d", &a)
#define pr(a) printf("%d", a)
#define scll(x) scanf("%I64d", &x)
#define prll(x) printf("%I64d", x)
#define scan(s) scanf("%[^\n]%*c", &s)
#define print(s) printf("%s", s.c_str()); // print string
#define sz(v) v.size()
typedef long long ll;
typedef vector<int> vi;
const int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int Mx = INT_MAX;
const int Mn = INT_MIN;
const ll MX = LLONG_MAX;
const ll MN = LLONG_MIN;
const double PI = acos(-1.0);
void Open()
{
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
const double EPS = -1e-2;
const ll mod = ll(1e9 + 7);
const int N = 2000 + 5;

//“Nobody but you have to believe in your dreams to make them a reality.” ― Germany Kent


int main() {

	Ma7moud_7amdy;
	//Open_Sesame;
	string s;
	cin >> s;
	if (s[3] == s[2] && s[4] == s[5])RT("Yes");
	cout << "No";
}

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

int main() {
    double N,x1,x2,y1,y2,total=0,c=0;
    cin >> N;
    vector<pair<int,int>> pos(N);
    vector<int> v(N);
    double kyori;
    for(int i=0;i<N;i++){
        cin >> pos.at(i).first >> pos.at(i).second;
        v.at(i)=i;
    }

    do{
        for(int i=0;i<v.size()-1;i++){
            x1=pos.at(v.at(i)).first;
            y1=pos.at(v.at(i)).second;
            x2=pos.at(v.at(i+1)).first;
            y2=pos.at(v.at(i+1)).second;
            kyori = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
            total+=kyori;
        }
        c++;
    }while (next_permutation(v.begin(), v.end()));
    cout << fixed << setprecision(10);
    cout << total/c<<endl;
    
}

Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pll, int> plp;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const bool debug = 0;
//--------------------------------//

int N, K;

int main() {
	cin >> N >> K;
	int ans = INF;
	REP(i, 1<<N) {
		ll now = 1;
		REP(j, N) {
			if (i >> j & 1) now = now * 2;
			else now += K;
		}
		chmin(ans, now);
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int A2 = A, B2 = B, C2 = C;
    for(int i = 0; i <= K; i++){
        for(int j = 0; j <= K - i; j++){
            for(int k = 0; k <= K - i - j; k++){
                A2 *= pow(2,i);
                B2 *= pow(2,j);
                C2 *= pow(2,k);
                if(B2 > A2 && C2 > B2){
                    cout << "Yes" << endl;
                    return 0;
                }
                A2 = A;
                B2 = B;
                C2 = C;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 4092
#include<bits/stdc++.h>
using namespace std;
#define fast {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
typedef long long int ll;
typedef string S;
#define M 1e18
#define AS 1000005
#define in(x)  cin>>x
#define o(x)  cout<<x
#define sp cout<<' '
#define nw cout<<endl
#define rt return
#define fr(i,a,n) for(ll i=a;i<=n;i++)
#define frm(i,a,n) for(ll i=n;i>=a;i--)
#define P pair<ll,ll>
#define vc vector<ll>
#define pb push_back
#define MP map<ll,ll>
bool sortin(const pair<ll,ll> &e,const pair<ll,ll> &f){return (e.first<f.first);}
bool POT(ll x){return x && (!(x&(x-1)));}
ll i,j,k,l,m,n,p,q,r,a,b,c,x,y,z,ts,mn=1e18,mod=1e9+7;
ll ar[AS],br[AS],xr[AS],tem[AS];
ll board[5000][5000];
int main()
{
    fast;
    int dx[4]={0,0,1,-1};
    int dy[4]={1,-1,0,0};
    in(n>>m);
    in(x>>y>>p>>q);
    x--;y--;p--;q--;
    S s[n+10];
    fr(i,0,n-1)in(s[i]);
    fr(i,0,n)fr(j,0,m)board[i][j]=-1;
    deque<P>dq;
    dq.push_back({x,y});dq.push_back({mn,mn});
    while(dq.size()>=2)
    {
        x=dq.front().first;y=dq.front().second;
        dq.pop_front();
        if(x==mn)
        {
            c++;
            dq.push_back({mn,mn});continue;
        }
        if(x<0 or y<0 or x>=n or y>=m or board[x][y]!=-1 or s[x][y]=='#')continue;
        board[x][y]=c;
        fr(i,0,3)
			dq.push_front({x+dx[i],y+dy[i]});
        fr(i,x-2,x+2)
        {
            fr(j,y-2,y+2)
            {
                dq.push_back({i,j});
            }
        }
    }
    o(board[p][q]);
}


Measured memory_bytes: 20652
#include <iostream>
#include<string>
#include<map>
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include <time.h>
#include<cmath>
#include<limits.h>
#include<unordered_map>
#include <set>
#include <iostream>     // std::cout, std::fixed
#include <iomanip>
#define PI 3.14159265
using namespace std;
const int N = 1e6 + 1;


int main() {
    int n; cin >> n;
    int x = n % 10;
    if (x == 3) {
        cout << "bon";
    }
    else if (x == 0 || x == 1 || x == 6 || x == 8) {
        cout << "pon";
    }
    else {
        cout << "hon";
    }
}



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

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long;
using pll = pair<ll, ll>;

int main()
{
    ll N;
    cin >> N;

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

    ll ans = 0;

    rep (i, N - 1)
    {
        if (A[i] <= A[i + 1]) { continue; }

        const auto d = A[i] - A[i + 1];
        ans += d;

        A[i + 1] += d;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4836
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var s = Read();
            var ans = "";
            for (int i = 0; i < s.Length; i++)
            {
                var x = ABC.BinarySearch(s[i]);
                ans += ABC[(x + n) % 26];
            }
            WriteLine(ans);
        }
        //ABC
        public static List<char> ABC = new List<char> { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 37076
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int A = scanner.nextInt();
    if ( A < 1000) {
      System.out.println("ABC");
    } else {
      System.out.println("ABD");
    }
  }
}


Measured memory_bytes: 22732
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

vector<ll>lay;
vector<ll>p;
ll n, k;

ll fun(ll n, ll x){
	if (n == 0)return (x <= 0 ? 0 : 1);
	if (x <= lay[n - 1] + 1)return fun(n - 1, x - 1);
	return p[n - 1] + 1 + fun(n - 1, x - 2 - lay[n - 1]);
	
}

int main(){
	cin >> n >> k;
	lay.push_back(1), p.push_back(1);
	for (int i = 1; i <= n; i++){
		ll l = lay[i - 1] * 2 + 3,pp = p[i - 1] * 2 + 1;
		lay.push_back(l);
		p.push_back(pp);
	}
	cout << fun(n, k) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_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(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

vector<vector<int>> G;
vector<vector<int>> dp;

void dfs(int cur, int dist, int ind, int par = -1){
//    cout << cur << "," << dist << "," <<  ind << "," << par << endl;
    if(dp[cur][dist] == inf){
        rep(i, dist + 1){
            dp[cur][i] = min(dp[cur][i], ind);
        }
        for(int v: G[cur]){
            if(par != v){
                dfs(v, dist - 1, ind, cur);
            }
        }
    }
}

struct query{
    int v, d, c;
};

template <typename T> inline void voutput(T &v){
    rep(i, v.size()){
        if (i) cout << " " << v[i];
        else cout << v[i];
    }
    cout << endl;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, M;
    cin >> N >> M;
    G.resize(N);
    dp.assign(N, vector<int>(11, inf));
    rep(i, M){
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    int Q;
    cin >> Q;
    vector<query> R(Q);
    rep(i, Q){
        query q;
        cin >> q.v >> q.d >> q.c;
        q.v--;
        R[i] = q;
    }
    
    reverse(all(R));
    
    rep(i, Q){
        dfs(R[i].v, R[i].d, i);
    }
    
    
    
    rep(i, N){
        if(dp[i][0] == inf){
            output(0);
        }
        else{
            output(R[dp[i][0]].c);
        }
    }
    
    return 0;
}


Measured memory_bytes: 16248
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<62);

int main() {
    cin>>N;
    ll res = 0;
    for(ll i = 2; i * i <= N; ++i){
        ll temp = 0;
        while(N%i == 0){
            ++temp;
            N /= i;
        }
        ll plus = 0, minus = 1;
        while(temp >= minus){
            ++plus;
            temp -= minus;
            ++minus;
        }
        res += plus;
    }
    if(N != 1) ++res;
    cout<<res<<endl;
}

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

const int INI = 0;
int n, m;

int main(){
  cin >> n >> m;
  int dig[10];
  rep(i, 10) dig[i] = INI;
  bool flag = false;
  bool flag2 = false;
  rep(i, m){
    int s, c; cin >> s >> c;
    if(dig[s] != INI && dig[s] != c){
      flag = true;
      break;
    }
    if(s == 1 && c == 0){
      if(n == 1){
        flag2 = true;
      }else{
        flag = true;
      }
      break;
    }
    dig[s] = c;
  }
  
  int res = 0;
  for(int i = 1; i <= n; i++){
    res *= 10;
    res += dig[i];
    cerr << res << endl;
  }
  if(dig[1] == INI){
      res += pow(10, n - 1);
  }
  if(flag){
    res = -1;
  }
  if(flag2 || n == 1 && m == 0){
    res = 0;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

N = int(input())
A = list(map(int,input().split()))


if A.count(1) == 0:
  print(-1)
  sys.exit()
else:
  
  cnt = 0
  for a in range(len(A)):
    if A[a] == cnt+1:
      cnt += 1
  print(len(A)-cnt)



Measured memory_bytes: 32368
package main

import "fmt"
//import "math"

func main(){
	var N int
	var A [200000]float64
	var maxtmp, max float64
	var maxIndex int

	fmt.Scan(&N)
	for i:= 0 ; i < N ; i++ {
		fmt.Scan(&A[i])
	}
	
	maxtmp = 0
	for i := 0 ; i < N ; i++ {
		if maxtmp < A[i]{
			maxtmp = A[i]
			maxIndex = i
		}
	}
	max = maxtmp
	maxtmp = 0
	if maxIndex == 0 {
		for j := 1 ; j < N ; j++{
			if maxtmp < A[j] {
				maxtmp = A[j]
			}
		}
	}else if maxIndex == N - 1{
		for j := 0 ; j < N - 1 ; j++{
			if maxtmp < A[j] {
				maxtmp = A[j]
			}
		}
	}else {
		for j := 0 ; j < maxIndex - 1 ; j++{
			if maxtmp < A[j]{
				maxtmp = A[j]
			}
		}
		for j := maxIndex + 1 ; j < N ; j++{
			if maxtmp < A[j] {
				maxtmp = A[j]
			}
		}
	}
	for i := 0 ; i < N ; i++ {
		if i == maxIndex {
			fmt.Println(maxtmp)
		}else{
			fmt.Println(max)
		}
	}

		/*if i == 0 {
			for j := 1 ; j < N ;j++{
				if maxtmp < A[j]{
					maxtmp = A[j]
				}
			}
		}else if i == N - 1{
			for j := 0 ; j < N - 1 ; j++{
				if maxtmp < A[j]{
					maxtmp = A[j]
				}
			}
		}else{
			for j := 0 ; j < i - 1 ; j++{
				if maxtmp < A[j]{
					maxtmp = A[j]
				}
			}
			for j := i + 1 ; j < N ; j++{
				if maxtmp < A[j] {
					maxtmp = A[j]
				}
			}
		}*/

		
	
}

Measured memory_bytes: 6400
#include <iostream>
#include<cstdio>
#include<deque>
#include<string>
#include<cstdlib>
#include<algorithm>
using namespace std;
string s;
int op,k,q;
int cnt=0;
char c;
int main()
{
    cin >> s;
    scanf("%d",&q);
    while (q--)
    {
        scanf("%d",&op);
        if (op==1)
            cnt++;
        else
        {
            scanf("%d %c",&k,&c);
            if (k==1&&cnt%2||k==2&&cnt%2==0)
              s.insert(s.end(), c);
            else
              s.insert(s.begin(), c);

        }
    }
    if (cnt%2)
        reverse(s.begin(), s.end());
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(in) in.begin(), in.end()
#define FIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<ll, ll> pll;

int main(){
    FIO;
    ll n;
    cin >> n;
    ll arr[n];
    for(ll i = 0 ; i < n ; i++){
        cin >> arr[i];
    }
    sort(arr, arr + n);
    if(n%2){
        cout << 0 << endl;
      	return 0;
    }
    ll index1 = n/2-1, index2 = n/2;
    ll tmp = arr[index2] - arr[index1];
    cout << tmp << endl;
    return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>

#define DigFor for(int i = 0; i < Dig; i++) 

using namespace std;

int main()
{
	int InpNum = 0, l = 0;


	while(cin >> InpNum >> l)
	{
		int TempNum1[10] = { 0 };
		int TempNum3[25] = { 0 };

		int tmp1 = 0, tmp2 = 0, tmp3 = 0;


		if(InpNum == 0 && l ==0){break;}

		tmp1 = InpNum;
		TempNum3[0] = InpNum;

		for(int i = 0; i < 10; i++)
		{
			tmp2 = (int)(tmp1 / 10) * 10;
			tmp3 = tmp1 - tmp2;

			TempNum1[i] = tmp3;

			tmp1 =(int)(tmp1 / 10);
			if(tmp1 == 0){break;} 
		}


		for(int j=0; j <= 20; j++)
		{

			int TempNum2[10] = { 0 };
			int n = 0;


			sort(TempNum1, TempNum1 + l);

			for(int i= l; i > 0; i--)
			{
				TempNum2[i] =  TempNum2[i] + TempNum1[n] - TempNum1[i - 1];

				if(TempNum2[i] < 0)
				{
					TempNum2[i] = TempNum2[i] + 10;
					TempNum2[i-1] = TempNum2[i-1] - 1;
				}

				n = n + 1;
			}

			for(int i=0; i<l; i++)
			{
				int h = 1;
				TempNum1[i] = TempNum2[i+1];
				TempNum3[j+1] = TempNum3[j+1] + TempNum2[i+1] * (int)pow(10.0, (double)(l - i - 1));
			}
		}

		int cnt = 0;

		for(int j=0; j<=20; j++)
		{
			if(cnt == 1){break;}

			for(int i=0; i<=20; i++)
			{
				if(i == j){}
				else
				{
					if(TempNum3[j] == TempNum3[i])
					{
						printf("%d %d %d\n", j, TempNum3[i], i-j);
						cnt = cnt + 1;
						break;
					}
				}
			}
		}
	}
     
    return 0;
}

Measured memory_bytes: 1204
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def POW(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x
    elif y % 2 == 0:
        return POW(x, y // 2) ** 2 % MOD
    else:
        return POW(x, y // 2) ** 2 * x % MOD
def mod_factorial(x, y): return x * POW(y, MOD - 2) % MOD
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from collections import Counter

def main():
    N = II()
    S = SI()
    b, w = 0, 0
    w = S.count('.')
    ans = w
    for s in S:
        if s == '.':
            w -= 1
        else:
            b += 1
        if w + b < ans:
            ans = w + b
    return ans

print(main())

Measured memory_bytes: 3884
// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back

int main() {
    
    // 1. 入力情報取得.
    int N, M;
    scanf("%d %d", &N, &M);
    vvi G(N);
    rep(i, M){
        int a, b;
        scanf("%d %d", &a, &b);
        a--, b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    
    // 2. 経路探索.
    // -> 頂点番号が, 1桁である場合の探索(※2桁以上は, 成立しない)
    int ans = 0;
    function<void(int, string, int)> dfs = [&](int s, string route, int N) {
        // 2-1. 終了条件.
        if(route.size() == N){
            ans++;
            return;
        }
        
        // 2-2. 次の頂点へ.
        int l = route.size();
        for(auto &u : G[s]){
            // すでに訪問済みか確認.
            bool ok = true;
            rep(i, l) if((route[i] - '0') == u) ok = false;
            
            // 未訪問の場合.
            if(!ok) continue;
            string nr = route + to_string(u);
            dfs(u, nr, N);
        }
    };
    dfs(0, "0", N);
    
    // 3. 出力.
    printf("%d\n", ans);
    return 0;
    
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

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


int main(){
    ll a, b, c, d; cin >> a >> b >> c >> d;
    ll ans=max(a*c, max(a*d, max(b*c, b*d)));
    cout << ans << endl;
    return 0;
}

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

const long long MOD = 1000000007;
const long long MAX = 2000000;

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

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



int main() {
	int N;
	cin>>N;
	if(N>=30){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}


}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,k,p[5050],c[5050];
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>p[i];
	} 
	for(int i=1;i<=n;i++)
	{
		cin>>c[i];
	}
	int ans=-1e18;
	vector<int> v;
	for(int i=1;i<=n;i++)
	{
		v.clear();
		int now=i;
		while(1)
		{
			v.push_back(c[now]);
			now=p[now];
			if(now==i)
			{
				break;
			}
		}
		int sum=0;
		for(int j=0;j<v.size();j++)
		{
			sum+=v[j];
		}
		int pres=0;
		for(int j=1;j<=v.size();j++)
		{
			if(j>k)
			{
				break;
			}
			pres+=v[j-1];
			int tmp=pres+(k-j)/v.size()*max(sum,0ll);
			ans=max(ans,tmp);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
int V,E;
int index;
vector< vector<int> > A;
vector<int> c;
stack<int> f;
vector< vector<int> > At;
vector<int> ct;
vector<int> SCC;

void dfsVisit(int u) {
    c[u] = 1;
    for(int i=0; i<A[u].size(); i++) {
        int v = A[u][i];
        if(c[v] == 0) dfsVisit(v);
    }
    f.push(u);
}

void dfsVisit2(int u) {
    ct[u] = 1;
    SCC[u] = index;
    for(int i=0; i<At[u].size(); i++) {
        int v = At[u][i];
        if(ct[v] == 0) dfsVisit2(v);
    }
}

int main() {
    cin >> V >> E;
    A.resize(V);
    c.resize(V);
    At.resize(V);
    ct.resize(V);
    SCC.resize(V);

    for(int i=0; i<E; i++) {
        int s,t;
        cin >> s >> t;
        A[s].push_back(t);
    }
    
    for(int i=0; i<V; i++) c[i] = 0;
    for(int i=0; i<V; i++) {
        if(c[i] == 0) dfsVisit(i);
    }

    for(int i=0; i<V; i++) {
        for(int j=0; j<A[i].size(); j++) {
            At[A[i][j]].push_back(i);
        }
    }

    for(int i=0; i<V; i++) ct[i] = 0;
    index = 0;
    while(!(f.empty())) {
        int u = f.top();
        f.pop();
        if(ct[u] == 0) {
            dfsVisit2(u);
            index++;
        }
    }

    int Q;
    cin >> Q;
    for(int i=0; i<Q; i++) {
        int u,v;
        cin >> u >> v;
        cout << (SCC[u] == SCC[v]) << endl;
    }
    return 0;
}


Measured memory_bytes: 4692
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define N 100000
int a[N];
signed main()
{
    int test=1;
    //cin>>test;
    while(test--){
      int n;
      cin>>n;
      int b,s=0;
      for(int i=0;i<n;i++){
        cin>>b;
        a[b]++;
        s+=b;
      }
      int q,c,bc,cc;
      cin>>q;
      for(int i=0;i<q;i++){
        cin>>b>>c;
        bc=a[b];
        s=s-bc*b+bc*c;
        a[c]+=bc;
        a[b]-=bc;
        cout<<s<<"\n";
      }

      
    }
    

    return 0;
}


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

int main() {
  int n, u, v;
  vector<int> start(2);
  cin >> n >> start[0] >> start[1];
  start[0]--;
  start[1]--;
  vector<vector<int>> g(n, vector<int>());
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  vector<vector<int>> dist(2, vector<int>(n, -1));
  for (int i = 0; i < 2; i++) {
    stack<pair<int, int>> st;
    dist[i][start[i]] = 0;
    st.push(make_pair(start[i], 0));
    while (!st.empty()) {
      int now, d;  // いまいる所, そこまでの距離
      tie(now, d) = st.top();
      st.pop();
      for (auto next : g[now]) {
        if (dist[i][next] == -1) {
          dist[i][next] = d + 1;
          st.push(make_pair(next, d + 1));
        }
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (dist[0][i] < dist[1][i]) ans = max(ans, dist[1][i] - 1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 7040
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	int n, a[3000],sum =0;cin >> n;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	cout << sum - n << endl;
}

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

using namespace std;
using vi = vector<int>;
vi X;
int n;
vector<vi> C;
int used[207];
int S;
bool isprime(int n) {
	if (n <= 2)return false;
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return true;
}
bool dfs(int v) {
	used[v] = true;
	if (v == S + 1) return true;
	for (int i = 0; i < S + 2; i++) {
		if (!used[i] && C[v][i] > 0) {
			if (dfs(i)) {
				C[v][i]--;
				C[i][v]++;
				return true;
			}
		}
	}
	return false;
}
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (!X.empty() && X.back() == x) {
			X.pop_back();
			X.push_back(x + 1);
		}
		else {
			X.push_back(x);
			X.push_back(x + 1);
		}
	}
	int E = 0;
	int O = 0;
	for (int x : X) {
		if (x % 2 == 0) {
			E++;
		}
		else {
			O++;
		}
	}
	S = X.size();
	C.resize(S+2,vi(S+2,0));
	for (int i = 0; i < S; i++) {
		if (X[i] % 2 == 0) {
			C[S][i] = 1;
		}
		else {
			C[i][S + 1] = 1;
		}
	}
	for (int i = 0; i < S; i++) {
		for (int j = i; j < S; j++) {
			if (isprime(abs(X[i] - X[j]))) {
				int a = i;
				int b = j;
				if (X[b] % 2 == 0)swap(a, b);
				C[a][b] = 1;
			}
		}
	}
	int ans = 0;
	while (dfs(S)) {
		memset(used, 0, sizeof(used));
		ans++;
	}
	if ((E - ans) % 2 == 0) {
		cout << ans + (E - ans + O - ans) << endl;
	}
	else {
		cout << ans + (E - ans - 1 + O - ans - 1) + 3 << endl;
	}
}

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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
const double PI = acos(-1.0);

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

ll a[maxn];

void solve() {
    string s;
    cin >> s;
    if (s == "ABC") cout << "ARC\n";
    else cout << "ABC\n";
}

int main() {
	header();
	solve();
	return 0;
}

Measured memory_bytes: 3652
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

def main():
    N = ii()
    B = li()

    '''
    flag = [0]*N
    l = N
    i = ind = N-1
    while True:
        if S[ind] == i:
            flag[ind] = 0

        while flag[i]:
            i -= 1
        ind = i
    '''
    ans = []
    for i in range(N):
        flag = 1
        for j in reversed(range(N-i)):
            if B[j] == j+1:
                a = B.pop(j)
                ans.append(a)
                flag = 0
                break
        if flag:
            print('-1')
            exit()

    for i in reversed(range(N)):
        print(ans[i])

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func main() {
	var ta, th int
	var aa, ah int
	fmt.Scan(&th, &ta, &ah, &aa)
	for i := 0;; i++ {
		ah -= ta
		if th <= 0 {
			fmt.Println("No")
			return
		}
		th -= aa
		if ah <= 0 {
			fmt.Println("Yes")
			return
		}
	}
}


Measured memory_bytes: 1752
n=int(input())
x=[0]
x.extend(list(map(int, input().split())))
x.extend([0])
cst=0
#print(x)
for i in range(1,n+2):
  cst+=abs(x[i]-x[i-1])
for i in range(1,n+1):
  print(cst-abs(x[i]-x[i-1])-abs(x[i]-x[i+1])+abs(x[i-1]-x[i+1]))


Measured memory_bytes: 85900
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define ill long long
#define fcout cout << fixed << setprecision(10)
using namespace std;

int main() {
  int x;
  cin >> x;
  if(x >= 1800) cout << 1;
  else if(x >= 1600) cout << 2;
  else if(x >= 1400) cout << 3;
  else if(x >= 1200) cout << 4;
  else if(x >= 1000) cout << 5;
  else if(x >= 800) cout << 6;
  else if(x >= 600) cout << 7;
  else cout << 8;
}


Measured memory_bytes: 3632
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>

using namespace std;

#define LINE DEBUG{ printf("LINE : %d\n", __LINE__); }
#define DEBUG if(false)

using ll = long long;
template<class T> using vec = vector<T>;

const int MOD = 1000000007;

int main(){
  int N, K;
  cin >> N >> K;
  vec<int> p(N);
  for(int i = 0; i < N; i++){
    cin >> p[i];
  }
  sort(p.begin(), p.end());
  int sum = 0;
  for(int i = 0; i < K; i++){
    sum += p[i];
  }
  cout << sum << endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  vector<int> a(n);
  for (int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  
  int now = 0, ans = 0;
  
  while (1){
    if (now == 1){
      cout << ans << endl;
      break;
    }
    if (ans > n){
      cout << "-1" << endl;
      break;
    }
    ans++;
    now = a.at(now) - 1;
  } 
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define speed                                                                  \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define oprecision                                                             \
  cout.precision(30);                                                          \
  cerr.precision(7);
#define bb bool
#define ii int
#define ll long long
#define ff float
#define dd double
#define cc char
#define ss string
#define forn(sz) for (int i = 1; i <= sz; i++)
#define forni(i, sz) for (int i = 1; i <= sz; i++)
#define fornid(i, m, sz) for (int i = m; i <= sz; i++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vii vector<ii>
#define vii64 vector<ll>
#define vb vector<bb>
using namespace std;
ff arr[10005], ans;
ii sz;
ii main() {
  speed;
  oprecision;
  /*#ifndef ONLINE_JUDGE
    freopen("outd.txt", "rt", stdin);
  #endif*/
  // code
  cin >> sz;
  forn(sz)cin >> arr[i];
  sort(arr + 1, arr + sz + 1);
  ans = (arr[1] + arr[2]) / 2;
  for(int i = 3; i <= sz; i++){
    ans = (ans + arr[i]) / 2;
  }
  cout << ans;
// endl

  return 0;
}

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

int main() {
	int n,m,ans=0,wer=0;
	cin>>n>>m;
	for(int i=1;i<100000;i++){
	    if(m%i==0&&m/i>=n){
	        ans=i;
	    }
	}
	if(n<10005){
	    for(int j=10005;j>=n;j--){
	        if(m%j==0)wer=m/j;
	    }
	}
	if(ans>wer)cout<<ans;
	else cout<<wer;
	return 0;
}

Measured memory_bytes: 256
$cos60 = 0.5
$sin60 = 0.86602540378

def koch(d, p1, p2)
  if d == 0
    return
  end
  sx = (2*p1[0] + 1*p2[0])/3
  sy = (2*p1[1] + 1*p2[1])/3
  tx = (1*p1[0] + 2*p2[0])/3
  ty = (1*p1[1] + 2*p2[1])/3
  ux = (tx-sx)*$cos60 - (ty-sy)*$sin60 + sx
  uy = (tx-sx)*$sin60 + (ty-sy)*$cos60 + sy
  koch(d-1, [p1[0], p1[1]], [sx, sy])
  puts format("%.8f %.8f", sx, sy)
  koch(d-1, [sx, sy], [ux, uy])
  puts format("%.8f %.8f", ux, uy)
  koch(d-1, [ux, uy], [tx, ty])
  puts format("%.8f %.8f", tx, ty)
  koch(d-1, [tx, ty], [p2[0], p2[1]])
end

# main
n = gets.to_i

puts format("%.8f %.8f", 0.0, 0.0)
koch(n, [0.0,0.0], [100.0,0.0])
puts format("%.8f %.8f", 100.0, 0.0)

Measured memory_bytes: 8808
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 100100100100100100;
struct edge{ll from;ll to;ll cost;};
edge G[5000];ll d[2500],V,E;
bool BellmanFord_reverse(ll s){//正の閉路が検出されたらtrue
  ll i,j;bool ne[V] = {};
  fill(d,d+V,-inf);d[s] = 0;
  for(i=0;i<V-1;i++){
    for(j=0;j<E;j++){
      if(d[G[j].from]!=-inf && d[G[j].to]<d[G[j].from]+G[j].cost){
        d[G[j].to] = d[G[j].from]+G[j].cost;
      }
    }
  }
  for(j=0;j<E;j++){
    if(d[G[j].from]!=-inf && d[G[j].to]<d[G[j].from]+G[j].cost) ne[G[j].to] = true;
  }
  for(i=0;i<V-1;i++){
    for(j=0;j<E;j++){
      if(ne[G[j].from]) ne[G[j].to] = true;
    }
  }
  return ne[V-1];
}
int main(){
  ll i,p;
  scanf("%lld%lld%lld",&V,&E,&p);
  for(i=0;i<E;i++){
    scanf("%lld%lld%lld",&G[i].from,&G[i].to,&G[i].cost);
    G[i].from--;G[i].to--;G[i].cost -= p;
  }
  if(BellmanFord_reverse(0)) printf("-1\n");
  else printf("%lld\n",max(0LL,d[V-1]));
}


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

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  int x = 0, y = n + 1;
  for(int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    x = max(x, u);
    y = min(y, v);
  }
  cout << max(0, y - x + 1) << '\n';
  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll> v(n);
    UnionFind uf(n);
    FOR(i,0,m){
        ll a,b;
        cin>>a>>b;
        a--; b--;
        uf.unite(a,b);
        v[a]++;
        v[b]++;
    }
    vector<vector<ll>> blk(n);
    FOR(i,0,k){
        ll a,b;
        cin>>a>>b;
        a--; b--;
        blk[a].push_back(b);
        blk[b].push_back(a);        
    }
    FOR(i,0,n){
        ll blc_num = 0;
        ll grp = uf.find(i);
        FOR(j,0,blk[i].size())if(grp == uf.find(blk[i][j])){
            blc_num++;
        //    cout<<blk[i][j]<<endl;
        }
        cout<<uf.size(i)-v[i]-1-blc_num;
        if(i == n-1)cout<<endl;
        else cout<<" ";
    }
}

Measured memory_bytes: 7936
import java.math.*

fun main(args: Array<String>) {
    val (n, k) = readInputLine().split(" ").map{it.toInt()}
    val vArr = readInputLine().split(" ").map{it.toInt()}.toIntArray()
    
    var max = 0
    
    for (i in 0..Math.min(n, k)) {
        for (j in 0..Math.min(n - i, k - i)) {
            val list = mutableListOf<Int>()
            for (l in 0 until i) {
                list.add(vArr[l])
            }
            for (l in 0 until j) {
                list.add(vArr[n - l - 1])
            }
            list.sort()
            
            for (l in 0 until k - i - j) {
                if (list.isEmpty()) {
                    break
                }
                if (list.first() < 0) {
                    list.removeAt(0)
                } else {
                    break
                }
            }

            val sum = list.sum()
            if (sum > max) {
                max = sum
            }
        }
    }
    
    println(max)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 41612
#include <iostream>
#include <string>
int main(){std::string s;int c[27]={},a=1;std::cin>>s;for(int i=0;i!=s.size();++i){++c[s[i]-97];a=(c[s[i]-97]>1?0:a);}std::cout<<(a?"yes":"no")<<"\n";}

Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<string>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<string>
#define UP(i,l,h) for(int i=l;i<h;i++)
#define DOWN(i,h,l) for(int i=h-1;i>=l;i--)
#define W(a) while(a)
#define MEM(a,b) memset(a,b,sizeof(a))
#define LL long long
#define INF 0x3f3f3f3f3f3f3f3f
#define MAXN 20050
#define MOD 1000000007
#define EPS 1e-3
using namespace std;
map<int,int> mp;

int main() {
    mp.clear();
    int n;
    scanf("%d",&n);
    int mx=0;
    UP(i,0,n) {
        int x;
        scanf("%d",&x);
        mp[x]++;
        mp[x-1]++;
        mp[x+1]++;
        mx=max(mx,max(mp[x],max(mp[x-1],mp[x+1])));
    }
    printf("%d\n",mx);
}


Measured memory_bytes: 4736
import java.util.Scanner;

class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        double x1 = sc.nextDouble();
        double y1 = sc.nextDouble();
        double x2 = sc.nextDouble();
        double y2 = sc.nextDouble();
        double a;
        double b;

       
       a = x2 - x1 ;
       b = y2 - y1;
        double c = Math.sqrt(a * a + b * b);
        System.out.printf("%.8f",c);
    }

}



Measured memory_bytes: 28220
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>

double round(double r) {
    return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);
}

using namespace std;




int main() {
	
	
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int ans=0;
	for(int i=0;i<a;i++){
		if(i<=b-1)ans+=c;
		else ans+=d;
	}
	cout<<ans<<endl;

    return 0;
}

	
	


	

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

using namespace std;

int main() {
    int N;
    cin >> N;
    int a;
    int gray = 0, brown = 0, green = 0, light_blue = 0, blue = 0, yellow = 0, orange = 0, red = 0;
    int count = 0;
    for (int i = 0; i < N; i++) {
        cin >> a;
        if (a < 400) {
            gray = 1;
        }
        else if (a < 800) {
            brown = 1;
        }
        else if (a < 1200) {
            green = 1;
        }
        else if (a < 1600) {
            light_blue = 1;
        }
        else if (a < 2000) {
            blue = 1;
        }
        else if (a < 2400) {
            yellow = 1;
        }
        else if (a < 2800) {
            orange = 1;
        }
        else if (a < 3200) {
            red = 1;
        }
        else {
            count++;
        }
    }
    int total = gray + brown + green + light_blue + blue + yellow + orange + red;
    if (total == 0) {
        total = 1;
        cout << total << " " << count << endl;
    }
    else {
        cout << total << " " << total + count << endl;

    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<string,ll> si;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
#define sort(a) sort(a.begin(),a.end());
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define mp make_pair
#define F first
#define S second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define nl "\n"
const int MOD = 1e9+7;
const ld PI = 3.1415926535898;
const ll LLMAX = LLONG_MAX;
#define N (int)1e6+1

double dp[301][301][301];
int n,k;

double solve(int one,int two,int three)
{
	if(one<0 || two<0 || three<0)return 0;
	else if(one+two+three==0)return 0;
	else if(dp[one][two][three]!=-1)return dp[one][two][three];
	double temp=(double)n+(double)one*solve(one-1,two,three) + (double)two*solve(one+1,two-1,three) + (double)three*solve(one,two+1,three-1);
	return dp[one][two][three]=temp/(one+two+three);
}

int main()
{
	ios
	cin>>n;
	int one=0,two=0,three=0;
	for(int i=0;i<=300;i++)
		for(int j=0;j<301;j++)
			for(int k=0;k<301;k++)
				dp[i][j][k]=-1;
	for(int i=0;i<n;i++)
	{
		cin>>k;
		if(k==1)one++;
		if(k==2)two++;
		if(k==3)three++;
	}
	double ans=solve(one,two,three);
	cout<<setprecision(12)<<ans<<nl;
}


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


int main() {
  int N;
  cin>>N;
  vector<long> a(N);
  for(int i=0;i<N;i++) cin>>a[i];
  vector<long> s(N);
  s[0]=a[0];
  long ans=0;
  if(s[0]==0) ans++;
  for(int i=0;i<N-1;i++){
    s[i+1]+=a[i+1]+s[i];
    if(s[i+1]==0) ans++;
  }

  map<long,long> m;
  for(int i=0;i<N;i++) m[s[i]]++;

  for (const auto& [k, v] : m){
          ans+=v*(v-1)/2;
      }
cout<<ans<<endl;
}


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

using namespace std;


int main()
{
	int n,x=0,y=0,a;
	int v[200000];
	
	cin >> n;
	
	for(int i=0;i<n;i++){
		cin >> v[i];
	}
	
	for(int i=0;i<n;i++){
		if(i%2 == 1) y += v[i];
		else x += v[i];
	}
	
	a = x - y;
	cout << a << ' ';
	a = a/2;
	for(int i=0;i<n-1;i++){
		a = v[i] - a;
		cout << a*2 << ' ';
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int n,m,i,j,s[1000][1000];
char a[1000][1000];
int main()
{
    cin>>n>>m;
    for(i=1;i<=n;i++)
        cin>>a[i];
    for(i=1;i<=n;i++)
    {
        for(j=0;j<m;j++)
        {
            if(a[i][j]=='#')
            {
                s[i-1][j-1]++;
                s[i-1][j]++;
                s[i-1][j+1]++;
                s[i][j-1]++;
                s[i][j+1]++;
                s[i+1][j-1]++;
                s[i+1][j]++;
                s[i+1][j+1]++;
            }
        }
    }
    for(i=1;i<=n;i++)
    {
        for(j=0;j<m;j++)
        {
            if(a[i][j]=='#')
                printf("#");
            else
                cout<<s[i][j];
        }
        cout<<'\n';
    }
    return 0;
}

Measured memory_bytes: 512
import math
def main():
    a, b, x = map(int, input().split())

    ans = 0
    if 2*x >= (a**2)*b:
        ans = math.atan((x/a - a*b)*(-2/a**2))*180/math.pi
    else:
        ans = math.atan(a*b**2/(2*x))*180/math.pi

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9380
S = list(input())

firstS = S[:len(S) // 2]
if len(S) % 2 == 0:
    secondS = list(reversed(S[len(S) // 2:]))
else:
    secondS = list(reversed(S[len(S) // 2 + 1:]))

count = 0

for x in range(len(firstS)):
    if firstS[x] != secondS[x]:
        count += 1
print(count)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define M 2550
#define LL long long
const int mo = 1e9 + 7;
int dp[52][5201][52]; // 放到第i位 在我 之前 的空位有h位.

void Add(int &res,int x) {
	res += x;
	if(res > mo) res -= mo;
	return ;
}
#define debug(x) cout << #x <<" " << x << endl;
main () {
	int n,k;
	cin >> n >> k;
	dp[1][M][0] = 1;
  	for(int i=1;i<=n;i++) {
		for(int j=0;j<=M*2;j++) {
			for(int h=i-1;h>=0;h--) {
				if(!dp[i][j][h]) continue;
				Add(dp[i+1][j][h],dp[i][j][h]); // 放自己.
				Add(dp[i+1][-2*i+j][h+1],dp[i][j][h]); // 放后面. 且当前位不放先.
				Add(dp[i+1][j][h],1LL*dp[i][j][h]*h%mo); // 放后面. 且当前位放前面空出来的.
				Add(dp[i+1][j][h],1LL*dp[i][j][h]*h%mo); // 放前面. 且当前位不放先.
				if(h) Add(dp[i+1][j+2*i][h-1],1LL*dp[i][j][h]*h%mo*h%mo); // 放前面 且当前位放前面空出来的.
			}
		}
	}
	cout<<dp[n+1][M+k][0];
	return 0;
}

Measured memory_bytes: 52608
s = input()
s = list(s)
s = s[::-1]

word_list = ['maerd', 'remaerd', 'esare', 'resare']
i = 0
while i != len(s):
    a = s[i:i+5]
    a = ''.join(a)
    b = s[i:i+6]
    b = ''.join(b)
    c = s[i:i+7]
    c = ''.join(c)
    if a in word_list:
        i += 5
    elif b in word_list:
        i += 6
    elif c in word_list:
        i += 7
    else:
        print('NO')
        exit()

print('YES')

Measured memory_bytes: 4652
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define sz(a)       (ll)(a.size())
#define cr(P)       cout<<P<<"\n";return;
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,x,n)   for(ll i=x;i<n;i++)
#define frr(i,x,n)  for(ll i=n-1;i>=x;i--)
using namespace std;


const ll N   =  500005;
const ll mod = 1e9 + 7;



void solve(){

  ll x=0,y=0,c=0,ans=0;
  ll n,m,k;
  cin>>n;
  
  
  for (ll i = 1; i <= n; ++i){
 
 	if(i% 3 and i%5){
 		c+=i;
 	}

  }
  c(c);
}

signed main(){
     
  ios_base::sync_with_stdio(false);   
  cin.tie(NULL);
  //int T;cin >> T;while (T--)
  solve();
  return 0;
}


Measured memory_bytes: 3652