akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string.h>
#include <bits/stdc++.h>

using namespace std;

char a[1000010];

int main()
{
    int b,i,l=0,sum=0,m=0;
    scanf("%s",a);
    b=strlen(a);
    for(i=0;i<b;i++)
    {
        if(a[i]=='g'&&l<m)
        {
            sum++;
            l++;
        }
        else if(a[i]=='g'&&l>=m)
        {
            m++;
        }
        else if(a[i]=='p'&&l>=m)
        {
            sum--;
            m++;
        }
        else if(a[i]=='p'&&l<m)
        {
            l++;
        }
    }
    printf("%d",sum);
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void){
  int k,x,i;
  scanf("%d%d",&k,&x);
  for(i=x-k+1;i<=x+k-1;i++){
    printf("%d",i);
    if(i!=x+k-1)
    printf(" ");
  }
  printf("\n");
  return(0);
}


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

int main(void){
    int N;
    cin>>N;
    for(int i=N;i<1000;i++){
        string n=to_string(i);
        int cnt=0;
        for(int j=0;j<n.size();j++){
            if(n[j]==n[0])
                cnt++;
        }
        if(cnt==n.size()){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import bisect

N,M = map(int,input().split())

P = []
Y = []
PY = []
dic = {}
for i in range(M):
    p,y = map(int,input().split())
    P.append(p)
    Y.append(y)

    dic[y] = ''

    PY.append((p,y))

PY = sorted(PY)
P  = sorted(P)
lenP = len(P)
left = 0
righ = 0
for i in range(1,N+1):

    t_list = []

    left = bisect.bisect_left(P,i,0,lenP)
    righ = bisect.bisect_right(P,i,0,lenP)

    # print(i,P)
    # print(left,righ)

    if i == P[left]:
        for j in range(left,righ):
            t_list.append(PY[j][1])
        t_list = sorted(t_list)
        for k in range(len(t_list)):
            y = t_list[k]
            dic[y] = str(i).zfill(6) + str(k+1).zfill(6)

    if lenP == righ:
        # print('break')
        break

for y in Y:
    print(dic[y])


Measured memory_bytes: 34292
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;

/*DP使ったほうがよくない？？WOWWOW*/
int main(){
  map<int,int> x;
  for(int i=0; i<3; i++){
    int s; cin>>s;
    x[s]=2;
  }
  if(x.size()==2){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }

}

Measured memory_bytes: 256
//AtCoder ABC050 B - Contest with Drinks Easy
#include <bits/stdc++.h>
using namespace std;
using lli=int64_t;

int main() {
    int N;
    cin>>N;
    vector<int> tbl(N+1,0);
    for(int i=1;i<=N;++i){
        cin>>tbl[i];
    }
    int M;
    cin>>M;
    vector<pair<int,int>> pt(M);
    for(auto&& p:pt){
        cin>>p.first>>p.second;
    }
    //brute-force?
    for(const auto& p:pt){
        lli ans=0;
        for(int i=1;i<=N;++i){
            ans += (i==p.first)?p.second:tbl[i];
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


int main(int argc, char const *argv[]) {
    int k;
    cin>>k;
    int n=k;
    if (k<=1){
        cout << k << endl;
        for(int i=1;i<=k;++i){
            for(int j=0;j<k;++j){
                cout << i;
                cout << " ";
            }
            cout<<endl;
        }
        return 0;
    }
    else{
        int m=((k+3)/4);
        int s=4*m-k;
        //4*m-s=k
        cout<<2*m<<endl;
        for(int i=0;i<2*m;++i){
            if(i%2==0){
                for(int j=0;j<2*m;++j){
                    cout<<(i+j)%(2*m)+1<<" ";
                }
                cout<<endl;
            }
            else{
                for(int j=0;j<2*m;++j){
                    int l=(i+j)%(2*m)+1;
                    if(l<=s){
                        cout<<l<<" ";
                    }
                    else{
                        cout<<2*m+l-s<<" ";
                    }
                }
                cout<<endl;
            }
        }
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1152
import java.util.*;
import java.io.*;

class Main {

    static int[] makePrimeArray( int lim ) {

	boolean[] isPrime = new boolean[lim + 1];
	Arrays.fill( isPrime, true );
	isPrime[0] = isPrime[1] = false;
	
	int index = 2;
	final int indexLim = ( int )Math.sqrt( lim );
	while ( index <= indexLim ) {
	    for ( int i = index * 2; i < lim; i += index ) {
		isPrime[i] = false;
	    }
	    index++;
	    while ( index <= indexLim && !isPrime[index] ) {
		index++;
	    }
	}
	int primeNo = count( isPrime, true );
	int[] ans = new int[primeNo];
	index = 0;
	for ( int i = 2; i <= lim; i++ ) {
	    if ( isPrime[i] ) {
		ans[index] = i;
		index++;
	    }
	}
	return ans;
    }

    static int count( boolean[] array, boolean val ) {
	int count = 0;
	for ( boolean a : array ) {
	    if ( a == val ) {
		count++;
	    }
	}
	return count;
    }
    
    public static void main(String[] args) {

	final Scanner stdin = new Scanner(System.in);

	int[] primes = makePrimeArray( 60000 );

	while ( stdin.hasNextInt() ) {

	    final int n = stdin.nextInt();
	    final int index = Arrays.binarySearch( primes, n );
	    if ( 0 <= index ) {
		System.out.printf( "%d %d\n", primes[index - 1], primes[index + 1] );
	    } else {
		System.out.printf( "%d %d\n", primes[-index - 2], primes[-index - 1] );
	    }	    
	}
    }    
}

Measured memory_bytes: 20192
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cctype>
#include<cstring>
#include<utility>
#include<cmath>
#include<string>
using namespace std;

int main(void){
  long long n,t=1,a=1,tt,ta;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>tt>>ta;
    long long x=t,y=a;
    if(x%tt==0) x/=tt;
    else x=x/tt+1;
    if(y%ta==0) y/=ta;
    else y=y/ta+1;
    long long j=max(x,y);
    t=j*tt;
    a=j*ta;
  }
  cout<<t+a<<endl;
  return 0;
}


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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  string S; cin >> S;
  ll n = S.size();
  ll p = 0;
  ll q = n-1;
  ll cnt = 0;
  while (p < q) {
    if (S[p] != S[q]) cnt++;
    p++;
    q--;
  }
  cout << cnt << endl;

  return 0;
}



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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

ll power(ll x,ll y,ll mod){
	ll result=1;
	while(y>0){
		if(y&1) result=result*x%mod;
		x=x*x%mod;
        y>>=1;
	}
	return result;
}

void solve(){
    ll m,n;
    cin >> m >> n;
    cout << power(m,n,1e9+7) << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

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

int find_all(const string str, const string subStr)
{
  int cnt = 0;
  int subStrSize = subStr.size();
  int pos = str.find(subStr);

  while (pos != string::npos)
  {
    cnt++;
    pos = str.find(subStr, pos + subStrSize);
  }
  return cnt;
}

int main()
{
  int N;
  cin >> N;
  int ans = 0;
  vector<string> s(N);
  int AB_cnt = 0;
  for (int i = 0; i < N; i++)
  {
    cin >> s.at(i);
  }
  for (int i = 0; i < N; i++)
  {
    AB_cnt += find_all(s.at(i), "AB");
  }
  int B_left = 0;
  int A_right = 0;
  int B_left_A_right = 0;
  for (int i = 0; i < N; i++)
  {
    if (s.at(i).at(0) == 'B')
      B_left++;
    if (s.at(i).at(s.at(i).size() - 1) == 'A')
      A_right++;
    if (s.at(i).at(0) == 'B' && s.at(i).at(s.at(i).size() - 1) == 'A')
      B_left_A_right++;
  }
  int B_left_only = B_left - B_left_A_right;
  int A_right_only = A_right - B_left_A_right;
  int made_AB = 0;
  if (B_left_A_right > 0)
  {
    made_AB += B_left_A_right - 1;
    if (B_left_only > 0 && A_right_only > 0)
    {
      made_AB += 2;
      made_AB += min(B_left_only - 1, A_right_only - 1);
    }
    else if (B_left_only == 0 && A_right_only > 0)
    {
      made_AB += 1;
    }
    else if (B_left_only > 0 && A_right_only == 0)
    {
      made_AB += 1;
    }
  }
  else
  {
    made_AB += min(B_left_only, A_right_only);
  }
  ans = AB_cnt + made_AB;
  cout << ans << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	char c;
	cin >> c;
	int x = c - 'A';
	if(x < 26) cout << 'A';
	else cout << 'a';
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  string s;
  cin>>s;
  ll k;
  cin>>k;

  ll n=s.size();
  ll dp[n][2][k+1];
  REP(i,n)REP(j,2)REP(r,k+1)dp[i][j][r]=0;

  ll cnt=0;
  REP(i,n){
    if(s[i]!='0')
      cnt++;

    REP(j, k+1){
      if(cnt!=j)
        dp[i][0][j]=0;
      else
        dp[i][0][j]=1;
    }

    if(i==0){
      dp[i][1][0]=1;
      dp[i][1][1]=(s[i]-'0')-1;
    }
    else{
      dp[i][1][0]=1;
      REP1(j,k+1){
        dp[i][1][j]=dp[i-1][1][j-1]*9 + dp[i-1][1][j]*1 +
          dp[i-1][0][j-1]*max(s[i]-'0'-1,0) + dp[i-1][0][j]*min(s[i]-'0',1);
      }
    }
  }

  cout<<dp[n-1][0][k]+dp[n-1][1][k]<<endl;

}


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

int main(){
  int n;
  cin>>n;
  double m=sqrt(n);
  cout<<n<<':';
  while(n%2==0) {
    cout<<" "<<2;
    n/=2;
  }
  for(int i=3;i<=m;i+=2){
    while(n%i==0){
      cout<<" "<<i;
      n/=i;
    }
  }
  if(n!=1) cout<<" "<<n;
  cout<<endl;
}







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

int main()
{
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    for (int i = 0; i < n; i++)
    {
        int u, k;
        cin >> u >> k;
        --u;
        for (int j = 0; j < k; j++)
        {
            int v;
            cin >> v;
            --v;

            g[u].push_back(v);
        }
    }
    vector<int> dist(n, -1);
    queue<int> q;
    q.push(0);
    dist[0] = 0;
    while (!q.empty())
    {
        int v = q.front();
        q.pop();
        for (auto next : g[v])
        {
            if (dist[next] != -1)
            {
                continue;
            }
            dist[next] = dist[v] + 1;
            q.push(next);
        }
    }
    for (int i = 0; i < n; i++)
    {
        cout << i + 1 << " " << dist[i] << endl;
    }
}



Measured memory_bytes: 3132
from itertools import combinations_with_replacement


n, m, q = map(int, input().split())
cl = []
dl = []
abl = []

for _ in range(q):
    a, b, c, d = map(int, input().split())
    cl.append(c)
    dl.append(d)
    abl.append([a, b])

ans = 0
for comb in list(combinations_with_replacement(range(1, m+1), n)):
    point = 0
    for i, ab in enumerate(abl):
        a, b = ab
        if comb[b-1] - comb[a-1] == cl[i]:
            point += dl[i]
    ans = max(ans, point)
print(ans)







Measured memory_bytes: 21448
#include <iostream>
#include<bits/stdc++.h>
#define lli long long
using namespace std;



int main()
{

        int n,m;
        cin>>n>>m;
        int x;
        cin>>x;
        int price[n+5];
        int ara[n+5][m+5];

        for(int i=1;i<=n;i++)
        {
            cin>>price[i];
            for(int j=1;j<=m;j++)
                cin>>ara[i][j];

        }
        int big=1<<n;
        big--;

        int ans=1e9;
        for(int i=0;i<=big;i++)
        {

            int temp[m+5];
            memset(temp,0,sizeof temp);
            int tt=0;
            for(int j=0;j<n;j++)
            {
                if(i&(1<<j))
                {
                    for(int k=1;k<=m;k++)
                        temp[k]+=ara[j+1][k];
                    tt+=price[j+1];

                }
                bool fl=1;
                for(int i=1;i<=m;i++)
                {
                    if(temp[i]<x)
                    {
                        fl=0;
                        break;
                    }

                }
                if(fl)ans=min(ans,tt);
            }



        }
        if(ans==1e9)ans=-1;

        cout <<ans<<endl;






}


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

rua = [0] * (n + 1)
rub = [0] * (n + 1)
for i in range(n):
    rua[i + 1] = rua[i] + a[i]
    rub[i + 1] = rub[i] + b[i]
    
ans = 0
for i in range(n):
    ans = max(ans, rua[i + 1] + rub[n] - rub[i])
print(ans)


Measured memory_bytes: 38256
object Main {

	def main(arg:Array[String]) = {
		val n = scala.io.StdIn.readLine().toInt;
		var list = scala.io.StdIn.readLine().split(" ").map(_.toInt);
  		list.reverse;

  		val sorted = list.sorted;
  		val left = sorted(sorted.size / 2 - 1);
  		val right = sorted(sorted.size / 2);

  		for (x <- list) {
  			if (x <= left) println(right);
  			else println(left);
  		}
	}
}



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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n;
vll l;
vll dp;

int main(){
  cin >> n;
  l.push_back(1);
  for(lli x = 6;x <= n;x*=6){
    l.push_back(x);
  }
  for(lli x = 9;x <= n;x*=9){
    l.push_back(x);
  }
  dp = vll(n+1,INT_MAX);
  dp[0] = 0;
  for(lli i = 0;i <= n;i++){
    for(lli y : l){
      if(i+y <= n) dp[i+y] = min(dp[i+y],dp[i]+1);
    }
  }
  cout << dp[n] << endl;

}


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

int main(){
    int N,K;cin>>N>>K;
    string s;cin>>s;
    vector<int> L,R;
    s="a"+s+"a";
    int count=0,count1=0;
    for(int i=1;i<N+2;i++){
        if(s.at(i)==s.at(i-1))count++;
        else if(s.at(i-1)=='R'&&s.at(i)=='L')count1++;
        else if(s.at(i-1)=='L'&&s.at(i)=='R')count1++;
    }

    int p=count1/2;
    int ans;
    if(K<=p){
        ans=count+K*2;
    }
    else if(count1%2==0){
        ans=N-1;
    }
    else{
        ans=count+p*2+1;
    }

    cout<<ans<<endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD=1e9+7;

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

  ll n,m;cin>>n>>m;
  std::vector<ll> ans;
  std::vector<bool> used(n+1);
  for(int i=1;i<=n;i++)used[i]=false;
  for(int i=0;i<m;i++){
      int e;cin>>e;
      ans.push_back(e);
  }
  for(int i=(int)ans.size()-1;i>=0;i--){
      if(!used[ans[i]]){
          cout<<ans[i]<<endl;
          used[ans[i]]=true;
      }
  }
  for(int i=1;i<=n;i++){
      if(!used[i]) cout<<i<<endl;
  }
  return 0;
}

Measured memory_bytes: 3972
def main():
    n, m = map(int, input().split())
    t = 1900 * m + 100 * (n-m)
    a = (1/2) ** m
    r = 1 - a

    print(int(a*t / ((1-r)**2)))
 
    
    
if __name__ == "__main__":
    main()

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

int main() {
 char b;
 cin >> b;
 char p;
 if (b == 'A') {
   p = 'T';
 } else if (b == 'T') {
   p = 'A';
 } else if (b == 'C') {
   p = 'G';
 } else {
   p = 'C';
 }
 cout << p << endl;
}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

def main():
    x1, y1, x2, y2 = map(int, sys.stdin.readline().split())
    dx = x2 - x1
    dy = y2 - y1
    print(x2 - dy, y2 + dx, x1 - dy, y1 + dx)

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int main()
{
    int n, d, a;
    cin >> n >> d >> a;
    vector<pair<long long, long long>> m(n);
    for (auto &&i : m)
    {
        cin >> i.first >> i.second;
        i.second = (i.second + a - 1) / a;
    }
    sort(begin(m), end(m));
    long long ans = 0;
    vector<pair<long long, long long>> s;
    long long minus = 0;
    int p = 0;
    for (int i = 0; i < n; i++)
    {
        while (p < s.size() && s[p].first < m[i].first)
        {
            minus -= s[p].second;
            p++;
        }
        long long check = max(0ll, m[i].second - minus);
        ans += check;
        minus += check;
        s.push_back(make_pair(m[i].first + d * 2, check));
    }
    cout << ans << "\n";
}

Measured memory_bytes: 9456
#include <bits/stdc++.h>
using namespace std;
#define arep(i, x, n) for (int i = int(x); i < (int)(n); i++)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9 + 7
using ll = long long;

int main() {
    float N;
    cin >> N;
    int sq = sqrt(N) + 1;

    int intN = N;
    int a[intN];
    rep(i, N) a[i] = 0;

    arep(i, 1, sq){
        arep(j, 1, sq){
            arep(k, 1, sq){
                int sum = i * i + j * j + k * k + i * j + j * k + k * i;
                if(sum <= intN){
                    a[sum - 1]++;
                }
            }
        }
    }

    rep(i, N) cout << a[i] << endl;
}

Measured memory_bytes: 3676
balls = gets.chomp.split(" ")
ball_counts = gets.chomp.split(" ").map(&:to_i)
ball_hash = {}
balls.length.times do |i|
  ball_hash[balls[i]] = ball_counts[i]
end
remove_ball_name = gets.chomp
ball_hash[remove_ball_name] -= 1
puts ball_hash.map {|k, v| v}.join(" ")

Measured memory_bytes: 3836
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

# N = int(readline())
# D = [int(d) for d in readline().split()]

import numpy as np

N, K = map(int, readline().split())
h = [int(x) for x in readline().split()]

print(len([x for x in h if x-K >= 0]))


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

int n;
string s;
int ans;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> s;
	for(int i=1; i+1<s.size(); ++i){
		string a = s.substr(0, i);
		string b = s.substr(i, s.size()-i);
		bool f[30] = {};
		bool g[30] = {};
		int tmp = 0;
		for(int j=0; j<a.size(); ++j)
			f[a[j]-'a'] = true;
		for(int j=0; j<b.size(); ++j)
			g[b[j]-'a'] = true;
		for(int j=0; j<26; ++j)
			if(f[j] && g[j])
				++tmp;
		ans = max(ans, tmp);
	}
	cout << ans << "\n";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define debug(var) cout << #var << ": " << var << endl;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
using ll = long long;
using ull = unsigned long long;
using vvint = vector<vector<int>>;
constexpr ll mod = 1e9 + 7;

int main() {

  int a; cin >> a;
  string s; cin >> s;
  if (a < 3200)cout << "red";
  else cout << s;

  return 0;
}

Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

using namespace std;

int main() {
	int n;
	int k;
	cin >> n;
	cin >> k;
	int ret = 1;
	for (int i = 0; i < n; i++) {
		if (ret < k) {
			ret <<= 1;
		} else {
			ret += k;
		}
	}
	cout << ret << endl;
	return 0;
}

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

object Main extends App {


  def exec(w:String):Unit =  {
    val len = w.length

    def shuffle(i:Int, cnt:Int):String =
      if(i == 0) (w drop (cnt%len))+(w take (cnt%len)) else { val m = readInt;shuffle(i-1, cnt+m) }

    if(w=="-") return else { val n = readInt;println(shuffle(n,0));exec(readLine) }

  }
  exec(readLine)
}

Measured memory_bytes: 43652
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	ll n,i,j,c;
	cin>>n;c=n;
	vector<ll>a,ans;
	a.pb(0);
	for(i=1;i<=n;i++){
		cin>>j;
		a.pb(j);
	}
	for(i=1;i<=n;i++){
		ll f=0;
		for(j=a.size()-1;j>0;j--)
			if(a[j]==j){
				a.erase(a.begin()+j);
				f=j;break;
			}
		//cout<<f<<"\n";
		if(f==0){cout<<"-1";return 0;}
		ans.pb(f);
	}
	reverse(all(ans));
	for(auto i:ans)cout<<i<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[300000];
int main(){
	ll n;
	cin>>n;
	ll i,j=1;
	for(i=0;i<n;i++){
		cin>>a[i];
		if(a[i]==j)
			j++;
	}
	if(j==1)
		cout<<"-1";
	else{
		cout<<n-j+1;
	}
} 

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

int main(){
	char S[10];
	cin >> S;
	int length = 0;
	int res = 0;
	for(int i = 0; S[i] != '\n' && S[i] != '\0'; i++){
		if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
			length++;
		}
		else{
			length = 0;
		}
		if(res < length) res = length;
	}
	cout << res << endl;
}


Measured memory_bytes: 256
from collections import deque
n = int(input())
to = [[] for i in range(n)]
col = [0] + [-1] * (n - 1)

for i in range(n - 1):
    u, v, w = map(int, input().split())
    to[u - 1].append((v - 1, w % 2))
    to[v - 1].append((u - 1, w % 2))

search = deque([0])
while search:
    v = search.popleft()
    for nv, nw in to[v]:
        if col[nv] != -1:
            continue
        col[nv] = (col[v] + nw) % 2
        search.append(nv)
print(*col, sep='\n')

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

using namespace std;

static int before = -1;
static int countN = 0;

int check(vector<int>& v){
	int n(0);
	for (auto x:v){
		if(x != 0){
			n++;
		}
	}
	return n;
}

void eat(vector<int>& v){
	int max = 0;
	int idx = -1;
    for(size_t i = 0; i < v.size(); ++i){
        if (i == before){
            continue;
        }else{
            if(max > v[i]){
                max = v[i];
                idx = i;
            }
        }
	}
    v[idx] -= 1;
	before = idx;
}



int main(){
	int K, T;
	scanf("%d %d", &K, &T);
    vector<int> a(T,0);
	if (T == 1){
		cout << K-1 << "\n";
		return 0;
	}
    
    int input;
    for (int i = 0; i< T; ++i){
        cin >> input;
        a[i] = input;
    }

    while (check(a) != 1){
	   int max = 0;
	   int idx = -1;
       for(size_t i = 0; i < a.size(); ++i){
           if (i == before){
             continue;
            }else{
                if(a[i] > max){
                    max = a[i];
                    idx = i;
                }
            }
	   }
        a[idx] -= 1;
	   before = idx;
    }
    
    for (auto x:a){
        countN += x;
    }
    
    cout << countN-1 << "\n";

}

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

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

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); --i)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

ll arr[MX], ac[MX];

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int N; cin >> N;

    F0R(i,N+1) cin >> arr[i];
    R0F(i,N+1) ac[i] = ac[i+1]+arr[i];

    ll cur = 1, res = 0;
    bool flag = false;
    F0R(i,N+1) {
        if (flag) {
            res += ac[i]; continue;
        }
        if (cur >= ac[i]) {
            res += ac[i]; flag = true;
            continue;
        }
        res += cur;
        cur -= arr[i];
        if (cur < 0) {
            res = -1; break;
        }
        cur *= 2;
    }

    cout << res << "\n";
}


Measured memory_bytes: 5212
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
int main(){
  int N;
  cin >> N;
  string s;
  cin >> s;
  string t_1="",t_2="";
  for(int i = 0;i < s.size();i++){
    if(i < s.size()/2)t_1 += s[i];
    else t_2 += s[i];
  }

  if(t_1 == t_2)cout << "Yes" << endl;
  else cout << "No" << endl; 
}

Measured memory_bytes: 256
<?php

//phpでは、変数はドル記号の後に変数名が続く形式で表現される.

$stdin = trim(fgets(STDIN));

//explodeで区切り文字によって文字列を分解.
//区切り文字はこの場合だと第一引数の" ".
$nums = explode(" ", $stdin);

//echoで出力.
echo (int)$nums[0] * (int)$nums[1];
 ?>



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

int main(){
	int n;
	cin >> n;
	while(n != 0){
		int s[n];
		for(int i = 0;i < n; i++){
			cin >> s[i];
		}
		sort(s,s+n);
		int tmp = 0;
		for(int i = 1;i < n-1; i++){
			tmp += s[i];
		}
		cout << tmp / (n-2) << endl;
		cin >> n;
	}
	return 0;
}


Measured memory_bytes: 3104
#include <stdio.h> 

int main()
{
	int a,i=1;
	while(scanf("%d",&a) )	
	{
		if(a == 0)
		{
			break;
		}
		printf("Case %d: %d\n",i++,a);
		
	}
	 
	return 0;
	
}


Measured memory_bytes: 2676
#include <iostream>

using namespace std;



int main()
{
    long long n,ans=0,p=10,k=1;
    cin>>n;
    if(n&1)
    {
        cout<<"0\n";
        return 0;
    }
    while(p<=n)
    {
        ans+=(n/p);
        p*=5;
        ++k;
    }
    cout<<ans<<"\n";
    return 0;
}


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

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

    if((A == B && B != C) || (A == C && C != B) || (B == C && C != A)){
        cout << "Yes" << endl;
    }

    else{
        cout << "No" << endl;
    }
}

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

using ll = long long;

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

	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	int n;
	ll k;
	cin>>n>>k;

	deque<int> path;
	vector<bool> vis(n+1);

	vector<int> A = {-69};

	for(int i=1; i<=n; i++)
	{
		int a;
		cin>>a;
		A.push_back(a);
	}

	int cur=1;

	while(!vis[cur])
	{
		if(k==0)
		{
			cout << cur << endl;
			return 0;
		}

		k--;

		vis[cur]=1;
		path.push_back(cur);

		cur = A[cur];
	}

	while(path.front()!=cur) path.pop_front();

	//cout << path.size() << endl;

	// while(!path.empty())
	// {
	// 	cout << path.front() << " ";
	// 	path.pop_front();
	// }

	// cout << k << endl;

	k %= ll(path.size());

	while(k--) path.pop_front();
	cout << path.front() << endl;
}

Measured memory_bytes: 4780
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
    ll n, a, b; cin >> n >> a >> b;
    ll ans = n / (a + b) * a;
    ll t = n % (a + b);
    if (t < a) ans += t;
    else ans += a;
    cout << ans << endl; 
}

