akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

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


class Median {
    priority_queue<ll> low;
    priority_queue<ll, vector<ll>, greater<ll> > high;
    ll lsum, hsum;

public:
    Median() {
        low.push(-1e18);
        high.push(1e18);
        lsum = hsum = 0;
    }

    // [1, 2, 3] [3, 5, 6]
    void update(ll x) {
        if (low.top() > x) {
            low.push(x);
            lsum += x;
        } else {
            high.push(x);
            hsum += x;
        }
        while (low.size() > high.size()) {
            hsum += low.top();
            lsum -= low.top();
            high.push(low.top());
            low.pop();
        }

        while (high.size() > low.size() + 1) {
            hsum -= high.top();
            lsum += high.top();
            low.push(high.top());
            high.pop();
        }
    }


    pair<ll, ll> query() {
        if (high.size() > low.size()) {
            assert(high.size() == low.size() + 1);
            ll med = high.top();
            ll sum = med * low.size() - lsum;
            sum += hsum - med * high.size();
            return {med, sum};
        } else {
            assert(high.size() == low.size());
            ll med = low.top();
            ll sum = med * low.size() - lsum;
            sum += hsum - med * high.size();
            return {med, sum};
        }
    }


};

int main() {

    int Q;
    cin >> Q;
    Median med;

    ll ans = 0;
    for (int i = 0; i < Q; i++) {
        int a;
        cin >> a;
        if (a == 1) {
            int b, c;
            cin >> b >> c;
            med.update(b);
            ans += c;
        } else {
            auto r = med.query();
            cout << r.first << " " << r.second + ans << endl;
        }
    }

}


Measured memory_bytes: 3828
#include<stdio.h>

int main(void) {
	int N, K, Q, a, i, flg;
	scanf("%d %d %d", &N, &K, &Q);

	int member[N];
	for (i = 0; i < N; i++) {
		member[i] = 0;
	}

	for (i = 0; i < Q; i++) {
		scanf("%d", &a);
		member[a - 1]+=1;
	}

	for (i = 0; i < N; i++) {
		//flg = K - Q + member[i];
		if ((K - Q + member[i]) > 0)printf("Yes\n");
		else printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int a=S.size();
  int b=0;
  for(int i=0;i<a-1;i++){
    for(int j=i+1;j<a;j++){
      if(S.at(i)==S.at(j)){
        cout<<"no"<<endl;
        b=1;
        break;
      }
      if(b==1)
        break;
    }
    if(b==1)
      break;
  }

 if(b==0)
   cout<<"yes"<<endl;
  
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string s1,s2;
   while(cin>>s1>>s2)
   {
       int len=0;
       len=s1.size();
       int len2=0;
       len2=s2.size();
       len2--;
       int ck=0;
       for(int i=0;i<len;i++)
       {
          if(s1[i]==s2[len2])
          {
              len2--;
          }
          else
          {
              ck=1;
              break;
          }
       }
       if(ck==1)
       {
           cout<<"NO"<<endl;
       }
       else
       {
           cout<<"YES"<<endl;
       }
   }


   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long
#define ull unsigned long long
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define vi vector<int>
#define pb push_back
#define F first
#define S second
#define REP(i,a,b) for(ll i = a; i < b; i++)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define pi 3.1415926535897932384626433

struct compare
{
	int val;
	compare(int const &i): val{i} {}

	bool operator()(const int& i) const
	{
		return (i == val);
	}
};

int main(){
    faster;
    int n, m;
    cin >> n >> m;

    int a[m], sum = 0;
    REP(i,0,m) {
        cin >> a[i];
        sum += a[i];
    }

    if(sum > n) {
        cout << -1 << "\n";
    } else if(sum == n) {
        cout << 0 << "\n";
    } else {
        cout << n - sum << "\n";
    }

    return 0;
}

Measured memory_bytes: 3712
import math


def solve():
    N = int(input())
    lowercase = 'abcdefghijklmnopqrstuvwxyz'
    ans = ''
    for i in range(len(str(N))):
        if N == 0:
            break
        j = N % 26
        N -= 1
        N = N // 26
        ans = lowercase[j - 1] + ans
    print(ans)


if __name__ == '__main__':
    solve()


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

using namespace std;

#define pb push_back
#define ll long long
#define MX 1000009

bool marked[MX+1];

ll gcd(ll a, ll b)
{
    return b == 0 ? a : gcd(b, a % b);
}

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

void sieve()
{
    marked[0] = true;
    marked[1] = true;
    for(int i = 4; i <= MX; i += 2)
        marked[i] = true;
    for(ll i = 3; i * i <= MX; i += 2)
    {
        for(ll j = i * i; j <= MX; j += i)
             marked[j] = true;
    }
}

int main()
{
    //cout << "Hello world!!" << endl;
 int n;
 cin >> n;
 int tot = n;
 int odd;
 if( n % 2 == 0)odd = n / 2;
 else odd = ( n / 2) + 1;
 double ans = (odd * 1.0) / tot;
 //cout << ans << endl;
printf("%0.10f\n", ans);

    return 0;
}


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

int main()
{
    int H, W, D, Q;
    cin >> H >> W >> D;

    int A, x[H * W], y[H * W];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A;
            x[A] = i;
            y[A] = j;
        }
    }

    cin >> Q;
    int L[Q], R[Q];
    for (int i = 0; i < Q; i++) cin >> L[i] >> R[i];

    int d[H * W + 1] = {};
    for (int i = D + 1; i <= H * W; i++) {
        d[i] = d[i - D] + abs(x[i] - x[i - D]) + abs(y[i] - y[i - D]);
    }

    for (int i = 0; i < Q; i++) {
        cout << d[R[i]] - d[L[i]] << endl;
    }

    return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>v(8,0);
	int gm=0;
	for(int i=0;i<n;++i){
		int a; cin>>a; a/=400;
		if(a<8)v.at(a)=true;
		else ++gm;
	}
	int mn=accumulate(v.begin(),v.end(),0);
	int mx=mn+gm;
	if(!mn&&gm)++mn;
	cout<<mn<<" "s<<mx<<"\n"s;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){
        int i,n,ans=0,u,v,mn,mx,k1,k2;
        cin>>n;
        for(i=1;i<=n;i++){
            ans+=(i*(i+1))/2;
        }
        for(i=1;i<n;i++){
            cin>>u>>v;
            mn=min(u,v);
            mx=max(u,v);
            k1=n-mx;
            k2=mn-1;
            k1++;
            k2++;
            ans-=(k1*k2);
        }
        cout<<ans;
    return 0;
}

