akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

int main(){

  int h,w,k;
  scanf("%d%d%d",&h,&w,&k);

  char c[6][7];
  int map[6][6] = {0};
  for(int i = 0; i < h; ++i){
    scanf("%s",c[i]);
  }

  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      if(c[i][j] == '#') map[i][j] = 1;
    }
  }

  int count = 0;

  for(int bit = 0; bit < (1<<h) ; ++bit){
    int t_map[6][6] = {0};

    for(int i = 0; i < h; ++i){
      for(int j = 0; j < w; ++j){
        t_map[i][j] = map[i][j];
      }
    }

    for(int i = 0; i < h; ++i){
      if((bit >> i) & 1){
        for(int j = 0; j < w; ++j){
          t_map[i][j] = 0;
        }
      }
    }

    int t_t_map[6][6] = {0};

    for(int bit_w = 0; bit_w < (1<<w) ; ++bit_w)
    {
      for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
          t_t_map[i][j] = t_map[i][j];
        }
      }

      for(int i = 0; i < w; ++i){
        if((bit_w >> i) & 1){
          for(int j = 0; j < h; ++j){
            t_t_map[j][i] = 0;
          }
        }
      }

    int sum = 0;

    for(int i = 0; i < h; ++i){
      for(int j = 0; j < w; ++j){
        if(t_t_map[i][j] == 1) sum ++;
      }
    }

      if(sum == k) count ++;
    }
  }


  printf("%d",count);


  return 0;
}


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


int main(void) {
  string s;
  cin >> s;
  if(s == "SUN") cout << 7 << endl;
  else if(s == "MON") cout << 6 << endl;
  else if(s == "TUE") cout << 5 << endl;
  else if(s == "WED") cout << 4 << endl;
  else if(s == "THU") cout << 3 << endl;
  else if(s == "FRI") cout << 2 << endl;
  else if(s == "SAT") cout << 1 << endl;
  
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
ll BASE_NUM = 1000000007;

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (size_t i = 0; i < N; i++)
  {
    cin >> A[i];
  }
  ll total = 0;
  ll max_height = A[0];
  for(int i = 1; i < N;i++){
    if (max_height > A[i]){
      total += max_height - A[i];
    }else{
      max_height = A[i];
    }
  }
  cout << total << endl;
  return 0;
}

Measured memory_bytes: 4836
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <new>

using namespace std;

typedef long long ll;

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

