akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <set>
#include <string>
#include <utility>

using namespace std;

typedef struct {
  long long value;
  int count;
} Prime;

deque<Prime> decomposit_prime(long long n) {
  long long div = 2;
  deque<Prime> primes(0);

  while (n >= div * div) {
    int cnt = 0;

    while (n % div == 0) {
      cnt++;
      n /= div;
    }

    if (cnt > 0) {
      primes.push_back(Prime{div, cnt});
    }

    div++;
  }

  if (n != 1) {
    primes.push_back(Prime{n, 1});
  }

  return primes;
}

deque<long long> get_prime_pows(deque<Prime> primes) {
  deque<long long> prime_pows(0);

  for (int i = 0; i < primes.size(); i++) {
    Prime prime = primes[i];

    for (int j = 1; prime.count > 0; j++) {
      if (prime.count < j) {
        break;
      }

      prime.count -= j;

      long long value = 1;
      for (int k = 0; k < j; k++) {
        value *= prime.value;
      }
      prime_pows.push_back(value);
    }
  }

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

  return prime_pows;
}

int main() {
  long long n;

  cin >> n;

  // 素因数分解する
  deque<Prime> primes = decomposit_prime(n);

  // 素因数分解した結果から作れる素数冪を列挙する
  deque<long long> prime_pows = get_prime_pows(primes);

  // for (int i = 0; i < primes.size(); i++) {
  //   cout << primes[i].value << ", " << primes[i].count << endl;
  // }
  // for (int i = 0; i < prime_pows.size(); i++) {
  //   cout << prime_pows[i] << endl;
  // }
  // 素数冪を小さいものからかけていき、nを超えたらそこまでの数を出力
  long long value = 1;
  for (int i = 0; i < prime_pows.size(); i++) {
    if (value > __LONG_LONG_MAX__ / prime_pows[i]) {
      cout << i << endl;
      return 0;
    }

    value *= prime_pows[i];
  }

  cout << prime_pows.size() << endl;

  return 0;
}

Measured memory_bytes: 3224
#include "bits/stdc++.h"
using namespace std;

#define all(x) (x).begin(),(x).end()
#define fastio ios_base::sync_with_stdio(false)

typedef double db;
typedef long long ll;
typedef unsigned long long ull;

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


int main() {
	fastio;
	
	int n; cin >> n;
	
	vector < int > v(n),dp(n, 0);

	for(int i = 0; i < n; ++i) cin >> v[i];

	dp[1] = abs(v[1] - v[0]);

	for(int i = 2; i < n; ++i) {
		dp[i] = min(dp[i - 1] + abs(v[i] - v[i - 1]), dp[i - 2] + abs(v[i] - v[i - 2]));
	}

	cout << dp[n - 1] << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  ll n,ans=0;
  cin>>n;
  if(n%2!=0 || n==0){
    cout<<0;
  }else{
    n/=2;
    while(1){
      int m=n%5;
      n-=m; n/=5;
      ans+=n;
      if(n==0){
        break;
      }
    }
    cout<<ans;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define P 998244353
#define N 160005
#define ll long long
using namespace std;
char S1[N],S2[N];
ll pw(ll a,ll b,ll c)
{
	ll ans=1;
	for (;b;a=(ll)a*a%c,b>>=1)
		if (b&1) ans=(ll)ans*a%c;
	return ans;
}
 
ll tl,tn,w[2][N],r[N],rn,ans[N];
void pre(ll x)
{
	tl=0;tn=1;
	while(tn<=x)tn<<=1,tl++;
	tn<<=1;tl++;
	ll W=pw(3,(P-1)/tn,P);
	w[0][0]=w[1][0]=1;
	for (ll i=1;i<tn;i++)
		w[0][i]=(ll)w[0][i-1]*W%P;
	for (ll i=1;i<tn;i++)
		w[1][i]=w[0][tn-i];
	for (ll i=1;i<tn;i++)
		r[i]=(r[i>>1]>>1)|((i&1)<<(tl-1));
	rn=pw(tn,P-2,P);
}
 
void dft(ll *a,ll f)
{
	for (ll i=0;i<tn;i++)
		if(i<r[i]) swap(a[i],a[r[i]]);
	for(ll i=1;i<tn;i<<=1)
	for(ll j=0,t=tn/(i<<1);j<tn;j+=i<<1)
	for(ll k=0,l=0;k<i;k++,l+=t)
	{
		ll x=(ll)w[f][l]*a[j+k+i]%P;
		ll y=a[j+k];
		a[j+k]=(y+x)%P;
		a[j+k+i]=(y+P-x)%P;
	}
	if(f)
		for (ll i=0;i<tn;i++)
			a[i]=(ll)a[i]*rn%P;
}
 
ll fac[N],ifac[N],inv[N],f[N];
void mul(ll a[],ll b[],ll c[],ll t)
{
	static ll A[N],B[N],C[N];
	for (ll i=0;i<tn;i++)
	{
		A[i]=b[i];
		B[i]=c[i];
	}
	dft(A,0);
	dft(B,0);
	for (ll i=0;i<tn;i++)
	{
		C[i]=(ll)A[i]*B[i]%P;
	}
	dft(C,1);
	for (ll i=0;i<tn;i++)
		a[i]=i<=t?C[i]:0;
}
int main()
{
	scanf("%s%s",S1,S2);
	ll n=strlen(S1);
	ll a=0,b=0;
	for (ll i=0;i<n;i++)
	{
		if (S1[i]=='1'&&S2[i]=='1') b++;
		else if (S1[i]=='1') a++;
	}
	fac[0]=inv[1]=fac[1]=ifac[1]=ifac[0]=1;
	for (ll i=2;i<=a+b+1;i++)
	{
		inv[i]=(ll)(P-P/i)*inv[P%i]%P;
		fac[i]=(ll)fac[i-1]*i%P;
		ifac[i]=(ll)ifac[i-1]*inv[i]%P;
	}
	for (ll i=0;i<=b;i++)
	{
		f[i]=ifac[i+1];
		//cout<<f[i]<<endl;
	}
	ans[0]=1;
	pre(b);
	for (ll i=a;i;i>>=1,mul(f,f,f,b))
		if (i&1) mul(ans,ans,f,b);
	
	ll Ans=0;
	for (ll i=0;i<=b;i++)
		Ans=(Ans+ans[i])%P;
	//cout<<Ans<<endl;
	Ans=(ll)Ans*fac[a]%P*fac[b]%P*fac[a+b]%P;
	printf("%lld\n",(Ans+P)%P);
	
}

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


def num2alpha(num):
    if num <= 26:
        return chr(64+num)
    elif num % 26 == 0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num % 26)


print(num2alpha(n).lower())


Measured memory_bytes: 9016
#include <stdio.h>
int main()
{
	int n,i;
	scanf("%d",&n);
	for(i=1;i<10;i++)
	{
		if(n%i==0&&(n/i)<10)
		{
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}
		

Measured memory_bytes: 1656
import java.util.Scanner

object Main {

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val s = sc.next().toCharArray
    val t = sc.next().toCharArray

    var cnt = 0
    (0 until s.length).foreach { i =>
      if (s(i) != t(i)) cnt += 1
    }

    println(cnt)
  }
}


Measured memory_bytes: 57948
import java.io.InputStreamReader;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		try(Scanner scan = new Scanner(new InputStreamReader(System.in))){
			int N = scan.nextInt();
			int L = scan.nextInt();
			
			int[] a = new int[N];
			int max = 0;
			
			a[0] = scan.nextInt();
			for(int i = 1; i<N; i++){
				a[i] = scan.nextInt();
				if(a[i-1] + a[i] > a[max] + a[max+1]){
					max = i-1;
				}
			}
			
			if(a[max] + a[max+1] < L){
				System.out.println("Impossible");
				return;
			}
			
			System.out.println("Possible");
			
			StringBuffer sb = new StringBuffer();
			
			for(int i = 0; i<max; i++){
				sb.append(i+1);
				sb.append("\n");
			}
			
			for(int i = N-2; i>=max; i--){
				sb.append(i+1);
				sb.append("\n");
			}
			
			System.out.print(sb.toString());;
		}
	}
}


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

