akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;

int gcd(int x, int y);

const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    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 { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;
    ll len = 0;
    rep(i, n) {
        len += a[i];
    }

    ll num = 0;
    ll num2 = len;
    ll diff = len;
    ll diff2 = len;
    rep(i, n) {
        num += a[i];
        num2 -= a[i];
        diff = abs(num - num2);
        if (diff == 0) {
            cout << 0 << endl;
            return 0;
        }
        if (diff > diff2)
            break;
        diff2 = diff;

    }

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

/*int main() {
    int x, y;
    cin >> x >> y;
    if (x == 1 && y == 1) {
        cout << 1000000;
        return 0;
    }
    int ans = 0;
    switch (x) {
    case 1:
        ans += 300000;
        break;
    case 2:
        ans += 200000;
        break;
    case 3:
        ans += 100000;
        break;
    }
    switch (y) {
    case 1:
        ans += 300000;
        break;
    case 2:
        ans += 200000;
        break;
    case 3:
        ans += 100000;
        break;
    }
    cout << ans << endl;
    return 0;
}
/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int64 INF = 1LL << 60;
const int MOD = 1e9 + 7;

const int N = 3000;
struct Edge {
  int x, y, z;
};

int main() {
  int n, m, val;
  scanf("%d%d%d", &n, &m, &val);
  vector<Edge> e(m);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d%d", &e[i].x, &e[i].y, &e[i].z);
    --e[i].x, --e[i].y;
    e[i].z -= val;
  }
  vector<int64> d(n, -INF);
  d[0] = 0;
  for (int k = 0; k < n; ++k) {
    for (auto& it : e) {
      int x = it.x, y = it.y, z = it.z;
      if (d[y] < d[x] + z) {
        d[y] = d[x] + z;
      }
    }
  }
  int64 ret = d[n - 1];
  for (int k = 0; k < n; ++k) {
    for (auto& it : e) {
      int x = it.x, y = it.y, z = it.z;
      if (d[y] < d[x] + z) {
        d[y] = d[x] + z;
      }
    }
  }
  if (d[n - 1] != ret) {
    puts("-1");
  } else {
    ret = max(ret, 0LL);
    printf("%lld\n", ret);
  }
  return 0;
}


Measured memory_bytes: 384
A,B = map(int,input().split())
S = list(input())
if len(S) != A+B+1:
    print('No')
    exit()
for i,s in enumerate(S):
    if i!=A and s != '-':
        continue
    if i==A and s == '-':
        continue
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 
#ifdef HOME
#include "/home/prateek2112/print.cpp"
#else
#define debug(...) 21
#endif

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   string n;
   cin >> n;
   int x = n.back()-'0';
   if(x == 3){
      cout << "bon";
   }else if(x == 0 or x == 1 or x == 6 or x == 8){
      cout << "pon";
   }else{
      cout << "hon";
   }
   return 0;
} 

Measured memory_bytes: 3608
a,b,q = gets.split.map(&:to_i)

shrines = []
temples = []

a.times do
  shrines << gets.to_i
end
b.times do
  temples << gets.to_i
end

def calc_dist(x,y)
  x + y + [x,y].min
end

ans = q.times.map do
  x = gets.to_i
  
  east_shrine_index = shrines.bsearch_index do |v|
    x < v
  end

  east_shrine = if east_shrine_index then shrines[east_shrine_index] end
  west_shrine = case east_shrine_index when 0 then nil when nil then shrines[-1] else shrines[east_shrine_index-1] end

  east_temple_index = temples.bsearch_index do |v|
    x < v
  end

  east_temple = if east_temple_index then temples[east_temple_index] end
  west_temple = case east_temple_index when 0 then nil when nil then temples[-1] else temples[east_temple_index-1] end

  possibles = []
  possibles << [east_shrine-x,east_temple-x].max  if east_shrine && east_temple
  possibles << calc_dist((east_shrine-x),(x-west_temple)) if east_shrine && west_temple
  possibles << calc_dist((x-west_shrine),(east_temple-x)) if west_shrine && east_temple
  possibles << [x-west_shrine,x-west_temple].max  if west_shrine && west_temple

  possibles.min
end.join("\n")

print ans


Measured memory_bytes: 7548
import collections

N = int(input())
A = input().split()

#A_set = set(A)

#ボールに書かれている 数字の内訳を辞書に登録
A_dic = collections.Counter(A)

#すべてのボールから同じボールを取り出す方法数
all_count = 0

for a in A_dic.keys():
    count_a = A_dic.get(a)
    all_count += (count_a * (count_a - 1) // 2)

#n個あるボールから 1個取り除いた場合の方法数
#すべてのボールから取り出す方法数 - (n-1)通り

for i in range(N):
    print(all_count - A_dic.get(A[i])+1)

Measured memory_bytes: 26784
#include <iostream>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
//#define hell        1000000007
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e7+1;
const long long mod = (long long) 998244353 ;
const long long hell = (long long) 1000000007;

using namespace std;
#include <stdio.h>

ll power(ll x,ll y)
{
  ll res=1;
  while(y>0){
    if(y%2) res=(x%hell*res%hell)%hell;
    x=(x%hell*x%hell)%hell;
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,hell-2);
}

void solve();


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/

ll a[101];
ll F(ll x,int n){
    ll cur=0;
    forn(i,0,n)
    cur+=(x-a[i])*(x-a[i]);
    
    return cur;
}

void solve(){
  int test;
  //cin>>test;
  test=1;
     
  while(test--){
        int n;
        cin>>n;
        
        forn(i,0,n)
        cin>>a[i];
        
        sort(a,a+n);
        ll ans=INT_MAX;
        ll l=a[0],h=a[n-1];
        
        while(true){
            if(h-l<=3){
                for(ll i=l;i<=h;i++){
                    ll v=F(i,n);
                    if(v<ans){
                        ans=v;
                    }
                }
                break;
            }
            ll m1=l+(h-l)/3;
            ll m2=h-(h-l)/3;
            
            ll v1=F(m1,n);
            ll v2=F(m2,n);
            
            if(v1<v2){
                h=m2;
            }
            else
            l=m1;
        }
        cout<<ans;
    }         
}    

    




///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll a,ll b)
{
    while( b != 0)
	{
		ll  t = b;
		b= a %t;
		a = t;
	}
	return a;
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1))*k);
  else
  return ((pw(k,x/2))*(pw(k,x/2)));
}





Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include <cmath>
#include<queue>
#include<cstdio>
//#include <bits/stdc++.h>
using namespace std;

int main(){
    double R;
    cin>>R;
    const double PI=3.14159265358979323846;
    cout<<2.0000*R*PI<<endl;
    return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define For(i, s, e) for(ll i = s;i <= e;i++)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;


int main() {
    string s,t;
    cin>>s>>t;
    bool f = 1;
    rep(i,s.size()) {
        if(s[i] != t[i]) f = 0;
    }
    if(f)cY
    else cN
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int in;
    vector <int> v;
    int s(0), save;
    int i = 0;
    while (i < 5) {
        cin >> in;
        s++;
        v.push_back(in);
        if (in == 0) { save = s; }
        i++;
    }
    cout << save << "\n";
    return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

ll func(vl &DP, vvl &G, ll now, ll score) {
  if (G[now].size() == 0)
    return score;
  if (DP[now] > -1)
    return DP[now] + score;
  ll max_score = 0;
  AUTO(c, G[now]) { max_score = max(max_score, func(DP, G, c, score + 1)); }
  DP[now] = max_score - score;
  return max_score;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, M;
  cin >> N >> M;
  vvl G(N), P(N);
  vl DP(N, -1); //ある点からの最長距離
  REP(i, M) {
    ll x, y;
    cin >> x >> y;
    x--;
    y--;
    G[x].push_back(y);
    P[y].push_back(x);
  }
  vl kouho; //始点の候補
  REP(i, N) {
    if (P[i].size() == 0)
      kouho.push_back(i);
  }
  ll ans = 0;
  AUTO(s, kouho) { ans = max(ans, func(DP, G, s, 0)); }
  // REP(i, N) cout << DP[i] << endl;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 19840
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> w(n);
  for (auto &e : w)
    cin >> e;

  int ng = -1, ok = 1e9;
  while (ok - ng > 1)
  {
    int mid = (ok + ng) / 2;
    int sum = 0, cnt = 0;
    for (int i = 0; i < n; ++i)
    {
      if (w[i] > mid)
      {
        cnt = k;
        break;
      }
      if (sum + w[i] <= mid)
        sum += w[i];
      else
      {
        sum = w[i];
        cnt++;
      }
    }
    cnt++;
    if (cnt > k)
      ng = mid;
    else
      ok = mid;
  }
  cout << ok << endl;

  return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    int a,b;
    int ans=0;
    cin>>a>>b;
    for(int i=a; i<=b; i++){
        std::string s = std::to_string(i);
        if(s.at(0)==s.at(4) && s.at(1)==s.at(3)){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3688
#include <stdio.h>
#include <string.h>

char S[100000];

void Do(void){
  int i, c1, c2, m;
  c1 = c2 = 0;
  for(i = 0;i < strlen(S);i++){
    if(S[i] != '0' + (i % 2)) c1++;
    if(S[i] != '1' - (i % 2)) c2++;
  }
  if(c1 < c2) m = c1;
  else m = c2;
  printf("%d\n", m);
}

int main(void){
  scanf("%s", S);
  Do();
  return 0;
}


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

int main() {
  string S,T;
  cin >> S >> T;
  int x = S.size();
  int a=0;
  
  for(int i=0;i<x;i++){
    if(S.at(i) == T.at(i))
      a++;
    else continue;
  }
  
  if(a==x) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;


int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  struct Dice {
    int u = 1, d = 6, l = 2, r = 5, f = 3, b = 4;
    void U(int n = 1) {
      for (int _ = 0; _ < n; ++_) swap(l, f), swap(f, r), swap(r, b);
    }
    void D(int n = 1) { U(3 * n & 3); }
    void L(int n = 1) {
      for (int _ = 0; _ < n; ++_) swap(f, u), swap(u, b), swap(b, d);
    }
    void R(int n = 1) { L(3 * n & 3); }
    void F(int n = 1) {
      for (int _ = 0; _ < n; ++_) swap(u, l), swap(l, d), swap(d, r);
    }
    void B(int n = 1) { F(3 * n & 3); }
  };
  auto fn = [&](int u, int f) -> Dice {
    for (int i = 0; i < 4; ++i) for (int j = 0; j < 4; ++j) for (int k = 0; k < 4; ++k) {
      Dice res;
      res.U(i), res.L(j), res.F(k);
      if (res.u == u and res.f == f) return res;
    }
    assert(false);
  };
  while (true) {
    int n; cin >> n;
    if (!n) break;
    VV<> h(32, V<>(32)), x(32, V<>(32));
    while (n--) {
      int u, f; cin >> u >> f;
      Dice a = fn(u, f);
      int i = 16, j = 16;
      while (true) {
        int oi = i, oj = j;
        for (int k = 6; k >= 4; --k) {
          if (a.l == k and h[i][j] > h[i][j - 1]) { a.B(), --j; break; }
          if (a.r == k and h[i][j] > h[i][j + 1]) { a.F(), ++j; break; }
          if (a.f == k and h[i][j] > h[i + 1][j]) { a.L(), ++i; break; }
          if (a.b == k and h[i][j] > h[i - 1][j]) { a.R(), --i; break; }
        }
        if (i == oi and j == oj) break;
      }
      ++h[i][j];
      x[i][j] = a.u;
    }
    V<> res(6);
    for (const auto& v : x) for (int e : v) if (e) {
      ++res[e - 1];
    }
    for (int i = 0; i < 6; ++i) cout << res[i] << " \n"[i == 5];
  }
}


Measured memory_bytes: 3188
import math
import itertools
N = int(input())
citys = [[0,0]]
for i in range(0,N,1):
    citys.append(list(map(int,input().split())))
dist = [[0 for i in range(0,N+1,1)]for j in range(0,N+1,1)]
for i in range(1,N+1,1):
    for j in range(1,N+1,1):
        dist[i][j]=math.sqrt((citys[i][0]-citys[j][0])**2 + (citys[i][1]-citys[j][1])**2)

total = 0
for i in list(itertools.permutations(range(1,N+1,1),N)):
    for j in range(0,N-1,1):
        total += dist[i[j]][i[j+1]]

print(total/math.factorial(N))


Measured memory_bytes: 45808
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

/*
i番目をjで塗る場合の数
*/

ll n,ans=1,MOD=1e9+7,before=0;
string s[2];

int main(void){
	cin>>n;
	cin>>s[0]>>s[1];
	rep(i,n){
		if(s[0][i]==s[1][i]){
			if(before==0)ans=(ans*3)%MOD;
			if(before==1)ans=(ans*2)%MOD;
			if(before==2)ans=(ans*1)%MOD;
			before=1;	
		}else{
			//赤、２色、赤
			if(before==0)ans=(ans*6)%MOD;
			if(before==1)ans=(ans*2)%MOD;
			if(before==2)ans=(ans*3)%MOD;
			i++;
			before=2;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end

a,b,x=gi

puts x-a<=b && x-a >= 0 ? "YES" : "NO"


Measured memory_bytes: 2428
def main():
    N = int(input())
    print(IsPrime(N))

def IsPrime(N):
    count = 0
    for i in range(N):
        inputNum = int(input())
        if(inputNum == 2):
            count += 1
            continue
        elif(inputNum % 2 == 0):
            continue

        flag = 0
        for j in range(3, int(pow(inputNum, 1/2))+1):
            if(inputNum % j == 0):
                flag = 1
                break
            else:
                continue
        if(flag == 0):
            count += 1
    
    return count

if __name__ == '__main__':
    main()

Measured memory_bytes: 5668
n, k = map(int, input().split())

P = list(map(int,input().split()))

#print(n, k)
#print(P)

P.sort()

#print(P)

kaimono = 0
count = 1
for p in P:
  if count > k:
    break
  #print(kaimono)
  kaimono += P[count-1]
  count = count + 1
  
print(kaimono)

Measured memory_bytes: 9176
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


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

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::string s;

  std::cin >> s;

  while (1) {
    s.pop_back();
    s.pop_back();

    int size = s.size();

    if (s.substr(0, size / 2) == s.substr(size / 2, size / 2)) {
      std::cout << size << std::endl;

      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc065/tasks/arc076_a

n, m = [int(i) for i in input().split()]


def perm(x):
    a = 1
    for i in range(1, x + 1):
        a = (a * i) % (10**9 + 7)
    return a


if abs(m - n) > 1:
    print(0)
    quit()


if m == n:
    ans = (2 * perm(m) * perm(n)) % (10**9 + 7)
else:
    ans = (perm(m) * perm(n)) % (10**9 + 7)

print(ans)


Measured memory_bytes: 62944
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int t = 0;
  cin >> t;
  int l = 0;
  l = (c - a) * 60 + d - b;
  cout << max(l - t,0) << endl;
}

Measured memory_bytes: 3572
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	final int MOD = 1000000007;
	int[] dx = { 1, 0, 0, -1 };
	int[] dy = { 0, 1, -1, 0 };

	void run() {
		for (;;) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			int s = sc.nextInt();
			if ((x | y | s) == 0) {
				return;
			}
			int ans = 0;
			for (int i = 1; i < s; i++) {
				for (int j = 1; j < s; j++) {
					int beforeSum = i * (100 + x) / 100 + j * (100 + x) / 100;
					if (beforeSum == s) {
						int afterSum = i * (100 + y) / 100 + j * (100 + y)
								/ 100;
						ans = Math.max(ans, afterSum);
					}
				}
			}
			System.out.println(ans);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

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

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

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}
	}
}

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

using namespace std;

int main() {
  string S;
  cin >> S;
  int S1 = (S.size() - 1) / 2;
  int S2 = (S.size() + 3) / 2;
  string ans;
  string sna;
  for (int i = 0; i < S1; i++) {
    ans += S.at(i);
  }
  for (int i = 0; i < S1; i++) {
    sna += S.at(i + (S2 - 1));
  }
  if (ans == sna) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define plll pair<ll,pll>
#define ppll pair<pll, pll>
#define pii pair<int, int> 
#define pb push_back
#define mod 1000000007
#define N 2000007
ll power(ll a,ll b){
    ll res=1ll;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res%mod;
}
ll ncr(ll n,ll k){
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i))%mod;
        pro/=(i+1);
    }
    return (pro)%mod;
}

void swap(ll *a,ll *b) {
    ll temp=*a;
    *a=*b;
    *b=temp;
}
vector<ll> prime;
void seive(){
    vector<bool > isprime(1000001,true);
    for(int i=2;i*i<=1000000;i++){
        if(isprime[i]){
            for(int j=i*i;j<=1000000;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=1000000;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
vector<ll> parent;
ll find(ll p) {
    if(parent[p]==p) return parent[p];
    return parent[p]=find(parent[p]); 
}
void unun(ll a,ll b) {
    ll r1=find(a);
    ll r2=find(b);
    if(r1!=r2) parent[r2]=r1;
}
void solve() {
    ld l;
    cin>>l;
    setprecision(16);
    ld x=(l/3.0);
    ld vol= (x*x*x);
    cout<<setprecision(16)<<vol;
}   


int main(void){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t=1;
    // cin>>t;
    while(t--) {
        solve();
        // cout<<endl;
    }
    return 0; 

}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;
 public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
       int n=sc.nextInt();
       if(n>=30)
       	System.out.println("Yes");
       else
       	System.out.println("No");

	   }
	
}

Measured memory_bytes: 35840
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<set>
using namespace std;

string fb(int x){
    if(x % 15 == 0)return "FizzBuzz";
    if(x % 3 == 0)return "Fizz";
    if(x % 5 == 0)return "Buzz";
    char c[1050];
    sprintf(c, "%d", x);
    string res = c;
    return res;
}

int main(){
    int a, b;
    while(cin >> a >> b, a | b){
	set<int> alive;
	int left = a, p = 0;
	for(int i = 0;i < a;i++)alive.insert(i);
	set<int>::iterator it = alive.begin();
	for(int i = 1;i <= b;i++){
	    string u;
	    cin >> u;
	    if(left == 1)continue;
	    if(u != fb(i)){
		alive.erase(it++);
		left--;
	    }
	    else{
		it++;
	    }
	    if(it == alive.end())it = alive.begin();
	}
	it = alive.begin();
	while(it != alive.end()){
	    if(it != alive.begin())cout <<" ";
	    cout << 1 + *it;
	    it++;
	}
	cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1296
#include<stdio.h>
int main()
{
int a,j,b;
scanf("%d",&a);  
  int c[a];
  b=0;
  for(j=0;j<a;++j)
  {
  scanf("%d",&c[j]);
    while(c[j]%2==0) {c[j]=c[j]/2;
                     b++;
                     }
  }
printf("%d",b);
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define Rep(i,n)for(int i=1;i<=n;i++)

typedef struct TF{int a,nt,nf,t[16],f[16];}tf;

int main(){
	int n,x,y,ans=0;
	tf f[16];
	rep(i,16){f[i].nt=0;f[i].nf=0;}
	scanf("%d",&n);
	Rep(i,n){
		scanf("%d",&f[i].a);
		rep(j,f[i].a){
			scanf("%d%d",&x,&y);
			if(y){f[i].t[f[i].nt]=x;f[i].nt++;}
			else {f[i].f[f[i].nf]=x;f[i].nf++;}
		}
	}
	rep(i,2<<n){
		int all[16]={0};
		Rep(j,n)if(i&1LL<<j)all[j]++;//kind
		int num=0,flag=1;
		Rep(j,n){
			if(!all[j])continue;
			num++;
			rep(k,f[j].a){
				rep(l,f[j].nt)if(all[f[j].t[l]]==0)flag=0;
				rep(l,f[j].nf)if(all[f[j].f[l]]==1)flag=0;
			}
		}
		if(flag)ans=(ans<num?num:ans);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1736
import sys
N, M, K = map(int, input().split())

for i in range(0, N+1):
    for j in range(0, M+1):
        ans = (M * i) + (N * j) - 2 * (i * j)
        if ans == K:
            print("Yes")
            sys.exit()
print("No")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a[3][3];
    for(int i = 0 ; i < 3 ; i++)
        for(int j = 0 ; j < 3 ; j++)
            cin >> a[i][j];
    int n;
    cin >> n;
    int hit[3][3] = {0};
    int b;
    // for (int h = 0; h < 3; h++)
    //     for (int w = 0; w < 3; w++)
    //         cout << hit[h][w] << endl;

    for(int i = 0 ; i < n ; i++){
        cin >> b;
        for(int h = 0 ; h < 3 ; h++)
            for(int w = 0 ; w < 3 ; w++)
                if(a[h][w] == b)
                    hit[h][w] = 1;
    }

   

    bool flag = false;
    for(int i = 0 ; i < 3 ; i++){
            if(hit[i][0] && hit[i][1] && hit[i][2])
                flag = true;
            if(hit[0][i] && hit[1][i] && hit[2][i])
                flag = true;
        }
    if(hit[0][0] && hit[1][1] && hit[2][2] || hit[0][2] && hit[1][1] && hit[2][0])
        flag = true;

    if(flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
char s[200010];
int main()
{
	scanf("%s",&s);
	int l=strlen(s);
	ll ans=0;
	int cnt=0;
	for (int i=0;i<l;i++)
	{
		if (s[i]=='B')
		{
			cnt++;
		}
		else
		{
			ans+=cnt;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  int x1, y1, x2, y2;
  cin >> x1 >>  y1 >>  x2 >>  y2;
  int dx = -(x1 - x2);
  int dy = -(y1 - y2);
  int x3 = x2 - dy;
  int y3 = y2 + dx;
  int x4 = x1 - dy;
  int y4 = y1 + dx;
  cout << x3 << " " << y3 << " " << x4 << " "  << y4 << endl; 
  return 0;
}

Measured memory_bytes: 3636
use strict;
use warnings;

my (%item, $blue, $r);
while(<>){
	chomp;
	$blue = $_ if($. == 1);
	if($. >= 2 and $. <= $blue + 1){
		$item{$_}++;
	}
	elsif($. >= $blue + 3){
		$item{$_}--;
	}
}

$r = 0;
for my $key (keys %item){
	$r = $item{$key} if ($r <= $item{$key});
}
print "$r\n";


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int r, D, x;
    cin >> r >> D >> x;
    for(int i=1; i<=10; i++){
        x = r*x-D;
        cout << x << endl;
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
def solve():
    ans=0;f=0
    s=input();n=len(s);k=int(input())
    if len(s)==1:
        return k//2
    for i in range(n-1):
        if s[i]!=s[i+1]:
            break
    else:return (n*k)//2
    count=1
    c1=0
    tmp=s[0]
    if s[-1]==tmp:
        j=1
        for j in range(n-1,1,-1):
            if s[j]!=tmp:
                break
            c1+=1
        n=j+1
        f=1

    for j in range(1,n):
        if s[j]!=tmp:
            break
        count+=1
    if f:
        ans+=(count+c1)//2*(k-1)
        ans+=c1//2
        ans+=count//2
    else:
        ans+=count//2*k
        
        
    i=j
    while i<n-1:
        count=1
        tmp=s[i]
        for j in range(i+1,n):
            if s[j]!=tmp:
                break
            count+=1
        i=j
        ans+=count//2*(k)
    return ans

print(solve())


Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, P[202020];
int loc[202020];
bool kept[202020];

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) {
		scanf("%d", P + i);
		--P[i];
		loc[P[i]] = i;
	}

	for (int i = 1; i < N; ++i) kept[i] = (loc[i - 1] < loc[i]);

	int ans = 0, con = 0;
	for (int i = 1; i < N; ++i) {
		if (kept[i]) {
			++con;
			ans = max(ans, con);
		} else {
			con = 0;
		}
	}
	printf("%d\n", N - 1 - ans);

	return 0;
}


Measured memory_bytes: 2048
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a*b, c*d) << endl;
	return 0;
}

Measured memory_bytes: 256
S = input()
ans = 0
for i in range(len(S)):
    for j in range(i + 1, len(S) + 1):
        T = S[i:j]
        cnt = 0
        for x in T:
            if x not in ['A', 'T', 'G', 'C']:
                break
            cnt += 1
        ans = max(ans, cnt)
print(ans)


Measured memory_bytes: 38256
import os
import statistics
def quickSort(arr):
   # 配列のメジアンより小さい要素を集めた配列
    left = []

    # 配列のメジアンより大きい要素を集めた配列
    right = []

    # 再帰の停止条件
    # 再帰的に配列を分割した後の、要素数が1以下になったら停止する
    if len(arr) <= 1:
        return arr

    # 配列の中央値(メジアン)を取得する
    median = int(statistics.median(arr))

    # 配列内に含まれる中央値の個数を数えるための変数
    medianFlg = 0

    for element in arr:
        # 配列の要素(element)が中央値より小さいので、
        # 配列leftに値を格納する
        if element < median:
            left.append(element)
        # 配列の要素(element)が中央値より大きいので、
        # 配列rightに値を格納する
        elif element > median:
            right.append(element)
        else:
        # elementが配列の中央値の場合は、
        # 返り値に加える中央値の個数分だけ、フラグに+1し続ける
            medianFlg += 1

    # print(left)
    # print(right)

    # 配列left、配列right毎に再帰を行い
    # 配列を小さな配列に区切る
    left = quickSort(left)
    right = quickSort(right)

    # 配列left、中央値の[median]、配列rightを結合したものを返す
    return left + [median] * medianFlg + right

N,K=map(int,input().split())
h=map(int,input().split())
H=list(h)
M=quickSort(H)
c=0
if N-K==0:
 print(c)
else:
 for i in range(N-K):
  c+=M[i]
 print(c)

Measured memory_bytes: 27508
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;


int main() {

	long N, M; cin >> N >> M;
	long res = 0;

	vector<pair<long, long>> task;

	for (int i = 0; i < M; i++) {

		long B, A; cin >> A >> B;
		task.push_back(make_pair(B, A));
	}

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

	long bri = task[0].first - 1;
	res++;

	for (int i = 0; i < M; i++) {

		if (task[i].second <= bri && bri < task[i].first) continue;
		bri = task[i].first - 1;
		res++;

	}

	cout << res << endl;

}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define v vector<ll> 
#define vv vector<v>
#define p pair<ll,ll>
#define arrayinput int n; int m; cin>>n>>m; v arr (n+1,-1); for (int i=0; i<n; i++){int temp; cin>>temp;arr[i]=temp;}
#define vp vector<pair<int,p> >
int LIM=2e5+10;
ll MOD=1e9+7;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int r,c,a,b;
    cin>>r>>c>>a>>b;
    for (int i=1; i<=r; i++)
    {
    	for (int j=1; j<=c; j++)
    	{
    		if (i<=b && j<=a)
    			cout<<1;
    		else if (i>b && j>a)
    			cout<<1;
    		else
    			cout<<0;
    	}
    	cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 1280
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;


typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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


    ll A, B, Q;
    cin >> A >> B >> Q;

    vector<ll> s(A), t(B);

    REP(i,A) cin >> s[i];
    REP(i,B) cin >> t[i];

    sort(ALL(s));
    sort(ALL(t));

    REP(_,Q){
        ll x;
        cin >> x;

        ll d = (ll)10e10+1;
        ll apos=0, ax, bpos=0, bx;

        REP(i,2){
            auto aitr = lower_bound(ALL(i?s:t),x);


            REP(j,2){
                apos = distance((i?s:t).begin(),aitr)-j;
                if (apos >= 0 and apos < (i?s:t).size()) ax = (i?s:t)[apos];
                else continue;
                auto bitr = lower_bound(ALL((1-i?s:t)),ax);

                REP(k,2){
                    bpos = distance((1-i?s:t).begin(),bitr)-k;
                    if (bpos >= 0 and bpos < (1-i?s:t).size()) bx = (1-i?s:t)[bpos];
                    else continue;

                    d = min(d,abs(x-ax) + abs(ax-bx));
                    //if (x == 899) cout << x << " " << ax << " " << bx << endl;
                }
            }

        }


        cout << d << endl; //break;
    }

    return 0;
}

Measured memory_bytes: 2944
n, x = map(int,input().split())

donuts = [int(input()) for i in range(n)]
MiniD = min(donuts)
CountD = 0
for i in range(0,n):
    x -=donuts[i]
    CountD +=1

while True:
    x -=MiniD
    if x<0:
        break
    CountD += 1
print(CountD)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char a[19999];
int num,ans,maxn;
int main()
{
	//gets(a);
	int n;
	
	//num=strlen(a);
	
	scanf("%d%s",&n,a+1);
	for(int i=1;i<=n;i++)
	{
		if(a[i]=='I')ans++;
		else if(a[i]=='D')ans--;
		
		maxn=max(maxn,ans);
		
	}
	cout<<maxn;
	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

main :: IO ()
main = getLine >>= putStrLn.unwords.map show.solve.map read.words

solve :: [Int] -> [Int]
solve [a, b] = [x, y]
  where
    (x, y) = gcdExt a b

gcdExt :: Int -> Int -> (Int, Int)
gcdExt _ 0 = (1, 0)
gcdExt a b = (y, x - q * y)
  where
    (!q, !r) = quotRem a b
    (!x, !y) = gcdExt b r

Measured memory_bytes: 3660
<?php
fscanf(STDIN, "%s", $s);
$arr = str_split($s);
$flg = 'No';
$tmp = $arr[0];
for($i = 1; $i < count($arr); $i++){
	if($tmp != $arr[$i]){
		$flg = 'Yes';
		break;
	}
	$tmp = $arr[$i];
}
echo $flg;
?>

Measured memory_bytes: 4856
import collections
import itertools
N=int(input())
S=[input() for _ in range(N)]
l=[]
l2=[]
l3=[]
sq=[]
lst=[]
cnt=0
for i in range(N):
    if (S[i][0]=="M")or(S[i][0]=="A")or(S[i][0]=="R")or(S[i][0]=="C")or(S[i][0]=="H"):
        l2.append(S[i][0])
c=collections.Counter(l2)
values=list(c.values())	#aのCollectionのvalue値のリスト(n_1こ、n_2こ…)
key=list(c.keys())	#先のvalue値に相当する要素のリスト(要素1,要素2,…)
for i in range(len(key)):
    sq.append(values[i])
    l.append([key[i],values[i]])#lは[要素i,n_i]の情報を詰めたmatrix
lst=list(itertools.combinations(sq,3))
for i in range(len(lst)):
    l3=list(lst[i])
    cnt=cnt+l3[0]*l3[1]*l3[2]

print(cnt)

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

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n,m;
    cin>>n>>m;
    int p10 = 1;
    for(int i=0;i<n-1;++i) p10 *= 10;
    
    vector<pair<int,int>> v(m);
    for(int i=0;i<m;++i){
        int s,c;
        cin>>s>>c;
        s--;
        v[i] = {s,c};
    }
    for(int i=0;i<1000;++i){
        string s = to_string(i);
        if(s.size() != n)continue;
        bool ng = false;
        for(auto cur : v){
            if(s.substr(cur.first,1) != to_string(cur.second)) ng = true;
        }
        if(!ng){
            cout << i << endl;
            return 0;
        }
    }
    
    cout << -1 << endl;
    return 0;
}

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

int main(void){
 
  /* 文字 */
  char moji;
  cin >> moji;
 
  /* アルファベットの小文字か大文字かを判定 */
  if((moji>= 'a') && (moji<='z')){
    cout << "a";
  }
  else if((moji>= 'A') && (moji<='Z')){
    cout << "A";
  }
  return 0;
}



Measured memory_bytes: 3632
# from line_profiler import LineProfiler
from collections import deque
from sys import stdin

def main():
    while(True):
        W, H = map(int, stdin.readline().split())
        if not W: break
        tx,ty = map(int, stdin.readline().split())
        kx,ky = map(int, stdin.readline().split())
        ma = [[False]*(W+2) for _ in range(H+2)]
        for i in range(1,H+1):
            for j,a in enumerate(stdin.readline().split()):
                ma[i][j+1] = bool(1-int(a))
        que = deque([[tx,ty,kx,ky,0]])
        pas = set()
        ans = "NA"
        while(que):
            tx,ty,kx,ky,c = que.popleft()
            if c > 100: break
            if tx == kx and ty == ky:
                ans = c
                break
            for dx,dy in [[-1,0],[0,-1],[1,0],[0,1]]:
                tdx, tdy = [ dx, dy] if ma[ty+dy][tx+dx] else [0,0]
                kdx, kdy = [-dx,-dy] if ma[ky-dy][kx-dx] else [0,0]
                if (tx+tdx,ty+tdy,kx+kdx,ky+kdy) in pas: continue
                que.append([tx+tdx,ty+tdy,kx+kdx,ky+kdy,c+1])
                pas.add((tx+tdx,ty+tdy,kx+kdx,ky+kdy))
        print(ans)

if __name__ == "__main__":
    # prf = LineProfiler()
    # prf.add_function(main)
    # prf.runcall(main)
    # prf.print_stats()
    main()


Measured memory_bytes: 35204
// https://atcoder.jp/contests/abc078/tasks/arc085_a

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 100;

int N, M;

void solve() {
  int t = 1900 * M + 100 * (N - M);
  int ans = t * (1 << M);
  printf("%d\n", ans);
}

void input() {
  scanf("%d%d", &N, &M);
}

int main() {
  input();
  solve();
  return 0;
}


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

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;
//const ll MAX_V=114514LL;
//const ll MAX = 500010LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={0,0,1,-1};
vl dy={1,-1,0,0};

//素因数分解O(√n)
map<ll,ll>prime_factor(ll n){
  map<ll,ll>res;
  for(ll i=2;i*i<=n;i++){
    while(n%i==0){
      res[i]++;
      n/=i;
    }
  }
  if(n!=1)res[n]=1;
  return res;
}

const ll MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
//finvが階乗の逆元

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll a, ll n, ll mod) {
  
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}



int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  /*--------------------------------*/
  ll n;cin>>n;ll m;cin>>m;
  vl a(m),b(m);
  vvl G(n);
  rep(i,m){
    cin>>a[i]>>b[i];
    a[i]--;b[i]--;
    G[a[i]].pb(b[i]);
  }
  ll shortest=n+1;
  vl res;
  rep(s,n){
    vl dist(n,-1);
    vl prev(n,-1);
    queue<ll>que;
    que.push(s);dist[s]=0;
    while(!que.empty()){
      auto v=que.front();que.pop();
      for(auto nv:G[v]){
        if(dist[nv]==-1){
          dist[nv]=dist[v]+1;
          prev[nv]=v;
          que.push(nv);
        }
      }
    }
    rep(t,n){
      if(t==s||dist[t]==-1)continue;
      for(auto nt:G[t]){
        
          if(nt==s){
            vl tmp({s});
            ll cur=t;
            while(cur!=s)tmp.pb(cur),cur=prev[cur];
            if(shortest>tmp.size()){
              shortest=tmp.size();
              res=tmp;
            }
          }
        
      }
    }
  }
  if(shortest==n+1)cout<<-1<<endl;
  else{
    cout<<res.size()<<endl;
    for(auto v:res)cout<<v+1<<endl;
  }
}

Measured memory_bytes: 3764
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n=Integer.parseInt(sc.nextLine());
    String s=sc.nextLine();
    int k=Integer.parseInt(sc.nextLine());
    char[] c=s.toCharArray();
    char comp=c[k-1];
    for(int i=0;i<n;i++){
      if(c[i]!=comp){
        c[i]='*';
      }
    }
    System.out.print(String.valueOf(c));
  }
}

Measured memory_bytes: 21844
n, a, b = gets.chomp.split(" ").map(&:to_i)
nums_in_condition = Array.new

n.times do |index|
  sum = (index+1).to_s.split('').map(&:to_i).sum
  nums_in_condition << index+1 if sum >= a && sum <= b
end


p nums_in_condition.sum

Measured memory_bytes: 14344