akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
inline void solve(void){
  int N,M;in(N,M);
  map<int,int>c;
  vector<bool>f(N+1);
  rep(i,M){
    int p;string s;in(p,s);
    if(!f[p]){
      if(s=="WA")c[p]++;
      if(s=="AC")f[p]=true;
    }
  }
  int cnt_ac=0;
  for(auto e:f)if(e)cnt_ac++;
  int cnt_wa=0;
  for(auto e:c)if(f[e.ft])cnt_wa+=e.sd;
  cout<<cnt_ac<<" "<<cnt_wa<<endl;
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i, n, k) for(int i = k; i < n; i++)
using namespace std;

int main(){
  int n, l, tsum, t;
  cin >> n >> l;
  
  t = l;
  rep(i, n+1, 1){
    tsum += l + i - 1;
    if(abs(t) > abs(l + i - 1)){
      t = l + i - 1;
    }
  }
  cout << tsum - t << endl;
}

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

using namespace std;

typedef long long ll;

template<typename T> ostream& operator << (ostream& os, vector<T> v) {
  for (auto& i : v) os << i << " "; return os; 
}
template<typename T> istream& operator >> (istream& is, vector<T>& v) {
  for (auto& i : v) is >> i; return is;
}
template<typename K, typename V> ostream& operator << (ostream& os, unordered_map<K, V> m) {
  for (auto& i : m) os << i.first << ":" << i.second << endl; return os;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> f(100010, true);
  vector<ll> dp(100010, 0);
  dp[0] = 1;
  for (int i=0; i<m; i++) {
    int v;
    cin >> v;
    f[v] = false;
  }
  for (int i=1; i<=n; i++) {
    if (f[i]) {
      if (i == 1) {
        dp[1] = dp[0];
      } else {
        dp[i] = dp[i-1] + dp[i-2];
        dp[i] %= 1000000007;
      }
    }
  }
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits//stdc++.h>
using namespace std;
#define int long long
#define rep(i,n,k) for(int i=n;i<k;i++)
#define P make_pair
#define F first
#define S second
#define M LLONG_MAX
signed main(void){
    int n,m,ans,p,q;
    ans=0;
    string s,s1,s2;
    vector<int> v;
    double w;
   cin>>n>>m;
   rep(i,0,m){
       cin>>p;
       ans=ans+p;
   }
   q=-1;
   cout<<max(q,n-ans)<<endl;
}


Measured memory_bytes: 3628
N = int(raw_input())
A = [int(raw_input()) for i in xrange(N)]

MAX = 999999999999999999999999999999999999999999999999999999999999999999999999999

dp1 = [-MAX for i in xrange(N)]
for i in range(1, N):
    dp1[i] = max(dp1[i - 1], A[i - 1])

dp2 = [-MAX for i in xrange(N)]
for i in range(N - 2, -1, -1):
    dp2[i] = max(dp2[i + 1], A[i + 1])

for i in xrange(N):
    print max(dp1[i], dp2[i])

Measured memory_bytes: 40476
n = int(input())
A = [int(i) for i in input().split()]

def Partition(A, p, r):
    i = p - 1
    for j in range(p, r):
        if A[j] <= A[r]:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i+1, A

q, A = Partition(A, 0, n-1)
for ni in range(n-1):
    if ni == q:
        print("[" + str(A[ni]) + "]",end = " ")
    else:
        print(A[ni], end = " ")
print(A[n-1])



Measured memory_bytes: 16372
N = int(input())
brick = list(map(int,input().split()))

def Break(n, lst):
  counter = 0
  cur = 1
  for i in range(len(lst)):
    if lst[i] == cur:
      cur += 1
    else:
      counter += 1
  if cur == 1:
    return -1
  return counter

print(Break(N, brick))



Measured memory_bytes: 24744
import java.util.*;

public class Main {
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] txy = new int[3][n+1];
		txy[0][0] = 0;
		txy[1][0] = 0;
		txy[2][0] = 0;
		for (int i = 1 ; i <= n ; i++) {
			txy[0][i] = sc.nextInt();
			txy[1][i] = sc.nextInt();
			txy[2][i] = sc.nextInt();
		}
		for (int i = 1 ; i <= n ; i++) {
			if (!check(txy[0][i] - txy[0][i-1],txy[1][i] - txy[1][i-1],txy[2][i] - txy[2][i-1])) {
				System.out.println("No");
				System.exit(0);
			}
		}
		System.out.println("Yes");
	}

	private static boolean check(int cnt, int x, int y) {
		if ((Math.abs(x) + Math.abs(y)) % 2 == cnt % 2
				&& Math.abs(x) + Math.abs(y) <= cnt) return true;
		return false;
	}
}


