akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

struct distance_num{
    int distance;
    int num;

    distance_num(int distance2, int num2)
    {
        distance=distance2;
        num=num2;
    }
};

int main()
{
    long N;
    std::cin >> N;
    std::vector<long> a;
    for(long i=0; i<N; i++){
        long temp;
        std::cin >> temp;
        a.push_back(temp);
    }
    std::sort(a.begin(),a.end());
    
    std::vector<distance_num> numbers;
    numbers.push_back(distance_num(a[0],1));
    for(long i=1; i<N; i++){
        if(a[i]!=a[i-1]){
            numbers.push_back(distance_num(a[i],1));
        }else{
            long length=numbers.size();
            numbers[length-1].num++;
        }
    }

    long result=0;
    for(long i=0; i<numbers.size();i++){
        if(numbers[i].num<numbers[i].distance){
            result+=numbers[i].num;
        }else{
            result+=numbers[i].num-numbers[i].distance;
        }
    }
    std::cout << result << std::endl;
    return 0;
}

Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
const int N = 111;
char s[N], a[N], b[N], c[N<<1];
int n;
bool judge(char *s){
    bool fl = 1;
    int n = strlen(s + 1);
    int cnt = 0;
    for(int i = 1;i <= n; i++)c[++cnt] = '#', c[++cnt] = s[i];
    c[++cnt] = '#';
    for(int i = (cnt + 1) >> 1;i >= 1; i--){
        if(c[i] != c[cnt-i+1])fl = 0;
    }
    return fl;
}
int main(){
    cin>>s + 1;
    n = strlen(s + 1);
    int cnt = 0;
    for(int i = 1;i <= (n - 1) >> 1; i++)a[i] = s[i];
    for(int i = (n + 3) >> 1;i <= n; i++)b[++cnt] = s[i];
    puts(judge(s) && judge(a) && judge(b) ? "Yes" : "No");
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

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

    vector<int> saisho(26,101),saigo(26,-1);

    for(int i=0; i<N; i++){
        if(saisho[S[i]-'a']==101)
            saisho[S[i]-'a'] = i;
    }
    for(int i=N-1; i>=0; i--){
        if(saigo[S[i]-'a']==-1)
            saigo[S[i]-'a'] = i;
    }

    for(int i=0; i<N; i++){
        int a=0;
        rep(j,26){
            if(saisho[j]<=i && saigo[j]>i)a++;
        }
        ans = max(a,ans);
    }

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



Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int w,h,x,y,r,n=0;
  scanf("%d%d%d%d%d", &w, &h, &x, &y, &r);
  if(x - r >= 0 && x + r <= w)
    n += 1;

  if(y - r >= 0 && y + r <= h)
    n += 1;

  if(n == 2)
    printf("Yes\n");
  else
    printf("No\n");


  return 0;
}