using namespace std;

//#define FILE_IO

typedef long long LL;

const int NMAX = 2e5 + 5;

int N, K;
LL v[NMAX];
LL val[NMAX];

class Normalizator
{
public:
    vector<LL> ord;
    unordered_map<LL, int> mp;

    void add(LL x)
    {
        if(mp.count(x)) return;
        mp[x];
        ord.push_back(x);
    }

    void normalize()
    {
        sort(ord.begin(), ord.end());
        for(int i = 0; i < ord.size(); i++)
            mp[ ord[i] ] = i + 1;
    }

    int get(LL x) { return mp[x]; }
}nrm;

class BinaryIndexedTree
{
public:
    int N;
    int aib[NMAX];

    void init(int _N) { N = _N; }

    void U(int pos, int val)
    {
        for(; pos <= N; pos += (pos & (-pos)))
            aib[pos] += val;
    }

    int Q(int pos)
    {
        int ans = 0;
        for(; pos > 0; pos -= (pos & (-pos)))
            ans += aib[pos];
        return ans;
    }
}aib;

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d%d", &N, &K);
    LL s = 0;
    nrm.add(0);
    for(int i = 1; i <= N; i++)
    {
        scanf("%lld", &v[i]);
        s += v[i];
        LL vl = s - 1LL * K * i;
        nrm.add(vl);
        val[i] = vl;
    }

    nrm.normalize();
    aib.init(nrm.ord.size());

    aib.U(nrm.get(0), 1);

    LL ans = 0;
    for(int i = 1; i <= N; i++)
    {
        LL vl = val[i];
        ans += aib.Q(nrm.get(vl));
        aib.U(nrm.get(vl), 1);
    }

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 14012
_ = gets
while l = gets do
  ps = l.split(' ').map(&:to_i)
  va = [ps[2] - ps[0], ps[3] - ps[1]]
  vb = [ps[6] - ps[4], ps[7] - ps[5]]
  sp = va[0] * vb[0] + va[1] * vb[1]
  vp = va[0] * vb[1] - vb[0] * va[1]
  if vp == 0
    puts 2
  elsif sp == 0
    puts 1
  else
    puts 0
  end
end


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;

