akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
using namespace std;
//long long extGCD(long long a, long long b, long long& x, long long& y);

int main() {
	//D
	/*string s;
	cin >> s;
	int i,counter = 0;
	for (i = 0; i < s.size(); i++) {
		if (i % 2 == 0) {
			if (s[i] == 'p')counter--;
		}
		else {
			if (s[i] == 'g')counter++;
		}
	}
	cout << counter << endl;
	return 0;
	*/

	int n;
	cin >> n;
	int i;
	long long T[1000], A[1000];
	for (i = 0; i < n; i++) {
		cin >> T[i] >> A[i];
	}
	long long ta, ao;
	ta = T[0], ao = A[0];
	long long x, y, k;

	for (i = 1; i < n; i++) {
		if (T[i] == A[i]) {
			if (ta < ao) {
				ta = ao;
			}
			else if (ao < ta) {
				ao = ta;
			}
		}
		else {
			if (ta * A[i] != ao * T[i]) {
				//taをT[i]の倍数にする.
				if(ta % T[i] != 0)ta = ta + T[i] - (ta % T[i]);
				if (ta * A[i] != ao * T[i]) {
					if (ta / T[i] * A[i] > ao) {
						ao = ta / T[i] * A[i];
					}
					else {
						if(ao % A[i] != 0)ao = ao + A[i] - (ao % A[i]);
						ta = ao / A[i] * T[i];
					}
				}
			}
		}
	}
	//cout << gojo(60, 100) << endl;

	//cout << x << ' ' << y << endl;
	cout << ta + ao << endl;
	return 0;
	
}
/*
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}*/

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

class PrimeNumber{
public:
    int N;
    vector<ll> table;

    void makeTable(int n){
        N = n;
        vector<bool> v(n+1, true);
        v[0] = false;
        v[1] = false;
        int m = sqrt(n);
        for(int i=2; i<=m; i++){
            if(v[i]){
                int j = i*2;
                while(j <= n){
                    v[j] = false;
                    j += i;
                }
            }
        }
        for(int i=0; i<=n; i++){
            if(v[i]){
                table.push_back(i);
            }
        }
    }

    bool is_prime(ll n){
        if(n < 2){
            return false;
        }
        ll m = sqrt(n);
        for(ll i=2; i<=m; i++){
            if(n%i == 0){
                return false;
            }
        }
        return true;
    }

    map<ll,int> factorization(ll n){
        static map<ll,int> mp;
        for(ll i=2; i*i<=n; i++){
            while(n%i == 0){
                n /= i;
                mp[i]++;
            }
        }
        if(n > 1){
            mp[n]++;
        }
        return mp;
    }
};

