akhauriyash/Code-Regression huggingface dataset:
n = gets.chomp.to_i

result = 0

(1..Math.sqrt(n)).each do |r|
  next if n % r != 0

  m = n / r - 1
  result += m if r < m

  r2 = n / r
  m2 = n / r2 - 1
 result += m2 if r2 < m2
end

puts result




Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<stdio.h>
#include<deque>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int main()
{
    int n, ans = 0;
    cin >> n;
    vector<int> v(n-1);
    rep(i, n-1)cin >> v[i];
    ans += v[0] + v[n-2];
    for(int i = 1; i < n-1; i++){
        ans += min(v[i-1], v[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, a;
	cin >> n;
	cin >> a;
	for(int i=0;i<=a;i++)
	{
		if((n-1*i)%500==0)
		{
			cout << "Yes" <<endl;
			return 0;
		}	
	}
	cout << "No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include <algorithm>
using namespace std;
int main()
{
	int arr[200000];
	int brr[200000];
	int n,m;
	cin>>n>>m;
	int p=0,q=0;
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		if(a==1)
		{
			arr[p++]=b;
		}
		if(b==n)
		{
			brr[q++]=a;
		}
	}
	if(p==0||q==0)
	{
		cout<<"IMPOSSIBLE";
	}
	else
	{
		sort(arr,arr+p);
		sort(brr,brr+q);
		int i,j=1;
		for(i=0;i<p;i++)
		{
			j--;
			for(j;j<q;j++)
			{
				if(arr[i]==brr[j])
				{
					break;
				}
				if(arr[i]<brr[j])
					break;
			}
			if(arr[i]==brr[j])
			break;
		}
		if(arr[i]==brr[j]&&i!=p)
			cout<<"POSSIBLE";
		else
			cout<<"IMPOSSIBLE";
	}
 } 

Measured memory_bytes: 1024
function main (input) {
    var arr = [];
    const N = input.split('\n')[0];
    for (var i = 0; i < N; i++){
        arr.push(input.split('\n')[i+1]);
    }
    ans = arr.filter(function (x,i,self){
        return self.indexOf(x) === i;
    });
    console.log(ans.length);
}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 11468
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1001001001;
const ll LONGINF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int main() {
    int N; scanf("%d", &N);
    vector<ll> A(N);
    ll sum = 0;
    for(int i=0; i<N; i++) scanf("%lld", &A[i]), sum ^= A[i];
    for(int i=0; i<N; i++) A[i] &= ~sum;

    ll ans = sum;
    vector<ll> base;
    for(auto e : A) {
        for(auto b : base) chmin(e, e ^ b);
        if(e != 0) base.emplace_back(e);
    }

    ll x = 0;
    for(auto e : base) chmax(x, x ^ e);

    ans += (x << 1);
    cout << ans << endl;
    return 0;
}


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



int main()
{

     ll a;
     string s;

     cin>>a>>s;
     if(a>=3200)cout<<s<<endl;
     else
        cout<<"red"<<endl;


    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] htfds)  {
        
        Scanner sc= new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        
        if (a<b&&b<c){
            System.out.println("Yes");
        }
            else{
                System.out.println("No");
            }
        }
  
    }


Measured memory_bytes: 26228
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int main(){
	string s;
	cin>>s;
	int N=s.size();
	int ans=N/2;
	rep(i,N) if(s[i]=='p') ans--;
	cout<<ans<<endl;
}

Measured memory_bytes: 512
N = int(input())
W = list(map(lambda x: int(x),input().split()))
W_cum=[0]
for i in W:
    w  = i + W_cum[-1]
    W_cum.append(w)

min_abs = W_cum[-1]
for i in W_cum[1:]:
    d_abs = abs(i-(W_cum[-1]-i))
    if d_abs<min_abs:
        min_abs = d_abs

print(min_abs)




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

class Rand
{
  public:
    Rand(int a, int b, int c, int x);

  public:
    void rand(int y);
    int Num();

  private:
    int rand();

  private:
    int m_a, m_b, m_c;
    int prev_x;
    int m_num;
    bool flag;
};

Rand::Rand(int a, int b, int c, int x)
{
  m_a = a;
  m_b = b;
  m_c = c;
  prev_x = x;
  m_num = 0;
  flag = true;
}

int Rand::rand()
{
  if (flag)
  {
    flag = false;
    return prev_x;
  }
  int result = ( m_a * prev_x + m_b ) % m_c;
  prev_x = result;
  ++m_num;
  return result;
}

void Rand::rand(int y)
{
  while (m_num < 10001)
  {
    if (y == rand() ) break;
  }
}

inline int Rand::Num()
{
  return (m_num == 10001 ? -1 : m_num);
}

int main(void)
{
  while (true)
  {
    int n, a, b, c, x;
    cin >> n >> a >> b >> c >> x;
    if ( n == 0 ) break;
    vector<int> reel(n);
    for (int& r : reel)
    {
      cin >> r;
    }
    Rand rand(a, b, c, x);
    for (int r : reel)
    {
      rand.rand(r);
    }
    cout << rand.Num() << endl;
  }
  return 0;
}

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

int main(){
   int a, b;
   cin >> a >> b;

   string a_str, b_str, ab_str;
   a_str = to_string(a);
   b_str = to_string(b);
   //cout << a_str << " "  << b_str << endl;
   ab_str = a_str + b_str;

   int ab;
   ab = atoi(ab_str.c_str());
   //cout << ab << endl;

   double sqrt_ab = sqrt(ab);
   int sqrt_ceil_ab = ceil(sqrt_ab);
   if (pow(sqrt_ceil_ab, 2) == ab){
      cout << "Yes" << endl;
   }else{
      cout << "No" << endl;
   }

}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    int A, B;
    cin >> A >> B;
    int x = max(A+B, A-B);
    x = max(x, A*B);
    cout << x << endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  char a,b; cin>>a>>b;
  if (a==b) cout << "H" << endl;
  else cout << "D" << endl;
}

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


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