Measured memory_bytes: 91264
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;cin>>h>>w;
  string s[h][w];
  int x,y;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>s[i][j];
      if(s[i][j]=="snuke"){
        x=i;y=j;
      }
    }
  }
  char a=y+'A';
  cout<<a<<x+1<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,a[2333],ans; 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=1;i<=m;i++)ans+=a[i];
	cout<<ans;
}


Measured memory_bytes: 3660
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

const int N = 2e5 + 5;
const int P = 10000;

int n, p;
string s;
int fr[P];

int main()
{
  cin >> n >> p >> s;
  long long ans = 0;
  if(p == 2 || p == 5){
    for(int i = 0 ; i < n ; i++) {
      if((s[i] - '0') % p == 0)
        ans += i + 1;
    }
  } else {
    fr[0]++;
    int v = 0, po = 1;
    for(int i = n - 1 ; i >= 0 ; i--){
      int cur = s[i] - '0';
      v = (v + po * cur) % p;
      ans += fr[v];
      fr[v]++;
      po = (po * 10) % p;
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);


    int n;
    cin>>n;
    vector <int> a(n);
    loop(i,0,n) cin>>a[i];

    sort(all(a),greater <int>());


    multiset <pair <int,pair <int,int> > > ms;

    ms.insert({-a[0],{0,0}});

    int ans=0;
    loop(i,1,n)
    {
        ans+=(-1LL*((*ms.begin()).first));
        pair <int,pair <int,int> > p=(*ms.begin());
        ms.erase(ms.begin());
        int x=p.second.first;
        int y=p.second.second;
        ms.insert({-1LL*min(a[i],a[x]),{i,x}});
        ms.insert({-1LL*min(a[i],a[y]),{i,y}});
    }
    cout<<ans;


    return 0;
}


Measured memory_bytes: 17184
#include<bits/stdc++.h>
using namespace std;
int L;
struct ii
{
    int x,y,w;
};
vector<ii> st;
bool get(int x,int k)
{
    return (x>>(k-1))&1;
}
void xuli()
{
    int t=1,n=1;
    while (t*2<=L)
    {
        st.push_back({n,n+1,0});
        st.push_back({n,n+1,t});
        t*=2;n++;
    }
    int res=L-t;
    for (int i=n-1;i>=1;i--)
    {
        if (get(res,i))
        {
            st.push_back({i,n,t});
            t=t+(res&(1<<(i-1)));
        }
    }
    cout<<n<<' '<<st.size()<<"\n";
    for (ii u:st)
    {
        cout<<u.x<<' '<<u.y<<' '<<u.w<<"\n";
    }
}
int main()
{
    //freopen("allyourpatharedifferentlength.inp","r",stdin);
   // freopen("allyourpatharedifferentlength.out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>L;
    xuli();
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#define maxn 5010
#define maxint 0x7fffffff/2
#define ll long long
using namespace std;
int main() {
	ll n;
	cin>>n;
	if(!n) cout<<n;
	ll sum=0;
	for(ll i=1; i<=n; i++) {
		if(i%5>0&&i%3>0) {
			sum+=i;
//			cout<<i<<endl;
		}
	}
	cout<<sum;
	return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}

main(){
  int n,k;
  cin>>n>>k;
  vector<vector<int>> v(n+1);
  int ans=0;

  FOR(i,2,n+1){
    v[1].PB(i);
  }
  ans=(n-1)*(n-2)/2;
  int m=0;

  if(ans<k){
    cout<<-1<<endl;
    return 0;
  }

  FOR(i,2,n+1){
    FOR(j,i+1,n+1){
      if(ans-m>k){
        m++;
        v[i].PB(j);
      }
    }
  }

  cout<<n+m-1<<endl;
  rep(i,n+1){
    rep(j,v[i].size()){
      cout<<i<<' '<<v[i][j]<<endl;
    }
  }

}


Measured memory_bytes: 384
#-------------------------------------------------------------------------------
#関数定義
def f(a,d,T):
    try:
        return T[d+1:].index(a)+(d+1)
    except ValueError:
        return len(T)

def g(a,d,T):
    try:
        return (d-1)-T[d-1::-1].index(a)
    except ValueError:
        return 0
#-------------------------------------------------------------------------------
#インポート
from math import inf,exp
from random import random,randint
import time
from copy import copy
#-------------------------------------------------------------------------------
#定数
TIME_LIMIT=1.864 #ループの時間制限  
A=26 #アルファベットの数
START=time.time()

ALPHA=15
ep=10**(-6) #アニーリングの微小温度
#-------------------------------------------------------------------------------
#読み込み部
D=int(input())

C=[True]+list(map(int,input().split())) #減る満足度のベース
S=[True]*(D+1) #S[d][i] :(d+1)日目にコンテストiを開催した時の満足度

for i in range(1,D+1):
    S[i]=[0]+list(map(int,input().split()))           
#-------------------------------------------------------------------------------
#貪欲部
L=[0]*(A+1)
T=[0]
for d in range(1,D+1):
    Y=-inf
    E=0
    for a in range(1,A+1):
        X=S[d][a]
        for s in range(1,A+1):
            if a!=s:
                X-=C[s]*(d-L[s])

        if X>Y:
            Y=X
            E=a
    L[E]=d
    T.append(E)
#-------------------------------------------------------------------------------
#調節部
t=time.time()-START
while t<TIME_LIMIT:
    d=randint(1,D)
    p=T[d]
    q=randint(1,A)
    Y=(d-g(p,d,T))*(f(p,d,T)-d)
    Z=(d-g(q,d,T))*(f(q,d,T)-d)
        
    Delta=(S[d][q]-S[d][p])+Z*C[q]-Y*C[p]
    if (Delta>=0) or (Delta<0 and random()<exp(Delta/(ALPHA*(TIME_LIMIT-t)+ep))):
        T[d]=q
    
    t=time.time()-START

for i in range(1,D+1):
    print(T[i])


Measured memory_bytes: 92996
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second

void solve(void){
	int N, M;
	cin >> N >> M;
	int ans = max(N+M, N-M);
	ans = max(ans, N*M);
	cout << ans << endl;
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  string s[n];
  rep(i,n) R s[i];
  int d[n*m][n*m];
  rep(i,n*m)rep(j,n*m) d[i][j]=MAX;
  rep(i,n*m) {
    int x=i/m,y=i%m;
    if(s[x][y]=='#') continue;
    d[i][i]=0;
    rep(j,4) {
      int xx=x+dx[j],yy=y+dy[j];
      if(check(n,m,xx,yy)&&s[xx][yy]!='#') d[i][xx*m+yy]=1;
    }
  }
  rep(k,n*m)rep(i,n*m)rep(j,n*m) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
  int ans=0;
  rep(i,n*m)rep(j,n*m) {
    if(d[i][j]!=MAX) ans=max(ans,d[i][j]);
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 896
#include<iostream>
 
using namespace std;
 
int main(){
    while( true ){
        int n;
        int ma = 0;
        int mi = 1000;
        int s = 0;
        cin >> n;

        if(n == 0){
            break;
        }

        int a[n];

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

        cout << (s - ma - mi)/(n - 2) << endl;
    }   
 
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <string>
#include <cstdlib>
#include <fstream>

int main(){
	int n, table[5]={};
	cin >> n;

	for(int i = 0; i < n; i++){
		string s;
		cin >> s;
		if(s[0]=='M'){
			table[0]++;
		} else if(s[0]=='A'){
			table[1]++;
		} else if(s[0]=='R'){
			table[2]++;
		} else if(s[0]=='C'){
			table[3]++;
		} else if(s[0]=='H'){
			table[4]++;
		}
	}

	int count=0;

	for(int i = 0; i < 5; i++){
		if(table[i]>0){
			count++;
		}
		//cout<<table[i]<<endl;
	}
	if(count<3){
		cout<<0<<endl;
		return 0;
	}

	long int com=0;

	for(int i = 0; i < 3; i++){
		for(int j = i+1; j < 4; j++){
			for(int k=j+1; k<5; k++){
				long int temp=table[i];
				temp=temp*table[j];
				temp=temp*table[k];
				com+=temp;
				//cout<<temp<<endl;
			}
		}
	}
	cout << com<<endl;

	return 0;
}

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

#define REP(i,n) for (int (i) = 0;(i) < (n);++(i))
#define FORN(i,a,b) for (int i = (a);i <=(b); ++i)
#define FORD(i,a,b) for (int i = (a); i >= (b); --i)
#define SORT(list) sort(ALL((list)));
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define IOS  cin.tie(0),cout.tie(0); ios::sync_with_stdio(false);
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;

const ll mod=1000000007;
// int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head


int main()   {  
	IOS
	string s;
	cin >> s;
	int l =0, r = sz(s)-1;
	int ans = 0;
	while(l < r) {
		if(s[l] != s[r]){
			// cerr << s[l] << " " << s[r] << '\n';
			ans++;
		}
		l++; r--;
	}
	cout << ans << '\n';
}  
  

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

using namespace std;

int main(){
  int N;
  cin >> N;
  N = N % 10;
  if (N==3) cout << "bon" <<endl;
  else if(N==0||N==1||N==6||N==8) cout<< "pon" <<endl;
  else cout<<"hon"<<endl;
  return 0;
}


Measured memory_bytes: 3624
from collections import deque

h,w=map(int,input().split())

maze=[list(input()) for i in range(h)]

ans=0

dx=[1,-1,0,0]
dy=[0,0,1,-1]


for i in range(h):
  for j in range(w):
        Q=deque()
        Q.append((i,j,0))
        
        if maze[i][j]=='#':
          continue

        dp=[[-1]*w for i in range(h)]

        dp[i][j]=0

        while Q:
          p=Q.popleft()
          ans=max(ans,p[2])
          for k in range(4):
            nx=p[0]+dx[k]
            ny=p[1]+dy[k]

            if 0<=nx<h and 0<=ny<w and maze[nx][ny]=='.' and dp[nx][ny]==-1:
              Q.append((nx,ny,p[2]+1))
              dp[nx][ny]=p[2]+1


print(ans)


Measured memory_bytes: 75096
#include<iostream>
using namespace std;
typedef long long ll;
//计算指数x可以分解几个组合
int solve(int x)
{
	int now=1,res=0;
	while(now<=x)
	{
		x-=now;
		now++;
		res++;
	}
	return res;
}
int main()
{
	ll n;
	int ans=0;
	cin>>n;
	//遍历到sqrt(n)即可
	for(ll i=2;i*i<=n;i++)
	{
		//能进if的i必定是素数
		if(n%i==0)
		{
			int cnt=0;//统计指数个数
			while(n%i==0)
			{
				n/=i;
				cnt++;
			}
			ans+=solve(cnt);
		}
	}
	if(n!=1) 
		ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3636
import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

""" Input
N = int(input())
N, A, B = map(int, input().split())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""

S = input().rstrip()
print('ARC' if S == 'ABC' else 'ABC')



Measured memory_bytes: 8964
#include <iostream>
#include <sstream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;


int main(void)
{
	string S; cin >> S;
	int N; cin >> N;
	int rev = 0;
	string l, r;
	rep(i, 0, N) {
		int t; cin >> t;
		if (t == 1)rev++;
		else {
			int f; cin >> f;
			char c; cin >> c;
			if (f == 1) {
				if (rev % 2 == 0)r.push_back(c);
				else l.push_back(c);
				//S = (rev % 2 == 0 ? c + S : S + c);
			}
			else {
				if (rev % 2 == 1)r.push_back(c);
				else l.push_back(c);
				//S = (rev % 2 == 1 ? c + S : S + c);
			}
		}
	}
	if (rev % 2 == 0) {
		reverse(r.begin(), r.end());
		cout << r << S << l << endl;
	}
	else {
		reverse(l.begin(), l.end());
		reverse(S.begin(), S.end());
		cout << l << S << r << endl;
	}


	return 0;
}


Measured memory_bytes: 1088
const input = require('fs').readFileSync('/dev/stdin', 'utf8');

const list = input.split(' ');

const n = Number(list[0]); // 煎餅の枚数

const k = Number(list[1]); // 人数

const output = () => {
  if (n % k === 0) {
    console.log(0); // 0を出力する
  } else {
    console.log(1); //1を出力する
  }
};

output();


Measured memory_bytes: 7372
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j,k;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		char[] s = sc.next().toCharArray();
		sc.close();
		long r=0,g=0,b=0;
		for (i = 0; i < s.length; i++) {
			switch(s[i]) {
				case 'R':
					r++;
					break;
				case 'G':
					g++;
					break;
				case 'B':
					b++;
					break;
			}
		}
		long total=r*g*b;
		for (i = 1; i < s.length-1; i++) {
			for (j = 1; Math.min(i-j, s.length-1-i-j) >=0; j++) {
				if(s[i-j]!=s[i]&&s[i]!=s[i+j]&&s[i-j]!=s[i+j]) total--;
			}
		}
		out.println(total);
	}
}


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

int main() {
  int n,ans=0;
  cin >> n;
  vector<int> p(n);
  for(int i=0;i<n;i++) cin >> p.at(i);
  for(int i=0;i<n-2;i++) {
    vector<int> a(3);
    a.at(0) = p.at(i);
    a.at(1) = p.at(i+1);
    a.at(2) = p.at(i+2);
    sort(a.begin(),a.end());
    if(p.at(i+1)==a.at(1)) ans++;
  };
  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++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int x,y;
    cin >> x >> y;
    if(x%y == 0) cout << -1 << endl;
    else cout << x << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;

int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	int A, B;
	cin >> A >> B;

	if (A >= 13) cout << B;
	else if (A >= 6) cout << B / 2;
	else cout << 0;

	return 0;
}


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

long long gcd(long long a,long long b){
  if(a%b == 0) return b;
  else return gcd(b,a%b);
}

int main(){
  long long A,B;
  cin >>A>>B;
  cout << A*B/gcd(A,B) << endl;
}

Measured memory_bytes: 256
from operator import add
from collections import defaultdict

class SegTree():
    def __init__(self, N, e, operator_func=add):
        self.e = e # 単位元
        self.size = N
        self.node = [self.e] * (2*N)
        self.operator_func = operator_func # 処理(add or xor max minなど)

    def set_list(self, l):
        for i in range(self.size):
            self.node[i+self.size-1] = l[i]
        for i in range(self.size-1)[::-1]:
            self.node[i] = self.operator_func(self.node[2*i+1], self.node[2*i+2])
    
    def update(self, k, x):
        k += self.size-1
        self.node[k] = x
        while k >= 0:
            k = (k - 1) // 2
            self.node[k] = self.operator_func(self.node[2*k+1], self.node[2*k+2])

    def get(self, l, r):
        # [l, r) についてqueryを求める
        x = self.e
        l += self.size
        r += self.size

        while l<r:
            if l&1:
                x = self.operator_func(x, self.node[l-1])
                l += 1
            if r&1:
                r -= 1
                x = self.operator_func(x, self.node[r-1])
            l >>= 1
            r >>= 1
        return x

N, T = map(int, input().split())
*A, = map(int, input().split())
tree = SegTree(N, 0, max)
tree.set_list(A)
d = defaultdict(int)
for i in range(N-1):
    d[(tree.get(i+1, N)-A[i])] += 1
print(d[max(d.keys())])

Measured memory_bytes: 94344
n = int(input())
a = list(map(int, input().split()))

a1 = []
a2 = []

for i in range(n):
    if i % 2 == 0:
        a2.append(a[i])
    else:
        a1.append(a[i])


if n % 2 != 0:
    #  偶数
    a2.reverse()
    res = a2 + a1

else:
    #  奇数
    a1.reverse()
    res = a1 + a2

[print(x, end=" ") for x in res]
print()

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

li = [chr(i) for i in range(97, 97+26)]

cnt = 0
check = 0
while True:
    cnt += 1
    check += 26**cnt
    
    if n <= check:
        break

for i in range(1, cnt):
    n -= 26**i

ans = []

for i in range(1, cnt+1):
    temp = (n-1) // 26**(cnt-i)
    ans.append(li[temp])
    n -= temp*26**(cnt-i)

print("".join(ans))


Measured memory_bytes: 9208
int main(){
  int a1,a2,a3;
  int max,min;
  scanf("%d%d%d",&a1,&a2,&a3);
  max=((a1>a2)&&(a1>a3))?a1:(a2>a3)?a2:a3;
  min=((a1<a2)&&(a1<a3))?a1:(a2<a3)?a2:a3;
  printf("%d",max-min);
  return 0;
}

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

#define endl '\n'

int const N = 100010;
vector<int> adj[N];
map<pair<int, int>, int> num;
set<int> used[N];
int n, ans[N], k;

void dfs(int v = 1, int p = -1){
    int at = 1;
    for (int f : adj[v]){
        if (f == p) continue;
        while(used[v].count(at)) at++;
        ans[num[{min(v,f), max(v,f)}]] = at;
        used[v].insert(at);
        used[f].insert(at);
        k = max(k, at);
        dfs(f, v);
    }
}

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

    cin >> n;
    for (int i=1; i<n; i++){
        int u,v; cin >> u >> v; u--; v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
        num[{u,v}] = i-1;
    }

    dfs();
    cout << k << endl;
    for (int i=0; i<n-1; i++) cout << ans[i] << endl;

}

Measured memory_bytes: 26752
#include<stdio.h>
#include<string.h>
char a[110];
int main()
{
	scanf("%s",a);
	int i,l=strlen(a),cnt=0;
	for(i=0;i<l/2;i++)
	{
		if(a[i]!=a[l-i-1])cnt++;
	}
	printf("%d\n",cnt);
}

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

struct tree{
  int parent;
  int depth;
  std::string type;
  std::vector<int> children;
  static int decide_type(tree T[],int);
  static void give(tree T[],int i);
  static void enter_from_root(tree T[],int root);
};

int tree::decide_type(tree T[],int n){
  int root=-2;
  for(int i=0;i<n;i++){
    if(T[i].parent==-1){
      T[i].type="root";
      root=i;
    }else if(T[i].children.empty()){
      T[i].type="leaf";
    }else{
      T[i].type="internal node";
    }
  }
  return root;
}

void tree::give(tree T[],int i){
  int n=T[i].children.size();
  if(n>0){
    for(int j=0;j<n;j++){
      T[T[i].children[j]].depth=T[i].depth+1;
      give(T,T[i].children[j]);
    }
  }
}

void tree::enter_from_root(tree T[],int root){
  T[root].depth=0;
  int n=T[root].children.size();
  if(n>0){
    for(int j=0;j<n;j++){
      T[T[root].children[j]].depth=T[root].depth+1;
      give(T,T[root].children[j]);
    }
  }
}

int main(){
  int n;
  std::cin>>n;
  tree T[n];
  for(int i=0;i<n;i++){
    T[i].parent=-1;
  }
  for(int i=0;i<n;i++){
    int x,c;
    std::cin>>x>>c;
    for(int j=0;j<c;j++){
      int y;
      std::cin>>y;
      T[x].children.push_back(y);
      T[y].parent=x;
      //std::cout<<"aa:"<<T[y].parent;
    }
  }
  int root=tree::decide_type(T,n);
  tree::enter_from_root(T,root);
  for(int i=0;i<n;i++){
    std::cout<<"node "<<i<<": parent = "<<T[i].parent
    <<", depth = "<<T[i].depth<<", "<<T[i].type<<", [";
    int c=T[i].children.size();
    for(int j=0;j<c;j++){
      std::cout<<T[i].children[j];
      if(j!=c-1){
        std::cout<<", ";
      }
    }
    std::cout<<"]"<<std::endl;
  }
}



Measured memory_bytes: 12600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        PrimeNumberGenerator png = new PrimeNumberGenerator();

        while(true){
            String tmpStr = br.readLine();
            if(tmpStr == null){
                break;
            }

            int n = Integer.parseInt(tmpStr);

            int count = 0;
            for(int i = 2; i <= n; i++){
                if(png.isPrime(i)){
                    count++;
                }
            }

            System.out.println(count);
        }
    }

}

class PrimeNumberGenerator {
	private final int N = 100000000;
    private boolean[] isPrime= new boolean[N + 1];

    public PrimeNumberGenerator() {
        Arrays.fill(isPrime, true);

        isPrime[0] = false;
        isPrime[1] = false;
//        isPrime[2] = true;

        int limit = (int)Math.sqrt(N)+1;
        for(int i = 2; i <= limit ; i++){
//            if(i % 2 == 0){
//                isPrime[i] = false;
//                continue;
//            }

            if(isPrime[i] == false){
                continue;
            }

            for(int j = i * 2; j <= N; j += i){
                isPrime[j] = false;
            }
        }
    }

    public boolean isPrime(int index){
        return isPrime[index];
    }
}

Measured memory_bytes: 122588
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: usize,
        p: usize,
    }
    println!("{}", (a * 3 + p) / 2);
}


Measured memory_bytes: 4352
//
//  main.cpp
//  ABC156A
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int N,R; // N:参加回数 R:内部レーティング
    cin>>N>>R;
    int ans;
    if(N<10){
        ans=R-100*N+1000;
    }else{
        ans=R;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

func solve() {
	days := [7]string{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"}
	s := getString()

	ans := -1
	for i, d := range days {
		if s == d {
			ans = 7 - i
		}
	}
	fmt.Fprintln(wr, ans)
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

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

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a,b;
	cin>>a>>b;
	if(a.size()>b.size()){
		cout<<"GREATER"<<endl;
	}
	else if(a.size()<b.size()){
		cout<<"LESS"<<endl;
	}
	else {
		for(int i=0;i<a.size();i++){
			if(a[i]>b[i]){
				cout<<"GREATER"<<endl;
				return 0;
			}
			else if(a[i]<b[i]){
				cout<<"LESS"<<endl;
				return 0;
			}
			else if(i==a.size()-1){
				cout<<"EQUAL"<<endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

import numpy as np

MOD = 10 ** 9 + 7

N,M = map(int,input().split())

# 1度は赤が0個になるような初期状態だけを考える
# 箱の状態、0個を経由したか否か
dp_T = np.zeros(N+1, dtype=np.int64)
dp_F = np.ones_like(dp_T)
dp_T[0] = 1
dp_F[0] = 0

for _ in range(M):
    prev_T = dp_T
    prev_F = dp_F
    dp_T = np.zeros_like(prev_T)
    dp_F = np.zeros_like(prev_F)
    # 赤赤
    dp_T[0:-1] += prev_T[1:]
    dp_F[1:-1] += prev_F[2:]
    dp_T[0] += prev_F[1]
    # 赤青
    dp_T[1:] += prev_T[1:]
    dp_F[2:] += prev_F[2:]
    dp_T[1] += prev_F[1]
    # 青赤
    dp_T[:-1] += prev_T[:-1]
    dp_F[:-1] += prev_F[:-1]
    # 青青
    dp_T[1:] += prev_T[:-1]
    dp_F[1:] += prev_F[:-1]
    
    dp_T %= MOD
    dp_F %= MOD

answer = dp_T.sum() % MOD
print(answer)

Measured memory_bytes: 12508
def frequency_of_appearance(numbers, count = 0)
  new_numbers = numbers.map{ |number| numbers.count(number) }
  return frequency_of_appearance(new_numbers, count + 1) if numbers != new_numbers
  [count, new_numbers]
end

results = []
while num_numbers = gets.strip.to_i
  break if num_numbers == 0
  results << frequency_of_appearance(gets.strip.split[0, num_numbers].map(&:to_i))
end

puts results.map{ |a| "#{a[0]}\n#{a[1].join(" ")}" }.join("\n")

Measured memory_bytes: 6108
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
#include<stdio.h>
using namespace std;
int main(){
    int r,c;
    cin >> r >> c;
    int retsu[r+1][c + 1];
    for(int i=0;i<=r;i++){
        for(int j = 0; j <=c; j++){
        retsu[i][j] = 0;
        }
    }
    for(int j = 0; j<r;j++){
        for(int k = 0; k < c; k++){
            int s;
            cin >> s;
            retsu[j][k] = s;
            retsu[j][c] +=s;
            retsu[r][k] +=s;
            retsu[r][c] +=s;
        }
    }
    for(int i=0;i<=r;i++){
        for(int j=0;j<=c;j++){
            if(j!=c){
                cout << retsu[i][j] << " " ;
            }else{
                cout << retsu[i][j] << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3092
#include "stdio.h"
int main()
{
    int a, b;

    scanf("%d %d", &a, &b);

    if((a+b)%2 == 0)
        printf("%d\n", (a+b)/2);
    else
        printf("%d\n", (a+b+1)/2);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;

long long gcd(long long x,long long y) {
	long long k = x, l = y;
	
	while (x != 0) {
		if (x < y)swap(x, y);
		x %= y;
	}
	return k*l/y;
}

int main() {
	long long A, B, C, D,E; cin >> A >> B >> C >> D;
	long long A1, A2, B1, B2,C1,C2;
	E = gcd(C, D);
	A1 = (A-1) / C; A2 = B / C; B1 = (A-1) / D; B2 = B / D; C1 = (A-1) / E; C2 = B / E;
	cout << B-A-((A2 - A1) + B2 - B1 - (C2 - C1))+1 << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
using ll = long long;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    vector<int> b(n,0);
    //偶数の差の絶対値は1から+2
    //組み合わせの数は2^(n/2)
    //奇数の差の絶対値は0から+2ずつ
    //組み合わせの数は2^(n/2)
    ll ans=0;
    ll mod=1e9+7;
    bool ok=true;
    if(n%2==0){
        rep(i,n) b[a[i]]++;
        for(int i=1; i<n; i+=2){
            if(b[i]!=2) ok = false;
        }
    }else{
        rep(i,n) b[a[i]]++;
        for(int i=0; i<n; i+=2){
            if(i==0&&b[i]!=1) ok=false;
            else if(i!=0&&b[i]!=2) ok=false;
        }
    }
    if(ok){
        ans=1;
        rep(i,n/2){
            ans*=2;
            ans%=mod;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    arc067d()
}

fun arc067d() {
    val (n, a, b) = readLine()!!.split(' ').map { it.toLong() }
    val xList = readLine()!!.split(' ').map { it.toLong() }

    var answer = 0L
    for (i in 0 until xList.lastIndex) {
        val curr = xList[i]
        val next = xList[i + 1]
        answer += Math.min((next - curr) * a, b)
    }

    println(answer)
}


Measured memory_bytes: 51760
/*
    oj d https://atcoder.jp/contests/abc166/tasks/abc166_a
    g++ A.cpp
    oj t
    oj s https://atcoder.jp/contests/abc166/tasks/abc166_a A.cpp
*/
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string S;
    cin >> S;

    if(S == "ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }

}

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

int i,j,n,nxt,code,MAX,sel;
int num[20],dist[20],wei[20],next[36000][20];
double time[36000][20],speed[36000],ttt,tim;

int main(){
	scanf("%d",&n);

	for(i=0;i<n;i++){
		scanf("%d %d %d",&num[i],&dist[i],&wei[i]);
		wei[i]*=20;
	}

	MAX=(int)pow(2.0,n);
	for(code=MAX-2;code>=0;code--){
		sel=0;
		for(j=0;j<n;j++){
			if(code >> j & 1)sel+=wei[j];
		}
		speed[code]=2000.0/(sel+70);
	}

	for(code=MAX-2;code>0;code--){
		for(i=0;i<n;i++){
			if(code >> i & 1){
				ttt=99999999;
				for(j=0;j<n;j++){
					if( !(code>>j&1) ){
						tim=time[code+ (1<<j) ][j]+abs(dist[i]-dist[j])/speed[code];
						if(tim<ttt){ttt=tim;sel=j;}
					}
				}
				time[code][i]=ttt;
				next[code][i]=sel;
			}
		}
	}

	ttt=99999999;
	for(j=0;j<n;j++){
		tim=time[1<<j][j];
		if(tim<ttt){ttt=tim;sel=j;}
	}
	time[0][0]=ttt;
	next[0][0]=sel;

	for(i=0,j=0;i<MAX-1;){
		nxt=next[i][j];
		printf("%s%d",i>0?" ":"",num[nxt]);
		i+=(int)pow(2.0,nxt);
		j=nxt;
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 9084
/* 十 聖イシドールスよ、迷えるプログラマを導き給え！ 十 */
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; i++)
 
//const long long INF = 1LL << 60;
const int INF = 1e9;
const long long MOD = 1000000007;
using ll = long long;

int main()
{
	int N = 0;
	std::cin >> N;

	ll all = 1;
	ll not_0 = 1;
	ll nand_0_9 = 1;

	for(int i = 0; i < N; i++)
	{
		all *= 10;
			all %= MOD;

		not_0 *= 9;
			not_0 %= MOD;

		nand_0_9 *= 8;
			nand_0_9 %= MOD;
	}
//	std::cout << all << "|" << not_0 << "|" << nand_0_9 << std::endl;
	ll ans = all - not_0 - not_0 + nand_0_9;
	
	ans %= MOD;

	ans=(ans+MOD)%MOD;

	std::cout << ans;

	return 0;
}

Measured memory_bytes: 3616
import collections

N = int(input())
la = list(map(int, input().split()))

c = collections.Counter(la)
lv = list(c.values())
lvmin = [i-1 for i in lv]

s = sum(i*(i-1)//2 for i in lv)

for i in range(N):
    ans = s - c[la[i]] + 1
    print(ans)

Measured memory_bytes: 26780
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

//***********************************
//mintを定義
//***********************************
const int mod = 1000000007;
struct mint {
  int x;
  mint(int x=0):x(x%mod){}   //メンバ変数xをx%modで初期化
  int get() const { return (int)x; }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;           //thisは暗黙的に左辺のポインタ
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }

  //累乗
  mint mpow(int t) const {
    if (!t) return 1;
    mint a = mpow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  //除算
  mint minv() const {
    return mpow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.minv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

//標準出力
ostream& operator<<(ostream& st, const mint a) 
{ st << a.get(); return st; };
//--------------------------------------------------

//***********************************
//場合の数の計算
//***********************************
const int MAX = 200010;
mint fac[MAX], finv[MAX];

//前計算
inline void INIT_F(){
    fac[0] = finv[0] = 1;
    for(int i=1; i<MAX-1; i++) {
        fac[i] = (fac[i-1]*mint(i));
        finv[i] = (finv[i-1]/mint(i));
    }
}

//nCk
mint mcomb(int n, int k) {
    if(n<k || k<0) return 0;
    else return ((fac[n]*finv[k])*finv[n-k]);
}

//nHk
mint mhcomb(int n, int k) {
  return mcomb(n+k-1, k);
}
//--------------------------------------------------

signed main() {
    INIT_F();

    int n, k;
    cin >> n >> k;
    k = min(k, n-1);

    mint res = 0;
    rep(i, k+1) {
        res += mcomb(n, i) * mhcomb(n-i, i);
    }
    

    cout << res << endl;


  return 0;
}

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

using namespace std;

int vals[100100];
int N;

int a, b;

int dis(int a, int b){
	return abs(a - b);
}

void solve(){
	sort(vals, vals + N);
	a = vals[N - 1];
	b = vals[0];
	for(int i = 1; i < N - 1; ++i){
		int x = vals[i];
		int dif1 = dis(a, b * 2);
		int dif2 = dis(a, x * 2);
		if(dif2 < dif1) b = x;
	}
}

int main(){
	scanf("%d", &N);
	for(int i = 0; i < N; ++i) scanf("%d", vals + i);
	solve();
	printf("%d %d\n", a, b);
	return 0;
}


Measured memory_bytes: 512
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;

int ketawa(int num) {
	int ret = 0;
	while (num >= 10) {
		ret += num % 10;
		num /= 10;
	}
	ret += num;
	return ret;
}

int main() {
	cin >> n;
	int ans = INF;
	for (int i = 1; i < n; i++) {
		ans = min(ans, ketawa(i) + ketawa(n - i));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
/*input
4
abcd

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
#define PI 3.14159265
#define endl '\n'
#define debug(x) cout << #x << " = " << x << endl;
#define MAX 100001

template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(ll a, ll b) {a += b; if (a < 0) a += mod; return a;}
inline int sub(ll a, ll b) {a -= b; if (a < 0) a += mod; return a;}
inline int mul(ll a, ll b) {return (a * 1ll * b) % mod;}
inline int pwr(ll x, ll y) {
    int ans = 1 % mod;
    while (y) {
        if (y & 1) ans = mul(ans, x);
        x = mul(x, x);
        y >>= 1;
    }
    return ans;
}
inline int inv(int a) {return pwr(a, mod - 2);}


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

    int n;
    cin >> n;
    string str;
    cin >> str;
    map <char, int> mp;
    for (auto it : str) {
        mp[it]++;
    }
    int ans = 1;
    for (auto it : mp) {
        ans = mul(ans, it.second + 1);
    }
    ans = sub(ans, 1);
    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 512