Measured memory_bytes: 2108
#include <stdio.h>
int main(void) {

	int A, B, ans;

	scanf("%d", &A);
	scanf("%d", &B);

	if (A <= B * 2)
		ans = 0;
	else
	{
		ans = A - B * 2;
	}

	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include "cstdio"
using namespace std;
#define LL long long
#define mod 29
LL a[110];
int main()
{
    a[0]=2;
    a[1]=1;
    int n;
    while(~scanf("%d",&n))
    {
        for(int i=2;i<=n;i++)
        {
            a[i]=a[i-1]+a[i-2];
        }
        cout<<a[n]<<endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int i, l[10], v1, v2, n;
    double p;
    
    while(scanf("%d,", &l[0]) != EOF){
        n = l[0];
        
        for(i = 1; i < 10; i++){
            scanf("%d,", &l[i]);
            n += l[i];
        }
        
        scanf("%d,%d", &v1, &v2);
        
        p = (double)n * v1 / (v1 + v2);
        
        for(i = n = 0; i < 10 && n < p; i++) n += l[i];
        
        printf("%d\n", i);
    }
 
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{
    int N,K;
    string S;
    cin >> N >> K >> S;

    S[K-1] += 32;
    fin(S);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <climits>
#include <vector>
#include <map>
#include <cstring>
#include <iomanip>
#include <queue>
using namespace std;
vector<pair<int, int> > edge[100000];
int MOD = 1000000007;
void calc(vector<long long>& dis, vector<long long>& pat, int S, int T){
   priority_queue<pair<long long,int> > pq;
   pat[S]=1;
   dis[S]=0;
   pq.push(make_pair(0,S));
   while(!pq.empty()){
      pair<long long,int> p = pq.top();
      pq.pop();
      long long dist = -p.first;
      int node = p.second;
      ////cout << node <<" " <<  dis[node]  <<"="<< dist  << " " << pat[node] << endl;
      if( dist > dis[node] ) continue;
      if( node == T ) break;
      for(int ei = 0; ei < (int)edge[node].size(); ei++){
         int nextnode= edge[node][ei].first;
         int elen = edge[node][ei].second;
         long long nextdist = dist+elen;
         ////cout << nextdist << " " << nextnode << " " << dis[nextnode] << endl;
         if( nextdist > dis[nextnode] ) continue;
         else if( nextdist < dis[nextnode] ){
            dis[nextnode] = nextdist;
            pat[nextnode] = pat[node];
            ////cout << nextdist << " " << nextnode<< endl;
            pq.push(make_pair(-nextdist, nextnode));
         }
         else{
            pat[nextnode] += pat[node];
            pat[nextnode] %= MOD;
         }
      }
   }
}
int main(){
   int N, M;
   cin >> N >> M;
   int S,T;
   cin >> S >> T;
   S--;
   T--;
   for( int i = 0 ; i < M; i++){
      int U,V,D;
      cin >> U >> V >> D;
      U--;
      V--;
      edge[U].push_back(make_pair(V,D));
      edge[V].push_back(make_pair(U,D));
   }
   vector<long long> dis(100000,LLONG_MAX);
   vector<long long> pat(100000,-1);
   vector<long long> dis2(100000,LLONG_MAX);
   vector<long long> pat2(100000,-1);
   calc(dis, pat, S,T);
   calc(dis2, pat2, T,S);
   //cout << pat[T] << "*" << pat2[S]<<endl;
   long long ans = pat[T]*pat2[S];
   long long dist = dis[T];
   for(int i = 0 ; i < N; i++){
      if(dis[i]*2 == dist){
         long long pp = pat[i]*pat2[i];
         pp %= MOD;
         //cout << "- " << pp*pp << endl;
         ans -= pp*pp;
         ans %= MOD;
      }
   }
   for(int i=0; i<N; i++){
      for(int j =0; j < (int)edge[i].size(); j++){
         int u = i;
         int v = edge[i][j].first;
         long long d = edge[i][j].second;
         ///cout <<u <<", "<< v << " : "<<  d << " " << dis[u] << " " << dis2[v] << " " <<endl;
         if( d+dis[u]+dis2[v] == dis[T] ){
            if( d+dis[u] <= dis2[v] || dis2[v]+d <= dis[u] ){
               //do nothing
            }
            else{
               long long pp = pat[u]*pat2[v];
               ////cout << pp << endl;
               pp %= MOD;
               ans -= pp*pp;
               //cout << "- " << pp*pp << endl;
               ans %= MOD;
            }
         }
      }
   }
   if(ans<0){
      ans+=MOD;
   }
   cout << ans << endl;
}


Measured memory_bytes: 13856
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i<i##_len; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
typedef long long ll;
const int MOD = 1000000007;
using namespace std;

int main(){
    string s, t; cin >> s >> t;
    string ans = "YES\n";
    REP(i, 3){
        if(s[i] != t[2-i]) ans = "NO\n";
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
import math
n = int(input())
x_list = list(map(int,input().split()))
 
avg = sum(x_list)/ len(x_list)
avg_up = math.ceil(avg)
avg_down = math.floor(avg)
 
up_sum = 0
down_sum = 0
for i in x_list:
    up_sum += (i - avg_up)**2
    down_sum += (i - avg_down)**2
    
print(min(up_sum,down_sum))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int N; cin >> N; ++N;
  vector<ll> res(N);
  res[0] = 2;
  res[1] = 1;
  for (int i = 2; i < N; ++i)
  {
    res[i] = res[i - 1] + res[i - 2];
  }
  
  cout << res.back() << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
array = [0]*(10**5+1)
for i in range(n):
    a,b = map(int,input().split())
    array[a] += b
for i in range(1,10**5+1):
    k -= array[i]
    if k <= 0:
        print(i)
        break

Measured memory_bytes: 11616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using ll=long long;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  int r;
  cin >> r;
  int ans=3*r*r;
  cout << ans << endl;
}

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

using i64 = int64_t;

int dp[1005][1005]={0};

void init(){
    for(int i=0;i<=1000;++i){
        for(int j=0;j<=1000;++j)dp[i][j] = 0;
    }
}

int main(){
    int n;
    while(cin >> n, n != 0){
        init();
        vector<int> v;
        for(int i=0;i<n;++i){
            int w;
            cin >> w;
            v.push_back(w);
        }
        for(int i=0;i<n-1;++i){
            if(abs(v[i]-v[i+1]) <= 1)dp[i][i+1] = 2;
        }
        for(int d=3;d<n;d+=2){
            for(int i=0;i+d<n;++i){
                if(abs(v[i]-v[i+d])<=1 && dp[i+1][i+d-1] == d-1)dp[i][i+d] = max(dp[i][i+d], dp[i+1][i+d-1]+2);
                for(int j=i+1;j<i+d;++j){
                    dp[i][i+d] = max(dp[i][i+d], dp[i][j]+dp[j+1][i+d]);
                }
                dp[i][i+d] = max(dp[i][i+d], dp[i+1][i+d-1]);
                /*if(dp[i+1][i+d-1] == d-1 && abs(v[i]-v[i+d])<=1){
                    dp[i][i+d] = dp[i+1][i+d-1] + 2;
                }else{
                    bool ok = false;
                    for(int j=i+1;j<i+d;++j){
                        if(dp[i][j]+dp[j+1][i+d] == d+1){
                            dp[i][i+d] = d+1;
                            ok = true;
                            break;
                        }
                    }
                    if(!ok)dp[i][i+d] = dp[i+1][i+d-1];
                }*/
            }
        }
        int ans = 0;
        for(int i=0;i<n;++i){
            for(int j=0;j<n;++j)ans = max(ans, dp[i][j]);
        }
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 7076
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(a, max(b, c))
#define MIN(x, y, z) min(a, min(b, c))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

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

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll X, Y;
  cin >> X >> Y;

  ll ans = 0;
  while (X <= Y) {
    ans++;
    X *= 2;
  }
  ANS;
  return 0;
}

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

int main()
{int N;
 int k;
 cin >> N;
 int a[100000] = {0};
 int max_num=0, num=0;
 for(int i=0; i<N; i++){
   cin >> k;
 	a[k] ++;}
num = a[0] + a[1] + a[2];
max_num = num;
 for(int i=0; i<99997; i++){
   num += a[i+3] - a[i];
   max_num=max(max_num, num);}
cout << max_num << endl;  
      
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30
#define M_MAX 1000001

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

vector<int>r;
int dp[M_MAX], odp[M_MAX];

int main(){
  fill(dp, dp+M_MAX, INF);
  //  fprintf(stderr, "error\n");
  fill(odp, odp+M_MAX, INF);

  int n = 0;
  while(++n){
    int x = n*(n+1)*(n+2)/6;
    if(x > 1000000) break;
    r.push_back(x);
    //    printf("%d %d\n", n, x);
  }

  dp[0] = odp[0] = 0;

  REP(i, 0, r.size()){
    int m = r[i];
    REP(j, m, M_MAX+1)
      dp[j] = min(dp[j], dp[j-m]+1);
    if(m%2)
      REP(j, m, M_MAX+1)
	odp[j] = min(odp[j], odp[j-m]+1);
  }

  //  printf("end\n");
  while(scanf("%d", &n) && n)
    printf("%d %d\n", dp[n], odp[n]);

  return 0;
}

Measured memory_bytes: 9020
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void div(VVI &a, int n, int offset, int v) {
    if (n < 2) return;
    REP(i,0,n/2) REP(j,n/2,n) {
        a[i+offset][j+offset] = a[j+offset][i+offset] = v;
    }
    div(a,n/2,offset,v+1);
    div(a,n-n/2,offset+n/2,v+1);
}

void solve() {
    int n;
    cin >> n;
    VVI a(n,VI(n));
    div(a,n,0,1);

    REP(i,0,n-1) {
        REP(j,i+1,n) cout << a[i][j] << " ";
        cout << endl;
    }
}

signed main() {
    solve();
    
    return 0;
}

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

typedef long long int ll;

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

  for(int i = 0 ; i < n ; i++){
    a[i] -= (i+1);
  }

  sort(a, a+n);
  int med1 = n / 2;
  int med2 = n / 2 + 1;

  ll sum1,sum2;
  sum1 = sum2 = 0;
  for(int i = 0 ; i < n ; i++){
    sum1 += abs(a[i] - a[med1]);
    sum2 += abs(a[i] - a[med2]);
  }
  cout << min(sum1,sum2) << endl;
  return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define INF 1000000000000000007
#define pb emplace_back
typedef vector<int> vi;
const int g=1e7;
int c[g+1];
void solve(){
int w=0,l=0,k=0,q=0,m=0,r=0,p=0,x=0,y=0,n=0;
cin>>n;
//vi c(n+1,0);
for(int i=1;i<=n;i++){
	for(int j=0;j<=n;j+=i)
	c[j]++;
}
ll ans=0;
for(int i=1;i<=n;i++){
	ans+=(ll)i*c[i];
}
cout<<ans;
}

int main(){
ios::sync_with_stdio(false);
cin.tie(0);
  int t=1;
  //cin>>t;
  while(t--){
  	solve();
  }
  return 0;
} 	

Measured memory_bytes: 42712
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @author Don Li
 */
public class Main {
    
    int N = (int) 2e5 + 10;
    int MOD = (int) 1e9 + 7;
    
    int[] sum = new int[N];
    
    void solve() {
        int n = in.nextInt();
        int[] c = new int[n];
        for (int i = 0; i < n; i++) c[i] = in.nextInt();
        
        int sz = 0;
        for (int i = 0; i < n; i++) {
            if (i == 0 || c[i] != c[i - 1]) c[sz++] = c[i];
        }
        c = Arrays.copyOf(c, sz);
        n = sz;
        
        int[][] dp = new int[n + 1][2];
        sum[c[0]] = dp[1][0] = 1;
        for (int i = 1; i < n; i++) {
            dp[i + 1][0] = (dp[i][0] + dp[i][1]) % MOD;
            dp[i + 1][1] = sum[c[i]];
            sum[c[i]] = (sum[c[i]] + dp[i + 1][0]) % MOD;
        }
        out.println((dp[n][0] + dp[n][1]) % MOD);
    }
    
    
    public static void main(String[] args) {
        in = new FastScanner(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);
        new Main().solve();
        out.close();
    }
    
    static FastScanner in;
    static PrintWriter out;
    
    static class FastScanner {
        BufferedReader in;
        StringTokenizer st;
        
        public FastScanner(BufferedReader in) {
            this.in = in;
        }
        
        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        public int nextInt() {
            return Integer.parseInt(nextToken());
        }
        
        public long nextLong() {
            return Long.parseLong(nextToken());
        }
        
        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}


Measured memory_bytes: 46952
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int N;
vector<string> G;
vector<int> dist;

bool dfs(int u, int d) {
  rep(v, N) {
    if (G[u][v] == '0') continue;
    if (dist[v] != -1) {
      if ((dist[v] % 2) == (d % 2)) return false;
      continue;
    }
    dist[v] = d + 1;
    if (!dfs(v, d + 1)) return false;
  }
  return true;
}

int main(void) {
  cin >> N;
  G.resize(N);
  rep(i, N) { cin >> G[i]; }
  dist.assign(N, -1);
  dist[0] = 0;
  if (!dfs(0, 0)) {
    cout << -1 << endl;
    return 0;
  }

  vector<vector<int>> dist2(N, vector<int>(N, N));
  rep(i, N) {
    dist2[i][i] = 0;
    rep(j, N) {
      if (G[i][j] == '1') {
        dist2[i][j] = 1;
        dist2[j][i] = 1;
      }
    }
  }
  rep(k, N) {
    rep(i, N) {
      rep(j, N) { dist2[i][j] = min(dist2[i][j], dist2[i][k] + dist2[k][j]); }
    }
  }

  int answer = 0;
  rep(i, N) {
    answer = max(answer, *max_element(dist2[i].begin(), dist2[i].end()));
  }
  cout << answer + 1 << endl;
  return 0;
}


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

int numToDig(int a) {
    return to_string(a).size();
}

int main() {

    int N, ans = 0, a = 0, b = 0, ab = 0;
    cin >> N;
    rep(i, N) {
        string S;
        cin >> S;
        rep(i, S.size()) {
            if (strncmp(&S[i], "AB", 2) == 0)
                ans++;
        }
        if (S[0] == 'B' && S[S.size() - 1] == 'A')
            ab++;
        else if (S[0] == 'B')
            b++;
        else if (S[S.size() - 1] == 'A')
            a++;
    }

    if (ab == 0)
        ans += min(a, b);
    else if (a + b > 0)
        ans += ab + min(a, b);
    else if (a + b == 0)
        ans += ab - 1;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::cmp::*;
use std::collections::HashSet;
use std::iter::Iterator;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
  input! {
  n: f64,
  }

  let maxcm = n.sqrt().floor() as i64;
  let mut min = 0;
  for i in 1..=maxcm {
    let n = n as i64;
    if n % i == 0 {
      let hantai = n / i;

      if min == 0 {
        min = hantai - 1 + i - 1;
      } else {
        min = min!(min, hantai - 1 + i - 1);
      }
    }
  }

  println!("{}", min);
}


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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;

const int MAX = 1e5 + 5;
vector<int> adj[MAX];
int color[MAX];
int n, m;

ll bfs(int source) {
	memset(color, -1, sizeof color);
	queue<int> q;
	q.push(source);
	color[source] = 0;
	ll w = 0, b = 0;
	while(!q.empty()) {
		int cur = q.front(); q.pop();
		w += color[cur] == 0;
		b += color[cur] == 1;
		for(auto &each : adj[cur]) {
			if(color[each] == -1) {
				color[each] = !color[cur];
				q.push(each);
			}
			else if(color[cur] == color[each]) {
				return (1LL * n * (n - 1)) / 2LL;
			}
		}
	}
	return w * b;
}

int main() {
	scanf("%d %d", &n, &m);
	fori(i, 0, m) {
		int u, v;
		scanf("%d %d", &u, &v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	ll p = bfs(1);
	printf("%lld\n", p - m);

	return 0;
}



Measured memory_bytes: 6272
#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;
long long mod = 1000000007;
long long modpow(long long m,long long n){
    long long res = 1;
    if(n > 0){
        res = modpow(m,n / 2);
        if(n % 2 == 0){
            res = (res * res) % mod;
        }
        else{
            res = (((res * res) % mod) * m) % mod;
        }
    }
    return res;
}
ll fac[200001];
ll conbi(ll a,ll b){//aCbをmodで割ったあまりを求める
  ll res = fac[a];
  res *= modpow(fac[b],mod - 2),res %= mod;
  res *= modpow(fac[a - b],mod - 2),res %= mod;
  return res;
}
int main(){
  fac[0] = 1;
for(int i = 1;i <= 200000;i++){
  fac[i] = fac[i - 1] * i;
  fac[i] %= mod;
}
  ll n;
  cin >> n;
  ll l = -1;
  ll r = -1;
  ll wa = 0;
  vector<ll> a(n + 1);
  for(int i = 0;i < n + 1;i++){
    cin >> a[i];
    wa += a[i];
  }
  wa -= (1 + n) * n / 2;
  for(int i = 0;i < n + 1;i++){
    if(wa == a[i]){
      if(l == -1)l = i;
      else r = i;
    }
  }
  //cout << l << " " << r << endl;
  for(int i = 1;i <= n + 1;i++){
    ll res = 0;
    res = conbi(n + 1,i);
    if(l + n - r >= i - 1)res -= conbi(l + n - r,i - 1);
    res += mod,res %= mod;
    cout << res << endl;
  }
}

Measured memory_bytes: 5524
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (int 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(int n, int k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main() {
  int n;
  cin>>n;
  vi a(n),t(n);
  rep(i,n) cin>>a[i];
  rep(i,n) t[i]=i+1;
  int cnt=0;
  rep(i,n){
    if(a[i]!=t[i]) cnt++;
  }
  if(cnt==0||cnt==2){
    cout<<"YES"<<endl;
    return 0;
  }
  cout<<"NO"<<endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int ans=0;
    int cnt=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A' ||s[i]=='T' ||s[i]=='G' ||s[i]=='C'){
            ans++;
            if(cnt<ans){
                cnt = ans;
            }
        }else{
            ans = 0;
        }
    }
    
    cout<< cnt <<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		int[] list = new int[3];
		for(int i = 3; i > 0; i--) {
			int x = s%10;
			s /= 10;
			list[i-1] = x;
			if(x == 1) {
				list[i-1] = 9;
			}else {
				list[i-1] = 1;
			}
		}
		for(int x : list) {
			System.out.print(x);
		}
	}
}


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

ll ans = 0;

const int N = 26;
ll x[N] = {},y[N] = {};

int main(){
    int n;
    cin >> n;
    for(int i = 111;i <= 999; i += 111){
        if(n <= i){
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	N, M := nextInt(), nextInt()

	s := make([][]int, M)
	for i := 0; i < M; i++ {
		k := nextInt()
		for j := 0; j < k; j++ {
			a := nextInt() - 1
			s[i] = append(s[i], a)
		}
	}

	p := make([]int, M)
	for i := 0; i < M; i++ {
		p[i] = nextInt()
	}

	res := 0
	for bit := uint(0); bit < (1 << uint(N)); bit++ {
		ok := true
		for i := 0; i < M; i++ {
			con := 0
			for _, v := range s[i] {
				if (bit & (1 << uint(v))) == (1 << uint(v)) {
					con++
				}
			}
			if con%2 != p[i] {
				ok = false
			}
		}
		if ok {
			res++
		}
	}

	fmt.Println(res)
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/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; }



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

  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  ll ans = infll;
  for(int i = -100; i <= 100; i++) {
    ll tmp = 0;
    rep(j,n) tmp += pow(abs(i - a[j]), 2);
    ans = min(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  int K, X;
  cin >> K >> X;
  for (int i = X - K + 1; i <= K + X - 1; ++i) {
    cout << i << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

#define MAX 100

int A[MAX][MAX];

int main(int argc, char const *argv[])
{
	int n,k,m,p;
	cin>>n;

	for (int i = 0; i < n; ++i)
	{
		cin>>k>>m;
		for (int j = 0; j < m; ++j)
		{
			cin>>p;
			A[k-1][p-1]=1;
		}
	}

	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			if (j!=0)
			{
				cout<<" ";
			}
			cout<<A[i][j];
		}
		cout<<endl;
	}

	return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<a;i++)
using namespace std;
using ll = long long;
int main(void){
    ll x;
    cin>>x;
    ll ans=0;
    ans+=x/500*1000;
    x-=x/500*500;
    ans+=x/5*5;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;

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

int main() {
    ll N,K;
    cin >> N >> K;
    ll out = 1;
    if(N%K==0) out = 0;
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String t = sc.nextLine();

		boolean ret = false;
		String tPrefix = t.substring(0, 1);
		String checkString = s;
		int prefIndex = checkString.indexOf(tPrefix);
		while (true) {
			checkString = s.substring(prefIndex);
			if (t.equals(checkString + s.substring(0, prefIndex))) {
				ret = true;
				break;
			}
			if (checkString.length() <= 1 || checkString.substring(1).indexOf(tPrefix) == -1) {
				break;
			}
			prefIndex += (checkString.substring(1).indexOf(tPrefix) + 1);
		}

		if (ret) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();
	}
}

Measured memory_bytes: 21716
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int L = sc.nextInt();
    String[] S = new String[N];
    for(int i=0; i<N; i++){
    	S[i] = sc.next();
    }
    Arrays.sort(S);
    StringBuilder string = new StringBuilder();
    for(int i=0; i<N; i++){
    	string.append(S[i]);
    }
    System.out.println(string);
  }
}

Measured memory_bytes: 23380
a, b = map(int, input().split())
grid = [list("." * 100) if i < 50 else list("#" * 100) for i in range(100)]
a -= 1
b -= 1

for i in range(0, 49, 2):
  if b == 0:
    break
  for j in range(0, 100, 2):
    grid[i][j] = "#"
    b -= 1
    if b == 0:
      break

for i in range(51, 100, 2):
  if a == 0:
    break
  turn = i % 2
  for j in range(0, 100, 2):
    grid[i][j] = "."
    a -= 1
    if a == 0:
      break
print(len(grid[0]), len(grid))
for line in grid:
  print("".join(line))

Measured memory_bytes: 3188
module MakeBinaryHeap (M : sig type t val compare : t -> t -> int end) = struct

  type t = { node : M.t array; mutable size : int }

  let make n (init : M.t) = { node = Array.make n init; size = 0 }

  let empty_p t = if t.size = 0 then true else false

  let pop t =
    let rec max_heapify i =
      let l = 2*i in
      let r = 2*i + 1 in
      let m = if l <= t.size && M.compare t.node.(l) t.node.(i) > 0 then l else i in
      let m = if r <= t.size && M.compare t.node.(r) t.node.(m) > 0 then r else m in
      if m = i then ()
      else begin
        let tmp = t.node.(i) in
        t.node.(i) <- t.node.(m);
        t.node.(m) <- tmp;
        max_heapify m
      end in
    let ret = t.node.(1) in
    t.node.(1) <- t.node.(t.size);
    t.size <- t.size - 1;
    max_heapify 1;
    ret

  let push x t =
    let parent i = int_of_float (floor (float_of_int i) /. 2.) in
    let rec doit i =
      let p = parent i in
      if i <= 1 || M.compare t.node.(p) t.node.(i) >= 0 then ()
      else begin
        let tmp = t.node.(i) in
        t.node.(i) <- t.node.(p);
        t.node.(p) <- tmp;
        doit p
      end in
    t.size <- t.size + 1;
    t.node.(t.size) <- x;
    doit t.size

end

module H = MakeBinaryHeap(struct type t = (int * int) let compare x y = snd x - snd y end)

let dijkstra g n =
  let h = H.make 100000 (0, 0) in
  let d = Array.make n max_int in
  let b = Array.make n false in
  d.(0) <- 0;
  b.(0) <- true;
  H.push (0, 0) h;
  while not (H.empty_p h) do
    let (u, x) = H.pop h in
    b.(u) <- true;
    if d.(u) < -x then ()
    else
      List.iter (fun (v, c) ->
        if not b.(v) && d.(v) > d.(u) + c then begin
          d.(v) <- d.(u) + c;
          H.push (v, (-d.(v))) h;
        end) g.(u);
  done;
  d

let rec make_pair acc = function
  | [] -> acc
  | v :: c :: tl -> make_pair ((v, c) :: acc) tl
  | _ -> assert false

let make_pair lst = make_pair [] lst

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let n = read_int () in
  let g = Array.make n [] in
  for _ = 0 to n - 1 do
    match read_line () |> split_on_char ' ' |> List.map int_of_string with
    | u :: _ :: l -> g.(u) <- make_pair l
    | _ -> assert false
  done;
  dijkstra g n |> Array.iteri (fun i e -> Printf.printf "%d %d\n" i e)

Measured memory_bytes: 30440
// 西川 宏斗(Nishikawa Hiroto)
// J4-170653
// 中央最前列

// ITP1_1_C Rectangle
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_C


#include <iostream>
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  cout << a * b << " " << (a + b) * 2 << endl;
  return 0;
}


Measured memory_bytes: 3052
package main

import (
	"fmt"
)

func main() {
	var a, b int

	fmt.Scanf("%d %d", &a, &b)
	fmt.Println(logic(a, b))
}

func logic(a, b int) int {
	if a > 9 || b > 9 {
		return -1
	}
	return a * b
}


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

using namespace std;

int main() {
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;

  int sum;
  if(a+b > 2*c) {
    if(x > y) {
      if(a > 2*c) sum = c * 2 * x;
      else sum = c * 2*y + a * (x-y);
    }
    else {
      if(b > 2*c) sum = c * 2 * y;
      else sum = c * 2*x + b * (y-x);
    }
  }
  else sum = a * x + b * y;
  
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    for(ll i=0;i<s.length();i++)
    cout<<'x';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"yes":"no")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    string s;
    cin >> s;
    unordered_set<char> us;
    rep(i, s.size()) us.emplace(s[i]);
    yorn(s.size() == us.size());
    return 0;
}

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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

int main(){
  int n,k;
  int R,S,P;
  int ans=0;
  cin>>n>>k>>R>>S>>P;
  string t;
  cin>>t;
  for(int i=k;i<n;i++){
    if(t[i]==t[i-k]){
      t[i]='0';
    }
  }
  REP(i,n){
    if(t[i]=='r'){
      ans+=P;
    }else if(t[i]=='s'){
      ans+=R;
    }else if(t[i]=='p'){
      ans+=S;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <string>

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

using namespace std;
int A, B, C, X, Y;

int main()
{
    scanf("%d %d %d %d %d", &A, &B, &C, &X, &Y);

    int ans = 0;
    if(2*C<A+B) {
        int tmp = min(X, Y);
        X -= tmp;
        Y -= tmp;
        ans += 2*C*tmp;
        if(X>0) {
            if(2*C<A) {
                ans += 2*C*X;
            } else {
                ans += A*X;
            }
        } else {
            if(2*C<B)
                ans += 2*C*Y;
            else
                ans += B*Y;
        }
    } else {
        ans += A*X + B*Y;
    }
    cout << ans << endl;


    return 0;
}


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

int main() {
	int n;
	cin >> n;

	vector<int> a(n);
	vector<int> b(n);
	vector<int> c(n - 1);

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

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

	for (int i = 0; i < n-1; i++) {
		cin >> c.at(i);
	}

	int cnt = 0;
	int aa = a.at(0);

	cnt += b.at(aa - 1);

	for (int i = 1; i < n; i++) {
		cnt += b.at(a.at(i) - 1);

		if (a.at(i) == aa + 1) {
			cnt += c.at(aa - 1);
		}

		aa = a.at(i);
	}

	cout << cnt << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();

		int a[] = new int [n];
		for (int i = 0; i < n; i++ ) {
			a[i] = scanner.nextInt();
		}
		for (int i = n - 1; i >= 0; i--) {
			System.out.print(a[i]);
			if (i == 0) {
				break;
			}
			System.out.print(" ");
		}
		System.out.println();
	}
}



Measured memory_bytes: 26324
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<map>
using namespace std;
#define ll long long
int main(){
    int D,G;
    cin  >> D >> G;
    ll p[D+1],c[D+1];
    int i,j;
    for(i=0;i<D;i++){
        cin >>p[i]>>c[i];
    }
    p[D]=0;
    c[D]=0;
    int min=10000;
    int max;
    int ptmp;
    int ntmp;
    for(i=0;i<(1<<D);i++){
        ptmp=0;
        ntmp=0;
        max=D;
        for(j=0;j<D;j++){
            if((i>>j)&1){
                ptmp+=(j+1)*100*p[j]+c[j];
                ntmp+=p[j];
            }else{
                max=j;
            }
        }
        if(ptmp<G){
            if((G-ptmp)/(100*(max+1))<=p[max]){
                ntmp+=(G-ptmp+100*(max+1)-1)/(100*(max+1));
            }else{
                ntmp=10000;
            }
        }
        //cout << ntmp <<endl;
        if(min>ntmp){
            min=ntmp;
        }
    }
    cout << min <<endl;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
  int a,b,c,mon,ans;
  cin>>a>>b>>c;
  for(int i=0;i<a;i++){
    cin>>mon;
    for(int m=0;m<b;m+=mon){
      ans+=1;
    }
  }
  cout<<ans+c<<endl;
}


Measured memory_bytes: 256
line=gets.chomp
l=line.length-1
a=[0]
b=[0]
c=0
m=0
n=0
for i in 0..l
  if line[i]=="<" then
    m=m+1
  else
    m=0
  end
  a.push(m)
end
for j in 0..l
  if line[l-j]==">" then
    n=n+1
  else
    n=0
  end
  b.push(n)
end
b.reverse!
for k in 0..a.length-1
  c=c+[a[k],b[k]].max
end
puts c

Measured memory_bytes: 10756
#include <bits/stdc++.h>
using namespace std;
const int mod=998244353;
int n,k,f[200005]={0,1},d[200005]={0,1,-1};
struct node{int l,r;}a[15];
bool cmp(node a,node b){return a.l<b.r;}
int main(){
    cin>>n>>k;
    for(int i=1;i<=k;i++)cin>>a[i].l>>a[i].r;
    sort(a+1,a+1+k,cmp);
    for(int i=1;i<=n;i++){
        f[i]=(f[i-1]+d[i])%mod;
//        cout<<f[i]<<" "<<d[i]<<endl;
        if(f[i])for(int j=1;j<=k&&a[j].l+i<=n;j++){
            d[i+a[j].l]=(d[i+a[j].l]+f[i])%mod,d[i+a[j].r+1]=(d[i+a[j].r+1]-f[i])%mod;
//            cout<<i<<" "<<i+a[j].l<<" "<<i+a[j].r+1<<endl;
        }
    }
    cout<<(f[n]+mod)%mod<<endl;
    return 0;
}


Measured memory_bytes: 5188
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
 
Node root;
 
void insert(int );
void inorder(Node );
Node treeSearch(Node ,int );
void preorder(Node );

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } 
    else if(com[0]=='f'){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    else if(com[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
 
  return 0;
 
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }
    else
      x=x->right;
  }
  z->parent=y;
 
  if(y==NIL){
    root=z;
  }
  else if(z->key<y->key){
    y->left=z;
  }
  else{
    y->right =z;
  }
}
 
void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
 
void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
 
Node treeSearch(Node u,int k){
  while(u!=NIL && k!=u->key){
    if(k<u->key){
      u=u->left;
    }
    else{
      u=u->right;
    }
  }
  return u;
}
 

Measured memory_bytes: 19364