akhauriyash/Code-Regression huggingface dataset:
function main(input){
  //初期条件（入力値を取り出し、N,A,Bを数値化した）
  var val = input;
  val = val.split(' ');
  var nod = val[0].length
  var con = [];
  for(var i=0;i<val.length;i++){
    con.push(Number.parseInt(val[i]));
  }
  //今回求める総和の初期条件を設定
  var totalSum = 0;
  for(var j=1;j<=con[0];j++){
    var sum = 0;
    var int = j;
    for(let k=0;k<nod;k++){
      var sum = (int%10)+sum;
      int = Math.floor(int/10);
    }
    if(sum >= con[1] && sum <= con[2]){
      totalSum += j;
    }
  }
  console.log(totalSum);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 32476
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;

int main() {
    string s;
    cin >> s;
    if (s[0] == s[2]) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define RI register int
#define CI const int&
using namespace std;
const int N=400005,mod=998244353;
int n,ans,num[N],g[N],tot; char s[N],t[N];
inline void inc(int& x,CI y)
{
	if ((x+=y)>=mod) x-=mod;
}
inline void dec(int& x,CI y)
{
	if ((x-=y)<0) x+=mod;
}
int main()
{
	RI i,j,k; for (scanf("%d%s",&n,s+1),k=1;k<=(n<<1);++k)
	if ((n<<1)%k==0&&(((n<<1)/k)&1))
	{
		for (num[++tot]=k,i=1;i<=(k>>1);++i)
		g[tot]=((g[tot]<<1)+s[i]-48)%mod,t[i]=s[i];
		for (i=(k>>1)+1;i<=n;++i) t[i]=((t[i-(k>>1)]-48)^1)+48;
		for (++g[tot],i=1;i<=n;++i) if (t[i]!=s[i])
		{ g[tot]-=(t[i]>s[i]); break; }
	}
	for (i=1;i<tot;++i) for (j=i+1;j<=tot;++j)
	if (num[j]%num[i]==0) dec(g[j],g[i]);
	for (i=1;i<=tot;++i) inc(ans,1LL*num[i]*g[i]%mod);
	return printf("%d",ans),0;
}

Measured memory_bytes: 512
#include<iostream>
#include<sstream>
#include<string>
using namespace std;
string func(string s){
	stringstream ss;
	s+='.';
	int now=0;
	string ans;
	char c;
	for(int i=0;s[i]!='.';i++){
		if(now==0){
			c=s[i];
		}
		if(s[i+1]!=c){
			ss<<(now+1)<<c;
			now=0;
		}else
			now++;
	}
	
	ss>>ans;
	return ans;
}
int main(){
	int n;
	while(cin>>n,n){
		string s;
		cin>>s;
		while(n--){
			s=func(s);
		}
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
from pprint import pprint

H, W = map(int, input().split(' '))

S = []
for i in range(H):
    S.append(input())

area = [[S[i][j] for j in range(W)] for i in range(H)]


def find_bomb(h, w):
    h_l = max(0, h - 1)
    h_upper = min(h + 1, H - 1)
    w_left = max(0, w - 1)
    w_right = min(w + 1, W - 1)

    if area[h][w] == '#':
        return '#'

    cnt = 0

    for i in range(h_l, h_upper + 1):
        for j in range(w_left, w_right + 1):
            if area[i][j] == '#':
                cnt += 1

    return str(cnt)


ans = [[find_bomb(i, j) for j in range(W)] for i in range(H)]

for h in ans:
    print(''.join(h))


Measured memory_bytes: 4084
#include <stdio.h>
#include <set>
using namespace std;
long long pw(long long b,int exp)
{
	long long ret=1,cur=b;
	while (exp)
	{
		if (exp&1)
			(ret*=cur)%=1000000007;
		(cur*=cur)%=1000000007;
		exp>>=1;
	}
	return ret;
}
int a[100002],ny[100002],fac[100002],nyf[100002];
int c(int a,int b)
{
	if (b>a||b<0)
		return 0;
	long long tmp=fac[a];
	(tmp*=nyf[b])%=1000000007;
	(tmp*=nyf[a-b])%=1000000007;
	return (int)tmp;
}
int main()
{
	int n;
	scanf("%d",&n);
	set<int> st;
	int firpos,lstpos;
	for (int i=1;i<=n+1;++i)
	{
		scanf("%d",a+i);
		if (!st.count(a[i]))
			st.insert(a[i]);
		else
			lstpos=i;
	}
	for (int i=1;i<lstpos;++i)
		if (a[i]==a[lstpos])
			firpos=i;
	int tml=firpos+n-lstpos;
	for (int i=1;i<=100001;++i)
		ny[i]=pw(i,1000000005);
	fac[0]=nyf[0]=1;
	for (int i=1;i<=100001;++i)
	{
		fac[i]=(int)(((long long)fac[i-1]*i)%1000000007);
		nyf[i]=(int)(((long long)nyf[i-1]*ny[i])%1000000007);
	}
	for (int i=1;i<=n+1;++i)
		printf("%d\n",(c(n+1,i)-c(tml,i-1)+1000000007)%1000000007);
	return 0;
}


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

int main(int,char**) {
    ios_base::sync_with_stdio(0); cin.tie(NULL);
    int A, B;
    cin >> A >> B;
    if ((A + B)% 2 == 0)
        cout << (A + B)/2 << endl;
    else 
        cout << "IMPOSSIBLE" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

const int MAX = 1000000;

int hamming[2000000];
int sum[2000000];

int main(void)
{
    int m, n;
    int i, j, k;

    for (i = 1; i <= MAX; i *= 2){
        for (j = 1; i * j <= MAX; j *= 3){
            for (k = 1; i * j * k <= MAX; k *= 5){
                hamming[i * j * k] = 1;
            }
        }
    }

    for (i = 1; i <= MAX; i++){
        sum[i] = sum[i - 1] + hamming[i];
    }

    while (scanf("%d %d", &m, &n) == 2){
        printf("%d\n", sum[n] - sum[m - 1]);
    }

    return (0);
}

Measured memory_bytes: 10836
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    ll n;
    scanf("%lld", &n);

    ll min = LINF;

    long i;
    for(i=1; i<=100000; i++) {
        if (n%i==0) {
            long count0=0;
            {
                ll curr=i;
                while(curr>0) {
                    curr /= 10;
                    count0++;
                }
            }
            long count1=0;
            {
                ll curr=n/i;
                while(curr>0) {
                    curr /= 10;
                    count1++;
                }
            }
            min = MIN(min, MAX(count0,count1));

        }
    }
    printf("%lld\n", min);

    return 0;
}



Measured memory_bytes: 128
n = gets.to_i
s = gets.chomp
 
 
a = []
a[0] = s[1..(-1)].count("E")
(1..(n-1)).each do |i|
    dif = 0
    if s[i] == "E"
        dif -= 1
    end
    
    if s[i-1] == "W"
        dif += 1
    end
    a[i] = a[i-1] + dif
end
puts a.min

Measured memory_bytes: 4868
S = input()
Flg = "Yes"

for i in range(len(S)//2):
    if(S[i] != S[len(S)-i-1]):
        Flg = "No"
for i in range((len(S)-1)//2):
    if(S[i] != S[(len(S)-1)//2-i-1]):
        Flg = "No"
j = 0
for i in range((len(S)+3)//2-1, len(S)):    
    if(S[i] != S[len(S)-j-1]):
        Flg = "No"
    j += 1    
print(Flg)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define vvl vector<vector<ll>>
#define vl  vector<ll>
#define rep(i,sta,end) for(ll i=sta;i<end;i++)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
typedef long long ll;
const ll MOD = 1000000007;
const double PI = acos(-1);
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||
signed main(){
	acc_io;
	ll a,b,x;
	cin>>x;
	rep(i,1,1000){
		a=i*i*i*i*i;
		rep(j,-1000,1000){
			b=j*j*j*j*j;
			if((a-b)==x){
				cout<<i<<" "<<j<<endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3612
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ll long long
#define ld long double
#define ii pair<int,int>
#define heap priority_queue
#define all(k) k.begin(),k.end()
#define rall(k) k.rbegin(),k.rend()
#define fa(a,c) for(auto &a:c)
#define yes "YES"
#define no "NO"




int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0);
  int a,b,c;
  cin>>a>>b>>c;
  cout<<max(0,c-a+b)<<endl;



	return 0;
}


Measured memory_bytes: 256
n, x, y = map(int, input().split())
x -= 1
y -= 1

ans = [0] * n
for i in range(n):
    for j in range(i + 1, n):
        d = min(abs(i - j),
                abs(i - x) + 1 + abs(y - j),
                abs(i - y) + 1 + abs(x - j))
        ans[d] += 1

for k in range(1, n):
    print(ans[k])


Measured memory_bytes: 3444
icase=0
if icase==0:
    n=int(input())
    a=list(map(int,input().split()))
    b=list(map(int,input().split()))
    c=list(map(int,input().split()))
    csum=sum(b)
    for i in range(n-1):
        if a[i]+1==a[i+1]:
            csum=csum+c[a[i]-1]
    print(csum)
    

Measured memory_bytes: 3060
S = input()
ls = len(S)
if ls<5:
    print('NO')
else:
    i = 0
    while True:
        if (ls-1>=i+4):
            if S[i:i+5]=='dream':
                if S[i:] == 'dream' or S[i:] == 'dreamer':
                    print('YES')
                    break
                elif ls-1>=i+7:
                    if (S[i+5:i+8]=='dre') or (S[i+5:i+8]=='era'):
                        i+=5
                        continue
                    elif (S[i+5:i+8]=='erd') or (S[i+5:i+8]=='ere'):
                        i+=7
                        continue

            elif S[i:i+5]=='erase':
                if S[i:] == 'erase' or S[i:] == 'eraser':
                    print('YES')
                    break
                elif ls-1>=i+5:
                    if S[i+5]=='r':
                        i += 6
                        continue
                    elif S[i+5]=='d' or S[i+5]=='e':
                        i += 5
                        continue
        print('NO')
        break

Measured memory_bytes: 3316
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
#include  <cstdio>
#include  <sstream>
#include  <bitset>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using ld = long double;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vd = vector<double>;
using Vld = vector<long double>;
using Vll = vector<vector<ll> >;
using Vldd = vector<vector<ld> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Pli = pair<ll, int>;
using VPi = vector<Pi>;
using VPl = vector<Pl>;
using VPli = vector<Pli>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

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; }

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };


ll ctable[2000][2000];

ll combination(int n, int r)
{
	if (n == r) return ctable[n][r] = 1;
	if (r == 0) return ctable[n][r] = 1;
	if (r == 1) return ctable[n][r] = n;
	if (ctable[n][r]) return ctable[n][r];
	return ctable[n][r] = (combination(n - 1, r) + combination(n - 1, r - 1)) % Mod;
}



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

	if (s == 1 || s == 2) {
		cout << 0 << endl;
		return 0;
	}
	if (s <= 5) {
		cout << 1 << endl;
		return 0;
	}

	int k = s / 3;
	ll ans = 0;
	for (int i = 1; i <= k; i++) {
		int s2 = s - 3 * i;
		//(s2+i)Ci
		ans += combination(s2 + i - 1, i - 1);
		ans %= Mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 16724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(int I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl



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

	ll N,K;
	cin >> N >> K;
	ll dp[N+1][K+1]={};
	FOR(i,0,N+1)dp[i][0] = 1;

	FOR(i,1,N+1){
		ll a;
		cin >> a;
		FOR(j,1,K+1){
			if(j-a-1 >= 0)dp[i][j] = dp[i][j-1] + dp[i-1][j] - dp[i-1][j-a-1];
			else dp[i][j] = dp[i][j-1] + dp[i-1][j];
			dp[i][j] = (dp[i][j]%MOD+MOD)%MOD;
		}
	}
	cout << dp[N][K] << endl;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
//Author: Ezio Sam
/* Shorthands */
#define ll long long
#define pb push_back
#define em emplace_back
#define mp make_pair
#define sp " "
#define cs "Case "
#define fi first
#define sn second

/* STL */
#define mem(a,n) memset(a, n, sizeof(a));
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define sz(x)  (int)x.size()
#define mx(v)  *max_element(v.begin(),v.end())
#define mxi(v) distance(v.begin(),max_element(v.begin(),v.end()))
#define mxa(a) *max_element(a, a.size())
#define r(a)   reverse(a.begin(),a.end())
/* loops */
#define fr(i,n)   for(__typeof(n) i=0;i<(n);i++)
#define fn(i,n)   for(__typeof(n) i=1;i<=(n);i++)
/*Special*/
#define Ezio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(something)  cerr<<#something<<" - "<<something<<"\n";

int main()
{

   Ezio
   ll t,m,n,x,a,b;
   string s;
   bool pos=false;
   cin>>n;
   fn(i,9){
       if(n%i==0){
        if(n/i<10){
          pos=true;
          break;
        }
       }
   }
   cout<<(pos?"Yes":"No")<<endl;
   return 0;
}


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

using ll=long long;
int main(){
    int n,m,k;
    cin>>n>>m>>k;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    vector<vector<ll>> dp(k+1,vector<ll>(n+1,0));
    for(int i=0;i<k;i++){
        deque<ll> deq;
        deque<int> ids;
        deq.push_back(dp[i][i]);
        ids.push_back(i);
        for(int j=i+1;j<=n;j++){
            while(m<j-ids.front()){
                deq.pop_front();
                ids.pop_front();
            }
            dp[i+1][j]=deq.front()+(i+1)*a[j-1];
            while(!deq.empty()){
                if(deq.back()<dp[i][j]) deq.pop_back(),ids.pop_back();
                else break;
            }
            deq.push_back(dp[i][j]);
            ids.push_back(j);
        }
    }    

    cout<<*max_element(dp[k].begin(),dp[k].end())<<endl;
    return 0;
}

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

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int t;
      cin >> t;
      a[t - 1]++;
    }
  }
  int ans = 0;
  for (auto&& e : a) {
    if (e == 0) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  ll ans = 0;
  rep2(i, 1, n+1){
    ll k = n / i;
    ans += (ll)i * k * (k+1)/2;
  }
  cout << ans << endl;
  return 0;
}

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

struct StNode
{
  StNode* m_poParnt;
  StNode* m_poLeft;
  StNode* m_poRigt;
  int m_nKey;

  StNode(int nNo) :
    m_poParnt(nullptr), m_poLeft(nullptr), m_poRigt(nullptr), m_nKey(nNo)
  { }
};

void fnInsert(StNode*& rpoRoot, StNode* poNewMe)
{
  StNode*  poParnt = nullptr;
  StNode** ppoNode = &rpoRoot;

  while (*ppoNode)
  {
    poParnt = *ppoNode;
    if (poNewMe->m_nKey < poParnt->m_nKey)
      ppoNode = &poParnt->m_poLeft;
    else
      ppoNode = &poParnt->m_poRigt;
  }
  poNewMe->m_poParnt = poParnt;
  *ppoNode = poNewMe;
}

void fnInOrder(StNode* poNode)
{
  if (!poNode)  return;

  fnInOrder(poNode->m_poLeft);
  cout << " " << poNode->m_nKey;
  fnInOrder(poNode->m_poRigt);
}

void fnPreOrder(StNode* poNode)
{
  if (!poNode)  return;

  cout << " " << poNode->m_nKey;
  fnPreOrder(poNode->m_poLeft);
  fnPreOrder(poNode->m_poRigt);
}

void fnBinSchTree(StNode*& rpoRoot)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  for (int i = 0; i < nMaxSiz; ++i)
  {
    string sCmd;
    cin >> sCmd;
    if (sCmd[0] == 'i')
    {
      int nNo;
      cin >> nNo;
      StNode* poNewNod = new StNode(nNo);
      fnInsert(rpoRoot, poNewNod);
    }
    if (sCmd[0] == 'p')
    {
      fnInOrder(rpoRoot);
      cout << endl;
      fnPreOrder(rpoRoot);
      cout << endl;
    }
  }
}

void fnPstOrder(StNode* poNode)
{
  if (!poNode)  return;

  fnPstOrder(poNode->m_poLeft);
  fnPstOrder(poNode->m_poRigt);
  delete poNode;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  StNode* poRoot = nullptr;

  fnBinSchTree(poRoot);
//fnPstOrder(poRoot);
  return 0;
}

Measured memory_bytes: 26620
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

#n,k,*a = map(int,read().split())
n, = map(int,read().split())

ans = [0]*(n+1)
for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            res = i*i+j*j+k*k+i*j+j*k+k*i
            if res <= n:
                ans[res] += 1

print(*ans[1:],sep="\n")


Measured memory_bytes: 9512
import java.util.*;

public class Main{
    public static void main(String[] args){
        double r, pi;
        pi = Math.PI;
        Scanner s = new Scanner(System.in);
        r = s.nextDouble();
        System.out.println(String.format("%.5f %.5f", r*r*pi, 2*r*pi));
    }
}


Measured memory_bytes: 28184
import numpy as np
if __name__ == "__main__":
    N, M, X = map(int, input().split())
    D = [list(map(int, input().split())) for _ in range(N)]
    ans = -1
    for i in range(2 ** N):
        rikai = np.zeros(M)
        cost = 0
        for j in range(N):
            if ((i>>j) & 1):
                cost += D[j][0]
                #print(rikai)
                rikai = rikai + np.array(D[j])[1:]
        #print(rikai)
        #print(cost)
        if np.all(X <= rikai):
            #print('Yes')
            if ans == -1:
                ans = cost
            else:
                ans = min(ans, cost)
    print(ans)
        

Measured memory_bytes: 27204
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String a = sc.next();
        String b = sc.next();

        if((a.equals("H") && b.equals("H")) || (a.equals("D") && b.equals("D"))){
            System.out.println("H");
        }
        else{
            System.out.println("D");
        }
    }
}

Measured memory_bytes: 23764
X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

comb = []
for a in range(X):
    b_max = K // (a+1)
    for b in range(min(Y, b_max)):
        c_max = K // ((a+1)*(b+1))
        for c in range(min(Z, c_max)):
            comb.append(sum([A[a], B[b], C[c]]))

comb.sort(reverse=True)

print(*comb[:K], sep='\n')


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

int main()
{
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        if (S[i] == 'A' && N - i >= 3)
        {
            if (S[i + 1] == 'B' && S[i + 2] == 'C')
                ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
struct UnionFind {
	vector<int> par; // uf(x,y)->y
	UnionFind() {}
	UnionFind(int NV) { init(NV); }
	void init(int NV) { par.clear(); rep(i, 0, NV) par.push_back(i); }
	void reset() { rep(i, 0, par.size()) par[i] = i; }
	int operator[](int x) { return par[x] == x ? x : par[x] = operator[](par[x]); }
	void operator()(int x, int y) { x = operator[](x); y = operator[](y); if (x != y) par[x] = y; }
};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, A[101010], B[101010];
//---------------------------------------------------------------------------------------------------
#define yes "Yes"
#define no "No"
pair<int, int> A2[101010], B2[101010];
string solve() {
	rep(i, 0, N) A2[i] = { A[i], i };
	sort(A2, A2 + N);
	rep(i, 0, N) B2[i] = { B[i], i };
	sort(B2, B2 + N);

	// 前提条件チェック
	rep(i, 0, N) if (A2[i].first > B2[i].first) return no;

	// ループが2つ以上ならyes
	UnionFind uf(N);
	rep(i, 0, N) uf(A2[i].second, B2[i].second);
	int cnt = 0;
	rep(i, 0, N) if (uf[i] == i) cnt++;
	if (1 < cnt) return yes;
	
	// ラストコーナー対策
	rep(i, 0, N - 1) if (A2[i].first <= B2[i + 1].first and A2[i + 1].first <= B2[i].first) return yes;

	return no;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];
	rep(i, 0, N) cin >> B[i];
	cout << solve() << endl;
}






Measured memory_bytes: 4088
import java.util.*;
import java.lang.*;



public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String today = sc.next();
        if(today.equals("Sunny")) System.out.println("Cloudy");
        if(today.equals("Cloudy")) System.out.println("Rainy");
        if(today.equals("Rainy")) System.out.println("Sunny");

    }
}


Measured memory_bytes: 19668
#include<stdio.h>
int main(void){
    int num;
    int limit;
    int height[100001];
    int ans=0;

    scanf("%d %d\n",&num,&limit);

    for(int i=0;i<num;i++){
        scanf("%d",&height[i]);
    }

    for(int j=0;j<num;j++){
        if(height[j]>=limit)ans++;
    }
    printf("%d",ans);

    return 0;    
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

const i64 mod = 1e9 + 7;
i64 ipow(i64 a, i64 b) {
    i64 x = a, y = 1;
    for (; b > 0; b >>= 1) {
        if (b & 1) (y *= x) %= mod;
        (x *= x) %= mod;
    }
    return y;
}
i64 inv(i64 x) {
    return ipow(x, mod - 2);
}
i64 fact(i64 x) {
    static vector<i64> f;
    i64 i = f.size();
    if (x >= i) {
        f.resize(x + 1);
        for (; i <= x; ++i) {
            f[i] = i == 0 ? 1 : i * f[i - 1] % mod;
        }
    }
    return f[x];
}
i64 perm(i64 n, i64 k) {
    return k <= n ? fact(n) * inv(fact(n - k)) % mod : 0;
}
i64 comb(i64 n, i64 k) {
    return k <= n ? fact(n) * inv(fact(k) * fact(n - k) % mod) % mod : 0;
}
int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for (int i = 0; i < m; ++i) cin >> a[i];
    sort(begin(a), end(a), greater<>());
    int l[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

    vector<int> dp_len(n + 1, -(1 << 30)), dp_num(n + 1, -1);
    dp_len[0] = 0;
    for (int i = 1; i <= n; ++i) {
        for (int x : a) {
            int j = i - l[x];
            if (j >= 0 && dp_len[j] + 1 > dp_len[i]) {
                dp_len[i] = dp_len[j] + 1;
                dp_num[i] = x;
            }
        }
    }
    /*
    for (int i = 0; i <= n; ++i) {
        cerr << i << ':' << dp_len[i] << ',' << dp_num[i] << '\n';
    }
    */
    string s;
    for (int i = n; i > 0; i -= l[dp_num[i]]) {
        s.push_back(dp_num[i] + '0');
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;
int main(){
	
	int a,b;
	string s;
	
		cin>>a;
		while(cin>>s,s!="="){
		cin>>b;
			if(s=="+")
				a+=b;
			else if(s=="-")
				a-=b;
			else if(s=="*")
				a*=b;
			else
				a/=b;
		}
		cout<<a<<endl;
		

}

Measured memory_bytes: 1204
function Main(input){
 input = input.split("\n");
 inputStr = input[0].split(" ");
 var N = Number.parseInt(inputStr[0]);
 var A = input[1].split(" ");
 var i = 0;
 var out = 0;
 var val = 0;
 var pos = 0;
 var abssum = 0;
 var mainus_cnt = 0;
 var zeroflg = 0;
  
 //負の数が幾つあるか数える
 for ( i = 0 ; i < N; i++) {
   if ( Number.parseInt(A[i]) < 0 ) {
     mainus_cnt += 1;
   }
   if ( Number.parseInt(A[i]) === 0 ) {
     zeroflg = 1;
   }
 }
 //console.log(mainus_cnt);
 //console.log(zeroflg);
  
 //0が無く、マイナスが偶数の場合、絶対値が最も小さい文字の場所を特定する
 if ( zeroflg === 0 &&  (mainus_cnt % 2)  !== 0 ) {
   val = Math.abs(Number.parseInt(A[0]));
   pos = 0;
   for ( i=1 ; i < N; i++) {
     if ( val > Math.abs(Number.parseInt(A[i])) ) {
        val = Math.abs(Number.parseInt(A[i]));
        pos = i;
     }
   }
 }
 //console.log(val);
 //console.log(pos);
  
 //forで回しながら絶対値を足しこむ。
 for ( i=0 ; i<N ; i++) {
   //console.log(i);
   if ( zeroflg === 1 || (( mainus_cnt % 2 ) === 0))  {
     abssum = abssum + Math.abs(Number.parseInt(A[i]));
   } else {
     if ( i === pos) {
       abssum = abssum - Math.abs(Number.parseInt(A[i]));
     } else {
       abssum = abssum + Math.abs(Number.parseInt(A[i]));
     }
   }
   //sum = sum + Math.abs(Number.parseInt(A[i]));
 }
 console.log(abssum);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 18380
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repf(i, j, n) for (int i = (j); i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)

signed main() {
  int n, k;
  cin >> n >> k;
  int m;
  if (k == 1)
    m = 0;
  else
    m = n - (k - 1) - 1;
  cout << m << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int ar[100005];
int32_t main(){
	int n,k;cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>ar[i];
	}
	sort(ar+1,ar+n+1);
	int ans = 10000000000;
	for(int i=1;i<=n-k+1;i++){
		ans = min(ans,ar[i+k-1]-ar[i]);
	}
	cout<<ans;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:

using pii=tuple<int,int>;
set<pii> candiate;
set<pii> black;


ll x[100010],y[100010];
ll ans[10];

int main(void){
	ll h,w,n;
	cin >> h >> w >> n;
	rep(i,n) cin >> x[i] >> y[i];

	const ll all=(h-2)*(w-2);

	rep(i,n){
		black.insert(make_tuple(x[i],y[i]));
		rep(d,9){
			int nx=x[i]+dx[d],ny=y[i]+dy[d];
			if(nx<=1||h<=nx) continue;
			if(ny<=1||w<=ny) continue;
			candiate.insert(make_tuple(nx,ny));
		}
	}

	for(auto &center:candiate){
		int cx,cy;
		tie(cx,cy)=center;
		int num=0;
		rep(d,9){
			int nx=cx+dx[d],ny=cy+dy[d];
			if(black.find(make_tuple(nx,ny))!=end(black)) num++;
		}
		ans[num]++;
	}


	ll num=0LL;
	rep(i,1,10) num+=ans[i];
	ans[0]=all-num;
	rep(i,10) cout << ans[i] << endl;
	return 0;
}

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

int64_t attack(int64_t h) {
    if (h == 1) {
        return 1;
    }
    int64_t sumAttack = 1 + attack(h / 2) * 2;

    return sumAttack;
}

int main() {
    int64_t h;
    cin >> h;

    cout << attack(h) << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int n, k;
  string s, result;

  cin >> n;
  cin >> s;
  cin >> k;

  char repl = s[k-1];
  result = "";

  for (int i = 0; i < n; i++) {
    char k = s[i];
    if (repl != k) {
      result += "*";
    } else {
      result += k;
    }
  }

  cout << result << endl;

  return 0;
}

Measured memory_bytes: 256
// luogu-judger-enable-o2
#include<bits/stdc++.h>
#define reg register
#define ll long long
#define inf 0x3f3f3f3f3f3f3f3fll
#define next liuyifan_next
using namespace std;
const ll p=1e9+7;
ll n,m,g[10000005],f[10000005],pow2[10000005],x,y,ans;
inline ll add(reg ll x,reg ll y) 
{
    return (x+=y)>p?x-p:x;
}
int main()
{
    cin>>n>>m;
    f[0]=pow2[0]=1; 
    for(reg ll i=1;i<=m;i++)pow2[i]=(pow2[i-1]<<1)%p; 
    for(reg ll i=1;i<=m;i++)
	{
		cin>>x>>y;
		x--;
		y--;
		g[x]|=(1<<y);
	} 
    for(reg ll s=1;s<1<<n;s++)
	if((s&1)==(s>>1&1))
    for(reg ll u=s;u;u=u-1&s) 
	if((u&1)==(u>>1&1)) 
    {
        ans=1;
        for(reg ll i=0;i<n;i++) 
		if(s>>i&1) 
        {
            if(u>>i&1)ans=ans*pow2[__builtin_popcount(g[i]&(s^u))]%p;
            else ans=ans*(pow2[__builtin_popcount(g[i]&u)]-1)%p; 
        }
        f[s]=add(f[s],f[s^u]*ans%p); 
    }
    cout<<(pow2[m]-f[(1<<n)-1]+p)%p<<endl;
    return 0;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
bool T=false;
int main(){
    int N,D;cin>>N>>D;
    long long cnt=0;
    for (int i = 0; i < N; i++)
    {
        long long a,b;cin>>a>>b;
        if(sqrt(a*a+b*b)<=D)cnt++;
    }
    cout<<cnt<<endl;
}

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

void solve()
{
    long long k;
    cin >> k;
    for(long long i = 0; i < k; i++)
        cout << "ACL";
}

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

    long long t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}

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

const int MAXN = 100000;
long long a[MAXN + 1];
long long b[MAXN + 1];

int main() {
	int n;
	long long m;
	cin >> n >> m;
	a[0] = 0;
	b[0] = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; i++) {
		b[i] += b[i - 1] + a[i];
	}
	long long left = a[1] * 2, right = a[n] * 2 + 1;
	auto count = [&](long long x) {
		long long result = 0;
		long long sum = 0;
		for (int i = 1, j = n; j > 0; j--) {
			while (i <= n && a[i] + a[j] < x) {
				i++;
			}
			long long num = n + 1 - i;
			result += num;
			sum += b[n] - b[i - 1] + a[j] * num;
		}
		return make_pair(result, sum);
	};
	while (left < right) {
		long long mid = (left + right) / 2;
		if (count(mid).first <= m) {
			right = mid;
		}
		else {
			left = mid + 1;
		}
	}
	auto result = count(left);
	cout << result.second + (m - result.first) * (left - 1) << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include <algorithm>
using namespace std;
int main() {
	int a;
	cin >> a;
	if (a < 1200) {
		cout << "ABC";
	}
	else if (a >= 1200 && a < 2800) {
		cout << "ARC";
	}
	else if (a >= 2800) {
		cout << "AGC";
	}

}



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

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

int lcm(int a, int b){
    return (a*b/gcd(a,b));
}

int main(){
    int x;
    cin >> x;
    cout << lcm(x,360)/x <<'\n';
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;
#define all(c) begin(c), end(c)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define rep(i, n) for (ll i = 0; i < ll(n); i++)

const ll mod = 1000000007;
struct mint {
    ll x;  // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> c(n);
    rep(i, n) cin >> c[i];
    sort(c.begin(), c.end());

    mint ans;
    for (int i = 0; i < n; i++) {
        ans += mint(c[i]) * mint(n - i + 1);
    }
    ans *= mint(4).pow(n - 1);
    cout << ans.x << endl;
}

Measured memory_bytes: 3952
n,maxw = map(int, input().split())
arr = [[-1 for i in range(maxw+1)] for j in range(n+1)]
arr[0][0] = 0
ans = 0
for i in range(n):
    v,w = map(int, input().split())
    for j in range(maxw):
        arr[i+1][j] = max(arr[i+1][j], arr[i][j])
        if j + w <= maxw and arr[i][j] >= 0:
            arr[i+1][j+w] = max(arr[i][j+w], arr[i][j] + v)
            ans = max(arr[i+1][j+w], ans)
print(ans)

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

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

    int a,b,c;
    // 引数の受け取り
    //
    cin >> a >> b >> c;
    
    if (abs(a-b) < abs(a-c)) cout << "A" << endl;
    else cout << "B" << endl;

    // 出力
    return 0;
}



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

using namespace std;

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

    vector<int> l(N);
    for (int i = 0; i < l.size(); i++) {
        cin >> l.at(i);
    }

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

    int lng = 0; 
    for (int i = 0; i < K; i++) lng += l.at(N - 1 - i);

    cout << lng << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;
typedef long long ll;

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

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}
const ll inf = 1LL<<60;

int main() {
  int n,k,high;cin>>n>>k;
  ll ans=inf;
  ll now=0;
  int color=0;

  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
  }
  for(int i=0;i<(1<<n);i++){
    high=a[0];
    color=1;
    now=0;
    for(int j=1;j<n;j++){
      if(1 & (i>>j)){
        if(a[j]<=high){
          now+=high-a[j]+1;
          high=high+1;
          color+=1;
        }else{
          color+=1;
          high=a[j];
        }
      }else{
        if(high<a[j]){
          high=a[j];
          color+=1;
        }
      }
    }
    if(k<=color){
      ans=min(ans,now);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;


int main()
{
	int n; cin >> n;
	int ans = 0;
	if (n < 9)
	{
		cout << n << endl;
		return 0;
	}

	ans += 9;

	if (n < 100)
	{
		cout << ans << endl; return 0;
	}

	if (n < 1000)
	{
		ans += (n - 100 + 1);
		cout << ans << endl; return 0;
	}

	ans += 900;

	if (n < 10000) { cout << ans << endl; return 0; }

	if (n == 100000) { cout << ans + 90000 << endl; return 0; }
	else
	{
		ans += (n - 10000 + 1);
		cout << ans << endl; return 0;
	}

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N;
struct data{
  long long a,b;
  bool operator < (const data &p)const{
    return a*p.b > p.a*b;
  }
};

typedef pair<data,string> P;
vector<P> t;

int main(){
  while(1){
    cin>>N;
    if(N==0)break;
    t.clear();
    for(int i=0;i<N;i++){
      string l;
      int p,a,b,c,d,e,f,s,m;
      cin>>l>>p>>a>>b>>c>>d>>e>>f>>s>>m;
      t.push_back(P((data){f*s*m-p,a+b+c+(d+e)*m},l));
    }
    sort(t.begin(),t.end());
    //reverse(t.begin(),t.end());
    for(int i=0;i<N;i++)cout<<t[i].second<<endl;
    cout<<'#'<<endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string.h>
#include <set>
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int N,M;

struct Info{
	char type[10],from[9],to[9];
};

struct Data{
	char from[9],to[9],message[51];
};

bool strCmp(char* base, char* comp){
	int length1 = 0,length2 = 0;
	for(int i=0;base[i] != '\0'; i++)length1++;
	for(int i=0;comp[i] != '\0'; i++)length2++;
	if(length1 != length2)return false;

	for(int i=0;base[i] != '\0'; i++){
		if(base[i] != comp[i])return false;
	}
	return true;
}


bool ambiguousCmp(char* base, char* comp){

	bool FLG = true;
	for(int i=0;base[i] != '\0'; i++){
		if(base[i] != comp[i]){
			if(base[i] == '?'){
				//Do nothing
			}else{
				FLG = false;
				break;
			}
		}
	}
	if(FLG)return true;
	else{
		return false;
	}
}

void strcpy(char* to,char* str){
	for(int i=0;str[i] != '\0';i++){
		to[i] = str[i];
		to[i+1] = '\0';
	}
}

void func(){

	Info info[N];

	char buf[10],from[9],to[9];
	bool FLG;

	for(int i = 0; i < N; i++){
		scanf("%s %s %s",info[i].type,info[i].from,info[i].to);
	}

	queue<Data> Q;

	int result;

	for(int loop = 0; loop < M; loop++){
		Data data;

		scanf("%s %s %s",data.from,data.to,data.message);

		result = 0;

		for(int i = 0; i < N; i++){
			if(ambiguousCmp(info[i].from,data.from) == true && ambiguousCmp(info[i].to,data.to) == true){
				if(info[i].type[0] == 'p'){
					result = 1;
				}else{
					result = 2;
				}
			}
		}

		if(result == 1){
			Q.push(data);
		}
	}

	printf("%d\n",Q.size());

	while(!Q.empty()){
		printf("%s %s %s\n",Q.front().from,Q.front().to,Q.front().message);
		Q.pop();
	}

}

int main(){

	while(true){
		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 3268
def slove():
    import sys
    import bisect
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    b = list(map(int, input().rstrip('\n').split()))
    c = list(map(int, input().rstrip('\n').split()))
    a.sort()
    b.sort()
    c.sort()
    t = 0
    for v in b:
        an = bisect.bisect_left(a, v)
        cn = n - bisect.bisect_right(c, v)
        t += (an * cn)
    print(t)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 94520
#include<cstdio>
#include<algorithm>
using namespace std;
int X, n;
int Mn[101000], Mx[101000], Q, Cur[101000];
int MnL[101000], MxL[101000];
int S[101000], T[101000], ck;
int main() {
	int i;
	scanf("%d%d", &X, &n);
	int t = 1, a;
	for (i = 1; i <= n + 1; i++) {
		if(i<=n)scanf("%d", &T[i]);
		else T[i] = 1e9;
		t *= -1;
		S[i] = S[i - 1] + t*(T[i] - T[i - 1]);
		Mn[i] = Mn[i - 1], Mx[i] = Mx[i - 1], MnL[i] = MnL[i - 1], MxL[i] = MxL[i - 1];
		if (Mn[i] > S[i]) Mn[i] = S[i], MnL[i] = i;
		if (Mx[i] < S[i]) Mx[i] = S[i], MxL[i] = i;
		if (Mx[i] - Mn[i] >= X) {
			if (!ck) {
				if (t == 1) Cur[i] = X;
				else Cur[i] = 0;
				ck = 1;
			}
			else {
				Cur[i] = min(X, max(0, Cur[i - 1] + t*(T[i] - T[i - 1])));
			}
		}
	}
	n++;
	scanf("%d", &Q);
	while (Q--) {
		scanf("%d%d", &t, &a);
		int pv = lower_bound(T + 1, T + n + 1, t + 1) - T - 1;
		int x;
		if (Mx[pv] - Mn[pv] >= X) {
			x = Cur[pv];
		}
		else {
			if (a + Mn[pv] <= 0) {
				x = S[pv] - S[MnL[pv]];
			}
			else if (a + Mx[pv] >= X) {
				x = S[pv] - S[MxL[pv]] + X;
			}
			else {
				x = a + S[pv];
			}
		}
		int tp = -1;
		if (pv % 2)tp = 1;
		printf("%d\n", max(min(x + tp * (t - T[pv]), X), 0));
	}
}

Measured memory_bytes: 3584
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int N,M;
int P[1001];
int num[600000];
int main()
{
	while(true){
		scanf("%d%d",&N,&M);
		if(N==0&&M==0)return 0;
		for(int i=0;i<N;i++)scanf("%d",&P[i]);
		N++;
		int now1=0;
		for(int i=0;i<N;i++){
			for(int j=i;j<N;j++){
				num[now1]=P[i]+P[j];
				now1++;
			}
		}
		sort(num,num+now1);
		int ans=0;
		int I=0;int J=now1-1;
		while(I<now1&&J>=0){
			if(num[I]+num[J]<=M){
				ans=max(ans,num[I]+num[J]);
				I++;
			}
			else J--;
		}
		printf("%d\n",ans);
	}
}

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

int main(){
    int h, w;
    while (1){
        cin >> h >> w;
        if (h==0 and w==0) break;
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++){
                if (i==0 || i==h-1 || j==0 || j==w-1) printf("#");
                else printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 3088
INF = 10**10

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

def dfs(num,ai,bi,ci):
  if num==n:
    ret = abs(a-ai) + abs(b-bi) + abs(c-ci) - 30
    return ret if min(ai,bi,ci) >0 else INF
  t0 = dfs(num+1,ai,        bi,        ci)
  ta = dfs(num+1,ai+ll[num],bi,        ci)         +10
  tb = dfs(num+1,ai        ,bi+ll[num],ci)         +10 
  tc = dfs(num+1,ai        ,bi,        ci+ll[num]) +10
  return min(t0,ta,tb,tc)

print(dfs(0,0,0,0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll  long long int
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i :c)
#define pii pair< int,int >
#define Fast_IO() ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
#define er(x) cout << x << " "
#define err(x,y) cout << x << " "<<y
const int MOD = 1000 * 1000 * 1000 + 7;
const int N = 100;
using namespace std;
clock_t time_p=clock();
void dem()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
ll a , b ;
ll gcd ( ll a , ll b  ) // a > b
{

    return  b == 0 ? a  : gcd( b , a % b ) ;
}
ll lcm ( ll a , ll b )
{
    return (a * b) / gcd( a , b ) ;

}
ll cal ( ll x )
{
    return ( b / x -  a / x ) + ( a % x == 0 );
}
int main()
{ // INCLUSION - EXCLUSION PRINCIPLE 
    Fast_IO();
    ll  c ,d ;
    cin >>a >> b >> c >> d ;
    cout <<  ( b -a +1 )- (cal ( c ) + cal ( d ) - cal ( lcm ( c, d )));

    return 0 ;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<int> b(n - 1); rep(i, n) cin >> b[i];
  int ans = b[0] + b[n - 2];
  rep(i, n - 2) {
    ans += min(b[i], b[i+1]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int H, N;
    cin >> H >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; ++i)
        cin >> A[i] >> B[i];

    vector<int> dp(H + 3, 1e9);
    dp[0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= H; ++j) {
            dp[min(H, j + A[i])] = min(dp[j] + B[i], dp[min(H, j + A[i])]);
        }
    }

    cout << dp[H] << endl;

    return 0;
}


Measured memory_bytes: 3644
use std::io::stdin;
 
fn main() {
 
    let mut x = String::new();
 
    std::io::stdin().read_line(&mut x)
        .expect("Failed to read line");
 
    let x: u32 = x.trim().parse()
        .expect("Please type a number");
 
    let y = x * x * x;
 
    println!("{}", y);
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    string ans = S;

    int stock = 0;
    REP(i,N){
        char c = S[i];
        if(c == '('){
            stock++;
        }
        else{
            if(stock == 0){
                ans = '(' + ans;
            }
            else stock--;
        }
    }

    for(int i = 0; i < stock; i++){
        ans += ')';
    }

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


Measured memory_bytes: 256