int main(){
    int n;
    cin >> n;
    
    PrimeNumber PN;
    map<ll,int> mp;

    for(int i=2; i<=n; i++){
        mp = PN.factorization(i);
    }

    ll ans = 1;

    for(auto i : mp){
        ans *= i.second + 1;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define re register
const int mod=998244353;
int ex(re int a,re int b)
{
	re int ans=1;
	for(;b;b>>=1,a=(long long)a*a%mod)if(b&1)ans=(long long)ans*a%mod;
	return ans;
}
int main()
{
	re int n,m,ans=0,jx=1;
	scanf("%d%d",&n,&m);
	for(re int i=0;i<=n&&i<=m;i++)
	{
		re int num=(long long)ex(n+1,m-i)*ex(m+1,n-i)%mod*jx%mod;//printf("**%d %d %d\n",i,num,jx);
		if(i&1)ans=(ans+mod-num)%mod;
		else ans=(ans+num)%mod;
		jx=(long long)jx*(n-i)%mod*(m-i)%mod*ex(i+1,mod-2)%mod;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>

using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;

int main()
{
    int n, m;
    cin >> n;
    cin >> m;

    priority_queue<int> q;
    REP(i, n)
    {
        int a;
        cin >> a;
        q.push(a);
    }

    REP(i, m)
    {
        int a = q.top();
        q.pop();
        q.push(a / 2);
    }

    ll ans = 0;
    REP(i, n)
    {
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 892
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC173B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] S = new string[N];
            for(int i = 0; i < N; i++)
            {
                S[i] = Console.ReadLine();
            }
            int[] ans = new int[4];
            for (int i = 0; i < N; i++)
            {
                if (S[i] == "AC")
                {
                    ans[0] += 1;
                }
                else if (S[i] == "WA")
                {
                    ans[1] += 1;
                }
                else if (S[i] == "TLE")
                {
                    ans[2] += 1;
                }
                else if (S[i] == "RE")
                {
                    ans[3] += 1;
                }
                else
                {
                }
            }
            Console.WriteLine("AC x {0}", ans[0]);
            Console.WriteLine("WA x {0}", ans[1]);
            Console.WriteLine("TLE x {0}", ans[2]);
            Console.WriteLine("RE x {0}", ans[3]);
        }
    }
}


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

#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
#define P pair<int,int>
using namespace std;


int main(){
   int x,n;cin>>x>>n;
   vector<bool> dp(102);
   rep(i,n){
       int p;cin>>p;
        dp.at(p)=1;
   }
   P ans(99999,-1);
   for(int j=0;j<=101;j++){
       if(dp.at(j)==1)continue;
       int dif=abs(x-j);
        ans=min(ans,P(dif,j));
   }
cout<<ans.second<<endl;
}

Measured memory_bytes: 3632
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
    
    buf := make([]byte, 1000)
    sc.Buffer(buf, 1400000000)

	N := inputLineAsNumArray(1)[0]
	spots := inputLineAsNumArray(N)

    spots = append([]int{0}, spots...)
    spots = append(spots, 0)
    var dirs []bool
    var diffs []int
    base := int(math.Abs(float64(spots[0])))
	for i:=0; i<N+1; i++ {
        if spots[i] < spots[i+1] {
            dirs = append(dirs, true)
        } else if spots[i] > spots[i+1] {
            dirs = append(dirs, false)
        } else {
            if i == 0 {
                dirs = append(dirs, true)
            } else {
                dirs = append(dirs, dirs[i-1])
            }
        }
        base += int(math.Abs(float64(spots[i]-spots[i+1])))
        
        if i>0 {
            diff := 0
            if dirs[i] != dirs[i-1] {
                diff = int(math.Abs(float64(spots[i]-spots[i-1]))) + int(math.Abs(float64(spots[i]-spots[i+1]))) - int(math.Abs(float64(spots[i+1]-spots[i-1])))
            }
            diffs = append(diffs, diff)
        }
	}

	for i:=1; i<N+1; i++ {
        fmt.Println(base-diffs[i-1])
	}
	
}

func inputLineAsNumArray(length int) []int {
	line := strings.Split(readLine(), " ")
	var nums []int
	for i := 0; i < length; i++ {
		num, _ := strconv.Atoi(line[i])
		nums = append(nums, num)
	}
	return nums
}

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



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

#define     F       first
#define     S       second
typedef pair<int, int>  pi;
typedef long long       ll;

vector<int>v;
vector<int>ans;
int res;
int sumOfDigits (int n)
{
    int sum = 0;

    while (n)
    {
        sum += n % 10;
        n /= 10;
    }

    return sum;
}


ll fastpow(ll a,ll b){
if(!b)
    return 1;

ll  sq=fastpow(a,b/2);
sq*=sq;
if(b%2!=0)
    sq*=a;

    return sq;

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

const int maxx=1e3+100;
int c[maxx];
int n,m,d;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
int x,y,z;
cin>>x>>y>>z;
x-=z;
cout<<x/(y+z)<<"\n";

	return 0;
}







Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <cmath>
#include <math.h>
#include <bits/stdc++.h>
#include <iomanip>

using ll = long long;
using std::cout;
using std::cin;
using std::endl;
using std::string;

int main(){
    int a,b,h,m;
    cin >> a >> b >> h >> m;
    double theta = std::abs(1.0*h/12+1.0*m/12/60-1.0*m/60);
    if(theta>0.5){
        theta = 1.0 - theta;
    }
    theta = theta*2*M_PI;
    double ans = std::sqrt(a*a + b*b - 2.0*a*b*cos(theta));
    cout << std::setprecision(15) << ans << endl;
    return 0;
}


Measured memory_bytes: 4216
# 04-Branch_on_Condition-Range.py

# ??????
# ???????????´??°a, b, c?????????????????????????????? a < b < c????????¶????????????????????°"Yes"?????????????????????????????°"No"???????????????????????°?????????????????????????????????

# Input
# ???????????´??°???????????§????????????????????????????????????
# Output
# Yes?????????No????????????????????????????????????

# Sample Input 1
# 1 3 8
# Sample Output 1
# Yes
# Sample Input 2
# 3 8 1
# Sample Output 2
# No

# print("a,b,c?????\??????")
a,b,c=map(int,input().split())
# print("a=%d, b=%d, c=%d."%(a,b,c))

if a<b and b<c:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 7640
import itertools
def main():
  a,b = map(int,input().split())
  ans = False
  if a % 3 == 0:
    ans = True
  elif b % 3 == 0:
    ans = True
  elif (a + b) % 3 == 0:
    ans = True
  print("Possible" if ans else "Impossible")
if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
/* --- author: dxm --- */
#include<bits/stdc++.h>
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
#define DEBUG

int main(){
#ifndef DEBUG
	freopen("my.in","r",stdin);
	freopen("my.out","w",stdout);
#endif
	ll n,m,d;
	scanf("%lld%lld%lld",&n,&m,&d);
	ll a=(n-d)*(m-1)*(d==0?1:2);
	ll b=n*n;
	printf("%.10lf",db(a)/db(b));
	return 0;
}

/*
Input:
-----------------
Output:
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  int a, b, t;
  cin >> a >> b >> t;
  
  int res = (t+0.5)/a;
  int ans = res*b;
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
n,m,q = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(q)]

ans = 0

import itertools
for con in itertools.combinations_with_replacement(list(range(m)), n):
    tmp = 0
    for i in l:
        a,b,c,d = i
        if con[b-1] - con[a-1] == c:
            tmp += d
    ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 9128
import java.util.*;
public class Main {
	private static Scanner sc;
	public static void main(String[] args) {
		sc = new Scanner (System.in);
		int N = sc.nextInt();
		int W = sc.nextInt();
		int v[] = new int [N+1];
		int w[] = new int [N+1];
		for (int i=0; i<N; i++){
			v[i]=sc.nextInt();
			w[i]=sc.nextInt();
		}
		int price[][] = new int [N+1][W+1];	
		for (int i=N-1; i>=0; i--){
			for (int j=1; j<=W; j++){
				if (j-w[i]<0) price[i][j]=price[i+1][j];
				else price[i][j]=Math.max(price[i+1][j], (price[i+1][j-w[i]]+v[i]));
			
			}
		}
		System.out.println(price[0][W]);
	}
}

Measured memory_bytes: 31152
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {

		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int k = sc.nextInt();

		int cnt = 0;
		for (int i = 0; i < n; i++) {
			cnt += (k <= sc.nextInt()) ? 1 : 0;
		}
		System.out.println(cnt);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
            }

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 22200
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 3e3+5;
const lli INF = 1e18;
const lli MOD = 1e9+7;

vi m;
vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	m = vi(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

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

// ---- コーディングはここから！ ('-')7
ii dp[2][N][N];
void solve(){
	int n; cin>>n; vl v(n); fore(i,0,n)cin>>v[i];
	fore(i,0,2)fore(j,0,N)fore(k,0,N)dp[i][j][k]={-1,0};
	ii aux = {-1,0};
	auto f=[&](auto f, int p, int a, int b)->ii{
			if(a>b)return ii{0,0};
			
			if(dp[p][a][b]!=aux)return dp[p][a][b];
			ii resa=f(f,p^1,a+1,b);
			if(p)resa.s+=v[a];
			else resa.f+=v[a];
			ii resb = f(f,p^1,a,b-1);
			if(p)resb.s+=v[b];
			else resb.f+=v[b];
			if(p==0){
				if(resa.f-resa.s > resb.f-resb.s)return dp[p][a][b]=resa;
				else return dp[p][a][b]=resb;
			}
			if(resa.f-resa.s < resb.f-resb.s)return dp[p][a][b]=resa;
			else return dp[p][a][b]=resb;
	};
	cout<<f(f,0,0,n-1).f - f(f,0,0,n-1).s<<ENDL;
//	cout<<

}

int main(){_
	//int t; cin>>t; while(t--)
	solve();
}


Measured memory_bytes: 286240
program answer
  implicit none
  integer(16) :: N, i, ans, a, b, count
  integer(16), allocatable :: P(:), s(:)
  read(*,*) N
  allocate(P(N),S(N))
  do i = 1, N
     read(*,*) P(i)
  end do

  do i = 1, n
     s(p(i))=i
  end do

  count=1
  ans=1
  do i = 1, n-1
     if(s(i)<s(i+1)) then
        count=count+1
     else
        ans=max(ans,count)
        count=1
     end if
  end do

  ans=max(ans,count)

  write(*,*) n-ans

  deallocate(P,S)
  stop
 end program answer

Measured memory_bytes: 8820
using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp2
{
    public class Program
    {

        static long D = (long)Math.Pow(10, 9) + 7;

        public static void Main(string[] args)
        {
            int mod = 2019;

            int[] AB = Read(Console.ReadLine());
            int A = AB[0];
            int B = AB[1];

            
            Console.WriteLine(Lcm(A,B));
            Console.ReadLine();
        }


        /// <summary>
        /// 最小公倍数
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        public static long Lcm(long a, long b)
        {
            return a * b / Gcd(a, b);
        }

        /// <summary>
        /// 最大公約数
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        public static long Gcd(long a, long b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }


        private static int[] Read(string input)
        {
            string[] strings = input.Split(' ');
            int num = strings.Length;
            int[] ints = new int[num];
            for (int i = 0; i < num; i++)
            {
                ints[i] = int.Parse(strings[i]);
            }
            
            return ints;
        }


    }


}


Measured memory_bytes: 13140
#include <cstdio>
#include <vector>
#include <utility>
using namespace std;
typedef pair<int,int> ii;

int n;
vector<ii> al[100005];
long long sz[100005];
long long ans;

int minus=1000000000;

void dfs(int i,int p){
    sz[i]=1;
    for (auto &it:al[i]){
        if (it.first==p) continue;
        
        dfs(it.first,i);
        ans+=2LL*min(sz[it.first],n-sz[it.first])*it.second;
        sz[i]+=sz[it.first];
        
        if (sz[it.first]*2==n) minus=it.second;
    }
}

void dfs2(int i,int p){
    for (auto &it:al[i]){
        if (it.first==p) continue;
        if (sz[it.first]>(n/2)){
            dfs2(it.first,i);
            return;
        }
    }
    
    //printf("centroid: %d\n",i);
    for (auto &it:al[i]){
        minus=min(minus,it.second);
    }
}

int main(){
    scanf("%d",&n);
    int a,b,c;
    for (int x=1;x<n;x++){
        scanf("%d%d%d",&a,&b,&c);
        al[a].push_back(ii(b,c));
        al[b].push_back(ii(a,c));
    }
    dfs(1,-1);
    if (minus==1000000000) dfs2(1,-1);
    
    //printf("%lld %d\n",ans,minus);
    printf("%lld\n",ans-minus);
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
#ifdef IS_MY_ENV
#include <tourist>
#endif
using namespace std;
 
int x[64];
 
signed main() {
 
    int n;
    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        cin >> x[i];
    }
    int cnt = 0;
    for ( int i = 1; i < n-1; i++ ) {
        if ( x[i-1] < x[i] && x[i] < x[i+1] ) cnt++;
        else if ( x[i-1] > x[i] && x[i] > x[i+1] ) cnt++;
    }
    cout << cnt << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
#define asn ans
bool dbg = false;

int N, M, A[1010];
itn SUM;

void solve() {
    FOR(N)
    SUM += A[i];
    int cnt = 0;
    FOR(N) {
        if (A[i] * 4 * M >= SUM) {
            cnt++;
        }
    }
    Yes(cnt >= M);
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    FOR(N)
    cin >> A[i];


    solve();
    return 0;
}


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

int main() {
    int A, B, C;
    cin >> A >> B >>C;

    if (A > B) {
        int t = A;
        A = B;
        B = t;
    }
    if (B > C) {
        int t = B;
        B = C;
        C = t;
    }
    if (A > B) {
        int t = A;
        A = B;
        B = t;
    }

    int ans;
    if ((A + B + C) % 2 == 3 * C % 2) {
        ans = (3 * C - A - B - C) / 2;
    }
    else {
        ans = (3 * (C + 1) - A - B - C) / 2;
    }

    cout << ans << endl;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int a, b;
    cin >> a >> b;
    string s(b, '0' + a);
    string t(a, '0' + b);
    dump(s <= t ? s : t);
    return 0;
}

Measured memory_bytes: 256
package main

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

const mod = 1000000007
const facNum = 500007

//　完全順列
func main() {
	sc := newScanner(os.Stdin)
	N, M := sc.i(), sc.i()
	fac, ifac := factorial()
	ans := 0
	for k := 0; k <= N; k++ {
		a := combination(N, k, fac, ifac) * Pow(-1, k)
		a = a * permutation(M, k, fac, ifac) % mod
		a = a * permutation(M-k, N-k, fac, ifac) % mod
		a = a * permutation(M-k, N-k, fac, ifac) % mod
		ans += a
		if ans < 0 {
			ans += mod
		}
		ans %= mod
	}
	fmt.Println(ans)
}

// fmt.Println("Yes")
// fmt.Println("No")

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}

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

//const factorial = new
func Pow(a, n int) int {
	ans := 1
	for n > 0 {
		if (n & 1) == 1 {
			ans = ans * a % mod
		}
		a = a * a % mod
		n = n >> 1
	}
	return ans
}

func Gcd(a, b int) int {
	if a < b {
		return Gcd(b, a)
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func combination(n, k int, fac, ifac []int) int {
	if n < k || n < 0 {
		return 0
	}
	if k == 0 {
		return 1
	}
	//while n != 0
	ans := ifac[k] * ifac[n-k] % mod
	return ans * fac[n] % mod
}

func permutation(n, k int, fac, ifac []int) int {
	if n < k || n < 0 {
		return 0
	}
	if k == 0 {
		return 1
	}
	return fac[n] * ifac[n-k] % mod
}

func abs(i int) int {
	if i < 0 {
		return -i
	}
	return i
}

// 階乗: factorial
// コンビネーションを計算する際に前もって計算しておく
// fac[k] => k! (mod M)
// ifac[k] => k!^(M-2) (mod M)
// n: ex. 2 * 10^5 => 200001
// fac, ifac := factorial()
func factorial() (fac []int, ifac []int) {
	fac = make([]int, facNum)
	fac[0] = 1
	ifac = make([]int, facNum)
	ifac[0] = 1
	for i := 1; i < facNum; i++ {
		fac[i] = fac[i-1] * i % mod
		ifac[i] = ifac[i-1] * Pow(i, mod-2) % mod
	}
	return
}

// vs: sorted slice int value
func lowerBound(vs []int, v int) (index int) {
	n := len(vs) / 2
	m := len(vs)
	for m != n {
		if vs[n] < v {
			n = (m-n+1)/2 + n
			//m = m
		} else {
			m = n
			n = n / 2
		}
	}
	return n
}

func IntSlice(n, init int) []int {
	r := make([]int, n)
	for i := range r {
		r[i] = init
	}
	return r
}


Measured memory_bytes: 9908
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll N=1000000007;
//ll power(ll a,ll b,ll mod)
//{
//    ll result=1;
//    while(b>0)
//    {
//        if(b%2==1)
//            result=(result*a)%mod;
//        a=(a*a)%mod;
//        b=b/2;
//    }
//    return result;
//}
//ll d,x,y;
//void extendedEuclid(ll a,ll b)
//{
//    if(b==0)
//    {
//        d=a; x=1; y=0;
//    }
//    else
//    {
//        extendedEuclid(b,a%b);
//        ll temp=x; x=y; y=temp-(a/b)*y;
//    }
//}
//ll modInverse(ll a,ll m)
//{
//    extendedEuclid(a,m);
//    return (x%m+m)%m;
//}
//ll lcm(ll a,ll b)
//{
//    if(a==0||b==0)
//        return 0;
//    else
//        return (a*b)/(__gcd(a,b));
//}
//void sieve(ll n)
//{
//    bool isPrime[n+1];
//    isPrime[0]=false; isPrime[1]=false;
//    for(ll i=2;i<=n;i++)
//        isPrime[i]=true;
//    for(ll i=2;i*i<=n;i++)
//    {
//        if(isPrime[i]==true)
//        {
//            for(ll j=i*i;j<=n;j+=i)
//                isPrime[i]=false;
//        }
//    }
//}
double min(double x, double y)
{
    return (x < y)? x: y;

}
double calcAngle(double h,double m)
{
    if (h == 12) h = 0;
    if (m == 60) m = 0;
    double hour_angle = 0.5 * (h * 60 + m);
    double minute_angle = 6 * m;
    double angle = abs(hour_angle - minute_angle);
    angle = min(360 - angle, angle);
    return angle;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long double a,b,h,m,j,k,p,pi=3.14159265358979323846264338327950L;
    cin>>a>>b>>h>>m;
    j=calcAngle(h,m);
    p=(j/180)*(pi);
    k=sqrt((a*a)+(b*b)-(2.0*a*b*cos(p)));
    cout<<fixed<<setprecision(20)<<k;
}


Measured memory_bytes: 4156
import java.util.Scanner;
//import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		String op = sc.next();
		long b = sc.nextLong();
		System.out.println(op.equals("+") ? a + b : a - b);
	}
}


Measured memory_bytes: 35640
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
typedef pair<pii,int>piii;
int main(){
    int n,m;
    while(cin>>n>>m,n+m){
        vvi hoge(n+1,vi(n+1,INF));
        //edge[index]=(distance,next_vertex)
        vector<vector<pii>>edge(n,vector<pii>());
        vector<vector<pii>>temp(n,vector<pii>());
        rep(i,m){
            int a,b,c; cin>>a>>b>>c;
            --a,--b;
            edge[a].push_back(pii(b,c));
            edge[b].push_back(pii(a,c));
        }
        vvi d(3,vi(n,INF));
        d[0][0]=0;
        priority_queue<piii,vector<piii>,greater<piii>>que;
        que.push(piii(pii(0,0),0));
        
        while(!que.empty()){
            piii now=que.top();que.pop();
        //cout<<now.first.first<<" "<<now.first.second<<" "<<now.second<<endl;
            for(int i=0; i<edge[now.second].size();i++){
                pii next=edge[now.second][i];
                if(now.first.second==0){
                    if(now.first.second==0&&d[0][next.first]>d[0][now.second]+next.second){
                        que.push(piii(pii(d[0][now.second]+next.second,0),next.first));
                        d[0][next.first]=d[0][now.second]+next.second;
                    }
                    if(now.first.second==0&&d[1][next.first]>d[0][now.second]){
                        d[1][next.first]=d[0][now.second];
                        que.push(piii(pii(now.first.first,1),next.first));
                    }
                }else if(now.first.second==1){
                    if(d[2][next.first]>d[1][now.second]){
                        que.push(piii(pii(d[1][now.second],2),next.first));
                        d[2][next.first]=d[1][now.second];
                    }
                }else if(now.first.second==2&&d[2][next.first]>d[2][now.second]+next.second){
                    d[2][next.first]=d[2][now.second]+next.second;
                    que.push(piii(pii(now.first.first+next.second,2),next.first));
                }
            }
        }
        cout<<min(d[0][n-1],d[2][n-1])<<endl;
    }
}

Measured memory_bytes: 3204
from itertools import permutations
import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

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 SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def gcd(a,b):
    while b:a,b=b,a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

def main():
    n,k=MI()
    aa=LI()
    aa2=[a//2 for a in aa]
    l=1
    for a2 in aa2:l=lcm(l,a2)
    for a2 in aa2:
        if l//a2%2==0:
            print(0)
            exit()
    print((k//l+1)//2)

main()


Measured memory_bytes: 14608
import bisect
#aaa = [0, 80, 230, 310, 460]
#print(bisect.bisect_left(aaa, 460))
#print(bisect.bisect_left(aaa, 459))

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

# 累積和
sa = [0] * (n+1)
for i in range(n):
  sa[i+1] = sa[i] + a[i]
sb = [0] * (m+1)
for i in range(m):
  sb[i+1] = sb[i] + b[i]

#print(sa)
#print(sb)
ans = 0
for ac in range(n+1):
  bc = 0
  # i = Aの机からの冊数
  rk = k - sa[ac] # bに使える時間
  if rk <= 0:
    if rk == 0:
      ans = max(ans, ac)
    else:
      ans = max(ans, ac-1)
    break
  if rk == sb[m]:
    bc = m
  else:
    bc = bisect.bisect_left(sb, rk) - 1
  #print(rk, bc)
  ans = max(ans, ac+bc)
print(ans)

Measured memory_bytes: 110688
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define len(x) ((int)(x).size())
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

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

const ll LINF = 1e18;
const int INF = 1e9;
const int MOD = 1e9+7;

/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////

int main(){
	fastio;
	int r;
	cin >> r;
	cout << r*r << endl;	
	return 0;
}

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

int main()
{
    int X, Y;
    int A[400] = {0, 300000, 200000, 100000};

    cin >> X >> Y;

    cout << A[X] + A[Y] + 400000 * (int)(X == 1 && Y == 1) << endl;

    return ( 0 );
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_set>
#include <random>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s, t; cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < s.size(); i++) if (s[i] != t[i])ans++;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector<int> s(n+1),m(n+1,0),a(n);
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    for(int i=n-2;i>=0;i--){
        m[i]=max(m[i+1],s[i+1]);
        a[i]=m[i]-s[i];
    }
    cout<<*max_element(a.begin(),a.end()-1)<<endl;
}

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

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}


int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

int f[10005];

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for(int i=1; i<=100; i++){
        for(int j=1; j<=100; j++){
            for(int k=1; k<=100; k++){
                int x=i*i + j*j + k*k + i*j + j*k + k*i;
                if(x<=n) f[x]++;
            }
        }
    }
    for(int i=1; i<=n; i++) cout << f[i] << "\n";
    return 0;
}


Measured memory_bytes: 3608
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;

int main(){

	double n;
	while(~scanf("%lf",&n)){
		double seq[11];
		seq[1]=n;
		for(int i=2;i<=10;i++){
			seq[i] = i%2 ? seq[i-1] / 3.0 : seq[i-1] * 2.0;
		}

		double sum=0;
		for(int i=1;i<=10;i++){
			sum += seq[i];
		}
		printf("%.9f\n",sum);
	}
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    char a, b;
    cin >> a >> b;

    if (a == 'H' && b == 'H') {
        cout << 'H' << endl;
    } else if (a == 'H' && b == 'D') {
        cout << 'D' << endl;
    } else if (a == 'D' && b == 'H') {
        cout << 'D' << endl;
    } else if (a == 'D' && b == 'D') {
        cout << 'H' << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define mod 1000000007 //10^9+7

int main(void){
	char S[100001];
	scanf("%s",S);
	int len = strlen(S),i,j;
	long long dp[len+1][4];
	dp[len][3] = 1;
	dp[len][0] = 0;
	dp[len][1] = 0;
	dp[len][2] = 0;
	for(i=len-1;i>=0;i--){
		int m=1;
		if(S[i] == '?')m=3;
		dp[i][3] = m*dp[i+1][3]%mod;
		for(j=2;j>=0;j--){
			int n=1,m=0;
			if(S[i]=='?')n=3;
			if(S[i]=='?' || S[i] =="ABC"[j])m=1;
			dp[i][j] = (n*dp[i+1][j]+m*dp[i+1][j+1])%mod;
		}
	}
	printf("%lld",dp[0][0]);
	
	return 0;
}

Measured memory_bytes: 3328
S[12][1024];f(n,s,u,i){for(S[n][s]++;i<10;i++)u&1<<i&&f(n+1,s+(i*(n+1)),u^(1<<i),0);}main(n,s){for(f(0,0,1023,0);~scanf("%d%d",&n,&s);)printf("%d\n",s>1023?0:S[n][s]);}

Measured memory_bytes: 324
#include<iostream>

int n,ans;

int sum(){
	ans = 0;
	int a=0,b=0,c=0,d=0;
	for(;a<10;a++){
		for(;b<10;b++){
			for(;c<10;c++){
				for(;d<10;d++)
					if(a+b+c+d==n)
						ans++;
				d=0;
			}
			c=0;
		}
		b=0;
	}
	return ans;
}

int main(){
	while(std::cin >> n)
		std::cout << sum() << std::endl;
	return 0;
}

Measured memory_bytes: 0
from fractions import gcd

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

def lcm(x, y):
    return (x * y) // gcd(x, y)

tmp = lcm(a[0], a[1])
for i in range(2, N):
    tmp = lcm(tmp, a[i])
tmp -= 1
ans = 0
for i in range(N):
    ans += tmp % a[i]

print(ans)

Measured memory_bytes: 5344
fn main() {
    let x: i32 = read();
    let y: i32 = read();
    let z: i32 = read();

    let mut people = 0;
    let mut room_chair = x-z;
    while room_chair >= 0 {
        people += 1;
        room_chair -= y+z;
    }
    println!("{}", people-1);
}

// 以下関数

use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub const MOD: u64 = 10e9 as u64 + 7;

pub fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    } else if n == 2 {
        return true;
    }
    let mut i = 2;
    while i * i < n {
        if n % i == 0 {
            return false;
        } else {
            i += 1;
            continue;
        }
    }
    true
}

pub fn lcm(mut n: i32, mut m: i32) -> i32 {
    n = if n > m { m } else { n };
    m = if n > m { n } else { m };
    let mut i = n;
    while i % m != 0 {
        i += n;
    }
    i
}

pub fn abs(n: i32) -> i32 {
    if n >= 0 {
        n
    } else {
        -n
    }
}

pub fn max(n: i32, m: i32) -> i32 {
    if n >= m {
        n
    } else {
        m
    }
}

pub fn min(n: i32, m: i32) -> i32 {
    if n <= m {
        n
    } else {
        m
    }
}

Measured memory_bytes: 4352
#include<iostream>
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;

int max(int a, int b ){
    if(a>=b) return a;
     return b ;
}

int func(string s, string t){
   int ans = 0;
   for(char c='a';c<='z';c++){
       bool founds = false ;
       bool foundt = false ;
       for(int i=0;i<s.length();i++){
           if(s[i]==c) founds = true ;
       }
       for(int i=0;i<t.length();i++){
           if(t[i]==c) foundt = true ;
       }
       if(founds && foundt) ans++ ;
   }
   return ans ;
}

int main() {
	
    int n ;
    string s ;    
    cin >> n >> s;

    int ans = 0;
    for(int i=0;i<=n;i++){
        int tmp = func(s.substr(0,i),s.substr(i));
        ans = max(ans,tmp) ;
    }
    cout << ans << endl ;  
	return 0;
}



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

int main() {
  string S;
  cin >> S;
  int A = 0;
  if (S[0] == 'A')
    ++A;
  if (S[1] == 'A')
    ++A;
  if (S[2] == 'A')
    ++A;
  if (A == 1 || A == 2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 998244353
#define INF 0x3f3f3f3f
#define LL long long
#define N 55

vector<int>G[N];
int n,m,low[N],dfn[N];
bool is_cut[N];
int father[N];
int tim=0;
void input()
{
    scanf("%d%d",&n,&m);
    int a,b;
    for(int i=1;i<=m;++i)
    {
        scanf("%d%d",&a,&b);
        G[a].push_back(b);/*邻接表储存无向边*/
        G[b].push_back(a);
    }
}
void Tarjan(int i,int Father)
{
    father[i]=Father;/*记录每一个点的父亲*/
    dfn[i]=low[i]=tim++;
    for(int j=0;j<G[i].size();++j)
    {
        int k=G[i][j];
        if(dfn[k]==-1)
        {
            Tarjan(k,i);
            low[i]=min(low[i],low[k]);
        }
        else if(Father!=k)/*假如k是i的父亲的话，那么这就是无向边中的重边，有重边那么一定不是桥*/
            low[i]=min(low[i],dfn[k]);//dfn[k]可能！=low[k]，所以不能用low[k]代替dfn[k],否则会上翻过头了。
    }
}
void count_()
{
    int rootson=0;
    Tarjan(1,0);
    for(int i=2;i<=n;++i)
    {
        int v=father[i];
        if(v==1)
        rootson++;/*统计根节点子树的个数，根节点的子树个数>=2,就是割点*/
        else{
            if(low[i]>=dfn[v])/*割点的条件*/
            is_cut[v]=true;
        }
    }

    int ans = 0;
    for(int i=1;i<=n;++i)
    {
        int v=father[i];
        if(v>0&&low[i]>dfn[v])/*桥的条件*/
            ans ++;
    }
    printf("%d\n",ans);
}
int main()
{
    input();
    memset(dfn,-1,sizeof(dfn));
    memset(father,0,sizeof(father));
    memset(low,-1,sizeof(low));
    memset(is_cut,false,sizeof(is_cut));
    count_();
    return 0;
}