int main() {
  int K;
  cin >> K;
  vector<int> a(32);
  a.at(0)=1;
  a.at(1)=1;
  a.at(2)=1;
  a.at(3)=2;
  a.at(4)=1;
  a.at(5)=2;
  a.at(6)=1;
  a.at(7)=5;
  a.at(8)=2;
  a.at(9)=2;
  a.at(10)=1;
  a.at(11)=5;
  a.at(12)=1;
  a.at(13)=2;
  a.at(14)=1;
  a.at(15)=14;
  a.at(16)=1;
  a.at(17)=5;
  a.at(18)=1;
  a.at(19)=5;
  a.at(20)=2;
  a.at(21)=2;
  a.at(22)=1;
  a.at(23)=15;
  a.at(24)=2;
  a.at(25)=2;
  a.at(26)=5;
  a.at(27)=4;
  a.at(28)=1;
  a.at(29)=4;
  a.at(30)=1;
  a.at(31)=51;
  cout << a.at(K-1) << endl;
}

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

const int INF = 1e9;

int main() {
  int n;
  cin>>n;
  string s[n];
  int ba = 0;
  int b = 0;
  int a = 0;
  int ans = 0;
  for (int i=0; i<n; i++) {
    cin>>s[i];
    int l = s[i].length();
    for (int j=1; j<l; j++) {
      if (s[i][j-1] == 'A' && s[i][j] == 'B') {
        ++ans;
      }
    }
    if (s[i][0] == 'B' && s[i][l-1] == 'A') {
      ++ba;
    } else if (s[i][0] == 'B') {
      ++b;
    } else if (s[i][l-1] == 'A') {
      ++a;
    }
  }
  if (ba > 0) {
    if (a > 0 && b > 0) {
      ans += ba + 1 + min(a-1, b-1);
    } else if (a > 0 || b > 0) {
      ans += ba;
    } else {
      ans += ba - 1;
    }
  } else {
    if (a > 0 && b > 0) {
      ans += min(a, b);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 2000000000;

int a, b;

int main(){
  cin >> a >> b;
  cout << (a+b+1)/2 <<endl;
}

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

using namespace std;

int main() {
  int n;
  long L,L1 = 1,L2 = 2;
  cin >> n;
  
  L = L1 + L2;
  for(int i = 2; i < n; i++) {
    L2 = L1;
    L1 = L;
    L = L1 + L2;
  }
  if(n == 1) L = 1;
  cout << L << endl;
}

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int s,w;
    cin >> s >> w;
    if(s>w)cout << "safe" << "\n";
    else cout << "unsafe" << "\n";
    return 0;
}

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

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ms(v, x) memset((v), (x), sizeof(v))
#define all(v) (v).begin(), (v).end()
#define ff first
#define ss second
#define iopt ios::sync_with_stdio(false); cin.tie(0)

int gcd(int a, int b) { return b == 0 ? a : gcd(b, a%b); }
int power(int x, int p, int MOD) {
    if(p == 0) return 1%MOD;
    if(p == 1) return x%MOD;
    int res = power(x, p/2, MOD);
    res = (long long)res*res%MOD;
    if(p&1) res = (long long)res*x%MOD;
    return res;
}

typedef pair<int, int> ii;
typedef long double LD;
typedef vector<int> vi;

int32_t main(){
  int n;
  cin >> n;
  int a[n];

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

  int ans = 0;
  int cur = 1;
  for(int i = 1; i < n; i++) {
    if(a[i] != a[i-1]) {
      ans += cur/2;
      cur = 0;
    }
    cur++;
  }

  ans += cur/2;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
//ショートカット
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,k,n) for(int i=k;i<n;i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

//関数
//最大公約数
long long gcd(long long m,long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m,long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x,long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  
  lin(N);lin(M);
  
  ll res=0;
  
  for(int i=1;i*i<=M;i++){
    if(M%i==0){
      if(i>=N)
        chmax(res,M/i);
      if(M/i>=N)
        chmax(res,i);
    }
  }
  
  cout<<res;
}

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

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

  int one = y / 1000;
  int five = 0;
  int ten = 0;

  int total = one + five + ten;
  int dif = total - n;
  while (dif > 0)
  {
    if (dif >= 4 && one >= 5)
    {
      one -= 5;
      five += 1;
      dif -= 4;
    }
    else if (five >= 2)
    {
      five -= 2;
      ten += 1;
      dif -= 1;
    }
    else
    {
      break;
    }
  }

  if (dif == 0)
  {
    cout << ten << " " << five << " " << one << endl;
  }
  else
  {
    cout << "-1 -1 -1" << endl;
  }
}

Measured memory_bytes: 256
// eddy1021
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long ll;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<LD,LD> Pt;
typedef tuple<int,int,int> tiii;
typedef tuple<LL,LL,LL> tlll;
#define mod9 1000000009ll
#define mod7 1000000007ll
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define FI first
#define SE second
#define X FI
#define Y SE
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
int __ = 1 , _cs;
/*********default*********/
#define N 101010
void build(){

}
LL n , e , t , x[ N ];
void init(){
  n = getint();
  e = getint();
  t = getint();
  for( int i = 1 ; i <= n ; i ++ )
    x[ i ] = getint();
  x[ n + 1 ] = e;
}
LL dp[ N ];
multiset< LL > S;
void solve(){
  LL bst = INF16;
  queue< int > Q;
  dp[ 0 ] = 0;
  Q.push( 0 );
  S.insert( t );
  for( int i = 1 ; i <= n ; i ++ ){
    while( Q.size() ){
      int j = Q.front();
      if( x[ i ] + x[ i ] - x[ j ] - x[ j + 1 ] >= x[ j + 1 ] - x[ j ] + t ){
        S.erase( S.find( dp[ j ] - x[ j ] + t ) );
        bst = min( bst , dp[ j ] - x[ j ] - x[ j + 1 ] - x[ j + 1 ] );
        Q.pop();
      }else break;
    }
    dp[ i ] = bst + x[ i ] + x[ i ] + x[ i ];
    if( S.size() )
      dp[ i ] = min( dp[ i ] , (*S.begin()) + x[ i ] );
    Q.push( i );
    S.insert( dp[ i ] - x[ i ] + t );
  }
  printf( "%lld\n" , dp[ n ] + e - x[ n ] );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,a[10000000],i,sum=0,c;
    cin>>n;
    for(i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    sum=sum+a[n-1];
    c=2;
    for(i=n-2;i>=0;i--)
    {
        if(n-c==1)
        {
            sum=sum+a[i];
            c++;
        }
        if(c==n) break;
        else
        {
            sum=sum+2*a[i];
            c=c+2;
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 5200
splitWhen :: (a -> Bool) -> [a] -> [[a]]
splitWhen p xs =
    case break p xs of
        (a,[])  -> [a]
        (a,[_]) -> a:[[]]
        (a,_:b) -> a : splitWhen p b

solve :: [Int] -> Int
solve = sum . map f . splitWhen (==0)
  where
    f [] = 0
    f h = let m = minimum h
           in m + solve (map (+(-m)) h)

main :: IO ()
main = do
    n <- readLn :: IO Int
    h <- map read . words <$> getLine :: IO [Int]
    print $ solve h


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
    int N = 0;
    cin >> N;

    int x =  ceil(N / 1.08);
    if(floor(x * 1.08) == N){
        cout << x << endl;
    }else{
        cout << ":(" << endl;
    }

}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;

int main()
{
	int a, b, c; scanf ("%d %d %d", &a, &b, &c);
	swap(a, b);
	swap(a, c);
	printf ("%d %d %d\n", a, b, c);
	return 0;
}

Measured memory_bytes: 3148
#define  _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <string.h>
#include <queue>
#include <functional>
#include <utility>
#define int long long
using namespace std;
signed main() {
	int n;
	cin >> n;
	typedef pair<int, int> p;
	p a[100006];
	int tmp;
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		a[i] = p(tmp, i);
	}
	sort(a, a + n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if ((i % 2 == 1 && a[i].second % 2 == 0) || i % 2 == 0 && a[i].second % 2 == 1)ans += 1;
	}
	cout << ans/2;
}

Measured memory_bytes: 1792
'use strict';
(function(stdin) {
    var inputs = stdin.toString().split('\n');
    var EOF = '0';
    var data = inputs.slice(0, inputs.indexOf(EOF));
    data.forEach(function(d,i,o) {
        console.log('Case', i + 1 + ':', d);
    });
 
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 20876
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 200010;
typedef pair<int, string> pis;

int main() {
	int n;
	cin >> n;
	string s[N];
	rep(i, n) cin >> s[i];
	map<string, int> mp;
	rep(i, n) mp[s[i]]++;
	vector<pis> v;
	for(auto i = mp.begin(); i != mp.end(); i++) {
		v.push_back(pis(i->second, i->first));
	}
	sort(v.begin(), v.end(), greater<pis>());
	vector<string> ans;
	for(auto p : v) {
		if(v[0].first == p.first) {
			ans.push_back(p.second);
		}
	}
	sort(ans.begin(), ans.end());
	for(auto a : ans) {
		cout << a << endl;
	}
}


Measured memory_bytes: 34412
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


template <typename T>
bool chmax(T & a, const T & b) {
	if (a < b) {
		a = b; 
		return true;
	}
	return false;
}
template <typename T>
bool chmin(T & a, const T & b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

int dx4[4] = { 1,0,0,-1 };
int dy4[4] = { 0,1,-1,0 };
int dx2[2] = { 1,0 };
int dy2[2] = { 0,1 };

/******************************************************************************************/


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);


	int L;
	cin >> L;

	double a = L / (double)3;
	double b = L / (double)3;
	double c = L - a - b;
	double ans = (double)a * b * c;
	
	cout << ans << endl;




	return 0;
}



Measured memory_bytes: 256
N,M=list(map(int,input().split()))

edge=[[] for _ in range(N)]
dist=[-float('inf') for _ in range(N)]
dist[0]=0

for _ in range(M):
    a,b,c=list(map(int,input().split()))
    edge[a-1].append((b-1,c))

tmp=-float('inf')
for n in range(N):
    flag=0
    tmp=dist[-1]
    for i in range(N):
        for b,p in edge[i]:
            if dist[b]<dist[i]+p:
                dist[b]=dist[i]+p
                flag=1
    if flag==0:
        break
if tmp!=dist[-1]:
    print('inf')
else:
    print(int(dist[-1]))

Measured memory_bytes: 3448
#include<iostream>
#include<string>
//#include<array>
#include<algorithm>
//#include<deque>
#include<vector>
//#include<utility>
#include<set>
//#include<map>
//#include<list>

using namespace std;

class UnionFind {
public:
	vector<int>data;
	UnionFind(int size) :data(size, -1) {};
	bool unionset(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x]) {
				swap(x, y);
			}
			data[x] += data[y];
			data[y] = x;
		}
		return x != y;
	}
	bool findset(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int gcd(int x, int y) {
	int tmp, r;
	if (x < y) {
		tmp = x;
		x = y;
		y = tmp;
	}
	r = x % y;
	while (r != 0) {
		x = y;
		y = r;
		r = x % y;
	}
	return y;
}

int main(void) {
	int A, B;
	cin >> A >> B;
	if (A > 8 || B > 8) {
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}
}

Measured memory_bytes: 256
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair

int main(){
	LCIN(n,m);
	VC1(n,x);
	VC1(m,y);
	ll val = 0;
	REP(i,n){
		val += i * x[i];
		val %= MOD;
		val -= (n - i - 1) * x[i];
		val += MOD;
		val %= MOD;
	}
	ll ans = val;

	val = 0;
	REP(i,m){
		val += i * y[i];
		val %= MOD;
		val -= (m - i - 1) * y[i];
		val += MOD;
		val %= MOD;
	}
	ans *= val;
	ans %= MOD;
	COUT(ans);


	return 0;
}


Measured memory_bytes: 1792
n = int(input())

dice = []
for i in range(n):
    dice.append(list(map(lambda x: int(x), input().split(" "))))

if n < 3:
    print("No")
    exit(0)

for i in range(n-2):
    if dice[i][0] == dice[i][1] and dice[i+1][0] == dice[i+1][1] and dice[i+2][0] == dice[i+2][1]:
        print("Yes")
        exit(0)

print("No")

Measured memory_bytes: 9200
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

using namespace std;
using ll = long long;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI = 4.0 * atan(1.0);

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

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

    cout << pow(N, 3) << endl;
    return 0;
}


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

#define loop(n) for(int i = 0; i < n; i++)
#define FOR(x,y,z) for(int x = y; x < z; x++)
#define REP(i,n) FOR(i,0,n)
#define INF 999999999
#define VEC vector<int>
#define in push_back
#define ans(x) cout<<x<<endl
typedef long long ll;
using namespace std;

ll n, k;
vector<ll>memo, retu;
int main()
{
	ll n,s[10000],goukei=0;
	cin >> n;
	REP(i, n) {
		cin >> s[i]; goukei += s[i];
	}
	sort(s, s + n);
	if (goukei % 10 != 0) {
		cout << goukei << endl; return 0;
	}
	REP(i, n) {
		if (s[i] % 10) {
			cout << goukei - s[i] << endl; return 0;
		}
	}
	cout << 0 << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;
  cin >> A;
  int64_t sum=0;
  for(int i=1;i<=A;i++){
    if(i%3==0||i%5==0){
      sum=sum+0;
    }
    else{
      sum=sum+i;
    }
  }
    cout << sum << endl;
  }

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


int main(){
  int x,y,a,b;
  cin >> x >> y;
  a = min(x,y);
  b = max(x,y);
  rep(i,b){
    cout << a;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Collections;
public class Remainder {
    static long div = 1000000007;
    static public void Main() {
        var NM =　Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var N = NM[0];
        var M = NM[1];
        var WA = new int[N+1];
        var AC = new bool[N+1];
        
        //ACのフラグを初期化
        for(int i = 0;i <= N ;i++){
            AC[i] = false;
        }
        //ACの数を保存
        for(int i = 0;i < M;i++){
            var inp =　Console.ReadLine().Split(' ').ToArray();
            var P = int.Parse(inp[0]);
            var S = inp[1];
            if(S == "AC"){
                AC[P] = true;
            }else if(S == "WA" && !AC[P]){
                WA[P]++;
            }
        }
        
        //ユニークAC数
        var UAC = 0L;
        var sum = 0L;
        for(int i = 1;i <= N ;i++){
            if(AC[i]){
                UAC++;
                sum += WA[i];
            }
        }    
            Console.WriteLine(UAC+" "+sum); } } 


Measured memory_bytes: 17760
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <limits.h>

#define ll long long

using namespace std;

int main(){

    int n;
    vector<pair<int,int>> v;

    cin >> n;

    for(int i = 0; i < n; i++){
        int tmpx,tmpy;
        cin >> tmpx >> tmpy;

        v.push_back(make_pair(tmpx,tmpy));
    }

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

    map<pair<int,int>, int> m;
    int mmax = 0;

    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            if(i == j) continue;

            int tmp1x = v[i].first;
            int tmp1y = v[i].second;

            int tmp2x = v[j].first;
            int tmp2y = v[j].second;

            m[make_pair(tmp2x - tmp1x, tmp2y - tmp1y)] = m[make_pair(tmp2x - tmp1x, tmp2y - tmp1y)] + 1;
            mmax = max(mmax, m[make_pair(tmp2x - tmp1x, tmp2y - tmp1y)]);
        }
    }

    int cost = 1 + (n - 1) - min(mmax, n - 1);

    cout << cost << endl;

    return 0;
}

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

class UnionFind {
private:
	vector<int> parent;
	vector<int> height;
	vector<int> m_size;

public:
	UnionFind(int size_) : parent(size_), height(size_, 0), m_size(size_, 1) {
		for (int i = 0; i < size_; ++i) parent[i] = i;
	}
	void init(int size_) {
		parent.resize(size_);
		height.resize(size_, 0);
		m_size.resize(size_, 0);
		for (int i = 0; i < size_; ++i) parent[i] = i;
	}
	int find(int x) {
		if (parent[x] == x) return x;
		return parent[x] = find(parent[x]);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		int t = size(x) + size(y);
		m_size[x] = m_size[y] = t;
		if (height[x] < height[y]) parent[x] = y;
		else parent[y] = x;
		if (height[x] == height[y]) ++height[x];
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	int size(int x) {
		if (parent[x] == x) return m_size[x];
		return size(parent[x] = find(parent[x]));
	}
};

int N,K,L,i;
int p[200000],q[200000],r[200000],s[200000];
int a[300000],b[300000];
map<pair<int, int>, int> mp;
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  cin >> N >> K >> L;
  UnionFind ufk(N);
  UnionFind ufl(N);
  for(i = 0;i < K;i++){
   cin >> p[i] >> q[i];
   p[i]--;q[i]--;
   ufk.unite(p[i], q[i]);
  }
  for(i = 0;i < L;i++){
    cin >> r[i] >> s[i];
    r[i]--;s[i]--;
    ufl.unite(r[i], s[i]);
  }
  for(i = 0;i < N;i++){
    a[i]=ufk.find(i);
    b[i]=ufl.find(i);
    mp[make_pair(a[i], b[i])]++;
  }
  for(i = 0;i < N;i++){
    cout<< mp[make_pair(a[i], b[i])] <<" \n"[i==N-1];
  }
  return 0;
}

Measured memory_bytes: 20736
#include <bits/stdc++.h>
using namespace std;
int n,t,a[200001];
long long ans;
int main() {
    cin>>n>>t;
    for (int i=0; i<n; i++) cin>>a[i];
    for (int i=1; i<n; i++) {
        if (a[i]-a[i-1]>t) ans+=t;
        else ans+=(a[i]-a[i-1]);
    }   
    ans+=t;
    cout<<ans<<'\n';
}

Measured memory_bytes: 4332
import math

a, b, x = map(int, input().split())
S = x / a

result = 0

if S >= a * b / 2:
    result = (2 * (a * b - S)) / a
    result = math.degrees(math.atan(result / a))
elif S < a * b / 2:
    result = (2 * S) / b
    result = math.degrees(math.atan(b / result))

print(result)

Measured memory_bytes: 3060
import sys
import bisect

MAX = 2000000
prime = [-1] * MAX
prime_list = []
i = 2
while MAX > i:
	if prime[i - 1] == -1:
		prime[i - 1] = 0
		temp = i * 2
		prime_list.append(i)
		while temp < MAX:
			prime[temp - 1] = 1
			temp += i
	if i == 2:
		i += 1
	else:
		i += 2

while True:
    N, P = map(int, sys.stdin.readline().split())
    
    if N == P == -1:
        break
    
    start = bisect.bisect_right(prime_list, N)
    candidate = []
    for i in xrange(start, min(start + 101, MAX)):
        for j in xrange(i, min(start + 101, MAX)):
            candidate.append(prime_list[i] + prime_list[j])
    candidate.sort()
    print candidate[P - 1]

Measured memory_bytes: 24644
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
int main(){
    vector<int> v(3);cin>>v[0]>>v[1]>>v[2];
    sort(all(v));
    int a=v[0];reps(&x,v)x-=a;
    int b=v[1],c=v[2];
    int r_b=b%2,r_c=c%2;
    int ans=0,r=r_b+r_c;
    if(r==1||r==2)ans++;
    if((r_c==r_b||r_c==0)&&(r_c%2!=r_b%2||r_c%2!=0))ans++;
    reps(x,v)ans+=(c-x)/2;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
long long a[200005],b[200005];
 
int main() {
    long long n,i,j;
    long long sum=0,ans=0;
    scanf("%lld",&n);
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    for(i=0; i<n; i++) {
        scanf("%lld",&a[i]);
        b[a[i]]++;
    }
    for(j=1; j<=n; j++) {
        if(b[j]>1)
            sum+=(b[j]*(b[j]-1))/2;
    }
    for(i=0; i<n; i++) {
        if(b[a[i]]>1)
            ans=sum-(b[a[i]]*(b[a[i]]-1)-(b[a[i]]-1)*(b[a[i]]-2))/2;
        else
            ans=sum;
        printf("%lld\n",ans);
    }
}

Measured memory_bytes: 5760
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int x[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
int y[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

int main(){
	int h, w;
	cin >> h >> w;
	string s[h];
	for(int i = 0; i < h; i++){
		cin >> s[i];
	}

	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(s[i].at(j) == '#'){
				cout << "#";
			}else{
				int cnt = 0;
				for(int k = 0; k < 8; k++){
					if(0 <= i + x[k] && i + x[k] < h
						&& 0 <= j + y[k] && j + y[k] < w){
						if(s[i + x[k]].at(j + y[k]) == '#'){
							cnt++;
						}
					}
				}
				cout << cnt;
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>){
    val sc = Scanner(System.`in`)

    val A = sc.nextInt()
    val B = sc.nextInt()

    val list = java.util.ArrayList<Int>()
    with(list){
        add(1)
        add(2)
        add(3)
        remove(A)
        remove(B)
    }

    println(list.get(0))

    sc.close()
}

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


int main (){
  string s;
  
  cin>>s;
  
  if(s=="Sunny")cout<<"Cloudy"<<endl;
  else if(s=="Cloudy")cout<<"Rainy"<<endl;
  else{cout<<"Sunny"<<endl;
       
       
      }
  
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  map<string,int> mp;
  rep(i,n){
    string s;
    cin >>s;
    sort(s.begin(),s.end());
    mp[s]++;
  }
  long long ans=0;
  for(auto p:mp){
    int q=p.second;
    for(int i=1;i<=q-1;i++){
      ans+=i;
    }
  }
  cout <<ans;
}

Measured memory_bytes: 11136
/**       In the name of Allah, the Gracious, the Merciful.
*               Praise be to Allah, Lord of the Worlds.
*               **************************************
*
*    I have not failed, I have just found 1000 WAYS that won't work.
*                 __________________________________
*                  Author  : Abd El-Twab  M. Fakhry
*                 __________________________________
*/

#include <ext/rope>
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define  read(arr, l, r)     for(int i = (l); i < (r); cin >> arr[i++])
#define  print(arr, l, r)    for(int i = (l); i < (r); cout << arr[i++] << " \n"[i == r])
#define  rep(i, l, r)        for (int i = l; i < r; i++)
#define  repr(i, r, l)       for (int i = r; i > l; i--)
#define  trav(a, x)          for (auto & a : x)
#define  PQ(T)               priority_queue < T, vector <T> , greater <T> >
#define  Unique(n)           (n).erase(unique(all(n)), (n).end())
#define  endl                '\n'
#define  all(a)              a.begin() , a.end()
#define  NumberOfDigits(n)   ((int)log10(n) + 1)
#define  sz(a)               (int)a.size()
#define  rall(a)             a.rbegin(), a.rend()
#define  rsz(sz)             resize(sz)
#define  ins(x)              insert(x)
#define  debug(x)            cout << #x << " = " << (x) << '\n'
#define  LINE_ON             cout << "line Number = " << __LINE__ << endl
#define  RT(n)               return cout << (n) << endl, 0;
#define  clr(arr, x)         memset(arr, x, sizeof(arr))
#define  F                   first
#define  S                   second
#define  PB                  push_back
#define  EB                  emplace_back
#define  get(n)              find_by_order(n)
#define  indexOf(n)          order_of_key(n)
#define  isPowerOfTwo(x)     (x && !(x & (x - 1)))
#define  Swap(n, k)           n ^= k, k ^= n, n ^= k;

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template <class T>
using indexed_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update >;
typedef long long            ll;
typedef unsigned int         uint;
typedef unsigned long long   ull;

int Dx8[8] = { 1, -1, 0, 0, 1, 1, -1, -1 }, Dx4[4] = { 0, 0, 1,-1};
int Dy8[8] = { 0, 0, 1, -1, 1, -1, 1, -1 }, Dy4[4] = { 1,-1, 0, 0};

const double inf  = 1.0 / 0.0,      pi  = 2 * acos(0.0),   error = 1e-9;
const int    MxsZ = (int)2e5 + 6,   mod = (1 << 30) + 7,      oo = 0x3f3f3f3f;

ll Gcd(ll a, ll b)     { return b ? Gcd(b, a % b) : a; }
ll Lcm(ll a, ll b)     { return a * b / Gcd(a, b); }

void Fast()
{
    cin.sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin.exceptions(cin.failbit);
}

void File()
{
    freopen("input.in", "r", stdin);
    freopen("output.out", "w", stdout);
}

/**----------------------->>  Template  <<-----------------------**/

int n, k;
string s;

/**------------------>>  Initialization gap  <<------------------**/

int main()
{
    Fast();

    cin >> n >> s >> k;
    char d = s[k - 1];
    rep(i, 0, sz(s)) if(s[i] != d) cout << "*";
    else cout << s[i];
}


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

using ll = long long;
using p = pair<ll, ll>;
constexpr ll INF = 1LL << 62;
ll MOD = 1e9 + 7;

ll N;
string S;
vector<ll> cnt;
ll uniq;

int main(void) {
  cnt = vector<ll>(26, 0);
  cin >> N >> S;
  for (auto&& s : S) {
    cnt[s - 'a']++;
  }

  ll ans = 0;

  for (auto c : cnt) {
    if (c == 0) {
      continue;
    }
    ans = ans + (ans * c) % MOD + c;
    ans %= MOD;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 1e9+7
#define mininf -922337203685477
#define pi acos(-1)
#define inf 0x3f3f3f3f
#define fast ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
typedef long long ll;
typedef unsigned long long ull;

int main(){
	fast
	int n;
	cin >> n;
	vector<int>arr;
	for(int i=0;i<n;i++){
		int x;
		cin >> x;
		arr.pb(x);
	}
	ll mins=inf;
	for(int i=1;i<=100;i++){
		ll cost=0;
		for(auto j:arr){
			cost+=(j-i)*(j-i);
		}
		mins=min(cost, mins);
	}
	cout << mins << '\n';
}

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

int main(){
  int N;
  cin >> N;
  bool flag = 0;
  for(int i = 0; i < N / 7 + 1;i++){
   	int tmp = N - i * 7;
    if(tmp % 4 == 0) flag = 1;
  }
  if(flag) cout << "Yes\n";
  else cout << "No\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c; cin >> a >> b >> c;
    int m = max({a, b, c});
    if (3 * m % 2 == (a + b + c) % 2) cout << (3 * m - (a + b + c)) / 2 << endl;
    else cout << (3 * (m + 1) - (a + b + c)) / 2 << 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 n = sc.nextInt();
		int k = sc.nextInt();

		int sum = 0;
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			int min = Math.min(x, Math.abs(x - k));
			sum += min;
		}

		System.out.println(sum * 2);

		sc.close();
	}

}


Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		sc.close();

		int answer = 0;

		if (N % 2 != 0) {
			answer = N * 2;
		} else {
			answer = N;
		}

		System.out.print(answer);

	}
}

Measured memory_bytes: 21844
using System;

namespace code_festival_2017_qualc_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            bool ret = false;
            for (int i = 0; i < s.Length - 1; i++)
            {
                if (s.Substring(i, 2) == "AC") ret = true;
            }
            Console.WriteLine(ret ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 11092
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop,heapify
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？


k=ii()
a,b=mii()
chk=False
for i in range(a,b+1):
    if i%k==0:
        chk=True
if chk:
    print("OK")
else:
    print("NG")






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

typedef long long ll;

map<ll,int> mp;
int n;
ll x,s,ans;

int main() 
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    while(cin >> n)
    {
        mp.clear(); mp[0] = 1; ans = s = 0;
        for(int i = 0; i < n; i++)
        {
            cin >> x;
            s += x;
            ans += mp[s];
            mp[s]++;
        }
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 12800
n = int(input())
p = [int(x) - 1 for x in input().split()]

x = 5 * (10 ** 4)
a = [1 + i * x for i in range(n)]
b = a[::-1]

for i in range(1, n):
    a[p[i]] += i

print(*a)
print(*b)

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

int n;
int ans;

void dfs(int pre, int sm, int c) {
    if (sm == n) {
        ans++;
        return;
    }
    if (c >= 4) {
        return;
    }

    for (int i = pre; sm + i * i <= n; i++) {
        dfs(i, sm + i * i, c + 1);
    }
}

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

    while (cin >> n, n) {
        ans = 0;
        dfs(1, 0, 0);
        cout << ans << endl;
    }
}

Measured memory_bytes: 3092
/*
    A - Tak and Hotels (ABC Edit)
    https://atcoder.jp/contests/abc044/tasks/abc044_a
*/

#include <iostream>
#include <vector>

using namespace std;

#define ll long long
#define forn(i, s, n) for (int i = s; i < n; i++)
#define whilen(val, n) while(n-- && cin >> val)
#define r_1(v) cin >> v
#define r_2(v1, v2) cin >> v1 >> v2


int main() {
    int n, k, x, y;
    r_1(n);
    r_1(k);
    r_1(x);
    r_1(y);
    if (n >= k) cout << (x * k) + (y * (n - k));
    else cout << (x * n);
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

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

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

bool ok(const vs& grid)
{
	int n=grid.size();
	rep(i,n) rep(j,n)
		if(grid[i][j]!=grid[j][i])
			return false;
	return true;
}

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n;cin>>n&&n;){
		vs grid(n);
		rep(i,n) cin>>grid[i];
		int res=0;
		rep(i,n){
			res+=n*ok(grid);
			grid.push_back(grid[0]);
			grid.erase(begin(grid));
		}
		cout<<res<<endl;
	}
}


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

#define int long long
#define pb push_back
#define all(a) begin(a), end(a)
#define deb(x) cout << #x << " = " << x << endl
#define debu(x, y) cout << "( " << #x << ", " << #y << " ) = ( " << x << ", " << y << " )" << endl

typedef long long ll;
ll mod=1000000007;

template <typename T> vector<T> readVector(int n) { vector<T> res(n); for (int i = 0 ; i < n ; i++) cin >> res[i]; return res; }

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int tt = 1;
    //cin >> tt;
    while(tt--) {
        int n;
        cin >> n;
        vector<int> a(n);
        for(int i=0; i<n; i++) {
            cin >> a[i];
        }
        int ans = 0;
        for(int i=1; i<n; i++) {
            if(a[i] >= a[i-1]) continue;
            ans += (a[i-1] - a[i]);
            a[i] = a[i-1];
        }
        cout << ans;
    }
    return 0;
}


Measured memory_bytes: 4692