Measured memory_bytes: 3632
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define add(x) accumulate(x)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end() 
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
const long double pie = 3.141592653589793238;
//
//
                void solve(){
                        ll n,m;
                        cin>>n>>m;
                        ll sm =0;
                        while(m--){
                                ll x;
                                cin>>x;
                                sm += x;
                        }
                        if(sm > n)
                                cout<<-1;
                        else
                                cout<<n-sm;
                }
                int main(){ 
                        hs;
                        ll t;
                        t=1;
                        // cin>>t;
                        for (int i=1; i<=t; i++){
                                //cout<<"Case #"<<i<<": ";
                                solve();
                         }
        return 0; 
}         
 

Measured memory_bytes: 3656
K = input().split()
N = int(K[0])
M = int(K[1])

if N >= 2 and M >= 2:
    print((N-2)*(M-2))
elif N == 1 and M >= 2:
    print(M-2)
elif N >= 2 and M == 1:
    print(N-2)
elif N == 1 and M == 1:
    print(1)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}


struct edge{
    int to;
    int cap;
    int rev;
    edge(){}
    edge(int to, int cap, int rev) : to(to), cap(cap), rev(rev) {}
};

int N;
vector<edge> G[110];
bool used[110];

void add_edge(int from, int to, int cap){
    G[from].push_back({to, cap, (int)G[to].size()});
    G[to].push_back({from, 0, (int)G[from].size() - 1});
}

int dfs(int v, int t, int f){
    if(v == t) return f;
    used[v] = true;
    for(auto& e : G[v]){
        if(!used[e.to] && e.cap > 0){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t){
    int flow = 0;
    while(true){
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, inf);
        flow += f;
        if(f == 0) break;
    }
    return flow;
}


int V, E;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> V >> E;

    for(int i = 0; i < E; i++){
        int u, v, c;
        cin >> u >> v >> c;
        add_edge(u, v, c);
    }
    cout << max_flow(0, V - 1) << endl;
    return 0;
}


Measured memory_bytes: 3236
using System;
using System.Collections.Generic;
using System.Linq;

namespace Welcome_to_AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var monsterArray = Console.ReadLine().Split().Select(_ => decimal.Parse(_)).ToArray();
            var heroArray = Console.ReadLine().Split().Select(_ => decimal.Parse(_)).ToArray();

            var killedMonsterCount = 0M;

            for (int i = 0; i < heroArray.Length; i++)
            {
                var monsterCount = monsterArray[i];
                var heroKillableCount = heroArray[i];
                if (monsterCount < heroKillableCount)
                {
                    killedMonsterCount += monsterCount;
                    heroKillableCount -= monsterCount;

                    var nextMonsterCount = monsterArray[i + 1];
                    if (nextMonsterCount < heroKillableCount)
                    {
                        killedMonsterCount += nextMonsterCount;
                        monsterArray[i + 1] = 0;
                    }
                    else
                    {
                        killedMonsterCount += heroKillableCount;
                        monsterArray[i + 1] -= heroKillableCount;
                    }
                }
                else
                {
                    killedMonsterCount += heroKillableCount;
                }
            }

            Console.WriteLine(killedMonsterCount);
        }
    }
}