Measured memory_bytes: 256
use proconio::input;
fn main() {
    input! {
        s:String,
    }
    let s_chars: Vec<char> = s.chars().collect();
    let mut cnt = 0;
    for i in 0..3 {
        if s_chars[i] == 'o' {
            cnt += 1;
        }
    }
    let ans = 700 + cnt * 100;
    println!("{}", ans);
}


Measured memory_bytes: 2160
// Contest: AtCoder Beginner Contest 177 (https://atcoder.jp/contests/abc177)
// Problem: F: I hate Shortest Path Problem (https://atcoder.jp/contests/abc177/tasks/abc177_f)


// region boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion

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

    int h, w; cin >> h >> w;
    set<pi> paths;
    multiset<int> rights;
    rep(i, w)
        paths.emplace(i, i), rights.emplace(0);

    rep(i, h) {
        int a, b; cin >> a >> b; --a;
        auto it = paths.lower_bound(pi(a, 0));
        auto ite = paths.lower_bound(pi(b, 0));
        if (it != ite) {
            int mx_start = prev(ite)->second;
            for (auto it2 = it; it2 != ite; ++it2)
                rights.erase(rights.find(it2->first - it2->second));
            paths.erase(it, ite);
            if (b != w)
                paths.emplace(b, mx_start), rights.emplace(b - mx_start);
        }
        cout << (sz(rights) ? *begin(rights) + i + 1 : -1) << '\n';
    }

    return 0;
}