int main(){
    ll a,b;
    cin >> a >> b;
    for(ll i=0;i<=1009;i++){
        if(floor(i*0.08) == a && floor(i*0.1) == b){
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        String[] arr = Console.ReadLine().Split();
        int N = int.Parse(arr[0]), K = int.Parse(arr[1]);
        int cnt = 0;
        while (0 < N)
        {
            N /= K;
            cnt++;
        }
        Console.WriteLine(cnt);
    }
}

Measured memory_bytes: 11220
#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>;

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

	cout << (char)(c + 1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int A, B, K; cin >> A >> B >> K;
  int cnt = 0;
  for (int i = 100; i > 0; i--)
  {
    if (A%i == 0 and B%i == 0) {
      cnt++;
    }
    if (cnt == K) {
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y>a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[100031];
int l[103331];
int j[3331];

long long x,y,z,mod=1000000007;
//string r;
char r[1];

P u[1];
priority_queue<P> q;
//stack<int> s;
set<int> s;
map<int,int> p;

vector<int> v[100101];

bool as(P a,P b)
{
  //if(a.x!=b.x)
  //return a.x<b.x;
  return a.x<b.x;
}

long long f(long long x,long long y)
{
  long long p=1;
  for(;y;y/=2,x*=x,x%=mod)
  if(y%2)
  {
    p*=x;
    p%=mod;
  }
  return p;
}

int main()
{
  scanf("%d",&a);
  for(int t=1;t<a;t++)
  {
    scanf("%d %d",&n,&m);
    v[n].push_back(m);
    v[m].push_back(n);
  }
  scanf("%d",&b);
  for(int t=1;t<=b;t++)
  {
    scanf("%d %d",&n,&m);
    l[n]=1;
    o[n]=m;
    q.push({n,m});
  }
  for(;q.size();)
  if(o[q.top().x]==q.top().y)
  {
    P s=q.top();
    q.pop();
    for(int h=0;h<v[s.x].size();h++)
    if(l[v[s.x][h]])
    {
      if(abs(s.y-o[v[s.x][h]])!=1)
      {
        puts("No");
        return 0;
      }
    }
    else
    {
      l[v[s.x][h]]=1;
      o[v[s.x][h]]=s.y+1;
      q.push({v[s.x][h],s.y+1});
    }
  }
  else q.pop();
  puts("Yes");
  for(int t=1;t<=a;t++)
  printf("%d\n",o[t]);
}
//1
//21




Measured memory_bytes: 8308
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    vector<ll> vl(a), vr(a), rui(a);
    REP(i, n) if(a[i]<0) vl[i] = vr[i] = 0;
    FOR(i, 1, n) {
        vl[i] += vl[i-1];
        rui[i] += rui[i-1];
    }
    for(ll i=n-2; i>=0; --i) vr[i] += vr[i+1];

    ll ans = 0;
    REP(i, n-k+1) {
        // [i, i+k-1] をすべて同じ色にする
        ll val = (i==0?0:vl[i-1]) + (i+k>=n?0:vr[i+k]);
        chmax(ans, val + rui[i+k-1]-(i==0?0:rui[i-1]));
        chmax(ans, val);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
using namespace std;
int main()
{
    int a, b, c; cin >> a >> b >> c;
    if (b-a+1<=c*2)
    {
        for (int i = 0; i <= b - a; ++i)
        {
            cout << i + a<<"\n";
        }
    }
    else
    {
        for (int i = 0; i < c; ++i)
        {
            cout << a + i << "\n";
        }
        for (int i = 0; i < c; ++i)
        {
            cout << b - c + i + 1<<"\n";
        }
    }
   
    return 0;
}


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


int main(){
    int n;
    cin>>n;
    
    vector<vector<int>> a(n,vector<int> (n,0));
    
    vector<vector<int>> v(n,vector<int> (n));
    for(int i=0;i<n;i++){
        int u,k;
        cin>>u>>k;
        for(int j=0;j<k;j++){
            int m;
            cin>>m;
            a.at(u-1).at(m-1)=1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n-1;j++){
            cout<<a.at(i).at(j)<<" ";
        }
        cout<<a.at(i).at(n-1)<<endl;
    }
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn 200000
#define mod 1000000007
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

char s[maxn+5];

int main()
{
    int n; scanf("%d",&n);
    scanf("%s",s+1);
    int l=1,r=n;
    int ans=0;
    while(l<=r)
    {
        while(s[l]=='R') l++;
        while(s[r]=='W') r--;
        if(l>=r) break;
        ans++;
        swap(s[l],s[r]);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 4024
#include <stdio.h>

int main() 
{
    int n;
    int array[1000000] = {0};
    unsigned long long int sum = 0;
    scanf("%d", &n);

    for (int i = 0; i < n; i++)
    {
        array[i] = i + 1;
        if ((array[i] % 3 != 0) && (array[i] % 5 != 0))
        {
            sum += array[i];    
        }
    }
    printf("%llu\n", sum);
}    


Measured memory_bytes: 1732
n=int(input())
s=[input() for _ in range(n)]
ans=sum([si.count('AB') for si in s])
endA=len([si for si in s if si[-1]=='A'])
startB=len([si for si in s if si[0]=='B'])
AB=len([si for si in s if si[0]=='B' and si[-1]=='A'])
if endA*startB==0:
      print(ans)
elif AB==endA and AB==startB:
      print(ans+AB-1)
else:
      print(ans+min(endA,startB))


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

bool f(string s) {
    int size = s.size();
    for (int i = 0; i < size/2; i++){
        if (s.at(i) != s.at(size-i-1)) return false;
    }
    return true;
}

int main() {
    int a, b, ret = 0;
    cin >>a >>b;
    for (int i = a; i <= b; i++) {
        if (f(to_string(i))) ret++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
  int m,n,i=0,j=0;
  scanf("%d%d",&n,&m);
  int x=n,y=m;
  while(y--)
  {
      i=i*10+n;
  }
  while(x--)

    {
        j=j*10+m;
    }
if(i>=j)
    printf("%d",i);
else
    printf("%d",j);
    return 0;
}



Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef pair<int,int> pii;

int n,s;
int l[555],r[555],w[555][555],t[555];;
pii p[555];

int main(){
  scanf("%d%d",&n,&s); s--;
  rep(i,n){
    scanf("%d%d",l+i,r+i);
    p[i] = pii(r[i],i);
  }
  rep(i,n)rep(j,n)scanf("%d",w[i]+j);
  rep(k,n)rep(i,n)rep(j,n)w[i][j] = min(w[i][j],w[i][k]+w[k][j]);

  sort(p,p+n);
  rep(i,n)t[i] = min(r[i]-l[i], r[i]-w[s][i]);

  rep(i,n){
    int v = p[i].second;
    if(t[v]<0)continue;

    for(int j=i+1;j<n;j++){
      int u = p[j].second;
      if(r[v]+w[v][u] <= r[u]){
	t[u] = max(t[u], t[v] + min(r[u]-w[v][u]-r[v], r[u]-l[u]) );
      }
    }
  }

  printf("%d\n",*max_element(t,t+n));
}  

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int n;
double a[maxn];

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);

  cin>>n;
  priority_queue<double,vector<double>,greater<double>> pq;
  for (int i=0; i<n; i++) {
    cin>>a[i];
    pq.push(a[i]);
  }


  while (int(pq.size()) > 1) {
    double x = pq.top(); pq.pop();
    double y = pq.top(); pq.pop();
    pq.push((x+y)/2.0);
  }

  cout<<pq.top()<<endl;  

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define deg_to_rad(deg) (((deg)/360)*2*M_PI)


int main(void)
{
	int a, b, c;
	double S, L, h, half_L;
	scanf("%d %d %d", &a, &b, &c);
	h = b * sin ( deg_to_rad((double)c));
	S = a * h /2 ;
	L = a + b + sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(deg_to_rad((double)c)));
	
	printf("%lf\n", S);
	printf("%lf\n", L);
	printf("%lf\n", h);
	return 0;
}

Measured memory_bytes: 684
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N,T;
    cin >> N >> T;
    vector<ll> c(N);
    vector<ll> t(N);
    ll min_cost = INF;
    for(size_t i=0;i<N; i++)
    {
        cin >> c[i] >> t[i];
        if(t[i]<=T)
        {
            min_cost = min(min_cost, c[i]);
        }
    }
    if(min_cost!=INF) cout << min_cost << endl;
    else cout << "TLE" << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    int n;
    cin >> n;
    map<string, int>m;
    rep(i, n){
        string s; cin >> s;
        m[s]++;
    }

    int MAX = 0;
    for (auto mm : m){
        chmax(MAX, mm.second);
    }

    vector<string> vs;
    for (auto mm : m){
        if(mm.second==MAX){
            vs.emplace_back(mm.first);
        };
    }

    // sort(vs.begin(), vs.end());
    
    // rep(i, vs.size()){
    //     cout << vs[i] << endl;
    // }

    for (auto it = m.begin(); it != m.end(); it++){
        if(it -> second == MAX){
            cout << it -> first << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 26868
#include <iostream>

#define ll long long

using namespace std;

int main()
{
  ll x, y;
  cin >> x >> y;
  if (x-y == 1 || x-y == 0 || x-y == -1){
    cout << "Brown" << endl;
  }else{
    cout << "Alice" << endl;
  }
  return 0;
}


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

using namespace std;

int main() {
    int t[4], n[4];
    for (int i = 0; i< 4; i++){
        cin >> t[i] >> n[i];
        switch(t[i]){
        case 1:cout << n[i] * 6000;break;
        case 2:cout << n[i] * 4000;break;
        case 3:cout << n[i] * 3000;break;
        case 4:cout << n[i] * 2000;break;
        }
        cout << endl;
    }
    return 0;
}

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


void solve(long long N, std::vector<std::string> S){
  map<string, long long> tab;
  for(auto x: S){
    tab[x]++;
  }

  vector<string> js = {"AC", "WA", "TLE", "RE"};
  for(auto j: js){
    cout << j << " x " << tab[j] << endl;
  }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  std::vector<std::string> S(N);
  for(int i = 0 ; i < N ; i++){
    std::cin >> S[i];
  }
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 6452
#include <stdio.h>
#include <math.h>


int main() {
	int N,M, i,j,k,l,ans,p;
	char A[51][51],B[51][51];
	scanf("%d %d",&N,&M);
	for(i=0;i<N;i++){
		scanf("%s",A[i]);
	}
	for(i=0;i<M;i++){
		scanf("%s",B[i]);
	}
	ans = 0;
	for(i=0;i<N-M+1;i++){
		for(j=0;j<N-M+1;j++){
			p=1;
			/*A[i][j]から始めて、A[i+k][j+l]がB[k][l]と等しいか判定*/
			for(k=0;k<M;k++){
				for(l=0;l<M;l++){
					if(A[i+k][j+l]!=B[k][l]){
						p=0;
					}
				}
			}
			if(p==1){
				ans = 1;
			}
		}
	}
	if(ans == 0){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define pi pair<int, int>
#define l first
#define r second
#define all(x) x.begin(), x.end()
#define fori(a, b, step) for (int i = a; i < b; i += step)
#define forj(a, b, step) for (int j = a; j < b; j += step)
#define int long long

const int maxn = 5e5 + 1, CC = 10001;

using namespace std;

int a[100];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, x;
    cin >> n >> x;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n);
    for (int i = 0; i < n; i++) {
        if (a[i] > x) {
            cout << i;
            return 0;
        }
        if (i == n - 1 && a[i] < x) {
            cout << i;
            return 0;
        }
        x -= a[i];
    }
    cout << n;
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 2e5 + 10;
int N;
LL A[MAX], B[MAX];

int main(void) {
    scanf("%d", &N);
    REP(i, N) scanf("%lld", A + i);
    REP(i, N) scanf("%lld", B + i);

    auto comp = [&](const int l_idx, const int r_idx) {
        return B[l_idx] - A[l_idx] < B[r_idx] - A[r_idx];
    };
    priority_queue<int, VI, decltype(comp)> pq(comp);
    REP(i, N) {
        if (A[i] < B[i]) pq.emplace(i);
        else if (A[i] > B[i]) {
            cout << -1 << endl;
            return 0;
        }
    }

    LL cnt = 0;
    while (!pq.empty()) {
        const auto cur_idx = pq.top();
        pq.pop();

        const int pre_idx = (cur_idx - 1 + N) % N;
        const int nxt_idx = (cur_idx + 1) % N;

        const LL cur_minus = B[pre_idx] + B[nxt_idx];

        const LL times = (B[cur_idx] - A[cur_idx]) / cur_minus;

        const LL minus = cur_minus * times;

        const LL val = B[cur_idx] - minus;
        if (times == 0 || val < A[cur_idx]) {
            cout << -1 << endl;
            return 0;
        }
        B[cur_idx] = val;
        if (A[cur_idx] != B[cur_idx]) {
            pq.emplace(cur_idx);
        }

        cnt += times;
    }

    cout << cnt << endl;
}


Measured memory_bytes: 4472
using System;

public class Program
{
	public static void Main(string[] args)
	{
		//var ss = new StreamScanner();
		//---------------------------------
		//????????????int, double, string?????????????????£????????????
		string ww = Console.ReadLine();
		string w = ww.ToUpper();
		int ans = 0;
	

		while(true)
		{
			string tt = Console.ReadLine();
			string t = tt.ToUpper();
			string[] strArray = t.Split(null);
			for (int i = 0; i < strArray.Length; i++)
			{
				if (strArray[i] == w)
				{
					ans += 1;
				}
			}


			if (tt=="END_OF_TEXT")
			{
				break;
			}

			
		}
		Console.WriteLine(ans);


		//int x = ss.Next<int>();
		//double d = ss.Next<double>();
		//string s = ss.Next<string>();

		//?????°???????????????????????¨?????????????????????????????????????????????????´???????
		//int[] array = ss.Next<int>(10);
		//---------------------------------

	}
}
public class StreamScanner
{
	private readonly char[] _c = { ' ' };
	private int _index = -1;
	private string[] _input = new string[0];
	private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

	public T Next<T>()
	{
		if (_index == _input.Length - 1)
		{
			_index = -1;
			while (true)
			{
				string rl = _sr.ReadLine();
				if (rl == null)
				{
					if (typeof(T).IsClass) return default(T);
					return (T)typeof(T).GetField("MinValue").GetValue(null);
				}
				if (rl != "")
				{
					_input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
					break;
				}
			}
		}
		return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
	}

	public T[] Next<T>(int x)
	{
		var ret = new T[x];
		for (var i = 0; i < x; ++i) ret[i] = Next<T>();
		return ret;
	}

	public T[][] Next<T>(int x, int y)
	{
		var ret = new T[y][];
		for (var i = 0; i < y; ++i) ret[i] = Next<T>(x);
		return ret;
	}
}

Measured memory_bytes: 9028
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;

namespace AtCoder
{
    class Point
    {
        public readonly int x;
        public readonly int y;
        public Point(int[] args)
        {
            x = args[0];
            y = args[1];
        }
    }
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        private static int Solve(List<Point> r1, IEnumerable<Point> b1)
        {
            int count = 0;
            foreach (Point blue in b1.OrderBy(blue => blue.x))
            {
                var r2 = r1.Where(red => red.x < blue.x && red.y < blue.y).OrderByDescending(red => red.y);
                if (r2.Count() > 0)
                {
                    r1.Remove(r2.First());
                    ++count;
                }
            }
            return count;
        }
        static void Main(string[] args)
        {
            int N = ReadInt();
            var r = new List<Point>(N);
            var b = new List<Point>(N);
            for (int i = 0; i < N; ++i) { r.Add(new Point(ReadInts())); }
            for (int i = 0; i < N; ++i) { b.Add(new Point(ReadInts())); }
            Console.WriteLine(Solve(r, b));
        }
    }
}


Measured memory_bytes: 13524
program increase
  implicit none

  integer(8) :: a, b, x, y, pr

  read(*,*) a, b

  x = 100 * a / 8
  y = 10 * b

  if (x == y) then
     pr = x 
  else if (x > y) then
     pr = x
     
     if (pr * 10 / 100  == b) then

        if (pr * 8 / 100 < a ) then

           pr = pr + 1

        end if
     else
        pr = -1
     end if

  else
     pr = y
     if (pr * 8 / 100 == a) then
        if (pr * 10 / 100 < b) then
           pr = pr + 1
        end if

     else
        pr = -1
     end if

  end if

  write(*,*) pr

end program increase



Measured memory_bytes: 256
import sys, collections
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    n = I()
    children = [[] for _ in range(n)]
    parent = [-1]*n
    for _ in range(n):
        ilr = LI()
        id = ilr[0]
        left = ilr[1]
        right = ilr[2]
        children[id] = (left, right)
        if left>=0: parent[left] = id
        if right>=0: parent[right] = id

    preorder = []
    inorder = []
    postorder = []

    def dfs(v):
        preorder.append(v)
        c0, c1 = children[v]
        if c0!=-1:
            dfs(c0)
        inorder.append(v)
        if c1!=-1:
            dfs(c1)
        postorder.append(v)
    
    root = parent.index(-1)
    dfs(root)

    print('Preorder')
    print('', *preorder)
    print('Inorder')
    print('', *inorder)
    print('Postorder')
    print('', *postorder)

if __name__ == '__main__':
    resolve()



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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> city(N);
  int a, b;
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    city.at(a - 1)++;
    city.at(b - 1)++;
  }
  for (int i = 0; i < N; i++) {
    cout << city.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int arr[200033];
int main()
{
	int n,i;
	cin>>n;
	long long int sum=0,ans=(1LL<<60),curr=0;
	for(i=0;i<n;i++)
	{
		cin>>arr[i];
		sum+=arr[i];
	}
	for(i=0;i<n-1;i++)
	{
		curr+=arr[i];
		ans = min(ans,max(curr,sum-curr)-min(curr,sum-curr));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
//
// Created by sark2 on 14-01-2020.
//

#include "bits/stdc++.h"

using namespace std;
#define pb push_back
#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define CASES int t;cin>>t;while(t--)

using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;

int main() {
    IOS

    unordered_set<int> st;
    int n; cin>>n;

    vector<int> a(n);

    for(int &x : a) {
        cin >> x;
        st.insert(x);
    }

    if(st.size() == n)
        cout<<"YES\n";
    else
        cout<<"NO\n";





}


Measured memory_bytes: 9288
import java.util.*;

public class Main {
	  public static void main(String args[]){
      	Scanner scan = new Scanner(System.in);
            
        int x = scan.nextInt();
        int a = scan.nextInt();
        int b = scan.nextInt();
        
        char cnt;
        
        if( Math.abs(a-x) > Math.abs(b-x))cnt = 'B';
        else cnt = 'A';
            
        System.out.println(cnt);
	  }
}

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

int main()
{
	array<int,3> v;
	for (auto& a : v) {
		cin >> a;
	}

	int ret = 0;
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) {
			for (int k = 0; k < 3; ++k) {
				if (i != j && j != k && k != i) {
					ret = max(ret, v[i] * 10 + v[j] + v[k]);
				}
			}
		}
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

"""
参考：http://blog.livedoor.jp/misteer/archives/9017497.html
　　　https://www.hamayanhamayan.com/entry/2018/04/21/225805
・累積max(累積和の応用)
・先に回る方向がiより手前にmaxがあったとしても、
　そのパターンは別の周回のiで考慮されているので、
　始点まで戻るマイナス分が多くなっていても問題ない。
　どのみち先に回る方向で最終的にansに採用されるのはiまで行った時のはず。
"""

N, C = map(int, input().split())
x, v = [0], [0]
for i in range(N):
    _x, _v = map(int, input().split())
    x.append(_x)
    v.append(_v)
# 累積max
mx_r = [0] * (N+2)
cal = 0
for i in range(1, N+1):
    cal += v[i] - (x[i] - x[i-1])
    mx_r[i] = max(cal, mx_r[i-1])
mx_l = [0] * (N+2)
cal = v[N] - (C - x[N])
mx_l[N] = cal
for i in range(N-1, 0, -1):
    cal += v[i] - (x[i+1] - x[i])
    mx_l[i] = max(cal, mx_l[i+1])

ans = 0
for i in range(N+1):
    # 右回り→左回り(max(右回りのみ, 逆走もする, 今までの最大))
    ans = max(mx_r[i], mx_r[i] - x[i] + mx_l[i+1], ans)
    # 左回り→右回り
    if i != 0:
        ans = max(mx_l[i], mx_l[i] - (C - x[i]) + mx_r[i-1], ans)
print(ans)


Measured memory_bytes: 20312
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <bits/stdc++.h>
#include <map>
using namespace std;
int main(){
    int N,A,B;
    cin >> N;
    if(N==1){
        cout << "Hello World" << endl;
    }else if(N==2){
        cin >> A >> B;
        cout << A+B << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9 + 7, A = 2e3 + 2;

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    
string s;
  cin >> s;
  for (auto i : s)
    cout << 'x';
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e4 + 11;
const int M = 1e3 + 11;
int n, m, a[M], b[M], c[M][14];
int dp[N];
void put(int x){
    for(int i = 6;i >= 0; i--){
        if(x >> i & 1)printf("1");
        else printf("0");
    }
    puts("");
}
int main(){
    cin>>n>>m;
    for(int i = 1;i <= m; i++){
        scanf("%d%d", &a[i], &b[i]);
        for(int j = 1;j <= b[i]; j++){
            scanf("%d", &c[i][j]);
            c[i][j]--;
        }
    }
    memset(dp, 127 / 9, sizeof(dp));
    dp[0] = 0;
    for(int i = 1;i <= m; i++){
        //printf("i=%d\n", i);
        for(int j = (1 << n) - 1;j >= 0; j--){
            int now = j;
            for(int k = 1;k <= b[i]; k++){
                if((now >> c[i][k] & 1) == 0)continue;
                now ^= 1 << c[i][k];
            }

            //put(now);
            //printf("dpnow=%d\n", dp[now]);
            dp[j] = min(dp[j], dp[now] + a[i]);
            //put(j);
            //printf("dpj=%d\n", dp[j]);
        }
    }
    if(dp[(1<<n)-1] == dp[1<<n])puts("-1");
    else printf("%d\n", dp[(1<<n)-1]);
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h> //:3
using namespace std;
typedef long long ll;
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define sz(x) (int)((x).size())
#define int long long

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

const int N = 1e6 + 11;

int n, a[N];
map<int, int>M;

void solve(){

    cin >> n;

    for(int i = 1; i <= n; i++){
        char c;
        cin >> c;
        a[i] = c - 'a';
        M[a[i]]++;
    }

    int r = 'R' - 'a';
    int ans = 0;
    int lim = M[r];

    for(int i = 1; i <= lim; i++){
        if(a[i] != r)ans++;
    }

    cout << ans << '\n';
}

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

    cout << setprecision(6) << fixed;

    int T = 1;
    //cin >> T;
    while(T--){
        solve();
    }
}

Measured memory_bytes: 5212
#include<stdio.h>
void trace(int A[],int N)
{
    int i;
    for( i=0;i<N;i++)
    {
        if(i>0)printf(" ");
        printf("%d",A[i]);
        
    }
    printf("\n");
    
    
}

void insertionsort(int A[], int N){
    int j,i,v;
    for(i=1;i<N;i++)
    {
        v=A[i];
        j=i-1;
        while(j>=0 &&A[j]>v){
        A[j+1]=A[j];
        j--;
    }
    A[j+1]=v;
    trace(A,N);
        
    }
     }   
        
        int main(){
            int N,i,j;
            int A[100];
            
            scanf("%d",&N);
            for(i=0;i<N;i++)scanf("%d",&A[i]);
            trace(A,N);
            insertionsort(A,N);
            return 0;
            
            
            
            
        }


Measured memory_bytes: 1928
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    string s, t;
    cin >> n >> s >> t;
    int ans = -1;
    for( int i = 0; i < n; ++i ) {
        if( s[i] == t[0] ) {
            bool flg = true;
            for( int j = i + 1; j < n; ++j ) {
                if( s[j] != t[j - i] ) {
                    flg = false;
                    break;
                }
            }
            if( flg ) {
                ans = max( ans, n - i );
            }
        }
    }

    if( ans == -1 ) cout << n * 2 << endl;
    else cout << n * 2 - ans << endl;
    return 0;
}



Measured memory_bytes: 256
n,m = map(int,input().split())
h=[]
h.extend(input().split())
h=list(map(int,h))
cnt = [0]*n
cnt2 = [0]*n
ans = 0

for i in range(m):
  a,b = map(int,input().split())
  if h[a-1] > h[b-1]:
    cnt[a-1] += 1  
  if h[a-1] < h[b-1]:
    cnt[b-1] +=1
  cnt2[a-1] +=1
  cnt2[b-1] +=1

for p in range(n):
  if cnt[p]==cnt2[p]:
    ans += 1
print(ans)

Measured memory_bytes: 20032
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

n, *h = map(int, read().split())

if n == 1:
    print("Yes")
    exit()

for i in range(n-2, 0, -1):
    if h[i] >= h[i+1] + 2:
        print("No")
        exit()
    elif h[i] > h[i+1]:
        h[i] -= 1

print("Yes")


Measured memory_bytes: 19048
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
#include<random>
#include<numeric>

//by Skeef79

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>
#define what_is(x) cout<<#x<<" is "<<x<<en;

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];
}

void solve()
{
	ld l;
	cin >> l;
	ld a = l / 3;
	cout <<fixed<<setprecision(8)<< a * a*a;
}

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

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	int tst = 1;
	//cin >> tst;
	while (tst--)
		solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

long long dp0[101][4]; //N未満
long long dp1[101][4];

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

    int L = N.size();
	fill( ( long long * )dp0, ( long long * )dp0 + sizeof( dp0 ) / sizeof( long long ), 0 );
  fill( ( long long * )dp1, ( long long * )dp1 + sizeof( dp1 ) / sizeof( long long ), 0 );
	dp0[0][0] = 1;
    dp1[0][1] = 1;
    dp0[0][1] = N.at(0)-'1';

	for ( int i = 0; i < L-1; ++i ){
		for ( int j = 0; j < K+1; ++j ){
			dp0[i+1][j] = dp0[i][j];
            if(j>0) dp0[i+1][j] += 9*dp0[i][j-1];

            if(N[i+1]=='0'){
                dp1[i+1][j] = dp1[i][j];
            }
            else{
                if(j>0){
                    dp0[i+1][j] += (N[i+1]-'1')*dp1[i][j-1];
                    dp1[i+1][j] += dp1[i][j-1];
                }
                dp0[i+1][j] += dp1[i][j];
            }
		}
	}

    cout << dp0[L-1][K] + dp1[L-1][K] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    ll x;
    cin>>x;
    ll now = 100;
    int i = 0;
    while(now<x){
        now += now/100;
        i++;
    }
    cout<<i<<endl;
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX_N=10e5;
int A[MAX_N];
int sa(int a,int b){return (a%b==0?b:sa(b,a%b));}
int main(void){
	int N;
		cin >>N;
	for(int i=0;i<N;i++){
		cin >> A[i];
	}
	sort(A,A+N);
	int ans=sa(A[0],A[1]);
	for(int i=2;i<N;i++)
		ans=sa(ans,A[i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
read n
read t a
s=( `dd` )
ans=1000000000;
id=0;
for((;i<n;i++))do
	w=$[(t-a)*1000-s[i]*6]
	w=$[w>0?w:-w]
	id=$[ans>w?i+1:id]
	ans=$[ans>w?w:ans]
done
echo $id

Measured memory_bytes: 552
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

#define SIZE 400000
#define SIZE0 200000
#define INF 1000000000

typedef long long ll;

struct Segtree {
  int segn2;
  vector<int> data;

  Segtree(int n) {
    for(segn2=1; segn2<n; segn2*=2);
    data.assign(segn2*2, 1000000000);
  }

  int query(int a, int b, int l = 0, int r = -1, int k = 0) {
    if (r == -1) r = segn2;
    if (a <= l && r <= b) return data[k];
    if (r <= a || b <= l) return INF;
    return min(query(a, b, l, (l+r)/2, k*2+1), query(a, b, (l+r)/2, r, k*2+2));
  }

  void set(int k, int x) {
    k += segn2-1;
    data[k] = x;
    while(k > 0) {
      k = (k-1)/2;
      data[k] = min(data[k*2+1], data[k*2+2]);
    }
  }
};


int N;
ll L;
int M;
pair<ll,ll> p[SIZE0];

int memo[SIZE];
int solve1() {
  Segtree seg(M+1);

  seg.set(0, 0);

  for(int i=0; i<M; i++) {
    memo[i] = INF;
  }
  memo[0] = 0;

  for(int i=0; i<N; i++) {
    int l = p[i].first;
    int r = p[i].second;

    int v = seg.query(l, r);
    memo[r] = min(memo[r], v+1);
    seg.set(r, memo[r]);

  }

  return seg.query(M-1, M);
}

int sum[SIZE];
int solve2() {

  for(int i=0; i<N; i++) {
    sum[p[i].first]++;
    sum[p[i].second]--;
  }

  int ans = 1e9;

  for(int i=0; i<M-1; i++) {
    sum[i+1] += sum[i];
    ans = min(ans, sum[i]);
  }

  return N - ans + 1;
}

int main(){
  vector<ll> vec;
  map<ll, int> dic;

  scanf("%d%lld", &N, &L);

  for(int i=0; i<N; i++) {
    ll l, r;
    scanf("%lld%lld", &l, &r);

    p[i] = {l, r};
    vec.push_back(l);
    vec.push_back(r);
  }

  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());

  M = vec.size();

  for(int i=0; i<vec.size(); i++) {
    dic[vec[i]] = i;
  }

  sort(p, p+N);

  for(int i=0; i<N; i++) {
    p[i].first = dic[p[i].first];
    p[i].second = dic[p[i].second];
  }


  int ans1 = solve1();
  int ans2 = solve2();

  printf("%d %d\n", ans1, ans2);

  return 0;
}



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

int main() {
  int n;cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  bool b = true;
  
  if(n%2==1){
    for(int i=0; i<n; i++){
      if(a[i]!=(i+1)/2*2){
        b = false;
      }
    }
  }
  
  else{
    for(int i=0; i<n; i++){
      if(a[i]!=i/2*2+1){
        b = false;
      }
    }
  }
  int m = n/2;
  long long ans = 1;
  while(m){
    ans = ans *2 % 1000000007;
    m--;
  }
  if(b){
    cout << ans << endl;
  }
  else cout << 0 << endl;
}

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

int main() {
  int N; cin >> N;
  vector<string> s(N); for (int i=0; i<N; i++) cin >> s[i];
  int M; cin >> M;
  vector<string> t(M); for (int i=0; i<M; i++) cin >> t[i];
  
  int res = 0;
  for (int i=0; i<s.size(); i++) {
    int cnt = count(s.begin(), s.end(), s[i]);
    int ccnt = count(t.begin(), t.end(), s[i]);
    
    res = max(res, cnt-ccnt);
  }
  cout << res << endl;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> fact ={1,1,2,6,24,120,720,5040,40320};
int helper(vector<int> str, int st) 
{ 
    int cr = 0; 
    for (int i = st+1; i<str.size(); i++) 
        if (str[i] < str[st]) 
            cr++; 
    return cr; 
} 
int findnum(vector<int> arr){
    int ans=0;
    int cr;
    for(int i=0;i<arr.size();i++){
    	cr = helper(arr, i); 
    	ans+= cr * fact[arr.size()-i-1];
    // 	cout<< cr * fact[arr.size()-i-1]<<endl;
    	// cout<<ans<<endl;
    }
    return ans+1;
}
int main() {
    int n;
    cin>>n;
    vector<int> arr1(n),arr2(n);
    for(int i=0;i<n;i++)
        cin>> arr1[i];
    for(int i=0;i<n;i++)
        cin>> arr2[i];
    int a = findnum(arr1);
    int b = findnum(arr2);
    // cout<<a<<endl<<b<<endl;
    cout<< abs(a-b)<<endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};


int main(){
    CIN(N);CIN(M);
    int s = 1;
    REP(w,M){
        s*=2;
    }
    COUT(s*((N-M)*100+M*1900));
    rt 0;
}


Measured memory_bytes: 256
from collections import *
from heapq import *
from itertools import *
from fractions import gcd
import sys
from decimal import *
import copy
input=lambda :sys.stdin.readline().rstrip()

s=list(input())
K=int(input())
N=len(s)
lst=[]
lstset=set()
for i in range(N):
    for m in range(i+1,min(N+1,i+6)):
        c="".join(s[i:m])
        if not c in lstset:
            lst.append(c)
            lstset.add(c)
lst.sort()
print(lst[K-1])


Measured memory_bytes: 6752
import itertools
N,M,Q=map(int,input().split())
ABCD=[list(map(int,input().split())) for _ in range(Q)]
tl=itertools.combinations_with_replacement(range(1,M+1),N)
ans=0
for l in tl:
    t=0
    for a,b,c,d in ABCD:
        if l[b-1]-l[a-1]==c:
            t+=d
    ans=max(ans,t)
print(ans)

Measured memory_bytes: 9208
#ABC123_C
N=int(input())

A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())

bn=min(A,B,C,D,E)

if N%bn==0:
    num=N//bn
else:
    num=N//bn+1

print(num+4)

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <stdlib.h>

using namespace std;

int main() {

	int n;
	int *k;
	
	while (cin >> n) {
		int counter = 0;
		k = (int *)malloc(sizeof(int) * n);
		if (k == NULL) {
			exit(0);
		}
		k[0] = 1;
		for (int i = 1; i < n; i++) {
			k[i] = 0;
		}

		for (int i = 1; i < n; i++) {
			if (k[i] == 0) {
				/*for (int j = 1; j < i; j++) {
					if (k[j] == 0) {
						if ((i+1) % (j+1) == 0) {
							k[i] = 1;
							break;
						}
					}
				}*/
				if (k[i] == 0) {
					for (int t = 2; t <= n/(i+1); t++) {
						k[(i+1)*t-1] = 1;
					}
				}
			}
		}

		for (int i = 1; i < n; i++) {
			if (k[i] == 0) {
				counter++;
			}
		}

		cout << counter << endl;

		free(k);
	}

	return 0;
}

Measured memory_bytes: 5360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define irep(i,a,b) for(typeof(i) i = (a); i < (b); ++i)
#define itrep(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)

// MOD p でいくつクラス
#define MOD 998244353
class mll {
	unsigned long long val = 0;
public:
	mll(long long y = 0) : val(((y % MOD) + MOD) % MOD) {}
	mll operator + (const mll& y) { return mll(*this) += y; }
	mll& operator += (const mll& y) {
		val = (val + y.val) % MOD;
		return *this;
	}
	mll operator - (const mll& y) { return mll(*this) -= y; }
	mll& operator -= (const mll& y) {
		val = (val - y.val + MOD) % MOD;
		return *this;
	}
	mll operator * (const mll& y) { return mll(*this) *= y; }
	mll& operator *= (const mll& y) {
		val = (val * y.val) % MOD;
		return *this;
	}
	mll operator / (const mll& y) { return mll(*this) /= y; }
	mll& operator /= (const mll& y) {
		long long a = y.val, b = MOD, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		mll c = val * u; // この計算でoverflowしないか？
		val = c.val;
		return *this;
	}
	bool operator >= (const mll& y) {
		return this->val >= y.val;
	}
	mll pow(long long t) const {
		if (!t) return 1;
		mll a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	unsigned long long getVal() {
		return val;
	}
	friend ostream& operator <<(ostream& os, mll& y) {
		os << y.val;
		return os;
	}
};
#undef MOD

vector<int> A;
vector<vector<mll> > dp;
vector<vector<bool> > F;

void ask(int i, int j) { // dp[i][j] をセットする。し終わったらreturn
	if (F[i][j]) return;
	ask(i - 1, j);
	dp[i][j] = dp[i - 1][j];
	if (j >= A[i - 1]) {
		ask(i - 1, j - A[i - 1]);
		dp[i][j] += dp[i - 1][j - A[i - 1]] / 2;
	}
	F[i][j] = true;
	return;
}

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

	int N, S;
	cin >> N >> S;
	A = vector<int>(N, 0);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	dp = vector<vector<mll> >(N + 1, vector<mll>(S + 1, 0));
	F = vector<vector<bool> >(N + 1, vector<bool>(S + 1, false));

	// i = 0;
	dp[0][0] = mll(2).pow(N); // dp[0][0] には、(0個,1ケース)を入れる。dp[0][j>0] はempty
	for (int j = 0; j <= S; j++) {
		F[0][j] = true;
	}
	// DP
	ask(N, S);

	cout << dp[N][S].getVal() << endl;
	return(0);
}


Measured memory_bytes: 75284
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=300010,Mo=1000000007;
char s[N];
int g[N],d[N],f[N][4][3];
inline void upd(int &x,long long y) {x=(x+y)%Mo;}
int main() {
    scanf("%s",s+1);
    int n=strlen(s+1),ans=0;
    for(int i=n;i;i--) g[i]=g[i+1]+(s[i]=='?');
    for(int i=d[0]=1;i<=n;i++) d[i]=2*d[i-1]%Mo;
    f[0][2][0]=1;
    for(int i=1;i<=n;i++)
	for(int j=0;j<4;j++)
	    for(int k=0;k<3;k++) {
		int v=f[i-1][j][k];
		if(v) {
		    if(s[i]=='0'||s[i]=='?')
			upd(f[i][j][k==2?1:k+1],v);
		    if(s[i]=='1'||s[i]=='?') {
			if(j-k==3) upd(ans,1LL*v*d[g[i+1]]);
			else if(j>k+1) upd(f[i][j+1-k][0],v);
			else upd(f[i][j][k-1],v);
		    }
		}
	    }
    cout<<(ans+f[n][3][0])%Mo;
    return 0;
}

Measured memory_bytes: 16896
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=input.split("\n");
var A=Arr[1].split(" ").map(Number);
var N=Arr[0]-0;
console.log(A.join(" "));
for(var i=1;i<=N-1;i++){
   var v=A[i];
   var j=i-1;
   while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
   }
A[j+1]=v;
console.log(A.join(" "));
}

Measured memory_bytes: 7908