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

// define maximum possible length of string X and Y
#define MAX 3003

// lookup[i][j] stores the length of LCS of substring X[0..i-1], Y[0..j-1]
int lookup[MAX][MAX];

// Recursive Function to find Longest Common Subsequence of
// string X[0..m-1] and Y[0..n-1]
string LCS(string X, string Y, int m, int n)
{
	// return empty string if we have reached the end of
	// either sequence
	if (m == 0 || n == 0)
		return string("");

	// if last character of X and Y matches
	if (X[m - 1] == Y[n - 1])
	{
		// append current character (X[m-1] or Y[n-1]) to LCS of
		// substring X[0..m-2] and Y[0..n-2]
		return LCS(X, Y, m - 1, n - 1) + X[m - 1];
	}

	// else when the last character of X and Y are different

	// if top cell of current cell has more value than the left
	// cell, then drop current character of string X and find LCS
	// of substring X[0..m-2], Y[0..n-1]

	if (lookup[m - 1][n] > lookup[m][n - 1])
		return LCS(X, Y, m - 1, n);

	else

	// if left cell of current cell has more value than the top
	// cell, then drop current character of string Y and find LCS
	// of substring X[0..m-1], Y[0..n-2]

		return LCS(X, Y, m, n - 1);
}

// Function to fill lookup table by finding the length of LCS
// of substring X[0..m-1] and Y[0..n-1]
void LCSLength(string X, string Y, int m, int n)
{
	// first row and first column of the lookup table
	// are already 0 as lookup[][] is globally declared

	// fill the lookup table in bottom-up manner
	for (int i = 1; i <= m; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			// if current character of X and Y matches
			if (X[i - 1] == Y[j - 1])
				lookup[i][j] = lookup[i - 1][j - 1] + 1;

			// else if current character of X and Y don't match
			else
				lookup[i][j] = max(lookup[i - 1][j], lookup[i][j - 1]);
		}
	}
}

int main()
{
	string X,Y;
  cin>>X>>Y;
	int m = X.length(), n = Y.length();

	// fill lookup table
	LCSLength(X, Y, m, n);

	// find longest common sequence
	cout << LCS(X, Y, m, n);

	return 0;
}


Measured memory_bytes: 68804
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n;cin>>n;
  string s;cin>>s;
  int mx=0;
  int x=0;
  for(int i=0;i<n;i++){
    if(s[i]=='I')x++;
    if(s[i]=='D')x--;
    mx=max(mx, x);
  }
  P(mx);
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec; typedef pair<int, int> pi;
int dd[] = { 0, 1, 0, -1, 0 };


int main()
{
	while (true)
	{
		int W, H;
		cin >> W >> H;
		if (W == 0 && H == 0) break;

		char C[30][30];
		int B[30][30];

		int sx = -1; int sy = -1;
		for (int i = 0; i < H; i++)
		{
			cin >> C[i];
			for (int j = 0; j < W; j++)
			{
				
				B[i][j] = 0;
				if (C[i][j] == '@')
				{
					sy = i;
					sx = j;
				}
			}
		}

		queue<pi> Q;
		Q.push(pi(sy, sx));
		B[sy][sx] = 1;
		int ans = 1;
		while (!Q.empty())
		{
			int ty = Q.front().first; int tx = Q.front().second;
			Q.pop();

			for (int r = 0; r < 4; r++)
			{
				int y = ty + dd[r];
				int x = tx + dd[r + 1];
				if (y < 0 || y >= H || x < 0 || x >= W)continue;
				if (C[y][x] == '#')continue;
				if (B[y][x])continue;
				ans++;
				B[y][x] = 1;
				Q.push(pi(y, x));
			}
		}

		cout << ans << endl;
	}
	return 0;
}

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

vector<int> X[1003];