Measured memory_bytes: 42304
S = input()
l = len(S)

seikai1 = [i % 2 for i in range(l)]
seikai2 = [1 ^ i for i in seikai1]

out = min(sum(i ^ int(j) for i, j in zip(seikai1, S)), \
          sum(i ^ int(j) for i, j in zip(seikai2, S)))
print(out)

Measured memory_bytes: 4724
#include <stdio.h>
#include <cmath>
#include <algorithm>

#define NUM 250000

int main(){
	int table[NUM],limit;

	for(int i=0; i < NUM;i++)table[i] = 1;
	table[0] = 0;
	table[1] = 0;

	limit = sqrt(NUM);

	for(int i=2;i<=limit;i++){
		if(table[i] == 1){
			for(int k=2*i;k < NUM; k += i){
				table[k] = 0;
			}
		}
	}

	int n,count,start,finish;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		count = 0;

		if(n%2==0){
			start = n+1;
		}else{
			if(n == 1){
				printf("1\n");
				continue;
			}else{
				start = n+2;
			}
		}

		finish = 2*n;

		for(int i=start; i<= finish; i += 2){
			if(table[i] == 1)count++;
		}
		printf("%d\n",count);
	}
	return 0;
}

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

int main() {
  string S, T;
  int count = 0;
  cin >> S >> T;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] != T[i]) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3920
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String str;
        int a, b;
        String op;
        while(true) {
            str = scan.nextLine();
            String[] num = str.split(" ", 0);

            a = Integer.valueOf(num[0]);
            b = Integer.valueOf(num[2]);
            op = num[1];
            if(op.equals("?")){
                break;
            }
            if(op.equals("+")){
                System.out.println(a+b);
            }else if(op.equals("-")){
                System.out.println(a-b);
            }else if(op.equals("*")){
                System.out.println(a*b);
            }else if(op.equals("/")){
                System.out.println(a/b);
            }
        }
        scan.close();
    }
}


Measured memory_bytes: 26376
#include<iostream>
using namespace std;
int main(){

  long long int n,a,b;
  cin>>n>>a>>b;
  b=b-a;
  a=0;
  
   cout<<max((long long int)0,b*(n-1)+a-(a*(n-1)+b)+1)<<endl;
  
return 0;
}


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