Measured memory_bytes: 256
#include <stdio.h>

int count[1000010],check[1000010],x[200010];
int main()
{
	int a;
	scanf("%d",&a);
	for(int i=1;i<=a;i++) scanf("%d",&x[i]);
	for(int i=1;i<=a;i++) count[x[i]]++;
	
	int ans = 0;
	for(int i=1;i<=1000000;i++)
	{
		if(count[i]>0)
		{
			if(count[i]==1 && check[i]==0) ans++;
			for(int j=i;j<=1000000;j+=i) check[j] = 1;
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 10220
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = 0
    
    for i in range(n):
        if a[i] >= b[i]:
            a[i] = a[i] - b[i]
            c += b[i]
            b[i] = 0
        else:
            c += a[i]
            b[i] = b[i] - a[i]
            a[i] = 0
            if a[i+1] >= b[i]:
                a[i+1] = a[i+1] - b[i]
                c += b[i]
                b[i] = 0
            else:
                c += a[i+1]
                b[i] = b[i] - a[i+1]
                a[i+1] = 0
    print(c) 
           
if __name__ == '__main__':
    main()


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

int main() {
	string s,a,b,rs,ra,rb;
	cin>>s;
	int n=s.length();
	
	a=s.substr(0,(n-1)/2);
	b=s.substr((n+3)/2-1);
	
	rs=s;
	reverse(rs.begin(),rs.end());
	ra=a;
	reverse(ra.begin(),ra.end());
	rb=b;
	reverse(rb.begin(),rb.end());
	
	if(s==rs&&a==ra&&b==rb)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int a,b;
  cin>>a>>b;
  cout<<a-b+1;
  }


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

using namespace std;

#define pb push_back
#define sz(a) ((int)a.size())

const int maxn = 2e5 + 5;

int n;
long long a[maxn];
vector<long long> has;

int main() {
  cin >> n;

  for (int i = 0; i < n; i++) cin >> a[i];

  long long tot = 0;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    has.pb(a[i] - i);
    tot += (a[i] - i);
    ans += abs(a[i] - i);
  }

  sort(has.begin(), has.end());

  long long now = 0;
  for (int i = 0; i < sz(has); i++) {
    tot -= has[i];
    now += has[i];
    long long t1 = now - has[i] * (i + 1);
    long long t2 = tot - has[i] * (n - 1 - i);
    ans = min(ans, abs(t1) + abs(t2));
  }

  cout << ans;

  return 0;
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using G = vector<vector<int>>;
    
int main(){
    int k;
    cin >> k;
    int sev = 7;
    sev %= k;
    set<int> st;
    int ans = 0;
    while(st.count(sev)==0){
        if(sev==0){
            cout << ans+1 << endl;
            return 0;
        }
        st.insert(sev);
        sev = (sev*10+7) % k;
        ans++;
    }
    cout << -1 << endl;

    return 0;
}

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

#define vi vector<int>
#define vii vector<int, int>
#define ll long long
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
#else
#define trace(...) 42
#endif

const int MOD = 1000000007;

int main(){
    IOS;
    int x, a;
    cin >> x >> a;

    if (x < a) cout << 0 << endl;
    else cout << 10 << endl;

    #ifdef LOCAL
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif

    return 0;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int n = in.nextInt();
        int[] a = in.nextIntArray(n);
        for (int i : a) {
            if (i % 2 == 0) {
                if (!(i % 3 == 0 || i % 5 == 0)) {
                    out.println("DENIED");
                    return;
                }
            }
        }
        out.println("APPROVED");
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 22100
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
int gcd(int a,int b)
{
   if(b==0) return a;
   return gcd(b,a%b);
}
int main()
{
    int x,y;
    while(scanf("%d %d",&x,&y)!=EOF)
      printf("%d %d\n",gcd(x,y),x/gcd(x,y)*y);
    return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
#define INF (1<<29)
int main(){
  int n,m;
  cin>>n>>m;
  if(n<=2){
    for(int i=0;i<n;i++){
      cout<<m;
      if(i!=n-1)cout<<" ";
      else cout<<endl;
    }
    return 0;
  }
  if(n%2==0){
    for(int i=0;i<n/2-1;i++){
      cout<<0<<" ";
    }
    for(int i=n/2-1;i<n;i++){
      cout<<m;
      if(i!=n-1)cout<<" ";
      else cout<<endl;
    }
  }else{
    for(int i=0;i<n/2;i++){
      cout<<0<<" ";
    }
    for(int i=n/2;i<n;i++){
      cout<<m;
      if(i==n-1)cout<<endl;
      else cout<<" ";
    }
  }
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define ft              first
#define sd              second
#define ll          long long
#define pb              push_back
#define mkp           make_pair
#define pll             pair<ll,ll>
#define vll             vector<ll int>
#define mll             map<ll,ll>
#define pqg             priority_queue<ll>
#define pqs             priority_queue<ll,vll,greater<ll>>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod          1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define MAXN   10000001
void online_judge()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
}

void ISO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main() {

    ISO();
   //online_judge();
    ll int n;
    cin >> n;
    ll ans = 0;
    for (ll int i = 1; i <= n; ++i)
    {
        ll m = n/i;
        ans += ((m*(m+1))/2)*i;
    }
    cout << ans << "\n";
    //cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
    return 0;
}

Measured memory_bytes: 3608
//JSD
#include<iostream>
using namespace std;
int main(){
	string s;
	cin>>s;
	bool res=1;
	for(int i=0;i<s.length();i++){
		if(i%2==0 && s[i]=='L') res=0;
		if(i%2==1 && s[i]=='R') res=0;
	}
	if(res) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;}
ll lcm(ll x, ll y) {return x/gcd(x,y)*y;}



int main() {
    int k;
    cin>>k;
    ll ans=0;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int l=1;l<=k;l++){
                ll tmp=gcd(i,j);
                ans+=gcd(tmp,l);
            }
        }
    }

    cout<<ans<<endl;
}



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


int main() {
  int N;cin >> N;
  vector<int> A(3*N);
  vector<int> B(3*N);
  for (int i = 0;i < 3*N;i++){
    int c;cin >> c;
    A.at(i) = c;
    B.at(3*N-1-i) = c;
  }


  priority_queue<int> pq;
  priority_queue<int> qp;
  long long int red,blue;
  for (int i = 0;i < N;i++){
    red+=-A.at(i);
    pq.push(-A.at(i));
    blue+=B.at(i);
    qp.push(B.at(i));
  }
  vector<long long int> R(N+1);
  vector<long long int> L(N+1);
  R.at(0) = -red;
  L.at(0) = blue;
  for (int i = N;i < 2*N;i++){
    red+=-A.at(i);
    pq.push(-A.at(i));
    red-=pq.top();
    pq.pop();

    blue+=B.at(i);
    qp.push(B.at(i));
    blue-=qp.top();
    qp.pop();

    R.at(i+1-N) = -red;
    L.at(i+1-N) = blue;
    
    //cout << -red << " " << blue << endl;
  }
  long long int MAX = -pow(10,14);
  for (int i = 0;i <= N;i++){
    MAX = max(MAX,R.at(i)-L.at(N-i));
    //cout << R.at(i) << " " << L.at(N-i) << endl;
  }
  cout << MAX << endl;






}       

Measured memory_bytes: 5108
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

typedef vector<int> vi;

int main() {
	while (true) {
		int n, m, score[1001];
		vi v;
		cin >> n >> m;
		if (n == 0 && m == 0) break;
		REP(i, n) scanf("%d", &score[i]);
		score[n++] = 0;

		REP(i, n) FOR(j, i, n) if (score[i] + score[j] <= m)
			v.push_back(score[i] + score[j]);

		sort(v.begin(), v.end());
		unique(v.begin(), v.end());

		int ans = 0;
		REP(i, v.size()) {
			if (m - v[i] < 0) continue;
			vi::iterator it = upper_bound(v.begin(), v.end(), m - v[i]);
			if (it != v.begin())
				ans = max(ans, *(it - 1) + v[i]);
		}

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

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

int main(){
  int n;
  cin>>n;
  
  vector<int> data(n);
  for (int i=0;i<n;i++){
    cin>>data.at(i);
  }
  
  sort(data.begin(),data.end());
  cout<<data.at(n-1)-data.at(0)<<endl;
  
  
    
}
  













Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

long long int solve(long long int n){
	if(n==2){return 3;}
	else if(n==4||n==6||n==9||n==11){return 2;}
	else{return 1;}
}

int main() {
	long long int n=0,m,a,b,c,d,e;
	long double z,w;
	string str,str2,str3;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a>>b>>c;
	if(b-a==c-b){cout<<"YES";}
	else{cout<<"NO";}




	cout<<endl;
} 


Measured memory_bytes: 256
x,y=[int(x) for x in input().split()]
for i in range(x):
  print("#"*y)

while True:
  x,y=[int(x) for x in input().split()]
  print()
  if x==0 and y==0:
    break
  else:
    for i in range(x):
      print("#"*y)



Measured memory_bytes: 5620
#include <stdio.h>
#include <set>

using namespace std;

set<int> hash;
int card[10];

inline int digit(int n)
{
	if (n >= 10){
		return (100);
	}
	else {
		return (10);
	}
}

int sel_card(int cur, int n, int m)
{
	if (m == 0){
		hash.insert(cur);
		return (0);
	}
	
	for (int i = 0; i < n; i++){
		if (card[i] != -1){
			int tmp = card[i];
			card[i] = -1;
			sel_card(cur * digit(tmp) + tmp, n, m - 1);
			card[i] = tmp;
		}
	}
	
	return (0);
}


int main(void)
{
	int n, m;
	
	while (1){
		hash.clear();
		
		scanf("%d%d", &n, &m);
		
		if (n == 0 && m == 0){
			break;
		}
		
		for (int i = 0; i < n; i++){
			scanf("%d", &card[i]);
		}
		
		sel_card(0, n, m);
		
		printf("%d\n", hash.size());
	}
	
	return (0);
}

Measured memory_bytes: 0
import java.util.*;

public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        int[] wa = new int[n];
        int[] va = new int[n];
        for(int i=0; i<n; i++){
            wa[i] = Integer.parseInt(sc.next());
            va[i] = Integer.parseInt(sc.next());
        }
        
        long[] dp = new long[(int)1e5+1];
        Arrays.fill(dp, (long)1e18);
        dp[0] = 0;
        for(int i=0; i<n; i++){
            for(int j=dp.length-1; j>=0; j--){
                if(va[i]+j<dp.length && dp[j+va[i]] > dp[j]+wa[i]){
                    dp[j+va[i]] = dp[j]+wa[i];
                }
            }
        }
        
        long ans = 0;
        for(int i=0; i<dp.length; i++){
            if(dp[i]<=w){
                ans = i;
            }
        }
        
        System.out.println(ans);
    }
}


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

int main(){
    int n;
    while(cin >> n, n){
        vector<int> v(n);
        for(int i = 0; i < n; i++) cin >> v[i];
        sort(v.begin(), v.end());
        int ans = 1e9;
        for(int i = 0; i < n - 1; i++){
            ans = min(ans, abs(v[i] - v[i + 1]));
        }
        cout << ans << endl;
    }

}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);dfm
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

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

// dp[i][j][k]:=残り1個の皿がi枚、2個の皿がj枚、3個の皿がk枚の時の期待値
// 全ての皿の枚数をn枚とすると、
// dp[i][j][k]=dp[i][j][k]*((n-i-j-k)/n) + dp[i-1][j][k]*(i/n) + dp[i+1][j-1][k]*(j/n) + dp[i][j+1][k-1]*(k/n) + 1
// ∴ dp[i][j][k]=(dp[i-1][j][k]*i + dp[i+1][j-1][k]*j + dp[i][j+1][k-1]*k + n)/(i+j+k)
double dp[305][305][305];
int n;

double rec(int i, int j, int k){
	if(dp[i][j][k]>=0) return dp[i][j][k];
	if(i==0&&j==0&&k==0) return 0.0;
	double res=0.0;
	if(i>0) res+=rec(i-1,j,k)*i;
	if(j>0) res+=rec(i+1,j-1,k)*j;
	if(k>0) res+=rec(i,j+1,k-1)*k;
	res+=n;
	res*=1.0/(i+j+k);
	return dp[i][j][k]=res;
}

int main(){
	cin>>n;
	int one=0, two=0, three=0;
	rep(i,n){
		int a; cin>>a;
		if(a==1){
			one++;
		}else if(a==2){
			two++;
		}else{
			three++;
		}
	}
	memset(dp,-1,sizeof(dp));
	coutd(rec(one,two,three))
}

Measured memory_bytes: 221952
#include <stdio.h>
int main(void)
{
    int i,n,m,sum = 0;
    int number[10000];
    scanf("%d %d",&n,&m);
    for(i=0;i<m;i++)
    {
        scanf("%d",&number[i]);
        sum += number[i];
    }

  if(n>=sum)
  {
      printf("%d",n-sum);
  }
  else
  {
      printf("-1");
  }
    return 0;
}


Measured memory_bytes: 1732
import collections

N = int(input())
V = list(map(int, input().split()))
v1 = []
v2 = []
for i in range(N):
  if i % 2 == 0:
    v1.append(V[i])
  else:
    v2.append(V[i])
    
c1 = collections.Counter(v1)
c2 = collections.Counter(v2)

a1 = c1.most_common()
a2 = c2.most_common()

if len(a1)==1:
  k1=0
else:
  k1=a1[1][1]
if len(a2)==1:
  k2=0
else:
  k2=a2[1][1]

if a1[0][0] != a2[0][0]:
  print(len(V)-a1[0][1]-a2[0][1])
elif a1[0][1]+k2 > k1+a2[0][1]:
  print(len(V)-a1[0][1]-k2) 
else:
  print(len(V)-k1-a2[0][1]) 
  

Measured memory_bytes: 21944