Measured memory_bytes: 22376
import collections
n=int(input())
s=[]
for i in range(n):
  c=input()
  s.append(c)
a=collections.Counter(s)
d=sorted(a.items(), key=lambda x:x[1])
e=max(a.values())
l=[]
for i in a:
  if a[i]==e:
    l.append(i)
l.sort()
for i in l:
  print(i)

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

int main(){
        int N,i,j;
        cin >> N;
        vector <string> s(N);
        for(i=0;i<N;i++){
        cin >> s.at(i);
        sort(s.at(i).begin(),s.at(i).end());
        }
        sort(s.begin(),s.end());
        long long c=0,tmp=1;
    for(i=1;i<N;i++){
            if(s.at(i)==s.at(i-1)){
                tmp++;
            }
            else{
                c+=(tmp*(tmp-1))/2;
                tmp=1;
            }
    }
    c+=(tmp*(tmp-1))/2;
    cout << c <<endl;
    return 0;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
int a[3][105],b[3][105];
int main()
{
	std::ios::sync_with_stdio(false);
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=2;i++)
		for(int j=1;j<=n;j++)
			cin>>a[i][j];
	for(int i=1;i<=n;i++)
		for(int j=i;j>=1;j--)
			b[1][i]+=a[1][j];
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j++)
			b[2][i]+=a[2][j];
	for(int j=1;j<=n;j++)
		ans=max(ans,b[1][j]+b[2][j]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (a, b, c) = (v[0], v[1], v[2]);
    if c <= b && c >= a {
        println!("Yes");
    } else {
        println!("No");
    }
}

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> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352