int main() {
    string A, B;
    cin >> A >> B;
    if (A.length()!=B.length()-1) {
        cout << "No" << endl;
        return 0;
    }
    if (A!=B.substr(0,A.length())){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
const int N=2005,mod=924844033;
int n,K,f[N][N][4],fac[N],g[N],tmp[N];
int main(){
	fac[0]=1;
	for(int i=1;i<=2000;i++)fac[i]=1ll*fac[i-1]*i%mod;
	scanf("%d%d",&n,&K);
	f[0][0][0]=1;
	for(int i=1;i<=n/K;i++)
		for(int j=0;j<i;j++)
			for(int S=0;S<4;S++){
				if(!f[i-1][j][S])continue;
				int l=S&2,r=S&1;
				if(!l&&i>1)(f[i][j+1][r<<1]+=f[i-1][j][S])%=mod;
				if(i<n/K)(f[i][j+1][r<<1|1]+=f[i-1][j][S])%=mod;
				(f[i][j][r<<1]+=f[i-1][j][S])%=mod;
			}
	g[0]=1;
	for(int res=0;res<K;res++){
		int tot=(n-res)/K+(res!=0);
		if(tot!=n/K)continue;
		memset(tmp,0,sizeof(tmp));
		for(int i=0;i<=n;i++){
			if(!g[i])continue;
			for(int j=0;j<=tot&&i+j<=n;j++){
				int sum=0;
				for(int k=0;k<4;k++)sum=(sum+f[tot][j][k])%mod;
				if(!sum)continue;
				tmp[i+j]=(tmp[i+j]+1ll*sum*g[i])%mod;
			}
		}
		memcpy(g,tmp,sizeof(tmp));
	}
	memset(f,0,sizeof(f));
	f[0][0][0]=1;
	for(int i=1;i<=n/K+1;i++)
		for(int j=0;j<i;j++)
			for(int S=0;S<4;S++){
				if(!f[i-1][j][S])continue;
				int l=S&2,r=S&1;
				if(!l&&i>1)(f[i][j+1][r<<1]+=f[i-1][j][S])%=mod;
				if(i<n/K+1)(f[i][j+1][r<<1|1]+=f[i-1][j][S])%=mod;
				(f[i][j][r<<1]+=f[i-1][j][S])%=mod;
			}
	for(int res=0;res<K;res++){
		int tot=(n-res)/K+(res!=0);
		if(tot==n/K)continue;
		memset(tmp,0,sizeof(tmp));
		for(int i=0;i<=n;i++){
			if(!g[i])continue;
			for(int j=0;j<=tot&&i+j<=n;j++){
				int sum=0;
				for(int k=0;k<4;k++)sum=(sum+f[tot][j][k])%mod;
				if(!sum)continue;
				tmp[i+j]=(tmp[i+j]+1ll*sum*g[i])%mod;
			}
		}
		memcpy(g,tmp,sizeof(tmp));
	}
	int ans=0;
	for(int i=0,coef=1;i<=n;i++,coef=-coef)ans=(ans+1ll*coef*g[i]*fac[n-i])%mod;
	cout<<(ans+mod)%mod<<"\n";
}

Measured memory_bytes: 63104
//#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) {

	int n;
	bool flag = false;

	cin >> n;

	FOR(i, 0, 25) {
		FOR(j, 0, 14) {
			if (i * 4 + j * 7 == n) {
				flag = true;
			}
		}
	}

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

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2) //O2ÓÅ»¯£¿

#include<bits/stdc++.h>
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define BINF 0x7fffffff
#define INF 0x3f3f3f3f
#define LINF 9223372036854775807
#define END(s) {cout<<s;return 0;}
#define CON(s) {cout<<s;continue;}
#define BRE(s) {cout<<s;break;}
#define pb push_back
#define All(a) a.begin(),a.end()  //with A in CAPITAL!!!
#define sz(a) (int)a.size()
#define F first
#define S second
#define LOCAL_JUDGE 1 //remember to change
using namespace std;
int a[1010];
int main(){
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) a[i]=i;
	long long res=1;
	for(int i=2;i<=n;i++){
		long long ans=0;
		for(int j=2;j<=n;j++){
			while(!(a[j]%i)){
				a[j]/=i;
				ans++;
			}
///			cout<<i<<" "<<j<<" "<<ans<<endl;
		}
		res=(res*(ans+1))%1000000007;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
def f(n,m,k,h);n==0?h:f(n-1,m,k,(1..m).map{|x|h.map{|s,c|[s+x,c]}.to_h}.inject{|a,b|a.merge!(b){|_,u,v|u+v}});end
while(n,m,k=gets.split.map &:to_i;n>0);p f(n,m,k,{0=>1}).map{|s,c|[s-k,1].max*c}.inject(:+).to_f / m ** n;end

Measured memory_bytes: 21640
#include<iostream>
using namespace std;
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<cmath>
#define int long long int
int binary_search(int arr[],int n,int start,int end,int k)
{
	if(start>end)
	    return -1;
	else
	{
		int mid=(start+end)/2;
		int total=0;
		int j;
		for(j=0;j<n;j++)
		{
			int here=arr[j]/mid;
			if(arr[j]%mid==0)
			   here--;
			total+=here;
		}
		if(total<=k)
		{
			int x=mid;
			int y=binary_search(arr,n,start,mid-1,k);
			if(y==-1)
			   return x;
			else
			   return y;
		}
		else
		   return binary_search(arr,n,mid+1,end,k);
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,k;
	cin>>n>>k;
	int j,arr[n];
	for(j=0;j<n;j++)
	   cin>>arr[j];
	int answer=binary_search(arr,n,1,10000000000,k);
	cout<<answer<<endl;
}


Measured memory_bytes: 5172
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[500][500];

ll count(ll p){
  ll ans = 0;
  while(p > 0){
    ans++;
    p /= 10;
  }
  return ans;
}

int main(){
  cin >> n;
  m = INF;
  for(ll i = 1;i * i <= n;i++){
    if(n % i == 0){
      m = min(m,max(count(i),count(n / i)));
    }
  }
  print(m);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll r;
    cin >> r;
    printf("%.10f\n", 2 * r * 3.14159265358);
    return 0;
}


Measured memory_bytes: 3784
"use strict"
function pow5(i) {
    return Math.pow(i , 5)
}
function main(arg) {
    const MAX_INT = Number.MAX_SAFE_INTEGER 
    // const MAX_INT = 10000
    let X = Number(arg.trim().split("\n")[0])
    // let list = []
    // for (let i = 0; i < 50000; i++) {
    //     let a = Math.pow(i , 5)
    //     list.push(a)
    //     if (a > Math.pow(10, 9)) {
    //         break
    //     }
    //     // console.log(Math.pow(i , 5))
    // }
    let finish = false
    for (let i = 0; i < MAX_INT; i++ ) {
        let A = pow5(i)
        // +
        for (let j = 0; j < MAX_INT; j++) {
            let B = pow5(j)
            if (A - B === X) {
                console.log([i, j].join(" "))
                finish = true
                break
            }
            if (j > 0) {
                let _B = pow5(j - 1)
                if (Math.abs(X - (A - B)) > Math.abs(X - (A - _B))) {
                    break
                }
            }
        }
        if (finish) return
        // -
        for (let j = 0; j < MAX_INT; j++) {
            let B = pow5(j) * -1
            if (A - B === X) {
                console.log([i, j * -1].join(" "))
                finish = true
                break
            }
            if (j > 0) {
                let _B = pow5(j - 1) * -1
                if (Math.abs(X - (A - B)) > Math.abs(X - (A - _B))) {
                    break
                }
            }
        }
        if (finish) return
    }
    // console.log()
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 32412
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    double L;
    cin >> L;
    printf("%lf\n", (L / 3) * (L / 3) * (L / 3));
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int Q;
    cin >> Q;
    REP(q, Q) {
        string X, Y;
        cin >> X >> Y;
        int len_x = X.length(), len_y = Y.length();
        vector<vector<int>> dp(len_x + 1, vector<int>(len_y + 1));

        FOR(i, 1, len_x)
             FOR(j, 1, len_y) {
                 if(X[i-1] == Y[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
                 else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
             }
             
        cout << dp[len_x][len_y] << endl;
    }
    return 0;
}


Measured memory_bytes: 6804
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
    long int A, B, K;

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

    K = A + B;

    K = K / 2;

    A = (A - K);

    B = (B - K);

    A = abs(A);

    B = abs(B);

    if (A == B)
    {
        printf("%d", K);
    }

    else
    {
        printf("IMPOSSIBLE");
    }


    return 0;
}


Measured memory_bytes: 1704
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,l,r) for(int i=l;i<r;i++)
#define LINF (ll)1e18
#define INF (int)1e9
struct aaa{aaa(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(10);};}aaaaaaa;
inline void in() {}
template <class Head, class... Tail>
inline void in(Head&& head,Tail&&... tail){
    cin>>head;
    in(move(tail)...);
}
template <class T>
inline void out(T t) {
    cout<<t<<'\n';
}
template <class Head, class... Tail>
inline void out(Head head,Tail... tail){
    cout<<head<<' ';
    out(move(tail)...);
}

int main(){
#define int ll
    int n;
    in(n);
    vector<int> a(n);
    rep(i,0,n){
        in(a[i]);
        a[i]-=i;
    }
    sort(a.begin(), a.end());
    int ans=0;
    rep(i,0,n){
        ans+=abs(a[i]-a[n/2]);
    }
    out(ans);
}




















Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
// #define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int p,q,a,n;

int rec(int x,int y,int c,int b){
    if(c>n)return 0;
    if(x*q==y*p)return 1;
    if(x*q>y*p)return 0;
    int ret=0;
    for(int i=b;y*i<=a;i++){
        ret+=rec(x*i+y,y*i,c+1,i);
    }
    return ret;
}

void run(){
    cin>>p>>q>>a>>n;
    if(!p)return;
    cout<<rec(0,1,0,1)<<endl;
    run();
}


Measured memory_bytes: 3028
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a,const void *b){
  return *(char*)b - *(char*)a;
}

int main(){
  char s[200001] = {};
  char t[200001] = {};
  char letter[26] = {};
  int lcnt = 0;
  int n = 0;
  int i = 0;
  int flag = 1;
  scanf(" %s",s);
  scanf(" %s",t);
  for(i=0;i<200001;i++){
    if(s[i] == '\0'){
      break;
    }
  }
  n = i;
  for(i=0;i<26;i++){
    letter[i] = 'X';
  }
  
  for(i=0;i<n;i++){
    if(letter[s[i] - 'a']  == 'X'){
      letter[s[i] - 'a'] = t[i];
      lcnt++;
    }else if(letter[s[i] - 'a'] != t[i]){
      flag = 0;
      break;
    }
  }
  //printf("%d",n);
  /*for(i=0;i<26;i++){
    printf("%c",letter[i]);
  }*/
  qsort(letter,26,sizeof(char),cmp);
  for(i=1;i<lcnt;i++){
    if(letter[i] == letter[i-1]){
      flag = 0;
    }
          //printf("%c %d",letter[i],lcnt);
  }
  if(flag){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

#define int long long

const int N = 2e5 + 10;

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);    
  int n, d;
  cin >> n >> d;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    ans += x * x + y * y <= d * d;
  }
  cout << ans;
  return 0;
}

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

bool c[300001];
int p,d;

bool solve(int k){

  if(k > d) return false;
  if(c[k]) return true;

  return solve(k+p);
}


int main(){

  int n,q,a;
  scanf("%d %d", &n, &q);

  for(int i=0;i<n;i++){
    scanf("%d", &a);
    c[a] = true;
    d = max(d, a);
  }

  while(q--){
    scanf("%d", &p);

    for(int i=p-1;i>=0;i--){
      if(solve(i)){
	printf("%d\n", i);
	break;
      }
    }

  }
}

Measured memory_bytes: 1480
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]

    A.sort()

    if N % 2 == 0:
        ans = sum(A[N // 2:]) * 2 - A[N // 2] - sum(A[:N // 2]) * 2 + A[N // 2 - 1]
    else:
        ans = sum(A[N // 2:]) * 2 - A[N // 2] - A[N // 2 + 1] - sum(A[:N // 2]) * 2
        ans = max(ans, sum(A[N // 2 + 1:]) * 2 - sum(A[:N // 2 + 1]) * 2 + A[N // 2] + A[N // 2 - 1])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 13716
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
  
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    int a[n + 5], s;
    reps(i,n){
      cin >> a[i];
      if(a[i] == 1){
	s = i;
      }
    }
    k --;
    int sum = 0;
    sum += (s - 1)/k;
    if((s - 1)%k){
      n += (s - 1)%k;
    }
    cout << sum + UPDight((n - s),k) << '\n';
    return 0;
}


Measured memory_bytes: 640
'''
　　2 2
入力2 0などの場合誤答がでる
　　2 9
'''
n,m = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(m)]

if n>1:#先頭が指定されない場合の最小値を予め入れておく
    b=[pow(10,n-1)]
else:
    b=[0]

count=0
for i in range(0,m):#指定された数字を桁数倍してbに代入
    b.append(A[i][1]*pow(10,n-A[i][0]))
    if n-A[i][0]==n-1:#このとき先頭が指定されたら、count+=1
        count+=1

if count>0 and n>1:#先頭が指定された場合(count>0)は最小値を削除
    b.remove(pow(10,n-1))
elif count>0 and n<=1:
    b.remove(0)
    
b=list(set(b))#ダブりの排除

if n>1:#0が指定された場合は0を削除する(そのため同じ桁に0とそれ以外が入ると-1を出力できない)
    b=[i for i in b if i != 0]

c=[]
for i in range(len(b)):#bに入っている数字の桁数をcに代入
    c.append(len(str(b[i])))
c=list(set(c))#ダブりが存在する場合は同じ桁に対し数字が複数回指定されている

if len(b)==len(c) and len(str(sum(b)))==n:#もしlen(b)==len(c)かつb内を全て合計した桁数がnと一致するならそれが最小
    print(sum(b))
else:
    print(-1)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws Exception {
    try (final var stdin = new InputStreamReader(System.in);
         final var br = new BufferedReader(stdin)) {
      final var s = br.readLine();
      final var t = br.readLine();

      var maxValue = Integer.MAX_VALUE;
      for (int i = 0; i < s.length() - t.length() + 1; i++) {
        final var sub = s.substring(i, i + t.length());

        var diffCount = 0;
        for (int j = 0; j < sub.length(); j++) {
          if (sub.charAt(j) != t.charAt(j)) {
            diffCount++;
          }
        }
        maxValue = Math.min(diffCount, maxValue);
      }

      System.out.println(maxValue);
    }
  }
}


Measured memory_bytes: 33108
#include <iostream>
#include <string>
#include <vector>

using namespace std;

vector<string> buf;
int row;
int column;
string rem;

main(){
  string in;
  while(getline(cin, in)){
    if(in == "END_OF_TEXT") break;
    in += '\n';
    buf.push_back(in);
  }
  char c;
  row = 0;
  column = 0;
  while(cin >> c){
    if(c == '-') break;
    switch(c){
      case 'a':
        column = 0;
        break;
      case 'e':
        column = (int)buf[row].size()-1;
        break;
      case 'p':
        column = 0;
        if(row > 0) --row;
        break;
      case 'n':
        column = 0;
        if(row+1 < buf.size()) ++row;
        break;
      case 'f':
        if(column+1 >= buf[row].size()){
          if(row+1 < buf.size()){
            column = 0;
            ++row;
          }
        }else{
          ++column;
        }
        break;
      case 'b':
        if(column == 0){
          if(row > 0){
            --row;
            column = (int)buf[row].size()-1;
          }
        }else{
          --column;
        }
        break;
      case 'd':
        if(column+1 == buf[row].size()){
          if(row+1 != buf.size()){
            buf[row].erase((int)buf[row].size()-1);
            buf[row] += buf[row+1];
            vector<string>::iterator ite = buf.begin();
            for(int i=0;i<row+1;i++) ++ite;
            buf.erase(ite);
          }
        }else{
          buf[row].erase(column, 1);
        }
        break;
      case 'k':
        rem = "";
        if(column+1 == buf[row].size()){
          if(row+1 != buf.size()){
            buf[row].erase((int)buf[row].size()-1);
            buf[row] += buf[row+1];
            vector<string>::iterator ite = buf.begin();
            for(int i=0;i<row+1;i++) ++ite;
            buf.erase(ite);
            rem += '\n';
          }
        }else{
          for(int i=column;i+1<buf[row].size();++i){
            rem += buf[row][i];
          }
          string::iterator ite = buf[row].begin();
          for(int i=0;i<column;i++) ++ite;
          buf[row].erase(ite, buf[row].end());
          buf[row] += '\n';
        }
        break;
      case 'y':
        if(rem.size() != 0){
          int irem;
          string back = buf[row].substr(column);
          buf[row] = buf[row].substr(0, column);
          for(irem = 0;irem<rem.size();irem++){
            buf[row] += rem[irem];
            ++column;
            if(rem[irem] == '\n'){
              vector<string>::iterator ite = buf.begin();
              for(int i=0;i<row+1;i++) ++ite;
              buf.insert(ite, "");
              column = 0;
              ++row;
            }
          }
          buf[row] += back;
        }
        break;
    }
  }
  for(int i=0;i<buf.size();i++){
    cout << buf[i];
  }
  return 0;
}

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

int main(){

    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A.at(i);

    ll money = 1000, num = 0;
    for(int i=0; i<N-1; i++){
        if(A.at(i)<A.at(i+1)){
            num = money/A.at(i);
            money -= num*A.at(i);
            money += num*A.at(i+1);
        }
    }

    cout << money << endl;
    return 0;
}

Measured memory_bytes: 3600
n,m = map(int,input().split())
pl = list(map(int,input().split()))

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(n)

for _ in range(m):
    x,y = map(int,input().split())
    uf.union(x-1, y-1)

ans = 0
for idx, p in enumerate(pl):
    if uf.same(idx, p-1):
        ans += 1

print(ans)




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

int main(){
int N;
   int count1 = 0; 
  int count2 = 0; 
  cin >> N;
  vector<int> A(N);
  for(int i=0;i < N;++i)
    cin >> A[i];
sort(A.begin(),A.end());
  cout << A[N/2]-A[N/2-1] << endl;


}

Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;
using uint = unsigned int;
using int64 = long long;
using i64 = int64;
using uint64 = unsigned long long;
using vint = vector<int>;
using vint64 = vector<int64>;
template<typename T>
using p_que = priority_queue<T>;
#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 fs first
#define sc second
#define eb emplace_back
#define all(x) x.begin(),x.end()

template<typename T>
vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "[";
	for (auto& e : v) os << e << ", ";
	return os << "]";
}

template<class T, class U> ostream& operator<<(ostream& os, const vector<pair<T, U>> p) {
	os << "P(" << p.first << ", " << p.second << endl;
}

/*
template<class T, class U> ostream& operator<<(ostream& os, const map<T, U>& mp) {
	os << "{";
	for (auto& e : mp) os << P << " ";
	return os << "}";
}
*/

void Main();
signed main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	Main();
}

/* Insert from here! */
template <typename Monoid>
struct SegmentTree {
	using F = function<Monoid(Monoid, Monoid)>;
	int sz;
	vector<Monoid> seg;

	const F f;
	const Monoid M1;

	SegmentTree(int n, const F f, const Monoid& M1) : f(f), M1(M1) {
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid& x) {
		seg[k + sz] = k;
	}

	void build() {
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid& x) {
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b) {
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid operator[](const int& k) const {
		return seg[k + sz];
	}
};

/* Cut from here! */

using pint = pair<int, int>;
struct LOG { int d, t, x; };

void Main() {
	int N, R, L; cin >> N >> R >> L;
	priority_queue<pint> que;
	rep(i, N) que.emplace(0, i*-1);
	vector<int> score(N, 0);
	vector<int> time(N, 0);

	int prevtime = 0;
	int looks, lookt;
	rep(i, R) {
		int t, d, x; cin >> d >> t >> x;
		while (1) {
			tie(looks, lookt) = que.top();
			lookt *= -1;
			if (score[lookt] == looks) break;
			else que.pop();
		}
		// 時間更新
		time[lookt] += t - prevtime;
		prevtime = t;
		//cout << "  add team : " << lookt << endl;
		// 得点更新
		score[d - 1] += x;
		que.emplace(score[d - 1], (d - 1)*-1);
		//cout << "  score : " << score << endl;
	}
	// 最後の時間更新
	while (1) {
		tie(looks, lookt) = que.top();
		lookt *= -1;
		if (score[lookt] == looks) break;
		else que.pop();
	}
	time[lookt] += L - prevtime;
	
	int maxtime=-1, ans;
	//cout << time;
	rep(i, N) {
		if (maxtime < time[i]) {
			maxtime = time[i];
			ans = i + 1;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 11820
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
    ll n; cin >>n;
    string s,t;cin >> s >>t;s+='1';
    vl v;
    for(int i=0;i<n;++i){
        if(s[i]==s[i+1]){
            v.pb(2);
            i++;
        }
        else v.pb(1);
    }
    ll ans;
    if(v[0]==1)ans=3;
    else ans=6;
    rep(i,v.size()-1){
        if(v[i]==1&&v[i+1]==1)ans*=2;
        if(v[i]==1&&v[i+1]==2)ans*=2;
        if(v[i]==2&&v[i+1]==1)ans*=1;
        if(v[i]==2&&v[i+1]==2)ans*=3;
        ans%=MOD;
    }
    cout <<ans <<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() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, a;
  cin >> n >> a;

  cout << n * n - a << endl;
  return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc091/tasks/abc091_a
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    map<string, int> mp1, mp2;
    string t;
    int n, m;
    cin >> n;
    REP(i, n) {
        cin >> t;
        mp1[t]++;
    }
    cin >> m;
    REP(i, m) {
        cin >> t;
        mp2[t]++;
    }
    int maxv = 0;
    for (auto &x : mp1) {
        maxv = max(maxv, x.second - mp2[x.first]);
    }
    cout << maxv << endl;

    return 0;
}

Measured memory_bytes: 256
#define r(i)for(i=0;i++<n;)
g[101][101],h[101][101];a,b,c;k;x;main(n){scanf("%d%*d",&n);r(a)r(b)g[a][b]=a-b?1e5:0;for(;~scanf("%d%d%d",&a,&b,&c);)h[a][b]=g[a][b]=g[b][a]=c;r(k)r(a)r(b)c=g[a][k]+g[k][b],c<g[a][b]?g[a][b]=c,h[a][b]=h[a][b]&&!++x:0;printf("%d",x);}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

	char c;
	cin >> c;
	cout << (char)(c + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
// #include <vector>
// #include <string>
// #include <set>
// #include <algorithm>

using namespace std;
// typedef unsigned long long ull;


int main(int argc, char const *argv[]) {
    int S;
    cin >> S;
    int h, m, s;

    s = S % 60;
    m = (S / 60) % 60;
    h = S / 3600;
    cout << h << ":" << m << ":" << s << endl;

    return 0;
}



Measured memory_bytes: 3108
N, K, *A = map(int, open(0).read().split())

MAX = 10 ** 5 + 1
MOD = 10 ** 9 + 7

# Factorial
fac = [0] * (MAX + 1)
fac[0] = 1
fac[1] = 1
for i in range(2, MAX + 1):
    fac[i] = fac[i - 1] * i % MOD
    
# Inverse factorial
finv = [0] * (MAX + 1)
finv[MAX] = pow(fac[MAX], MOD - 2, MOD)
for i in reversed(range(1, MAX + 1)):
    finv[i - 1] = finv[i] * i % MOD

def comb(n, k):
    if n < k or k < 0:
        return 0
    return (fac[n] * finv[k] * finv[n - k]) % MOD


A.sort()
ans = 0
for i in range(N):
    if i >= K - 1:
        ans += comb(i, K - 1) * A[i]
    if i + K - 1 < N:
        ans -= comb(N - i - 1, K - 1) * A[i]
    ans %= MOD
print(ans)



Measured memory_bytes: 91752
import sys
from itertools import combinations
input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


def main():
    n = int(input().rstrip())
    m = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
    for _ in range(n):
        s = input().rstrip()
        if s[0] in m:
            m[s[0]] += 1
    ans = 0
    for c in combinations(m, 3):
        ans += m[c[0]] * m[c[1]] * m[c[2]]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9156
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

ll INF = 9*1e18;

int main() {
	int n;
	cin >> n;
	vector<ll> outt(n + 1);
	rep(i, n + 1) cin >> outt[i];
    if(n==0&&outt[0]==1){
      cout<<1<<endl;
      return 0;
    }
    if(outt[0]!=0){
      cout<<-1<<endl;
      return 0;
    }
	vector<ll> ok(n + 1);
	ok[0] = (ll)1;
	vector<ll> maxx(n + 1, INF), minn(n + 1,(ll)0);
	maxx[n] = 0;
	for (int i = n - 1; i >= 0; i--) {
		minn[i] = (minn[i + 1] + outt[i + 1] + 1) / 2;
		if (maxx[i + 1] != INF) {
			ll cnt;
			cnt = maxx[i + 1] + outt[i + 1];
			if (cnt < INF) maxx[i] = cnt;
		}
	}

	rep(i, n) {
		ll cnt = 2 * ok[i] - outt[i + 1];
		cnt = min(cnt, maxx[i + 1]);
		if (cnt < minn[i + 1]) {
			cout << -1 << endl;
			return 0;
		}
		ok[i + 1] = cnt;
	}
	ll ans = 0;
	rep(i, n + 1) ans += ok[i] + outt[i];
	cout << ans << endl;
}


Measured memory_bytes: 6372