akhauriyash/Code-Regression huggingface dataset:
import math
D, G = map(int, input().split())

P = []
for _ in range(D):
    p, c = map(int, input().split())
    P.append((p, c))

ans = 10000
for i in range(2 ** D):
    score = 0
    solve = 0
    maxj = -1
    for j in range(D):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            score += (j+1)*P[j][0]*100+P[j][1]
            solve += P[j][0]
        else:
            maxj = max(maxj, j)

    if maxj == -1:
        if score >= G:
            ans = min(ans, solve)
    elif score+(maxj+1)*(P[maxj][0]-1)*100 >= G:
        solve += max(0, math.ceil((G-score)/(maxj+1)/100))
        ans = min(ans, solve)
    # print(bin(i), ans, solve, score, maxj, score+(maxj+1)*(P[maxj][0]-1))

print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
#include<algorithm>
#include<set>
using namespace std;
int Lmax[100000];
int Lmin[100000];
int Rmax[100000];
int Rmin[100000];
pair<int,int> tate[100000];
pair<int,int> yoko[100000];
//max{x1-x2+y1-y2,x1-x2-y1+y2,-x1+x2+y1-y2,-x1+x2-y1+y2}
//max{abs((x1+y1)-(x2+y2)),abs((x1-y1)-(x2-y2))}
int main(){
	int a;
	scanf("%d",&a);
	for(int i=0;i<a;i++){
		int b,c;
		scanf("%d%d",&b,&c);
		tate[i]=make_pair(b+c,b-c);
		yoko[i]=make_pair(b-c,b+c);
	}
	std::sort(tate,tate+a);
	std::sort(yoko,yoko+a);
	int ret=999999999;
	int val=0;
	for(int i=0;i<a;i++){
		val=max(min(max(abs(tate[0].first-tate[i].first),abs(yoko[0].first-tate[i].second)),max(abs(yoko[a-1].first-tate[i].second),abs(tate[a-1].first-tate[i].first))),val);
	}
	ret=min(ret,val);
	val=0;
	for(int i=0;i<a;i++){
		val=max(min(max(abs(tate[0].first-tate[i].first),abs(yoko[a-1].first-tate[i].second)),max(abs(yoko[0].first-tate[i].second),abs(tate[a-1].first-tate[i].first))),val);
	}
	ret=min(ret,val);
	printf("%d\n",ret);
}

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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

        }

        public void Solve(ConsoleInput cin)
        {
            //85のB
            //var a = cin.ReadInt;
            //int[] b = new int[a];
            //var list = new List<int>();

            //for (int i = 0; i < a; i++)
            //{
            //    b[i] = cin.ReadInt;
            //    if (!(list.Contains(b[i])))
            //    {
            //        list.Add(b[i]);
            //    }

            //}
            //WriteLine(list.Count());

            var N = cin.ReadInt;
            var Y = cin.ReadInt;
            bool T= false;


            for (int i = 0; i <= N; i++)
            {
                for (int j = 0; j <= N-i; j++)
                {

                    if (Y == i * 10000 + j * 5000 + (N-i-j) * 1000)
                    {
                        WriteLine("{0} {1} {2}", i, j, (N-i-j));
                        T = true;
                        return;
                    }

                }
            }
        
            if(!T) WriteLine("{0} {1} {2}", -1, -1, -1);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13268
#include<iostream>
using namespace std;
int dp[102][4][4]={},n,k,s[102]={},a,x;
int f(int day,int rev,int rerev){
	if(day==n)return 1;
	if(dp[day][rev][rerev]!=0)return dp[day][rev][rerev];
	int ans=0;
	for(int i=1;i<=3;i++){
		if(!(i==rev && i==rerev)){
			if(s[day+1]==0 || s[day+1]==i){
				ans+=f(day+1,i,rev);
				ans%=10000;
			}
		}
	}
	return dp[day][rev][rerev]=ans;
}
int main(){
	cin>>n>>k;
	for(int i=0;i<k;i++){
		cin>>a;
		cin>>s[a];
	}
	cout<<f(0,0,0)<<endl;
	return 0;
}

Measured memory_bytes: 1176
#include "bits/stdc++.h"
#define inf 0x3f3f3f3f
#define pb push_back
#define vi vector<int>
#define fi first
#define se second 
#define mp make_pair
typedef unsigned long long ull;
//typedef pair<int,int> P;
#define LL long long 
#define pi acos(-1)
#define MOD 998244353
typedef long long ll;
using namespace std;
const int maxn = 10005;
char b;
const char p[]="ACGT";
int main(){
	cin>>b;
	cout<<p[p+3-strchr(p,b)]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef     long long       ll;
typedef     vector<ll>      vll;
#define     pb              push_back
#define     nn              "\n"
#define     all(p)          p.begin(),p.end()
#define     zz(v)           (ll)v.size()
#define     ss              ' '
#define     pii             pair<ll,ll>
#define     gcd(a,b)        __gcd(a,b)
#define     lcm(a,b)        (a*b)/gcd(a,b)
#define     S(a)            scanf("%lld",&a)
#define     SS(a,b)         scanf("%lld %lld",&a,&b)
#define     SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)

const ll N=300010;
ll tree[N*4];


//ll make_tree(ll node,ll b,ll e)
//{
//    ll x,y;
//    if(b==e)
//    {
//        tree[node]=ar[b];
//        return ar[b];
//    }
//
//    x=make_tree(node*2,b,(b+e)/2);
//    y=make_tree(node*2+1,(b+e)/2+1,e);
//
//    tree[node]=max(x,y);
//
//    return tree[node];
//}

ll val (ll node,ll b,ll e,ll i,ll j)
{
    ll x,y;
    if(b>j||e<i)
        return 0;

    if(b>=i&&e<=j)
        return tree[node];

    x=val(node*2,b,(b+e)/2,i,j);
    y=val(node*2+1,(b+e)/2+1,e,i,j);

    return max(x,y);

}

void update_value(ll node,ll b,ll e,ll i,ll num)
{
    if(b==e&&b==i)
    {
        tree[node]=max(tree[node],num);
        return;
    }
    if(i<b||i>e)
        return ;

    ll l=node*2;
    ll r=l+1;
    ll m=(b+e)/2;
    update_value(l,b,m,i,num);
    update_value(r,m+1,e,i,num);

    tree[node]=max(tree[l],tree[r]);

}




int main()
{
//    ios::sync_with_stdio(0);
//    cin.tie(0);
    memset(tree,0,sizeof(tree));

    ll n,k;
    cin>>n>>k;
    for(ll i=0; i<n; i++)
    {
        ll s;
        cin>>s;

        ll l= max(0LL,s-k);
        ll r= min(N,s+k);

        ll q=val(1,0,N,l,r);

        update_value(1,0,N,s,q+1);

//        for(ll j=0;j<=10;j++)
//        {
//            cout<<tree[j]<<ss;
//        }
//        cout<<nn;



    }




    cout<<val(1,0,N,0,N)<<nn;








}


Measured memory_bytes: 12992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int k;
int ans;
int main()
{
    cin>>k;
    for(int a=1;a<=k;a++){
        for(int b=1;b<=k;b++){
            for(int c=1;c<=k;c++){
                int mid=__gcd(a,b);
                ans+=__gcd(mid,c);
            }
        }
    }
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 3624
#include <cstdio>

int n;
int play[205][3], cnt[3][105], res[205];

int main() {
    scanf("%d",&n);
    for(int i=0; i<n; i++) for(int j=0; j<3; j++) {
        scanf("%d",&play[i][j]);
        cnt[j][play[i][j]]++;
    }
    for(int i=0; i<n; i++) for(int j=0; j<3; j++) {
        if (cnt[j][play[i][j]]==1) res[i]+=play[i][j];
    }
    for(int i=0; i<n; i++) printf("%d\n", res[i]);
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define END getchar();getchar();return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

signed main() {
	int q, sum[114514];
	sum[0] = 0;
	for (int i = 1; i < 110000; i++) {
		if (i % 2 == 0) {
			sum[i] = sum[i - 1];
		}
		else if (prime(i) && prime((i + 1) / 2)) {
			sum[i] = sum[i - 1] + 1;
		}
		else {
			sum[i] = sum[i - 1];
		}
	}
	cin >> q;
	rep(i, q) {
		int r, l;
		cin >> l >> r;
		cout << sum[r] - sum[l - 1] << endl;
	}

	END;
}


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

using namespace std;

int main()
{
	int N;
	string S;

	cin >> N >> S;

	int R, B;
	R = B = 0;
	for (int i = 0; i < N; i++)
	{
		if (S[i] == 'R')
		{
			R++;
		}
		else
		{
			B++;
		}
	}

	if (R > B)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

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

using namespace std;

#define pii pair<int,int>
#define point pair<double,double>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PI acos(-1)
#define MOD 1e9+7


int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(b<c || d<a)cout<<0<<endl;
	else
    {
        if(a>c)
        {
            swap(a,c);
            swap(b,d);
        }
        cout<<min(b,d)-c<<endl;
    }
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }

    int ans = 0;
    int cnt = 1;
    for (int i = 0; i < n - 1; i++) {
        if (a.at(i) == a.at(i + 1)) cnt++;
        else {
            ans += cnt / 2;
            cnt = 1;
        }
    }
    ans += cnt / 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
    string s;
    cin >> s;
    int res=0;
    for(int i=0;i<3;++i) {
        if(s[i]=='o') {
            ++res;
        }
    }
    int price=700+res*100;
    cout << price << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N =sc.nextInt();
    int min = 120000;
    for(int A=1; A<=N-1; A++){
      int B = N-A;
      int sumA = sumOfdigits(A);
      int sumB = sumOfdigits(B);
      if((sumA + sumB) < min){
        min = sumA + sumB;
      }
    }
    System.out.println(min);
  }
     private static int sumOfdigits(int n){
     int sum=0;
     while(n>0){
       sum +=n%10;
       n=n/10;
     }
     return sum;
   }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long i=a;i<n;i++)
#define per(i,a,n) for (long long i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
bool comp(int a,int b){
return a>b;
}
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int main()
{
	fast;
	string s,t;
	cin>>s>>t;
	ll l1,l2;
	l1=s.length();
	ll res=0;
	rep(i,0,l1)
	{
		if(s[i]!=t[i])
		res++;
	}
	
	cout<<res;
	
	
	
	


}



Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 

    int main(){
      string s;
      cin>>s;
      lint numh=0,numc=0,numh2=0,numa2=0,numc2=0;
      lint n=s.size();
      rep(i,n){
          if(s[i]=='?')numh++;
          else if(s[i]=='C')numc++;
      }
      lint ans=0;
      rep(i,n){
          if(s[i]=='A')numa2++;
          else if(s[i]=='C')numc2++;
          else if(s[i]=='B'){
           lint x=numa2*(numc-numc2);
           x%=MOD;
           x*=modpow(3,numh,MOD);
           x%=MOD;
           ans+=x;
           x=numa2*(numh-numh2);
           x%=MOD;
           x*=modpow(3,numh-1,MOD);
           ans+=x;
           x=(numc-numc2)*(numh2);
           x%=MOD;
           x*=modpow(3,numh-1,MOD);
           x%=MOD;
           ans+=x;
           x=(numh2)*(numh-numh2);
           x%=MOD;
           x*=modpow(3,numh-2,MOD);
           x%=MOD;
           ans+=x;
           ans%=MOD;
          }else{
           lint x=numa2*(numc-numc2);
           x%=MOD;
           x*=modpow(3,numh-1,MOD);
           x%=MOD;
           ans+=x;
           x=numa2*(numh-numh2-1);
           x%=MOD;
           x*=modpow(3,numh-2,MOD);
           ans+=x;
           x=(numc-numc2)*(numh2);
           x%=MOD;
           x*=modpow(3,numh-2,MOD);
           x%=MOD;
           ans+=x;
           x=(numh2)*(numh-numh2-1);
           x%=MOD;
           x*=modpow(3,numh-3,MOD);
           x%=MOD;
           ans+=x;
           ans%=MOD;            
           numh2++;
          }

      }
      cout<<ans<<endl;
    }
      

Measured memory_bytes: 3736
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cassert>
#define FILL(a, n, x) memset((a), (x), sizeof ((a)[0]) * (n))
#define FILLA(a, x) memset((a), (x), sizeof (a))
#define COPY(a, n, b) memcpy((b), (a), sizeof ((a)[0]) * (n))
#define COPYA(a, b) memcpy((b), (a), sizeof (a))
using namespace std;

typedef pair<int, int> pii;
typedef long long li;
typedef unsigned long long lu;
const int inf = ~0U >> 2;
const li infl = ~0LLU >> 2;

template <class T> inline void Min(T &x, T y) { if (y < x) x = y; }
template <class T> inline void Max(T &x, T y) { if (y > x) x = y; }

const int mod = 998244353;
inline int Add(int x) { return x >= mod ? x - mod : x; }
inline void Add(int &x, int y) { x += y; if (x >= mod) x -= mod; }
inline int Sub(int x) { return x < 0 ? x + mod : x; }
inline void Sub(int &x, int y) { x -= y; if (x < 0) x += mod; }
inline int Mul(int x, int y) { return (int)((li)x * y % mod); }
inline int Mul(int x, int y, int z) { return Mul(x, Mul(y, z)); }
int Pow(int x, int y) { int z = 1;
  for (; y; y >>= 1, x = Mul(x, x)) { if (y & 1) z = Mul(z, x); } return z; }
inline int Inv(int x) { return Pow(x, mod - 2); }
inline int Fix(li x) { x %= mod; if (x < 0) x += mod; return (int)x; }
inline int Fix(int x) { x %= mod; if (x < 0) x += mod; return x; }

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

const int maxn = 5e5;

int N, K;
int fact[maxn + 1], ifact[maxn + 1];

void InitFact(int N) {
  fact[0] = 1;
  for (int i = 1; i <= N; ++i) {
    fact[i] = Mul(fact[i - 1], i);
  }
  ifact[N] = Inv(fact[N]);
  for (int i = N; i >= 1; --i) {
    ifact[i - 1] = Mul(ifact[i], i);
  }
}

int Binom(int n, int m) {
  assert(m >= 0 && m <= n);
  return Mul(fact[n], ifact[m], ifact[n - m]);
}

int Solve(int N, int A, int B) {
  if (A - B >= K) {
    return Binom(N, A);
  }
  int X = K - (A - B);
  assert(X <= B);
  int ans = Binom(N, A);
  int t = 2 * (-(B - X) - 1) - (A - B);
  if (t >= -N) {
    assert((t + N & 1) == 0);
    t = (t + N) >> 1;
    assert(t >= 0 && t <= N);
    Sub(ans, Binom(N, t));
  }
  return ans;
}

int main(void) {
  scanf("%d%d", &K, &N);
  InitFact(N);
  int ans = 0;
  for (int A = max(K, N + 1 >> 1); A <= N; ++A) {
    int B = N - A;
    if (A == B) {
      Add(ans, Solve(N - 1, A, B - 1));
    } else {
      Add(ans, Solve(N, A, B));
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,int> s;
int n;
ll ans=0;
ll sum=0;
int main()
{

    scanf("%d",&n);
    ++s[0];
    while(n--)
    {
        ll x;
        scanf("%lld",&x);
        sum+=x;
        ans+=s[sum];
        ++s[sum];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 12800
A = 0
B = 0
AB = 0
O = 0
while True :
    try :
        n, blood = input().split(",")
        if blood == "A" :
            A += 1
        elif blood == "B" :
            B += 1
        elif blood == "AB" :
            AB += 1
        elif blood == "O" :
            O += 1
        
    except EOFError :
        break

print(A)
print(B)
print(AB)
print(O)


Measured memory_bytes: 5560
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
int N;
  cin >>N;
  if((N==1) ||(N==2)|| (N==3)|| (N==5) ||(N==6) ||(N==9) ||(N==10)|| (N==13)|| (N==17))  {
cout <<"No"<< endl;
  }
else {
cout <<"Yes"<< endl;
}
}



Measured memory_bytes: 256
N = int(input())

Ans = [2 * i for i in range(N+1)]
Ans[0] = 0
Ans[1] = 1
ans = N * (N + 1) - 1
for i in range(2, N+1):
    if i * 2 > N+1:
        break
    for j in range(2 * i, N+1, i):
        Ans[j] += j
        ans += j

print(ans)

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

int N;
int A[100];

void disp(void)
{
  for (int i=0; i<N; ++i) {
    cout << A[i];
    if (i != (N-1)) {
      cout << " ";
    } else {
      cout << "\n";
    }
  }
}

int main(void)
{
  cin >> N;
  for (int i=0; i<N; ++i) {
    cin >> A[i];
  }
  disp();
  for (int i=1; i<N; ++i) {
    int v = A[i];
    int j = i - 1;
    while ( (j>=0) && (A[j] > v) ) {
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    disp();
  }
  
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

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

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
	ll i, j;
	ll N;
	cin >> N;
	string S;
	cin >> S;
	ll ans = N;
	for (i = 0; i < N - 1; i++) {
		if (S[i] == S[i + 1]) {
			ans--;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
import collections
import sys
input = sys.stdin.readline
H, W = map(int, input().split())
A = [list(input()) for i in range(H)]
dp = [[H+W]*W for i in range(H)]

q = collections.deque()
for i in range(H):
    for j in range(W):
        if A[i][j] == "#":
            dp[i][j] = 0
            q.append([i, j])
            break
    if q:
        break


while(q):
    x, y = q.popleft()
    if x > 0:
        if dp[x-1][y] > dp[x][y]+1:
            if A[x-1][y] == ".":
                dp[x-1][y] = dp[x][y]+1
            else:
                dp[x-1][y] = 0
            q.append([x-1, y])
    if x < H-1:
        if dp[x+1][y] > dp[x][y]+1:
            if A[x+1][y] == ".":
                dp[x+1][y] = dp[x][y]+1
            else:
                dp[x+1][y] = 0
            q.append([x+1, y])
    if y > 0:
        if dp[x][y-1] > dp[x][y]+1:
            if A[x][y-1] == ".":
                dp[x][y-1] = dp[x][y]+1
            else:
                dp[x][y-1] = 0
            q.append([x, y-1])
    if y < W-1:
        if dp[x][y+1] > dp[x][y]+1:
            if A[x][y+1] == ".":
                dp[x][y+1] = dp[x][y]+1
            else:
                dp[x][y+1] = 0
            q.append([x, y+1])
ans = 0
for i in range(H):
    ans = max(ans, max(dp[i]))
print(ans)


Measured memory_bytes: 127448
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string str;
  cin >> str;
  int atcglen = 0;
  int atcgmax = 0;
  for(int i=0 ; i < str.size(); i++ ){
    if (str.at(i) == 'A'||str.at(i) == 'T'||str.at(i) == 'G'||str.at(i) == 'C'){
      atcglen++;
      if (atcglen > atcgmax){
        atcgmax = atcglen;
      }
    } else {
      atcglen = 0;
    }
  }
  cout << atcgmax << endl;
}

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

int main()
{
	int n, ans=1e9;
	cin >> n;
	vector<int> a(n);
	for (int i=0; i<n; i++) cin >> a.at(i);
	for (int i=0; i<n; i++) {
		int j = 0;
		while (a.at(i) % 2 == 0) {
			a.at(i) /= 2;
			j++;
		}
		ans = min(ans, j);
	}

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 256
N, W = map(int, input().split())

DP = [[0] * (W + 1) for _ in range(N+1)]

for i in range(1, N+1):
    w, v = map(int, input().split())
    for j in range(1, W+1):
        DP[i][j] = max(DP[i][j-1], DP[i-1][j])
        if j - w >= 0:
            DP[i][j] = max(DP[i][j], DP[i-1][j-w] + v)

print(DP[N][W])


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

void solve(int ans[10001]){
    bool flag=true;
    int count=0;
    int all=0;
    for(int i=2;;i++){
        for(int j=2;j<i/2+1;j++){
            if(i%j==0){
                flag=false;
                break;
            }
        }
        if(flag){
            count++;
            all += i;
            ans[count]=all;
            if(count==10000){
                break;
            }
        }
        else{
            flag=true;
        }
    }
}

int main()
{
    int ans[10001];
    solve(ans);
    int num;
    while(cin>>num,num){
        cout<<ans[num]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1196
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:

};

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

    int n;
    cin >> n;
    int d;
    cin >> d;

    vector<vector<int>> P(n);
    for (int i = 0; i < n; ++i) {
        vector<int> p;
        for (int j = 0; j < d; ++j) {
            int x;
            cin >> x;
            p.push_back(x);
        }
        P[i] = p;
    }

    auto ok = [&](vector<int>& A, vector<int>& B) {
        int n = A.size();
        long long dis = 0;

        for (int i = 0; i < n; ++i) {
            int d = A[i] - B[i];
            dis += d * 1LL * d;
        }

        int d = (int)(sqrt(dis) + 0.5);
        return d * 1LL * d == dis;
    };
    
    int res = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            if (ok(P[i], P[j])) {
                ++res;
            }
        }
    }

    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace test
{
    class Program
    {
        struct Vector
        {
            public decimal x;
            public decimal y;
        }

        static void Main(string[] args)
        {
            List<string> resultList = new List<string>();

            string input;
            while ((input = Console.ReadLine()) != null)
            {
                string[] inputArray = input.Split(' ');

                int gap = GetGapNumber(inputArray);

                resultList.Add(GetCorrectTexts(input, gap));

            }

            foreach (string s in resultList)
            {
                Console.WriteLine(s);
            }

        }

        static int GetGapNumber(string[] inputArray)
        {
            int gap = 0;

            foreach (string s in inputArray)
            {
                if (s.Length == 3)
                {
                    if ((int)s[0] - (int)s[1] == 12 || (int)s[0] - (int)s[1] == -14)
                    {
                        if ((int)s[1] - (int)s[2] == 3 || (int)s[1] - (int)s[2] == -23)
                        {
                            gap = (int)s[0] - 116;
                            break;
                        }

                    }

                }
                else if (s.Length == 4)
                {
                    if ((int)s[0] - (int)s[1] == 12 || (int)s[0] - (int)s[1] == -14)
                    {
                        if ((int)s[1] - (int)s[2] == -1 || (int)s[1] - (int)s[2] == 25)
                        {
                            if ((int)s[2] - (int)s[3] == -10 || (int)s[2] - (int)s[3] == 16)
                            {
                                gap = (int)s[0] - 116;
                                break;
                            }
                        }
                        else if ((int)s[1] - (int)s[2] == 7 || (int)s[1] - (int)s[2] == -19)
                        {
                            if ((int)s[0] == (int)s[3])
                            {
                                gap = (int)s[0] - 116;
                                break;
                            }
                        }
                    }
                }
            }

            return gap;
        }


        static string GetCorrectTexts(string input, int gap)
        {
            StringBuilder sb = new StringBuilder();
            foreach (char c in input)
            {
                if ((int)c >= 97 && (int)c <= 122)
                {
                    int a = (int)c - gap;
                    if (a > 122)
                    {
                        a -= 26;
                    }
                    else if (a < 97)
                    {
                        a += 26;
                    }

                    sb.Append((char)a);
                }
                else
                {
                    sb.Append(c);
                }

            }

            return sb.ToString();

        }

    }
}

Measured memory_bytes: 5408
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)


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

ll n,p,ans=1;
int main(){
	scanf("%lld%lld",&n,&p);
	for(ll k=2;k*k<=p;k++)if(p%k==0){
		int cnt=0;
		while(p%k==0)p/=k,cnt++;
		ans*=po(k,cnt/n);
	}
	if(p!=1)ans*=po(p,1/n);
	printf("%lld",ans);
}

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

int main()
{
    int n,m,c,s=0;
    cin>>n;
    if(n==25)
        cout<<"Christmas"<<endl;
    if(n==24)
        cout<<"Christmas Eve"<<endl;
    if(n==23)
        cout<<"Christmas Eve Eve"<<endl;
    if(n==22)
        cout<<"Christmas Eve Eve Eve"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;

//解説ac

int main()
{
	int a;
	ll b, n;
	cin >> a >> b >> n;
	ll x = b - 1;
	if (n < b) x = n;
	cout << a*x / b;
}

Measured memory_bytes: 3632
def judge(x):
    count = 0
    for hi in h:
        count += max(hi - b*x + c-1, 0)//c 
    if count<=x:
        return True
    else:
        return False

n,a,b=map(int,input().split())
h = [int(input()) for _ in range(n)]

c= a-b

ng = 0
ok = 10**9

while ok - ng > 1:
    mid = (ng+ok)//2
    if judge(mid):
        ok = mid
    else:
        ng = mid
        
print(ok)

Measured memory_bytes: 7196
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int n, m, x, y;
    cin >> n;
    m = n/15;
    x = 800*n;
    y = 200*m;
    cout << x-y;

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5, M = 3e3 + 5;
char s[N];
int cnt[M];
int main()
{
    int k = 1, sum = 0;
    scanf("%s", s);
    int len = strlen(s);
    for (int i = len - 1; ~i; --i)
    {
        sum = (sum + k * (s[i] - '0')) % 2019;
        ++cnt[sum];
        k = k * 10 % 2019;
    }
    ll ans = 0;
    for (int i = 0; i < 2019; ++i)
    {
        if (!i)
            ans += cnt[i];
        ans += cnt[i] * (cnt[i] - 1ll) / 2;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3924
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,n,x;
  cin >> N;
  int sum=0;
  n=N;
  
  while (n>0){
    x = n%10;
    n=n/10;
    sum = sum + x;
  }

  if (N%sum == 0){
    cout << "Yes" << endl;
  }
    else{
      cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

const double PI = acos(-1);
constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class Task{
public:
    void solve(istream& in, ostream& out){
        int H, W, K, nxt = 1;
        in>>H>>W>>K;
        vc<string> grid(H);
        vvc<int> ans(H, vc<int>(W, 0));
        for(auto& g : grid) in>>g;
        vc<int> cntc(W, 0);
        REP(i, H) REP(j, W) if(grid[i][j]=='#') cntc[j]++;
        REP(j, W){
            if(not cntc[j]) continue;
            REP(i, H){
                ans[i][j] = (cntc[j] ? nxt : nxt-1);
                if(grid[i][j]=='#') ++nxt, cntc[j]--;
            }
        }
        REP(i, H){
            REP(j, W){
                if(not ans[i][j]) continue;
                for(int k=j-1;0<=k;--k){
                    if(ans[i][k]) break;
                    ans[i][k] = ans[i][j];
                }
                for(int k=j+1;k<W;++k){
                    if(ans[i][k]) break;
                    ans[i][k] = ans[i][j];
                }
            }
        }
        REP(i, H){
            REP(j, W) out<<ans[i][j]<<' ';
            out<<'\n';
        }
    }
};

int main(){
    istream& in(cin);
    ostream& out(cout);
    ios_base::sync_with_stdio(false);
    in.tie(nullptr), out.tie(nullptr);
    Task solver;
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 4128
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

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

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInt2() (int, int) {
	return nextInt(), nextInt()
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, c := nextInt2()
	x, v := make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		x[i], v[i] = nextInt(), nextInt()
	}

	sv1 := make([]int, n)
	sv1[0] = v[0] - x[0]
	for i := 1; i < n; i++ {
		sv1[i] = sv1[i-1] + v[i] - (x[i] - x[i-1])
	}
	sv2 := make([]int, n)
	sv2[n-1] = v[n-1] - (c - x[n-1])
	for i := n - 2; i >= 0; i-- {
		sv2[i] = sv2[i+1] + v[i] - (x[i+1] - x[i])
	}

	vmax1 := make([]int, n)
	vmax1[0] = 0
	for i := 1; i < n; i++ {
		if sv1[i] > sv1[vmax1[i-1]] {
			vmax1[i] = i
		} else {
			vmax1[i] = vmax1[i-1]
		}
	}
	vmax2 := make([]int, n)
	vmax2[n-1] = n - 1
	for i := n - 2; i >= 0; i-- {
		if sv2[i] > sv2[vmax2[i+1]] {
			vmax2[i] = i
		} else {
			vmax2[i] = vmax2[i+1]
		}
	}

	ans := 0
	for i := 0; i < n; i++ {
		get := sv1[vmax1[i]]
		if i < n-1 {
			getRev := get - x[vmax1[i]] + sv2[vmax2[i+1]]
			ans = max(ans, get, getRev)
		} else {
			ans = max(ans, get)
		}
	}
	for i := n - 1; i >= 0; i-- {
		get := sv2[vmax2[i]]
		if i > 0 {
			getRev := get - (c - x[vmax2[i]]) + sv1[vmax1[i-1]]
			ans = max(ans, get, getRev)
		} else {
			ans = max(ans, get)
		}
	}

	puts(ans)
}


Measured memory_bytes: 7688
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


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

    int s = max(A, C), f = min(B, D);

    cout << max(0, f-s) << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		sc.close();

		int p = (int)Math.pow(N, 0.5);

		int ans = Integer.MAX_VALUE;
		for(int i = 1 ; i <= p ; i++){
			if(N%i == 0){
				ans = Math.min(ans, comp(i,N/i));
			}
		}

		System.out.println(ans);

	}
	private static int comp(long m, long n) {
	    if(Long.toString(m).length() >= Long.toString(n).length()){
	    	return Long.toString(m).length();
	    }
	    else{
	    	return Long.toString(n).length();
	    }
	}
}


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

int main(){
    int n;
    cin>>n;
    vector<int> p(n);
    rep(i,n){
        cin>>p[i];
    }
    int ans=0;
    for(int i=1; i<n-1; i++){
        if(p[i-1]<p[i]&&p[i]<p[i+1])ans++;
        if(p[i-1]>p[i]&&p[i]>p[i+1])ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
import itertools

N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]

imos = [0] * (N + 2)
for lr in LR:
    l, r = lr[0], lr[1]
    imos[l] += 1
    imos[r + 1] -= 1
acc = itertools.accumulate(imos)

res = 0
for a in acc:
    if a == M:
        res += 1

print(res)

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

#define ll long long
ll S, x[3], y[3];

int main() {
	while (scanf("%lld", &S) != EOF) {
		ll E9 = 1e9;
		x[0] = 0, y[0] = 0;
		x[2] = 1e9, y[2] = 1;
		y[1] = S / (E9) + (S % E9 != 0);
		x[1] = y[1] * E9 - S;
		for (int i = 0; i < 3; ++i) {
			printf("%lld %lld%c", x[i], y[i], " \n"[i == 2]);
		}
	}
	return 0;
}


Measured memory_bytes: 256
H,W,K=map(int,input().split())
import numpy as np
def f(x):
  if x=='.':
    return 0
  else:
    return 1
C=np.array([list(map(f,list(input()))) for i in range(H)])
ans=0
for h in range(1,2**H):
  _h=[]
  for i in range(H):
    if h%2==1:
      _h.append(i)
    h=h//2
  
  for w in range(1,2**W):
    _w=[]
    for i in range(W):
      if w%2==1:
        _w.append(i)
      w=w//2
    _h=np.array(_h)
    _w=np.array(_w)
    a=C[_h[:,None],_w]
    if np.count_nonzero(a)==K:
      ans+=1
print(ans)

Measured memory_bytes: 26976
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1000000007
#define mxval 1e9 + 7
#define grt [](auto x,auto y){return x>y;}
#define pii pair<int,int>
/*********VARIABLE****************/
using namespace std;
int i,j,n,m,k,l,q,t,a,b,sum[3],tot[3],cnt[3];
/*********FUNCTIONS**************/
int powom(int a,int b) {
    int result = 1;
    while (b > 0) {
        if (b & 1)
            result = result * a;
        a = a * a;
        b >>= 1;
    }
    return result;
}
/***********MAIN**************/
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cin>>n;
    vector<int> v(n);
    for(auto &x : v){
        cin>>x;
    }
    sort(all(v));
    long double ans = v[0];
    for(int i=1;i<n;i++){
        ans = (ans+v[i])/2.0;
    }
    cout<<ans;
    return 0;
}
//.........

Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	string s, t; cin >> s >> t;
	int n = s.size() - t.size();
	int res = 1000;
	for (int i = 0; i <= n; ++i)
	{
		int cnt = 0;
		rep(j, t.size())
		{
			if (s[i + j] != t[j])++cnt;
		}
		chmin(res, cnt);
	}
	cout << res << endl;
}

Measured memory_bytes: 3628
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        DecimalFormat df = new DecimalFormat("0.00000000");
        
        final long H = Long.parseLong(sc.next());
        final int N = Integer.parseInt(sc.next());
        long sum = 0;
        for (int i=0; i<N; i++)
            sum += Long.parseLong(sc.next());
        out.println(sum >= H ? "Yes" : "No");
        
        out.flush();
    }
}

Measured memory_bytes: 45032
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
char a[15]={'a','b','c','d','e','f','g','q','r','s','t','v','w','x','z'};
using namespace std;
int main(){
    char str[33]={0};
    while(1){
        scanf("%s",str);
        if(str[0] == '#')break;
        int len = 0;
        len = strlen(str);
        int cnt = 0;
        int x = 0;
        int f = 0;
        for(int i = 0;i < len; i++){
            for(int j = 0;j < 15; j++){
                if(str[i] == a[j]){
                    f = 1;
                    break;
                }
                else {
                    f = 0;
                }
            }
            if(i == 0){
                x = f;
                continue;
                }
            if(x == f){
                continue;
            }
            cnt++;
            x = f;
        }
        printf("%d\n",cnt);
    }
    return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> p(n, vector<int>(n, 0));
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        p[a-1][b-1]++;
        p[b-1][a-1]++;
    }
    for (int i = 0; i < n; i++) cout << accumulate(p[i].begin(), p[i].end(), 0) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
int main(){
    string s1,s2;
    cin >> s1;
    cin >> s2;
    if(s1.size()==s2.size()){
        for(int i=0;i<s1.size();i++){
            cout << s1[i] << s2[i];
        }
    }
    else{
        cout << s1[0];
        for(int i=0;i<s2.size();i++){
            cout << s2[i] << s1[i+1];
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int main()
{
	long long a, b;
	scanf("%lld%lld", &a, &b);
	if (a > 0 && b > 0) {
		printf("Positive");
	}
	else if (a < 0 && b>0) {
		printf("Zero");
	}
	else {
		if ((a + b + 1) % 2 == 0) {
			printf("Positive");
		}
		else {
			printf("Negative");
		}
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = 0;
		for(int i = 0; i < 4; i++) {
			if(n%10 == 2) {
				ans ++;
			}
			n /= 10;
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  cout << a[0]+a[1];
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MOD 1000000007
int main(void){
  long long int n,k,ans=0;
  scanf("%lld %lld",&n,&k);
  for(long long int i=k;i<=n+1;i++){
    ans=(ans+(n-i+1)*i+1)%MOD;
  }
  printf("%lld\n",ans);
}

Measured memory_bytes: 1696
A,B,C,X,Y = map(int,input().split())
ans = 100000000000000000000000000000000000000
for c in range (0,100001):
  price = A*max(0,X-c)+B*max(0,Y-c)+C*2*c
  if price < ans:
    ans = price
print(int(ans))


Measured memory_bytes: 9100