int main(){
  FASTER;
  ll n, m;
  cin >> n >> m;
  if (n == m){
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    int a, b, c;
    cin >> a >> b >> c;

    if ((c >= a) && (c <= b))
    {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

int main()
{
	string str;
	cin >> str;
	
	int cnt = 0;
	for(int i=0; i < str.size(); i++) {
		if(cnt == 0 && str[i] == 'C') cnt++;
		if(cnt == 1 && str[i] == 'F'){
			cnt++;
			break;
		}
	}
	
	if(cnt == 2) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath> 
using namespace std;
long long n,ans;
int s;
int main(){
    scanf("%lld",&n);
    for(int i=sqrt(n);i>0;--i) 
        if(n%i==0){
            ans=n/i;
            break;
        }
    while(ans>0){
        ++s;
        ans/=10;
    }
    printf("%d\n",s);
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back


int MOD=1000000007;
int N,cnt;
char s[100005][20];
vector<string> sorteds;
int ans=0;



signed main(){
    scanf("%lld",&N);
    rep(i,N){
        scanf("%s",s[i]);
        sort(s[i],s[i]+10);
        string str(s[i]);
        sorteds.pb(str);
    }
    sort(sorteds.begin(),sorteds.end());
    int scnt=1;
    rep(i,N){
        if(i==0)continue;
        if(sorteds[i].compare(0,11,sorteds[i-1].c_str())==0){scnt++;}
        if(scnt>1&&sorteds[i].compare(0,11,sorteds[i-1].c_str())!=0){
            ans+=scnt*(scnt-1)/2;
            scnt=1;
        }
        if(scnt>1&&i==N-1)ans+=scnt*(scnt-1)/2;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 7668
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
 
    int x;
    cin>>x;

    if(x==2){
        cout<<x<<endl;
    }
    else{
       bool prime_flag;
      do{
         prime_flag=true;
         for(int i=2;i*i<=x;i++){
             if(x%i==0){
                 x++;
                 prime_flag=false;
                 break;
             }
         }
        }while(prime_flag==false);
    cout<<x<<endl;
    }
    
    return 0;
}  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{   
  char ch[2];
  int count = 0;
  cin>>ch;
  for(int i=0;i<strlen(ch);i++)
  {
    if(ch[i]=='9')
        count++;
        
  }
  if(count==0)
  cout<<"No"<<endl;
  else
  cout<<"Yes"<<endl;
  
}


Measured memory_bytes: 3576
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
ll a[100009],dp[100009];
ll DP(ll n,ll k)
{

    if(dp[n]!=-1)
    {
        return dp[n];
    }
    if(n==0)
    {
        return dp[n] = 0;
    }
    ll ans = 1e18;
    for(ll i=1;i<=k && n-i>=0;i++)
    {
        ans = min(ans,DP(n-i,k)+abs(a[n]-a[n-i]));
    }
    return dp[n] = ans;
}
int main()
{
    ll i,n,t,k,j,x=0,y=0,m;
    sff(n,k);
    memset(dp,-1,sizeof dp);
    rep0(i,n)
    {
        sf(a[i]);

    }
    cout<<DP(n-1,k)<<endl;
    return 0;
}



Measured memory_bytes: 6528
// 5/2

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

long long H[100010];

int main() {
    long long N;  // 展望台の数
    long long M;  // 展望台を結ぶ道の数

    cin >> N >> M;

    for (long long i = 0; i < N; i++) {
        cin >> H[i];
    }

    Graph G(N);

    for (long long i = 0; i < M; i++) {
        long long a, b;
        cin >> a >> b;
        a--; b--;

        G[a].push_back(b);
        G[b].push_back(a);
    }

    long long ans = 0;

    for (int i = 0; i < N; i++) {
        bool good = true;

        // cout << i + 1 << "番目" << endl;

        for (auto j : G[i]) {
            // cout << "道の先： " << j + 1 << " 高さ：" << H[j] << endl;
            if (H[i] <= H[j]) good = false;
        }

        // if (G[i].size() == 0) good = false;

        if (good) {
            ans++;
            // cout << "good!" << endl;
        }

    }

    cout << ans << endl;
}


Measured memory_bytes: 9068
#include<bits/stdc++.h>
#define llu unsigned long long
#define ll long long
#define INF 0x3f3f3f3f
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;


template <typename T> 
inline void inp(T &any) {
    cin >> any;
}
template <typename T, typename... U> 
inline void inp(T &a, U &...b) {
    cin >> a; inp(b...);
}
// scan vector
template <typename T> 
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U> 
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second; 
    return in;
}

int main()	
{
	#ifdef SANS
		freopen("C:\\Users\\ASUS\\Documents\\Sublime\\input_output\\inputf.txt","r",stdin);
		freopen("C:\\Users\\ASUS\\Documents\\Sublime\\input_output\\outputf.txt","w",stdout);
	#endif
	fast
	int t=1;
	// cin>>t;
	while(t--)
	{
		int a,b;
		cin>>a>>b;
		cout<<(a*b);
	}
	#ifdef SANS
		cout<<"\nTime Elapsed:"<<1.0*clock()/CLOCKS_PER_SEC <<"sec\n";
	#endif
}

Measured memory_bytes: 3640
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int a, b;
	cin >> a >> b;
	repn(i, 1, 1001){
		ld i1 = i;
		ld one = floor((ld)((ld)(i1 * 8) / 100));
		ld two = floor((ld)((ld)(i1 * 10) / 100));
		if(abs(one - a) < 1e-8 && abs(two - b) < 1e-8){
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  double r,h,j,k;
   scanf("%lf",&r);
   k=3.141592653589;
   printf("%8f " ,h=r*r*k); 
    printf("%8f" ,j=r*2*k); 
 cout<<endl;
  return 0;
 }




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

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

    vector<int> ans(4);
    for(i = 0; i < n; i++) {
        if (judge[i] == "AC") {
            ans[0]++;
        }
        else if (judge[i] == "WA") {
            ans[1]++;
        }
        else if (judge[i] == "TLE") {
            ans[2]++;
        }
        else {
            ans[3]++;
        }
    }

    cout << "AC x " << ans[0] << endl;
    cout << "WA x " << ans[1] << endl;
    cout << "TLE x " << ans[2] << endl;
    cout << "RE x " << ans[3] << endl;
}


Measured memory_bytes: 6752
#include <cstdio>
#include <algorithm>

const int MAXN = 105;
const int MAXK = 100005;
const int MOD = 1000000007;

int a[MAXN];
long long f[2][MAXK];

int main() {
    int n, K;
    scanf("%d %d", &n, &K);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);

    int curr = 0, last = 1;
    std::fill(f[curr], f[curr] + a[0] + 1, 1);
    std::fill(f[curr] + a[0] + 1, f[curr] + K + 1, 0);
    for (int i = 1; i < n; i++) {
        for (int j = 1; j <= K; j++) {
            f[curr][j] += f[curr][j - 1];
            f[curr][j] >= MOD ? f[curr][j] -= MOD : 0;
        }
        curr ^= 1, last ^= 1;
        for (int j = 0; j <= K; j++) {
            f[curr][j] = f[last][j] - (j - a[i] - 1 >= 0 ? f[last][j - a[i] - 1] : 0);
            f[curr][j] < 0 ? f[curr][j] += MOD : 0;
        }
    }

    printf("%lld\n", f[curr][K]);
    
    return 0;
}

Measured memory_bytes: 1664
n = int(input())
li = [list(map(int, input().split())) for _ in range(n)]
li_2 = sorted(li, key=lambda x: x[1])
time = 0
for i in range(n):
  time += li_2[i][0]
  if time <= li_2[i][1]:
    if i == n-1:
      print("Yes")
  elif time > li_2[i][1]:
    print("No")
    break;

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

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    long long n,k;
    cin>>n>>k;
    long long ans=(n/k)*(n/k)*(n/k);
    if(k%2==0){
        long long t=((2*n)/k-(n/k));
        ans+=t*t*t;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
n = int(input())
d = []
for i in range(n):
    d.append(input())
# [d1, d2, d3, ..., dN]
a = [int(m) for m in d]#int型に直す
ans = 0
for i in range(n):
    if i == n - 1:
        ans += a[i] // 2
    else:
        ans += a[i] // 2
        ans += (a[i + 1] + a[i] % 2) // 2
        if a[i + 1] > 0:
            a[i + 1] = a[i + 1] + a[i] % 2 - ((a[i + 1] + a[i] % 2) // 2) * 2
        else:
            a[i + 1] = 0
print(ans)

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

int main() {
    int n, q; cin >> n >> q;
    vector<stack<int>> s(n);
    while (q--) {
        int com; cin >> com;
        if (com == 0) {
            int t, x; cin >> t >> x; s[t].emplace(x);
        } else if (com == 1) {
            int t; cin >> t;
            if (!s[t].empty()) cout << s[t].top() << endl;
        } else if (com == 2) {
            int t; cin >> t;
            if (!s[t].empty()) s[t].pop();
        }
    }
    return 0;
}


Measured memory_bytes: 4320
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

bool isBingo(vector<vector<bool> > res)
{
    bool bingo = true;
    for(int i = 0; i < 3; i++){
        bingo = true;
        for(int j = 0; j < 3; j++){
            if(!res[i][j]){
                bingo = false;
            }
        }
        if(bingo){
            return true;
        }
    }

    for(int j = 0; j < 3; j++){
        bingo = true;
        for(int i = 0; i < 3; i++){
            if(!res[i][j]){
                bingo = false;
            }
        }
        if(bingo){
            return true;
        }
    }
    bingo = true;
    for(int j = 0; j < 3; j++){
        if(!res[j][j]){
            bingo = false;
        }
    }
    if(bingo){
        return true;
    }
    bingo = true;
    for(int j = 0; j < 3; j++){
        if(!res[2-j][j]){
            bingo = false;
        }
    }
    if(bingo){
        return true;
    }


    return false;
}

int main(void)
{
    vector<vector<int> > bingo;
    vector<vector<bool> > res;
    for(int i = 0; i < 3; i++){
        vector<int> row;
        vector<bool> rrow;
        for(int j = 0; j < 3; j++){
            int tmp;
            cin >>tmp;
            row.push_back(tmp);
            rrow.push_back(false);
        }
        bingo.push_back(row);
        res.push_back(rrow);
    }
    int n;
    cin >>n;

    for(int k = 0; k < n; k++){
        int tmp;
        cin >>tmp;
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                if(tmp == bingo[i][j]){
                    res[i][j] = true;
                }
            }
        }
    }

    if(isBingo(res)){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

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

using namespace std;

static const ll INF = 1e15;

int main() {
	string s;
	cin >> s;
	int n = s.size();
	ll u = 0;
	ll b = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
			b++;
			u = max(u, b);
		}
		else {
			b = 0;
		}
	}
	cout << u << endl;
	return 0;
}


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

int main()
{


        long long n,m,a,b,c,d,e,f,g,h,p,q,r,fr,sc,tr,sz,tz,i,j,k,mx=LLONG_MIN,mn=LLONG_MAX;
        long long x=0,y=0,cnt=0,res=0,ttl=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr; string str,ttr,ntr;

        scanf("%lld",&n);

        for(i=1;i*i<=n;i++)
        {
            if(n%i==0)
            {
                p=i;  q=n/i;

                r=(p-1)+(q-1);  if(r<mn)mn=r;


            }

        }



        printf("%lld\n",mn);












    return 0;
}





Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a % b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

int main() {
    int x[3];
    rep(i, 3) cin >> x[i];
    rep(i, 3) {
        if(x[i] == x[(i + 1) % 3] && x[i] != x[(i + 2) % 3]) {cout << "Yes" << endl; END;}
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
r,g,b,n = map(int,input().split())
p = 0
for i in range(n+1):
    ri = r*i
    if ri > n:
        break
    else:
        for j in range((n+1)-(r*i)):
            gj = g*j
            if ri + gj > n:
                break
            else:
                if (n - (ri + gj)) % b == 0:
                    p += 1
print(p)

Measured memory_bytes: 9124
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());


//https://www.instagram.com/p/B_Z9Oxdp-Kh/
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int pwmd(int a, int n)
{
	if (!n)
		return 1;
	int pt = pwmd(a, n / 2);
	pt *= pt, pt %= mod;
	if (n & 1)
		pt *= a, pt %= mod;
	return pt;
}
int pow(int a,int b)
{
	int ans=1;
	while(b>0)
	{
		if(b&1)
			ans*=a;
		a*=a;
		b=b>>1;
	}
	return ans;
}
vector<pair<int,int>> vec;
bool compare(pair<int,int> v1,pair<int,int> v2)
{
	return v1.ss<v2.ss;
}
int32_t main()
{       
    FIO;
    int s,w;
    cin>>s>>w;
    if(w>=s)
    	cout<<"unsafe"<<endl;
    else
    	cout<<"safe"<<endl;
   
    return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;


int M,K;
int p2[20];
int a[300000];
int ans[300000];
int main(){
    cin>>M>>K;
    if(M==0){
        if(K==0){
            cout<<"0 0";
        }else{
            cout<<"-1";
        }
        return 0;
    }else if(M==1){
        if(K==0){
            cout<<"0 0 1 1";
        }else{
            cout<<"-1";
        }
        return 0;
    }
    
    p2[0]=1;
    int g,s;
    for(int i=1;i<=M;i++){
        p2[i]=p2[i-1]*2;
        if(p2[i]>K){
            g=p2[i];
            s=p2[i-1];
        }
    }
    int mx=p2[M];
    
    if(K>=mx){
        cout<<"-1";
        return 0;
    }

    cout<<K<<" ";
    for(int i=s;i<g;i++){
        if(i!=K)cout<<i<<" ";
    }
    for(int i=0;i<mx;i++){
        if(i!=K && (i<s||i>=g)){
            cout<<i<<" ";
        }
    }
        cout<<K<<" ";
    for(int i=mx-1;i>=0;i--){
        if(i!=K && (i<s||i>=g)){
            cout<<i<<" ";
        }
    }

    for(int i=g-1;i>=s;i--){
        if(i!=K)cout<<i<<" ";
    }
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int K;
string x;
int ge(string n) {
	return n[n.size() - 1] - '0';
}
int shi(string n) {
	return n[n.size() - 2] - '0';
}
void make(string &x) {
	if(ge(x) >= min(shi(x) + 1, 9)) {
		//进位
		int pos = x.size() - 2;
		while(pos > 0 && x[pos] >= min(char(x[pos - 1] + 1), '9')) {
			pos--;
		}
		if(pos == 0 && x[0] == '9') {
			int len = x.size();
			x = "1";
			for(int i = 1; i <= len; i++)x += "0";
			//cout << x << endl;
			return ;
		}
//		pos++;
		x[pos]++;
		for(int j = pos + 1; j < x.size(); j++) {
			if(x[j - 1] == '0')x[j] = '0';
			else x[j] = x[j - 1] - 1;
		}
	}
	else {
//		printf("****");
//		cout <<ge(x) << ' ' << shi(x) << endl;
		x = x.substr(0, x.size() - 1) + char(ge(x) + '1');
	}
//	cout << x << endl; 
}
int main() {
	cin >> K;
	if(K <= 10) {
		cout << K << endl;
		return 0;
	}
	K -= 10;
	x = "10";
	while(K--) {
		make(x);
	}
	cout << x << endl;
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int hun = n/100;
    int ten = n/10 - hun*10;
    int one = n - hun*100 - ten*10;
    if(hun == ten && ten == one){cout << n << endl;}
    else if(hun == ten && ten >= one){cout << hun << hun << hun << endl;}
    else if(hun > ten ) {cout << hun << hun << hun << endl;}
    else{cout << hun+1 << hun+1 << hun+1 << endl;}
    return 0;
}

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

int main(){
	int N,T;
	cin >> N >> T;
	int c[N],t[N];
	for(int i = 0; i < N; i++)cin >> c[i] >> t[i];
	int min = 1e9;
	for(int i = 0; i < N; i++){
		if(t[i] <= T){
			if(c[i] < min)min = c[i];
		}
	}
	if(min == 1e9)cout << "TLE" << endl;
	else cout << min << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstdlib>
#include<utility>

typedef long long ll;
#define INF 10e9

using namespace std;

int p[12];

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> p[i];
	sort(p, p + n);
	int ans = p[n - 1] / 2;
	for (int i = 0; i < n - 1; i++) ans += p[i];
	cout << ans << endl;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n,k) = get!(usize, usize);
    let a = get!([usize]);

    let sum = a.iter().sum::<usize>();

    let mut divs = BTreeSet::new();
    for i in 1..((sum as f64).sqrt() as usize + 1) {
        if sum % i == 0 {
            divs.insert(i);
            divs.insert(sum/i);
        }
    }

    let mut mx = 0;
    for div in divs { 
        let mut rem = a.iter().map(|&e| e%div).collect::<Vec<_>>();
        rem.sort();
        let rsum = rem.iter().sum::<usize>();
        let need = rem.into_iter().take(n-rsum/div).sum::<usize>();
        if need <= k {
            mx = div;
        }
    }
    println!("{}", mx);
}


Measured memory_bytes: 8572
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
 
 
#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000
 
using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;
typedef string::const_iterator State;
 
int dy[5] = { 0,0,1,-1,0 };
int dx[5] = { 1,-1,0,0 ,0 };
 
 
int main(void) {
	
	string s;
	long long int k;
	long long int point = 0;
 
	cin >> s;
	cin >> k;
 
	FOR(i, 0, s.size() - 1) {
		point = i + 1;
		if (s[i] != '1') {
			cout << s[i] << endl;
			break;
		}
		if (point == k) {
			cout << 1 << endl;
			break;
		}
		if (i == s.size() - 1) {
			cout << 1 << endl;
			break;
		}
		
	}
 
 
	return 0;
}

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

#define all(x) (x).begin(), (x).end()
typedef long long ll;

int main(int argc, char const* argv[])
{
   int a, b;
   cin >> a >> b;
   if(a <= 5)
      cout << 0 << endl;
   else if(a < 13)
      cout << b/2 << endl;
   else
      cout << b << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#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(a) (a).begin(),(a).end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define ub(s,x) upper_bound(all(s),x)-s.begin()
#define uniq(a) a.erase(unique(all(a)),a.end())
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }


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


Measured memory_bytes: 256
#import time

str = raw_input()
K = int(raw_input())

#t_start = time.time()

#print str, K,  len(str)

#dic = []
dic = set()

i = 1

#while i <= len(str):
while i <= K:
    idx = 0
    while True:
        head = idx
        tail = i + idx
        if tail > len(str):
            break
        else:
#            dic.append(str[head:tail])
            dic.add(str[head:tail])
            idx = idx + 1

    i = i + 1


#dic_set = list(set(dic))
#dic_set.sort()
#print dic_set

dic_set = list(dic)
dic_set.sort()


print dic_set[K-1]
#print time.time() - t_start


Measured memory_bytes: 3968
#include <iostream>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

int main() {
  string S;
  cin >> S;
  int difmin = INT_MAX;
  for (int i = 0; i < S.size() - 2; i++) {
    int j = (int)(S[i] - '0');
    int k = (int)(S[i+1] - '0');
    int l = (int)(S[i+2] - '0');
    int num = 100 * j + 10 * k + l;
    if (abs(753 - num) < difmin) {
      difmin = abs(753 - num);
    }
  }
  cout << difmin << endl;
}


Measured memory_bytes: 256
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

void dfs(int now, vector<vector<bool>>pass, vector<bool>& isVisited) {
    int N = pass.size();
    isVisited[now] = true;
    for (int i = 1; i < N; i++) {
        if (pass[now][i] == true && isVisited[i] == false)dfs(i, pass, isVisited);
    }
    return;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<int>a(M),b(M);
    vector<vector<bool>>pass(N+1, vector<bool>(N+1, false));
    for (int i = 0; i < M; i++) {
        cin >> a[i] >> b[i];
        pass[a[i]][b[i]] = pass[b[i]][a[i]] = true;
    }

    int ans = 0;
    for (int i = 0; i < M; i++) {
        vector<bool>isVisited(N + 1, false);
        pass[a[i]][b[i]] = pass[b[i]][a[i]] = false;
        dfs(1, pass, isVisited);
        if (count(isVisited.begin(), isVisited.end(), false) > 1)ans++;
        pass[a[i]][b[i]] = pass[b[i]][a[i]] = true;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String o = input.readLine( );
		String e = input.readLine( );
		String[] oList = o.split("");
		String[] eList = e.split("");
		int max = Math.min(o.length(), e.length());
		for(int i=0; i<max; i++){
			System.out.print(oList[i]);
			System.out.print(eList[i]);
		}
		if(o.length()>e.length()){
			System.out.println(oList[max]);
		}else{
			System.out.println();
		}
	}
}


Measured memory_bytes: 21204
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

ll gcd(ll a, ll b) {
    if(a < b){
        return gcd(b, a);
    }
    ll r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

int main(){
    ll n, x;
    cin >> n >> x;
    vector<ll> xi(n);
    for(int i = 0; i < n; ++i){
        cin >> xi.at(i);
    }
    ll ans = abs(x - xi.at(0));
    for(int i = 1; i < n; ++i){
        ans = gcd(ans, abs(x - xi.at(i)));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;


signed main(){
	int n, m;
	cin >> n >> m;
	vi d(n);
	d[0] = 0;
	rep(i, 1, n){
		cin >> d[i];
	}
	rep(i, 1, n){
		d[i] += d[i - 1];
	}
	int now = 0, ans = 0, mod = 100000;
	rep(i, 0, m){
		int a;
		cin >> a;
		ans += abs(d[now] - d[now + a]);
		now += a;
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1532
#include "iostream"
#include "vector"

using namespace std;

int main(void) {
    vector<int> A={
    	1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
   	
    cin >> K;
    cout << A[K-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 200010
using namespace std;
char s[maxn];
long long a[26];
int main()
{
    scanf("%s",s);
    int n=strlen(s);
    for(int i=0;i<n;i++)
    a[s[i]-'a']++;
    long long ans=0,s=0;
    for(int i=0;i<26;i++)
    {
        s+=a[i];
        ans+=a[i]*a[i];
    }
    ans=(s*s-ans)/2+1;
    cout<<ans<<endl;
return 0;
}



Measured memory_bytes: 384
n = $stdin.gets.to_i
a_org = $stdin.gets.split.map(&:to_i)


a = a_org.sort

max = a[-1]


half = max.to_f / 2

b = a.sort {|i, j| 
  (i-half).abs <=> (j-half).abs
}

puts max
puts b[0]


Measured memory_bytes: 10864
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		Cb r=new Cb(s[0]<<1);
		long ans=0,p1=(s[1]*Fp(100-s[3],mod-2))%mod,p2=(s[2]*Fp(100-s[3],mod-2))%mod;
		for(int i = 0;i<s[0];i++) {
			ans+=((Fp(p1,s[0])*Fp(p2,i))%mod)*((r.C1(s[0]+i-1,i)*(s[0]+i))%mod);
			ans+=((Fp(p1,i)*Fp(p2,s[0]))%mod)*((r.C1(s[0]+i-1,i)*(s[0]+i))%mod);
			ans%=mod;
		}
		ans=(ans*((100*Fp(100-s[3],mod-2))%mod))%mod;
		Console.WriteLine("{0}",ans);
	}
	static long Fp(long x,long e){
		long r=1;
		while(e>0){
			if((e&1)>0){r*=x;r%=mod;}
			x=(x*x)%mod;
			e>>=1;
		}
		return r;
	}
}


public class Sc{
	private string[] a;
	private int n=-1,m=0;
	public int I{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return int.Parse(a[n]);}}
	public long L{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return long.Parse(a[n]);}}
	public double D{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return double.Parse(a[n]);}}
	public string S{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return a[n];}}
	public string Sz{get{return Console.ReadLine();}}
	public int[] Ia{get{if(n!=-1&&n!=a.Length-1){m=n;n=-1;return Array.ConvertAll(a.Skip(m+1).ToArray(),int.Parse);}return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2(int b){return Array.ConvertAll((((b&1)!=0?"0 ":"")+Console.ReadLine()+((b&2)!=0?" 0":"")).Split(),int.Parse);}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public string[] Sa2{get{return (Console.ReadLine()+" 0").Split();}}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
}
public class Cb{
	private const int mod=(int)1e9+7;
	public long[] r;
	public Cb(int n){
		r=new long[n];
		r[0]=1;
		for(int i=1;i<n;i++){r[i]=(r[i-1]*i)%mod;}
	}
	public long C1(long n,long k){return (r[n]*Mi(r[k]*r[n-k]))%mod;}
	public long C2(long n,long k){
		long l=1;
		n%=mod;
		for(int i=1;i<=k;i++){l=(l*(n-i+1))%mod;l=(l*Mi(i))%mod;}
		return l;
	}
	public long P(long n,long k){return (Mi(r[n]*r[n-k]))%mod;}
	public long Mi(long a){
		a=(a+mod)%mod;
		long b=mod,u=1,v=0;
		while(b>0){long t=a/b;a-=t*b;a^=b;b^=a;a^=b;u-=t*v;u^=v;v^=u;u^=v;}
		u%=mod;
		if(u<0){u+=mod;}
		return u%mod;
	}
}


Measured memory_bytes: 14432
#include <cstdio>
#include <string>

int main(int argc, char *argv[]) {
	const int start_day = 3;
	const int days[12] = {
		31, 29, 31, 30, 31, 30,
		31, 31, 30, 31, 30, 31
	};
	const std::string week[] = {
		"Monday", "Tuesday", "Wednesday", "Thursday",
		"Friday", "Saturday", "Sunday"
	};
	
	while (true) {
		int month, day, sum = start_day;
		fscanf(stdin, "%d %d", &month, &day);
		if (month == 0) {
			break;
		}
		sum += day-1;
		for (int i = 0; i < month-1; i++) {
			sum += days[i];
		}
		printf("%s\n", week[sum%7].c_str());
		
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main() {
     int N , X;
     cin >> N >> X;
     vector<int> L(N);
     for(int i = 0;i < N;i++){
          cin >> L[i];
     }

     vector<int> D(N+1);
     D[0] = 0;
     for(int i = 0;i < N;i++){
          D[i+1]=D[i] + L[i];
     }

     int ans = 0;
     for(int i = 0;i < N+1;i++){
          if(D[i] <= X){
               ans++;
          }
     }

     cout << ans << endl;
}

Measured memory_bytes: 256
loop do
  a = gets.split(" ").map{|x| x.to_i}
  h = a[0]
  w = a[1]
  break if h + w == 0
  for i in 1..h do
    for j in 1..w do
      if i % 2 == 1
        printf ((j % 2 == 1) ? "#" : ".")
      else
        printf ((j % 2 == 1) ? "." : "#")
      end
    end
    puts
  end
  puts
end


Measured memory_bytes: 6884
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
typedef long long ll;
#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
  if( ch == 'A') return 1;
  else if( ch == 'C') return 2;
  else if( ch == 'G') return 3;
  else if( ch == 'T') return 4;
  else  return 0;
}

ll getKey(char str[]){
  ll sum = 0,i,p=1;
  rep(i,strlen(str)){
    sum += p*getChar(str[i]);
    p *=3;
  }
  return sum;
}

int h1(int key){ return key % M;}
int h2(int key){ return 1 + (key % (M -1));}


int find(char str[]){
  ll key,i,h;
  key = getKey(str);
  for(int i = 0;; i++){
    h = (h1(key) + i * h2(key)) % M;
    if( strcmp(H[h],str) == 0) return 1;
    else if( strlen(H[h]) == 0) return 0;
  }
  return 0;
}

int insert(char str[]){
  ll key,i,h;
  key = getKey(str);
  for(int i = 0;; i++){
    h = (h1(key) + i * h2(key)) % M;
    key = getKey(str);
    if( strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(){
  int n; cin >> n;
  char str[L], com[9]; //文字と命令
  rep(i,M) H[i][0] = '\0';//?
  rep(i,n){
    scanf("%s %s", com, str);

    if(com[0] == 'i'){
      insert(str);
    }else{
      if(find(str)){
        printf("yes\n");
      }else{
        printf("no\n");
      }
    }
  }
  return 0;
}



Measured memory_bytes: 17432
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

int main(){
    ull L, R;
    cin >> L >> R;
    ull min_m = 2020;
    for(ull i = L; i <= R; i++){
        if(i == L + 2019) break;
        for(ull j = i + 1; j <= R; j++){
            if(j == L + 2019) break;
            min_m = min(min_m, (i * j) % 2019);
        }
    }
    cout << min_m << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAXNUM 111111
#define rep(i,s,t) for(int i=s;i<t;i++)
typedef long long ll;
const ll mod=1e9+7;
vector<int> e[MAXNUM];int degree[MAXNUM];
int n,k;ll res=1;int fa[MAXNUM];
int q[MAXNUM],top,front;
int main()
{
    int a,b;scanf("%d%d",&n,&k);
    rep(i,1,n)scanf("%d%d",&a,&b),e[a].push_back(b),e[b].push_back(a);
    q[top++]=1;degree[0]=-1;
    while(top!=front)
    {
        int x=q[front++];
        degree[fa[x]]++;
        res=res*max(0,k-degree[fa[x]])%mod;
        for(int k:e[x])
            if(k!=fa[x])
            fa[k]=x,q[top++]=k,degree[k]++;
    }
    printf("%lld\n",res);
}

Measured memory_bytes: 7544
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n,k;
    cin >> n >> k;
    vector<ll> x(n);
    REP(i,n)cin >> x[i];
    ll answer = 1000000000;
    int l=0;
    if(k  == 1){
        REP(i,n)answer = min(answer,llabs(x[i]));
        cout << answer << endl;
        return 0;
    }
    
    int r = k-1;
    while(r < n){
        answer = min(answer,llabs(x[l])+llabs(x[r]-x[l]));
        answer = min(answer,llabs(x[r])+llabs(x[r]-x[l]));
        l++;
        r++;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>


void swap(int *x, int *y)
{
  int tmp;

  tmp = *x;
  *x = *y;
  *y = tmp;
 
}


int selectionSort(int *A, int N) // N個の要素を含む0-オリジンの配列A
{
  int minj, tmp;
  int count = 0;
  
  for(int i=0; i<N; i++){
    minj = i;
    for(int j=i; j<N; j++){
      if (A[j] < A[minj])
        minj = j;
    }
    if (i != minj) {
      swap(&A[i], &A[minj]);
      count++;
    }
  }

  return count;
}

int main(void)
{
  int A[100], N, i;
  int count;
  
  scanf("%d",&N);
  for(i=0;i<N;i++) {
    scanf("%d", &A[i]);//配列読み込み
  }    

  count = selectionSort(A, N);

  for (int i = 0; i< N-1; i++)
    printf("%d ", A[i]);
  printf("%d\n", A[N-1]);

  printf("%d\n", count);

  return 0;
}

  



Measured memory_bytes: 2096