int main() {

    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int N;
    cin >> N;
    
    int ptr = 0;
    
    while(ptr * (ptr - 1) / 2 < N)
        ptr++;
    
    if(ptr * (ptr - 1) / 2 > N)
    {
        cout << "No\n";
        return 0;
    }
    
    cout << "Yes\n";
    
    int k = 0;
    cout << ptr << "\n";
    
    for(int i=1; i<=ptr; i++)
    {
        for(int j=i+1; j<=ptr; j++)
        {
            k++;
            X[i].push_back(k);
            X[j].push_back(k);
        }
    }
    
    for(int i=1; i<=ptr; i++)
    {
        cout << X[i].size() << " ";
        
        for(auto x : X[i])
            cout << x << " ";
        cout << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 2304
r,g,b,n = map(int,input().split())
R = n//r+1
G = n//g+1
cnt = 0
for i in range(R+1):
    for j in range(G+1):
        t = n-i*r-j*g
        if t%b==0 and t>=0:
            cnt += 1
print(cnt)



Measured memory_bytes: 40684
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int N;
	while(~scanf("%d", &N)) {
		string s, t;
		cin >> s >> t;
		int ans = -1;
		for(int len = N; ; ++ len) {
			bool ok = true;
			rep(i, len) {
				if(i < (int)s.size() && len - 1 - i < (int)t.size())
					ok &= s[i] == t[i - (len - t.size())];
			}
			if(ok) {
				ans = len;
				break;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 256
fn main() {
    let md1 : Vec<i64> = read_vec();
    let md2 : Vec<i64> = read_vec();
    if md2[0] - md1[0] == 1 {
        println!("1");
    } else {
        println!("0");
    }
    
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
LL a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	MEM(a, 0x01);
	int n, m;
	cin >> n >> m;
	while (m--)
	{
		int val, b;
		cin >> val >> b;
		int mask = 0;
		for (int i = 0; i < b; i++)
		{
			int x;
			cin >> x;
			mask |= 1 << (x - 1);
		}
		for (int i = mask; i; i = (i - 1) & mask)
		{
			a[i] = min(a[i], 1LL * val);
		}
	}
	a[0] = 0;
	for (int i = 1; i < (1 << n); i++)
	{
		for (int j = i; j; j = (j - 1) & i)
		{
			a[i] = min(a[i], a[j] + a[j ^ i]);
		}
	}
	if (a[(1 << n) - 1] >= INF) a[(1 << n) - 1] = -1;
	cout << a[(1 << n) - 1] << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define INF 98765432198765432
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
int ddx[] = { 0,0,1,1,1,-1,-1,-1 }, ddy[] = { 1,-1,1,0,-1,1,0,-1 };

Vi v[501];
int main() {
	int n,m,q;
	scanf("%d%d%d",&n,&m,&q);
	while(m--)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		v[x].pb(y);
	}
	fup(i,1,n,1)sort(ALL(v[i]));
	while(q--)
	{
		int ans=0;
		int x,y;
		scanf("%d%d",&x,&y);
		fup(i,x,y,1)ans+=upper_bound(ALL(v[i]),y)-v[i].begin();
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 2176
#include <stdio.h>
int main()
{
  int i,j,n,v,k,A[1000];

  scanf("%d",&n);

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

  for(i=0;i<n;i++)
    {
      v=A[i];
      j=i-1;
      while(j>=0 && A[j]>v)
	{
	  A[j+1]=A[j];
	  j--;
	  A[j+1]=v;
	}
      for(k=0;k<n;k++)
	{
	  if(k==n-1)
	    {
	      printf("%d",A[k]);
	    }
	  else
	    {
	      printf("%d ",A[k]);
	    }
	}
      printf("\n");
    }
  return 0;
}

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

using namespace std;
using ll=long long;

int main()
{
    vector<ll>x;
    int a[3]={3,5,7};
    x.push_back(3);x.push_back(5);x.push_back(7);
    int s=0;int b=0;
    for(int i=0;i<10;i++){
        int k=(int)x.size();
        for(int j=s;j<k;j++){
            for(int q=0;q<3;q++){
                int l=x[j]*10+a[q];
                x.push_back(l);
            }
        }
        s+=k-b;
        b=s;
    }
    ll n;cin >>n;
    int ans=0;
    for(int i=0;i<(int)x.size();i++){
       int c=x[i];
       if(x[i]>n){
        cout << ans << endl;
        return 0;
       }
       bool flg[3];for(int j=0;j<3;j++)flg[j]=false;
       while(c>0){
        flg[(c%10)%3]=true;
        c/=10;
       }
       bool tmp=true;
       for(int j=0;j<3;j++)if(!flg[j])tmp=false;
       if(tmp)ans++;


    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6512
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

LL imos[7001][7001];

LL get_sum(int x1,int x2,int y1,int y2){
    return imos[y1+2000][x1+2000]-imos[y1+2000][x2+2000]-imos[y2+2000][x1+2000]+imos[y2+2000][x2+2000];
}

int main(){
    int N,k;
    cin >> N >> k;
    for(int i=0;i<N;i++){
        LL x,y;
        char c;
        cin >> x >> y >> c;
        if(c=='B') imos[y%(2*k)+2000][x%(2*k)+2000]++;
        else imos[(y+k)%(2*k)+2000][x%(2*k)+2000]++;
    }
    for(int i=0;i<4*k;i++){
        for(int j=0;j<4*k;j++){
            imos[i+2000][j+2001]+=imos[i+2000][j+2000];
        }
    }
    for(int i=0;i<4*k;i++){
        for(int j=0;j<4*k;j++){
            imos[j+2001][i+2000]+=imos[j+2000][i+2000];
        }
    }
    LL ans=0;
    // for(int i=-2*k;i<2*k;i++){
    //     for(int j=-2*k;j<2*k;j++){
    //         cout << imos[i+2000][j+2000];
    //     }
    //     cout << "\n";
    // }
    for(int i=-k;i<k;i++){
        for(int j=-k;j<k;j++){
            LL sum=get_sum(j,j-k,i,i-k)+get_sum(j+k,j,i+k,i)+get_sum(j+2*k,j+k,i,i-k)+get_sum(j,j-k,i+2*k,i+k)+get_sum(j+2*k,j+k,i+2*k,i+k)+get_sum(j+3*k,j+2*k,i+k,i)+get_sum(j+k,j,i+3*k,i+2*k)+get_sum(j+3*k,j+2*k,i+3*k,i+2*k);
            ans=max(sum,ans);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 221440
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.AGC_Challenge
{
    class _002_A
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] ab = ReadInts();
            long a = ab[0];
            long b = ab[1];
            if (a * b < 0 || a == 0 || b == 0)
            {
                Console.WriteLine("Zero");
            }
            else
            {
                if (0 < a || (b < 0 && (b - a) % 2 == 1))
                {
                    Console.WriteLine("Positive");
                }
                else
                {
                    Console.WriteLine("Negative");
                }
            }
        }

        private static string Read() { return Console.ReadLine(); }
        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: 13140
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace AtCoder
{
    static class Program
    {
        static void Main()
        {
            //ここから

            int N = IO.ReadLineToInt();
            var a = IO.ReadLineToIntList();

            bool[] color = new bool[8];
            for(int i = 0; i < 8; i++)
            {
                color[i] = false;
            }
            int free = 0;
            
            for(int i = 0; i < N; i++)
            {
                var n = a[i] / 400;
                if (n > 7) { free++; }
                else { color[n] = true; }
            }

            int min = Math.Max(1, color.Count(c => c == true));
            int max = color.Count(c => c == true) + free;
            

            //ここまで

            Console.WriteLine(min+" "+max);
            Console.ReadKey();
        }

    }

    static class Func
    {
        static public long mod = 1000000007;
        static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
        static public long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }
        static public long LCM(long a, long b) { return (long)a * b / GCD(a, b); }
        static public long Factorial(long a) { return a == 1 ? a : a * Factorial(a - 1); }


        public static double ToAngle(this double radian)
        {
            return (double)(radian * 180 / Math.PI);
        }

        public static double ToRadian(this double angle)
        {
            return (double)(angle * Math.PI / 180);
        }

        static public long Conbination(long n, long m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * Conbination(n - 1, m - 1) / m;
        }

        static public void Factoring(long num, ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for (long i = 2; i < Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }
    }

    static class IO
    {
        static public string ReadLineToString() { return Console.ReadLine(); }

        static public int ReadLineToInt() { return int.Parse(Console.ReadLine()); }
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public List<string> ReadLineToStringList() { return Console.ReadLine().Split(' ').ToList(); }

        static public List<int> ReadLineToIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }

        static public List<double> ReadLineToDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }

        static public void WriteStrings(object[] strings) { foreach (var o in strings) { Console.Write(o + " "); } }
    }
}

Measured memory_bytes: 13396
main:: IO ()
main = do
    [a,b,c] <- (map read . words) <$> getLine
    putStrLn $ if solve (a,b,c) then "Yes" else "No"

-- |
--
-- >>> solve (1,3,2)
-- True
--
-- >>> solve (6,5,4)
-- False
solve :: (Int,Int,Int) -> Bool
solve (a,b,c) = a <= c && c <= b


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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

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

	double a, b;
	cin >> a >> b;
	cout << fixed << setprecision(10) << a / b;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
        while(true){
          int x=sc.nextInt();
          int y=sc.nextInt();
          if(x==0&&y==0) break;
          if(x<y){
             System.out.println(x+" "+y);
          }
           else{
              System.out.println(y+" "+x);
            }
        }
    }
}


Measured memory_bytes: 35820
import sys
# sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
# arr = [[int(el) for el in input().split()] for i in range(n)]

def cal(a, b, k):
    for i in range(a, b + 1):
        if i % k == 0:
            return True
    return False

k = int(input())
a, b = map(int, input().split())

if cal(a, b, k):
    print ('OK')
else:
    print ('NG')

Measured memory_bytes: 9244
N, x = map(int, input().split())
a = sorted(list(map(int, input().split())))

for i in range(N):

    x -= a[i]
    if x < 0:
        print(i)
        break    
else:
    if x == 0:
        print(N)
    else:
        print(N-1)    


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;cin>>n>>k;
    vector<int> a(n);
    rep(i,n){
      cin>>a[i];
      a[i]--;
    }
    vector<int> foo;
    map<int,int> mp;
    int key=a[0];
    while(1){
      if(mp.find(key)!=mp.end())break;
      mp[key]=1;
      foo.push_back(key);
      key=a[key];
    }
    if(k<=foo.size()){
        cout<<foo[k-1]+1<<endl;
        return 0;
    }
    ll tmp=0;
    ll rot=foo.size();
    rep(i,foo.size()){
      if(foo[i]==key){
        tmp=i;
        k-=i;
        rot-=i;
        break;
      }
    }
    k%=rot;
    if(k==0)cout<<foo[tmp+rot-1]+1<<endl;
    else cout<<foo[k+tmp-1]+1<<endl;
    return 0;
}


Measured memory_bytes: 13884
#include <iostream>
int main(){
	int W,H,x,y,r;
	std::cin>>W>>H>>x>>y>>r;
	if((x-r>=0)&&(x+r<=W)&&(y>=0+r)&&(y<=H-r)){
		std::cout<<"Yes"<<std::endl;
	}else{
		std::cout<<"No"<<std::endl;
	}
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<string.h>
#include<vector>
using namespace std;
vector<char> Q;
int main()
{
	char s[200005];
	scanf("%s",s);//字符串
	int len=strlen(s);
	//printf("%d\n",len);
	for(int i=0;i<len;i++){
		if(!Q.empty()&&s[i]=='T'&&Q.back()=='S'){
			//把S拿出来
			Q.pop_back();
		}
		else
			Q.push_back(s[i]);//入数组
	}
	int cnt=0;
	while(!Q.empty()){
		Q.pop_back();
		cnt++;
	}
	printf("%d\n",cnt);
}

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

string s,t;
int main() {

    cin >> s >> t;

    int cnt = 0;
    for(int i = 0 ; i < 3 ; i++) {
        if(s[i]==t[i]) cnt++;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
s = set()
all = 0
for i in a:
    if i >= 3200:
        all += 1
    else:s.add(i//400)
if not s:
    print(1,end=" ")
else:print(len(s),end=" ")
print(len(s)+all)

Measured memory_bytes: 3060
from collections import Counter
N=int(input())
S=list()
Y=list()
for i in range(N):
    S.append(input())
X=Counter(S)
F=X.most_common()[0][1]
keys = [k for k, v in X.items() if v == F]
keys.sort()
for i in range(len(keys)):
    print(keys[i])


Measured memory_bytes: 45032
import collections

n=int(input())
s = []
max = 0

for i in range(n):
    s.append(input())

c = collections.Counter(s)

for i in c.items():
    if i[1] > max:
        max = i[1]

s2 = [i[0] for i in c.items() if i[1] == max]

s2.sort()

for j in range(len(s2)):
    print(s2[j])



Measured memory_bytes: 35572
package main

import "fmt"

func main() {

	var n, m, l, a_ij, b_jk int
	fmt.Scan(&n, &m, &l)
	
	a := make([][]int, n)
	for i:=0; i<n; i++ {
		a[i] = make([]int, m)
		for j:=0; j<m; j++ {
			fmt.Scan(&a_ij)
			a[i][j] = a_ij
		}
	}
	b := make([][]int, m)
	for j:=0; j<m; j++ {
		b[j] = make([]int, l)
		for k:=0; k<l; k++ {
			fmt.Scan(&b_jk)
			b[j][k] = b_jk
		}
	}

	c := make([][]int, n)
	for i:=0; i<n; i++ {
		c[i] = make([]int, l)
		for k:=0; k<l; k++ {
			for j:=0; j<m; j++ {
				c[i][k] += a[i][j]*b[j][k]
			}
			if k==l-1 {
				fmt.Print(c[i][k])
			} else {
				fmt.Print(c[i][k]," ")
			}
		}
		fmt.Println()
	}

}


Measured memory_bytes: 2608
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define fin(ans) cout << (ans) << endl
const int INF = 1<<30;
const ll MOD = 1000000007;

int main() {
    long long N,K;
    cin >> N >> K;

    ll now = N;
    now %= K;
    ll ans = min((-1)*(now-K),now);
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import itertools
input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def main():
    H, N = read_values()
    A = read_list()
    print("Yes" if sum(A) >= H else "No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 14104
fun main(args: Array<String>) {
    val S = readLine()!!.toInt()
    var list = linkedSetOf(S)
    for (i in 2..1000000) {
        var last = list.last()
        if (last%2 == 0) {
            last /= 2
        } else {
            last = last*3 + 1
        }
        if (list.contains(last)) {
            println(i)
            break
        }
        list.add(last)
    }
 }


Measured memory_bytes: 37996
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1

int main() {
  string s;
  vector<char> S(4);
  cin>>s;
  rep(i, 4)
  {S[i]=s[i];
  }
  sort(ALL(S));
  if(S[0]==S[1]&&S[2]==S[3])
  {
  if(S[1]!=S[2])
  {cout<<"Yes"<<endl;
  return 0;}
    
  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int MAXN = 1e5 + 1 ;
int dp[MAXN][3] ;
int a[MAXN] ;
int b[MAXN] ;
int c[MAXN] ;
int n ;
int main(){
    cin >> n ;
    for ( int i = 0 ; i < n ; i++ ){
        cin >> a[i] >> b[i] >> c[i] ;
    }
    dp[0][0] = a[0] ;
    dp[0][1] = b[0] ;
    dp[0][2] = c[0] ;
    for ( int j = 1 ; j < n ; j++ ){
        dp[j][0] = a[j] + max( dp[j-1][1] , dp[j-1][2]) ;
        dp[j][1] = b[j] + max( dp[j-1][0] , dp[j-1][2]) ;
        dp[j][2] = c[j] + max( dp[j-1][1] , dp[j-1][0]) ;
    }
    cout << max( max(dp[n-1][0] , dp[n-1][1] ) , dp[n-1][2] ) ;
    return 0;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define for_int(i,a,b) for(int i=(a);i<=(b);++i)
#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)
#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)
#define IOS ios::sync_with_stdio(false);
#define ull unsigned long long
#define ll long long
#define db double
#define HPMAX 1005
#define KMP_MAX 1005
#define prime_MAX 1000005
#define quick_pow_mod 1000000007
#define PII pair<int,int>
const int factor_N = 10000005;
const int tree_arr_N = 1000005;
using namespace std;
/*
	1.注意边界情况
	2.优先考虑时间复杂度
!!! 3.求最大值时，答案应至多初始化为INT_MIN；求最小值时，答案应至少初始化为INT_MAX
	4.遇事不决先暴力
	5.代码要写简洁
*/
//快读
int read() {
	char c = getchar();
	int x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-') f = -1;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
	return x * f;
}
//快速幂
ll quick_pow(ll a, ll n, ll mod) {
	ll ans = 1;
	a %= mod;
	if (n == 0) return 1 % mod;
	while (n) {
		if (n & 1)
			ans = (ans * a) % mod;
		n >>= 1;
		a = (a * a) % mod;
	}
	return ans % mod;
}
ll n;
const ll mod = 1000000007;
int main() {
	n = read();
	ll ans = 0;
	ans += quick_pow(10, n, mod);
	ans -= quick_pow(9, n, mod);
	ans -= quick_pow(9, n, mod);
	ans += quick_pow(8, n, mod);
	ans %= mod;
	ans = (ans + mod) % mod;
	cout << ans << endl;
	return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    if(n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8){
        cout << "pon" << endl;
    }else if(n%10 == 2 || n%10 == 4 || n%10 == 5 || n%10 == 7 || n%10 == 9){
        cout << "hon" << endl;
    }else{
        cout << "bon" << endl; 
    }

    return 0;
}

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

using namespace std;

typedef long long LL;

int main() {
    int n, m;
    cin >> n >> m;
    set<int> solved;
    map<int,int> wrongs;
    int penalty = 0;
    for (int i = 0; i < m; ++i) {
        int p;
        string s;
        cin >> p >> s;
        if (s == "AC") {
            if (solved.find(p) == solved.end()) {
                solved.insert(p);
                penalty += wrongs[p];
            }
        } else if (solved.find(p) == solved.end()) {
            wrongs[p]++;
        }
    }
    cout << solved.size() << ' ' << penalty << '\n';
    return 0;
}

Measured memory_bytes: 9600
N = int(input())
P = list(map(int,input().split()))
P.sort(reverse=True)
a = 0
b = 0
for i in range(N-1):
    if P[i] > 0:
        if a == 0:
            if P[i] == P[i+1]:
                a = P[i]
                P[i] = -i
                P[i+1] = -i -1
        elif b == 0:
            if P[i] == P[i+1]:
                b = P[i]
                P[i] = -i
                P[i+1] = -i -1
        else:
            break
    else:
        continue
ans = a * b
print(ans)

Measured memory_bytes: 14244
#include <cstdio>
#include <cstring>
#include <string>
#include <string.h>
#include <cmath>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#define pi acos(-1.0)
#define INF 0x3f3f3f3f
#define SIZE 200005
#define read(a,n) for(i=0;i<n;i++)cin>>a[i];
#define pii pair<int,int>
#define pb push_back
using namespace std;
typedef	long long ll;
ll n, m, i, j, k, h, t, maxn, ttt, t1, t2, sig = 0;
int main() 
{
	
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	int ss[5] = { a,b,c,d,e };
	int minn = INF, mix = 0;
	for (i = 0; i < 5; i++) {
		if (minn > (ss[i] % 10 == 0 ? 10 : ss[i] % 10))
		{
			minn = (ss[i] % 10 == 0 ? 10 : ss[i] % 10);
			mix = i;
		}
	}
	swap(ss[4], ss[mix]);
	int sum = 0;
	for (i = 0; i < 5; i++) {
		if (i == 0) {
			while ((ss[0] % 10))
				ss[0]++;
			sum = ss[0];
			continue;
		}
		if (i != 4) {
			sum += ss[i];
			while ((sum % 10)) {
				sum++;
			}
			continue;
		}
		sum += ss[i];
	}
	cout << sum;
	return 0;
}


Measured memory_bytes: 256
function main(input) {
  const nums = input.split(" ")
  const a = parseInt(nums[0], 10)
  const p = parseInt(nums[1], 10)
  const result = Math.floor((a * 3 + p) / 2)
  console.log(result)
}

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

Measured memory_bytes: 7372
#include<stdio.h>
#define M 500000
int a[M],b[M],count=0;
void ms(int *a,int l,int r){
  int i,j,k,m;
  if(r>l){
    m=(r+l)/2;
    ms(a,l,m);
    ms(a,m+1,r);
    for(i=m+1;i>l;i--)
      b[i-1]=a[i-1];
    for(j=m;j<r;j++)
      b[r+m-j]=a[j+1];
    for(k=l;k<=r;k++){
      a[k]=(b[i]<b[j])?b[i++]:b[j--];
      count++;
    }
  }
}

main(){
  int i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  ms(a,0,n-1);
  for(i=0;i<n-1;i++)
    printf("%d ",a[i]);
  printf("%d\n%d\n",a[n-1],count);
  return 0;
}

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

int main() {
	int N, M, SUM = 0;
	cin >> N >> M;
	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i], SUM += A[i];
	sort(A.begin(), A.end(), greater<int>());
	if (A[M - 1] * M * 4 < SUM) cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <functional>
using namespace std;

typedef int W;

const int MAX_V = 400 * (1 << 10);
const W INF = 1 << 20;

struct edge {
	int to;
	W cost;
};
typedef pair<W, int> P;

vector<edge> G[MAX_V];
W d[MAX_V];


void dijkstra(int s) {
	priority_queue< P, vector<P>, greater<P> > que;
	fill(d, d + MAX_V, INF);
	d[s] = 0;
	que.push(P(0, s));
	while(!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int w, h;
string b[20];
int wf[400][400];

struct point {
	int x, y;
};

int v(int x, int y) {
	return w * y + x;
}

int v2(int x, int y, int s) {
	return s * (h*w) + v(x, y);
}

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

	while(cin >> w >> h, w | h) {
		memset(wf, INF, sizeof wf);
		for(int i = 0; i < 400; i++) {
			for(int j = 0; j < 400; j++) {
				if(i == j) wf[i][i] = 0;
				else wf[i][j] = INF;
			}
		}
		for(int i = 0; i < MAX_V; i++) {
			G[i].clear();
		}

		for(int i = 0; i < h; i++) {
			cin >> b[i];
		}
		vector<point> p;
		int sx = -1, sy = -1;
		for(int y = 0; y < h; y++) {
			for(int x = 0; x < w; x++) {
				if(b[y][x] == 'o') {
					sx = x, sy = y;
				}
				if(b[y][x] == '*') {
					p.push_back(point{ x, y });
				}
				if(b[y][x] != 'x') {
					int dx[] = { 1, 0, -1, 0 }, dy[] = { 0, 1, 0, -1 };
					for(int i = 0; i < 4; i++) {
						int nx = x + dx[i], ny = y + dy[i];
						if(0 <= nx && nx < w && 0 <= ny && ny < h && b[ny][nx] != 'x') {
							wf[v(x, y)][v(nx, ny)] = wf[v(nx, ny)][v(x, y)] = 1;
						}
					}
				}
			}
		}

		for(int k = 0; k < h*w; k++) {
			for(int i = 0; i < h*w; i++) {
				for(int j = 0; j < h*w; j++) {
					wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j]);
				}
			}
		}

		p.push_back(point{ sx, sy });
		for(int i = 0; i < p.size(); i++) {
			for(int j = 0; j < p.size(); j++) {
				for(int k = 0; k < 1 << (p.size() - 1); k++) {
					if(k & (1 << j)) {
						G[v2(p[i].x, p[i].y, k)].push_back(
							edge{ v2(p[j].x, p[j].y, k ^ (1 << j)), wf[v(p[i].x, p[i].y)][v(p[j].x, p[j].y)] }
						);
					}
				}
			}
		}

		dijkstra(v2(sx, sy, (1 << (p.size() - 1)) - 1));
		int ans = INF;
		for(int i = 0; i < p.size() - 1; i++) {
			ans = min(ans, d[v2(p[i].x, p[i].y, 0)]);
		}

		if(ans == INF) {
			cout << -1 << endl;
		}
		else {
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 20436
N, K = map(int, input().split())
A = list(map(lambda x: int(x)-1, input().split()))

town = 0
visited = [town]
index = 0
visited_index = {town: index}
loop = None
while K > 0:
    K -= 1
    town = A[town]
    if town in visited_index:
        loop = visited[visited_index[town]:]
        break
    visited.append(town)
    index += 1
    visited_index[town] = index

if loop:
    K %= len(loop)
    print(loop[K]+1)
else:
    print(town+1)


Measured memory_bytes: 32304
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
long long int a = 0, b = 0, c = 0,d=0,e=0, ans = 0, x = 0, y = 0, z = 0, n = 0, m = 0, maxy = 0, mini = 9999, counter = 0, endp = 0, checker = 0;

std::vector <long long int> vec{}, vecsec{}, vecth{};
long long int iremono[100001], sec[100001];
long long int iremono2[100001], check[100001],xpo[10000001],ypo[10000001],hei[1000001];
std::vector<std::string>kinds{}, kaku{};
char maze[1000][1000];
int sx, sy;
int gx, gy;
vector<pair<long long int, long long int>>pairs;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
bool okada = false, okada2 = false;
std::string output, output2, input, input2;
char re;
int starta, startb, enda, endb,ab;


unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int kaizyo(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}

int H, W;//はんい
bool qw = false, er = false, ty = false,ui=false;
int main() {
	cin >> a;
	rep(i, a) {
		cin >> iremono[i];
		if (i == 0) {
			iremono2[i] = iremono[i];
		}
		else {
			iremono2[i] = iremono2[i - 1] + iremono[i];
		}
	}
	//0もある
	for (int i = 1; i < a; i++) {
		counter = std::abs((iremono2[a - 1] - iremono2[i])-iremono2[i]);
		mini = std::min(mini, counter);
}
	cout << mini << endl;
}


Measured memory_bytes: 4352
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()
	s := scanText()

	ans := 0

	for i := 0; i < n; i++ {
		a := zalgo(s[i:])

		for i := 0; i < len(a); i++ {
			if a[i] < i+1 {
				ans = max(ans, a[i])
			}
		}
	}

	fmt.Println(ans)
}

func min(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res > a[i] { res = a[i] }
	}
	return res
}

func max(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res < a[i] { res = a[i] }
	}
	return res
}




func zalgo(s string) []int {
	n := len(s)
	res := make([]int, n)
	i, j := 1, 0
	for i<n {
		for i+j < n && s[j] == s[i+j] {
			j++
		}
		res[i] = j
		if j == 0 {
			i++
			continue
		}
		k := 1
		for i+k < n && k+res[k] < j {
			res[i+k] = res[k]
			k++
		}
			i += k
			j -= k
	}
	return res
}


Measured memory_bytes: 10880
def main():
    x, y, a, b, c = map(int, input().split())
    red_apples = sorted(list(map(int, input().split())), reverse=True)[:x]
    green_apples = sorted(list(map(int, input().split())), reverse=True)[:y]
    colorless_apples = sorted(list(map(int, input().split())), reverse=True)[:min(x+y, c)]

    print(sum(sorted(red_apples + green_apples + colorless_apples, reverse=True)[:x+y]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 22504
// Problem : D - Replacing
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//mst,pq,mp,st,q
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n;
		cin>>n;
		int arr[n];
		int sum = 0;
		map<int,int> mp;
		for(int i=0;i<n;++i)
		{
			cin>>arr[i];
			mp[arr[i]]++;
			sum+=arr[i];
		}
		int q;
		cin>>q;
		while(q--)
		{
			int b,c;
			cin>>b>>c;
			sum-= b*mp[b];
			sum+= c*mp[b];
			mp[c]+= mp[b];
			mp[b] = 0;
			cout<<sum<<"\n";
		}		
    }
    return 0;
}


Measured memory_bytes: 10244
def mapt(fn, *args):
    return tuple(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))


def calc(i, h):
    return all(h[i] >= h[j] for j in range(i))


def main():
    n = int(input())
    h = Input()
    ans = 1
    for i in range(1, n):
        ans += calc(i, h)
    print(ans)


main()

Measured memory_bytes: 9148
import java.util.Scanner;

class Problem {
    private String S;

    Problem() {
        Scanner sc = new Scanner(System.in);
        S = sc.next();
    }

    int solve() {
        int max = 0;
        int cur = 0;

        for (int i = 0; i < S.length(); i++) {
            char c = S.charAt(i);
            if (c == 'A' || c == 'C' || c == 'G' || c == 'T') {
                cur++;
            } else {
                max = Math.max(max, cur);
                cur = 0;
            }
        }
        max = Math.max(max, cur);

        return max;
    }
}

public class Main {
    public static void main(String[] args) {
        System.out.println(new Problem().solve());
    }
}


Measured memory_bytes: 23252
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct edge
{
	int v,nxt;
}e[500005];
int n,m,h[100005],t,deg[100005],vis[100005];
void add(int u,int v)
{
	e[++t].v=v;
	e[t].nxt=h[u];
	h[u]=t;
}
void dfs(int u)
{
	vis[u]=1;
	for(int i=h[u];i;i=e[i].nxt)
	{
		int v=e[i].v;
		if(vis[v]) continue;
		dfs(v);
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v);
		add(v,u);
		deg[u]++,deg[v]++;
	}
	for(int i=1;i<=n;i++)
		if(deg[i]%2)
		{
			printf("No\n");
			return 0;
		}
	int ct=0;
	for(int i=1;i<=n;i++)
		if(deg[i]>=6)
		{
			printf("Yes\n");
			return 0;
		}
		else if(deg[i]==4) ct++;
	if(ct!=2)
	{
		if(ct<=1) printf("No\n");
		else printf("Yes\n");
		return 0;
	}
	for(int i=1;i<=n;i++)
		if(deg[i]==4)
		{
			vis[i]=1;
			break;
		}
	for(int i=1;i<=n;i++)
		if(deg[i]==2)
		{
			dfs(i);
			for(int i=1;i<=n;i++)
				if(!vis[i])
				{
					printf("Yes\n");
					return 0;
				}
			printf("No\n");
			return 0;
		}
	return 0;
}

Measured memory_bytes: 4864
#include <iostream>
using namespace std;
int main(){
  string S;
  while(cin >> S, S != "#"){
    if(S.length() <= 2){
      cout << 0 << endl;
      continue;
    }
    int ans = 0;
    int f[2] = {S[0],S[1]}, m = 1;
    for(int i = 1; i < S.length(); ++i){
      if((m == 1 && (S[i]-'0'-1)%3 > (f[1-m]-1)%3)){
	++ans;
	f[1-m] = S[i] - '0';
      }else if((m == 0 && (S[i]-'0'-1)%3 < (f[1-m]-1)%3)){
	++ans;
	f[1-m] = S[i] - '0';
      }else{
	f[m] = S[i] - '0';
	m = 1-m;
      }
    }
    int t = 0;
    f[0] = S[1];
    f[1] = S[0];
    m = 0;
    for(int i = 1; i < S.length(); ++i){
      if((m == 1 && (S[i]-'0'-1)%3 > (f[1-m]-1)%3)){
	++t;
	f[1-m] = S[i] - '0';
      }else if((m == 0 && (S[i]-'0'-1)%3 < (f[1-m]-1)%3)){
	++t;
	f[1-m] = S[i] - '0';
      }else{
	f[m] = S[i] - '0';
	m = 1-m;
      }
    }
    //cout << ans << endl;
    //cout << t << endl;
    ans = min(ans,t);
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;

using int64 = long long;
const int mod = (int) (1e9 + 7);

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}


int main() {
  int N;
  cin >> N;
  vector< int > V(N);
  cin >> V;
  sort(begin(V), end(V));
  double ret = V[0];
  for(int i = 1; i < N; i++) {
    ret += V[i];
    ret /= 2;
  }
  cout << ret << endl;

}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

type Dish struct {
	Time int
	Diff int
}
type Dishs []Dish

func (p Dishs) Len() int {
	return len(p)
}

func (p Dishs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

type ByDiff struct {
	Dishs
}

func (b ByDiff) Less(i, j int) bool {
	return b.Dishs[i].Diff > b.Dishs[j].Diff
}

func main() {
	var a, b, c, d, e int
	fmt.Scan(&a, &b, &c, &d, &e)
	dish := []Dish{
		{a, (10 - a%10) % 10},
		{b, (10 - b%10) % 10},
		{c, (10 - c%10) % 10},
		{d, (10 - d%10) % 10},
		{e, (10 - e%10) % 10},
	}
	// fmt.Println(dish)
	sort.Sort(ByDiff{dish})
	// fmt.Println(dish)
	fmt.Println(dish[0].Time + dish[1].Time + dish[1].Diff + dish[2].Time +
		dish[2].Diff + dish[3].Time + dish[3].Diff + dish[4].Time + dish[4].Diff)
}


Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    int ans = INF;
    rep(i, S.length()) {
        int match = 0;
        rep(j, T.length()) {
            if(i + j >= S.length()) {match = -10000; break;}
            if(S[i + j] == T[j]) match++;
        }
        int n = T.length();
        ans = min(ans, n - match);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3656
n = int(input())
k = int(input())
x = list(map(lambda x:int(x),input().split()))
dist = 0
for i in range(n):
  if x[i]<=abs(k-x[i]):
    dist += 2*x[i]
  else:
    dist += 2*abs(k-x[i])
print(dist)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define F first
#define S second
#define INF 1000000000000000
struct e{
    ll t,a,b;
};
int n,m,s,t;
ll ds[100005],pt[100005],ans=INF;
vector<e>g[100005];
vector<ll>o;
int main(void){
    cin>>n>>m>>s>>t;
    s--;
    t--;
    for(int i=0;i<m;i++){
        ll v,u,a,b;
        cin>>v>>u>>a>>b;
        v--;
        u--;
        g[v].push_back(e{u,a,b});
        g[u].push_back(e{v,a,b});
    }
    for(int i=0;i<n;i++){
        ds[i]=INF;
        pt[i]=INF;
    }
    priority_queue<P,vector<P>,greater<P> >dik;
    ds[s]=0;
    dik.push(P(0,s));
    while(!dik.empty()){
        ll v=dik.top().S,c=dik.top().F;
        dik.pop();
        if(c>ds[v])continue;
        for(int i=0;i<g[v].size();i++){
            e u=g[v][i];
            if(ds[u.t]>c+u.a){
                ds[u.t]=c+u.a;
                dik.push(P(c+u.a,u.t));
            }
        }
    }
    pt[t]=0;
    dik.push(P(0,t));
    while(!dik.empty()){
        ll v=dik.top().S,c=dik.top().F;
        dik.pop();
        if(c>pt[v])continue;
        for(int i=0;i<g[v].size();i++){
            e u=g[v][i];
            if(pt[u.t]>c+u.b){
                pt[u.t]=c+u.b;
                dik.push(P(c+u.b,u.t));
            }
        }
    }
    for(int i=n-1;i>=0;i--){
        ans=min(ans,ds[i]+pt[i]);
        o.push_back(ans);
    }
    for(int i=o.size()-1;i>=0;i--)cout<<INF-o[i]<<endl;
}


Measured memory_bytes: 13688
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
#define int long long
using ll = long long;
using namespace std;
const int INF = 1LL << 50;
using P       = pair<int, int>;

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

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

signed main() {
    int n;
    cin >> n;
    vector<int> hs(n);
    rep(i, 0, n) {
        int h;
        cin >> h;
        hs[i] = h;
    }

    int ans = 0;
    int nax = -1;
    rep(r, 0, n) {
        if (nax <= hs[r]) {
            ans++;
            nax = hs[r];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256