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

#define MOD (1000 * 1000 * 1000 + 7)
typedef long long ll;
typedef long double ld;

int main() {
	
	string str = "";
	
	char c;
	while((c = getchar()) != '\n') {
		if(c == 'B') {
			if(!str.empty()) 
				str.pop_back();	
		}
		else 
			str += c;
	}
	
	cout << str << endl;
	
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

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

	bool isOK = [=]() {
		char c;
		for (int i = 0; i < a; ++i) {
			std::cin >> c;
			if (c < '0' || '9' < c)
				return false;
		}

		std::cin >> c;
		if (c != '-')
			return false;

		for (int i = 0; i < b; ++i) {
			std::cin >> c;
			if (c < '0' || '9' < c)
				return false;
		}

		return true;
	}();

	std::cout << (isOK ? "Yes" : "No") << std::endl;
}

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

int main(){
    int N,K,X,Y;
    cin >> N >> K >> X >> Y;
    int total = 0;
    for(int i = 1; i <= N; i++){
        if(i > K) total += Y;
        else total += X;
    }
    cout << total << endl;
}

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

int n, x, y;
int ans[2001];
int main() {
  cin >> n >> x >> y;
  --x; --y;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int dist = min(j - i, abs(i - x) + abs(j - y) + 1);
      ++ans[dist];
    }
  }
  
  for (int k = 1; k < n; ++k) {
    cout << ans[k] << endl;
  }
}

Measured memory_bytes: 256
N = int(input())

def p_adic_valuation_factorial(n, p):
    result = 0
    pow_p = p
    while n >= pow_p:
        result += n // pow_p
        pow_p *= p
    return result

if N % 2 == 0:
    e2 = N // 2 + p_adic_valuation_factorial(N // 2, 2)
    e5 = p_adic_valuation_factorial(N // 2, 5)
    result = min(e2, e5)
else:
    result = 0
print(result)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std ;
int main()
{
    int N;
    string S;
    cin >> N;
    cin >> S;
    for(int i = 0;i < S.size();++i)
    {
        if(S.at(i) + N <= 'Z') S.at(i) += N;
        else S.at(i) = S.at(i) + N - 26;
    }
    cout << S << endl;
}


Measured memory_bytes: 256
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<set>
#include<vector>
#include<map>
#include<queue>
#define ll long long
using namespace std;
int main(){
	double P=3.1415926;
	double X;
	cin>>X;
	cout<<X*2.0*P<<endl;
	return 0;
}


Measured memory_bytes: 3776
// AOJ 2945 Poison Swamp
// 2019.8.8 bal4u

#include <stdio.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void out(int n) { // 非負整数の表示（出力）
	int i;
	char b[20];
	if (!n) pc('0');
	else {
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}

int N, A, B, C, D;
int x[105], y[105];
char f[105];

inline static int ABS(int x) { return (x >= 0)? x: -x; }
inline static int MIN(int a, int b) { return (a <= b)? a: b; }

int calc(int i) {
	int t, a;
	if (A <= x[i] && x[i] <= C) return MIN(ABS(y[i]-B), ABS(y[i]-D));
	if (B <= y[i] && y[i] <= D) return MIN(ABS(x[i]-A), ABS(x[i]-C));
	t = 100000;
	if ((a = ABS(x[i]-A) + ABS(y[i]-B)) < t) t = a;
	if ((a = ABS(x[i]-C) + ABS(y[i]-B)) < t) t = a;
	if ((a = ABS(x[i]-A) + ABS(y[i]-D)) < t) t = a;
	if ((a = ABS(x[i]-C) + ABS(y[i]-D)) < t) t = a;
	return t;
}

int main()
{
	int i, N, ans;
	
	while ((N = in())) {
		A = in(), B = in(), C = in(), D = in();
		memset(f, 0, N+1);
		for (i = 0; i <= N; i++) {
			x[i] = in(), y[i] = in();
			if (A <= x[i] && x[i] <= C && B <= y[i] && y[i] <= D) f[i] = 1;
		}
		
		ans = 0;
		for (i = 1; i <= N; i++) {
			if (f[i-1] && f[i]);
			else if (f[i-1]) ans += calc(i);
			else if (f[i]) ans += calc(i-1)-1;
			else ans += MIN(ABS(x[i-1]-x[i]) + ABS(y[i-1]-y[i]), calc(i-1)-1 + calc(i));
//			printf("[%d] ans=%d\n", i, ans);
		}
		out(ans);
	}
	return 0;
}


Measured memory_bytes: 2068
K = int(input())

def nd(n):
    ans = 0
    nn = n
    while(nn > 0):
        ans += nn%10
        nn //= 10
    return ans/n

def k_next(k):
  d = 1
  c_max = 0
  ans = k
  while(d < k*10):
    cand = (k//d+1)*d+(k%d)
    if nd(cand) >= c_max:
      c_max = nd(cand)
      ans = cand
    d *= 10
  return ans

k = 1
for i in range(K):
  print(k)
  k = k_next(k)




Measured memory_bytes: 3188
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<u64> = procon_read();
	let x = v[0];
	let t = v[1];
	if x < t {
		println!("0");
	}else{
		println!("{}", x-t);
	}
}

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

int main() {
  int n, k;
  cin >> n >> k;
  int a = 1;
  
  for (int i = 0; i < n; i++) {
    if (a < k)
      a *= 2;
    else
      a += k;
  }
  
  cout << a << endl;
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#include <math.h>
#include <map>
#define ll long long 
#define PI 3.14159265358979323846
#define INF 10000000000
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
using namespace std;

int main() {
	ll N, K;
    cin >> N >> K;
	vector<ll> H(N);
	rep(i, N) cin >> H[i];
	sort(H.begin(), H.end());
	ll ans = 0;
	rep(i, N - K) ans += H[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4820
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#include <bitset>
#include <math.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 998244353;
const int INF = LLONG_MAX/3;
const int MAX = 510000;

/*-----Library-----*/

struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
    vector<int> sizeuf; //要素数
    UnionFind(int n = 1) {
        init(n);
    }
    
    void init(int n = 1) {
        par.resize(n); rank.resize(n); sizeuf.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
            sizeuf[i]=1;
        }
    }
    
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
    
    bool issame(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 (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        sizeuf[x]+=sizeuf[y];
        return true;
    }
    
    int size(int x){
        return sizeuf[root(x)];
    }
};

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

long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

/*-----Library-----*/

signed main(){
    int n;
    cin>>n;
    int d[114514];
    int cnt[114514]={};
    for(int i=0;i<n;i++){
        cin>>d[i];
        cnt[d[i]]++;
    }
    if(d[0]!=0||cnt[0]!=1){
        cout<<0<<endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        if(cnt[i]==0&&cnt[i+1]>0){
            cout<<0<<endl;
            return 0;
        }
    }
    int ans=1;
    for(int i=1;i<n-1;i++){
        if(cnt[i]==0)continue;
        else {
            for(int j=0;j<cnt[i];j++){
                ans*=cnt[i-1];
                ans%=MOD;
            }
        }
        
    }
    cout<<ans<<endl;
    return 0;
}


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

int main () {
  int n;
  cin>>n;
  
  bool cnt =false;

  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      if(i*j ==n)cnt =true;
    }
  }
  if(cnt ==true){
    cout <<"Yes"<<endl;
  }else{
    cout <<"No"<<endl;
  }
  return 0;
  }





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

int group(int m){
  int t;
  if(m==2){
    t=3;
  }
  if(m==4||m==6||m==9||m==11){
    t=2;
  }
  else{
    t=1;
  }
  return t;
}
 
int main() {
  int a,b;
  cin >> a >> b;
  
  if(a==2||b==2){
    cout <<"No"<<endl;
  }
  else{
  
  a=group(a);
  b=group(b);
  
  
  if(a==b){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
    
  }

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define rep(i,n) for (int i = 0; i<n; i++)
using namespace std;

int main() {
    string n;
    cin >> n;
    int sum = 0;
    
    rep(i,n.length()) sum += (n[i] - '0');
    if(sum % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3728
N,K=map(int,input().split())
a=[int(i) for i in input().split()]
S=[0 for i in range(N+1)]
for i in range(1,N+1):
    S[i]=S[i-1]+a[i-1]
List=[]
for i in range(N+1):
    for j in range(i):
        List.append(S[i]-S[j])
List.sort(reverse=True)
def program(Y,L):
    #print(L)
    M=len(L)
    t=[bin(i)[2:][::-1] for i in L]
    b=[i+"0"*(Y-len(i)) for i in t]
    X=[[] for i in range(Y)]
    for i in b:
        for j in range(Y):
            if i[j]=="1":
                X[j].append(i)
    #print("X",X)
    l=Y
    for i in range(Y-1,-1,-1):
        if len(X[i])>=K:
            l=i
            break
    if l==Y:
        return 0
    #print(X[l])
    R=[]
    for i in X[l]:
        if i[:l]=="":
            R.append(0)
            continue
        R.append(int(i[:l][::-1],2))
    R.sort(reverse=True)
    return program(l,R)+2**l
#print(K,N)
print(program(42,List))


Measured memory_bytes: 510336
#include <iostream>
using namespace std;
int main(void)
{
    int A,B,C,D,E;
    cin>>A>>B>>C>>D>>E;
    if(A<0&&B>0)
    {
        cout<<(0-A)*C+D+B*E<<endl;
    }
    if(A<0&&B<0)
    {
        cout<<(A-B)*C<<endl;
    }
    if(A>0&&B>0)
    {
        cout<<(B-A)*E<<endl;
    }
    return 0;
}



Measured memory_bytes: 3072
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

int main(){
    int N;
    cin >> N;
    map<ll,int> m;
    vector<ll> a;
    for(int i = 0; i < N; i++){
        ll b;
        cin >> b;
        a.emplace_back(b);
        m[b]++;
    }
    sort(a.begin(),a.end(),greater<>());
    ll maxi = 0;
    ll maxi2 = -1;
    for(auto num : a){
        auto ite = m.find(num);
        if(ite -> second >= 4) {
            maxi = maxi2 = ite -> first;
            break;
        }
        else if(ite -> second >= 2) {
            maxi = ite -> first;
            break;
        } 
    }
    if(maxi == maxi2) {
        cout << maxi * maxi2 << endl;
        return 0;
    }
    for(auto num : a){
        auto ite = m.find(num);
        if(ite -> first == maxi) continue;
        if(ite -> second >= 2) {
            maxi2 = ite -> first;
            break;
        } 
    }
    cout << maxi * maxi2 << endl;
    return 0;
}


Measured memory_bytes: 7284
#include<bits/stdc++.h>
using namespace std;
int a[100005],b[100005];
int main()
{
  int n,m,max=INT_MIN,min=INT_MAX;
  cin>>n>>m;
  for(int i=0;i<m;i++)
  {
  	cin>>a[i]>>b[i];
  if(a[i]>max)max=a[i];
  	if(b[i]<min)min=b[i];
  }
int ans=min-max+1;
if(ans<=0)
  cout<<"0\n";
  else
  cout<<ans<<"\n";

}

Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	for i := 0; ; i++ {
		var x, y int
		fmt.Scan(&x, &y)
		if x == 0 && y == 0 {
			break
		}
		if x < y {
			fmt.Println(x, y)
		} else {
			fmt.Println(y, x)
		}
	}
}


Measured memory_bytes: 1260
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(x) memset(x,0,sizeof(x))
#define MINUS(x) memset(x,-1,sizeof(x))
#define UNIQUE(x) (x).erase(unique(ALL(x)), (x).end())
#define TOUPPER(x) transform(ALL(x), (x).begin(), ::toupper)
#define TOLOWER(x) transform(ALL(x), (x).begin(), ::tolower)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll qp(ll a,ll b){ll ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
ll qp(ll a,ll b,ll mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int INF = 1e9;
const ll INFL = 1e18;
const int MOD = 1e9 + 7;
const int MAX_N = 200005;

int N;
ll K;
int A[MAX_N];
ll pre[MAX_N];

int main() {
    cin >> N;
    cin >> K;
    rep(i,N) {
        cin >> A[i];
        A[i]--;
    }
    rep(i,N) pre[i] = -1;
    int now = 0;
    while(pre[now] == -1 && K > 0) {
        pre[now] = K;
        K--;
        now = A[now];
    }
    if(K == 0) {
        cout << now + 1 << endl;
        return 0;
    }
    K %= (pre[now] - K);
    while(K > 0) {
        K--;
        now = A[now];
    }
    cout << now + 1 << endl;
    return 0;
}


Measured memory_bytes: 5952
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

int main(){  
  string s,t;
  cin >> s >> t;
  vector<vector<int>> dp(3010, vector<int>(3030,0));
  int n=s.size(), m=t.size();

  rep(i,n){ rep(j,m){
    dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+(s[i]==t[j]));
    dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j]);
    dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1]);
  } }
  
  int i=n,j=m;
  string ans="";
  while(i>0 && j>0){
    if(dp[i][j]==dp[i][j-1]){ j--; }
    else if(dp[i][j]==dp[i-1][j]){ i--; }
    else if(dp[i][j]==dp[i-1][j]+1){
      ans += s[i-1];
      i--; j--;
    }
  }
  reverse(ans.begin(),ans.end());
  cout << ans << endl;
  return 0;
}

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

int main()
{
  string S ;
  cin>>S ;
  
  int N ;
  if(S.size()==3) N=S.at(2)-'0' ;
  else if(S.size()==2) N=S.at(1)-'0' ;
  else if(S.size()==1) N=S.at(0)-'0' ;
  
  if(N==2||N==4||N==5||N==7||N==9) cout<<"hon"<<endl ;
  else if(N==0||N==1||N==6||N==8) cout<<"pon"<<endl ;
  else if(N==3) cout<<"bon"<<endl ;
  
  return 0 ;
}

Measured memory_bytes: 3592
W, H, N = map(int,input().split())
D = [list(map(int,input().split())) for k in range(N)]
mx = 0
my = 0
MX = W
MY = H
for d in D:
    if d[2] == 1:
        mx = max(mx,d[0])
    elif d[2] == 2:
        MX = min(MX,d[0])
    elif d[2] == 3:
        my = max(my,d[1])
    else:
        MY = min(MY,d[1])

if MX <= mx or MY <= my:
    print(0)
else:
    print((MX-mx)*(MY-my))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>
 
#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;
 
int mp[11][11];
int a[210][210];
 
int main()
{
	int h,w;cin >> h >> w;
	
	REP(i,10)REP(j,10)
	{
		cin >> mp[i][j];
	}
	
	REP(k,10)REP(i,10)REP(j,10)
	{
		mp[i][j] = min(mp[i][j] ,mp[i][k] + mp[k][j]);
	}
	
	ll ans = 0;
	
	REP(i,w)
	{
		REP(i,h)
		{
			int tmp;
			cin >> tmp;
			if(tmp != -1 && tmp != 1)
			{
				ans += mp[tmp][1];
			}
		}
	}
	
	cout << ans << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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; }
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0, 0,-1,1,-1, 1,-1};
int dy[]={0,1,-1, 0,1,-1,-1, 1};

 
 
LL fpow(LL a, LL n){
    LL x = 1;
    while(n > 0){
        if(n&1){
            x=x*a%mod;
        }
        a=a*a%mod;
        n >>= 1;
    }
    return x;
}
 

int main(){
    LL n;cin >> n;
    vector<LL> c(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    sort(ALL(c));
    LL ans = 0;
    for (int i = 0; i < n; i++) {
        ans = (ans + (n + 1 - i) * fpow(2, (n - 1) * 2) %mod * c[i]%mod)%mod;
    }
    cout << ans << endl;
    return 0;
}


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

ll x[100005];
int main()
{
    ll n,a,b;
    ll sum;
    while(cin >> n >> a >> b)
    {
        sum = 0;
        for(int i = 0;i < n;i++)
            cin >> x[i];
        sort(x,x + n);
        for(int i = 1;i < n;i++)
        {
            sum += min((x[i] - x[i - 1])* a,b);
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
using namespace std;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

long long int combination(long long int n, long long int r){
    if (n == r || r == 0)  return 1;
    else  return combination(n, r - 1) * (n - r + 1) / r;
}

int main(void){
    
    long long int n;
    cin>>n;
    vector<string> s;
    long long int ans = 0;

    for(int i=0;i<n;i++){
        string a;
        cin>>a;
        s.push_back(a);
        sort(s[i].begin(), s[i].end());
    }
    sort(s.begin(), s.end());
    //for(int i=0;i<n;i++) cout<<s[i]<<endl;

    long long int count = 1;
    //int ans = 0;
    for(int i=0;i<n-1;i++){
        if(s[i] == s[i+1]){
            //cout<<i<<endl;
            count++;
            //cout<<count;
        }else{
            if(count!=1){
              //  cout<<i<<endl;
                ans += combination(count, 2);
                count = 1;
            }
        }
        if(i ==n-2){
           //     cout<<i<<endl;
                ans += combination(count, 2);
                count = 1;
            }

    }



    /* int len = n;
    vector<int> index(n);
    int count;
    while(s.size()> 1){
        index [0] = 0;
        count = 1;
       // cout<<s[0]<<endl;
        for(int i=1;i<len;i++){
            //cout<<s[i]<<endl;
            if(s[0] == s[i]){
                len--;
                //index[count] = i;
                count++;
                remove(s, i);
                i--;
            }
        }
        ans += combination(count, 2);
        remove(s,0);
        //cout<<count<<endl;
        // for(int i=0;i<count;i++){
        //     //cout<<index[i]<<" ";
        //     remove(s,index[i]-i);
        // }
        //cout<<endl;
        len = n -count;
        //cout<<"len : "<<len<<endl;
    }*/

    cout<<ans<<endl;
    
    return 0;

}

Measured memory_bytes: 5748
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program
{

    static void Main(string[] args)
    {
        int N = int.Parse(ReadLine());
        var S = ReadLine().ToCharArray();

        var result = new int[N];

        int WCount = 0;
        for (int i = 0; i < N; i++)
        {
            result[i] = WCount;
            if (S[i] == 'W')
            {
                WCount++;
            }

        }

        int ECount = 0;
        for (int i = N - 1; i >= 0; i--)
        {
            result[i] += ECount;
            if (S[i] == 'E')
            {
                ECount++;
            }

        }

        WriteLine(result.Min());
    }


}


Measured memory_bytes: 13920
#include<iostream>
#include<cstring>
#include<cstdio> 
#define INF 0x3f3f3f3f

using namespace std;

const int N=20;
int c[N];
int n,m,x;
int a[N][N];
int ans=INF;
int main()
{
	cin>>n>>m>>x;
	for(int i=1;i<=n;i++){
		cin>>c[i];
		for(int j=1;j<=m;j++){
			cin>>a[i][j];
		}
	}
	for(int i=1;i<(1<<n);i++){
		int sum=0;//记录每种状态所花的钱 
		int res[N];//记录每种算法掌握程度 
		memset(res,0,sizeof(res));
		for(int j=0;j<n;j++){
			if(i&(1<<j)){//如果选择j+1本书 
				for(int k=1;k<=m;k++){
					res[k]+=a[j+1][k];
				}
				sum+=c[j+1];
			}
		}
		bool flag=0;
		for(int j=1;j<=m;j++){
			if(res[j]<x){
				flag=1;
				break;
			}
		}
		if(!flag) ans=min(sum,ans);
	}
	if(ans==INF) puts("-1");
	else cout<<ans<<endl;	
	return 0;
}

Measured memory_bytes: 3644
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

from bisect import bisect

n = int(input())
x = list(map(int, input().split()))
l = int(input())

depth = [-1]*n
depth[-1] = 0

m = 20
par = [[-1]*n for i in range(m)]

def dfs(i):
    if depth[i] >= 0:
        return depth[i]
    j = bisect(x, x[i]+l)-1
    if j == n:
        j = n-1
    par[0][i] = j
    depth[i] = dfs(j) + 1
    return depth[i]

for i in range(n):
    dfs(i)

for i in range(m-1):
    for j in range(n):
        par[i+1][j]=par[i][par[i][j]]

def hoge(x, y):
# xからk個上の頂点がy以上になる最小のkを求める
    k = 0
    for i in range(m)[::-1]:
        if 0 <= par[i][x] < y:
            k += 1<<i
            x = par[i][x]
    return k+1

q = int(input())
ans = []
for i in range(q):
    a,b = map(int, input().split())
    a,b = a-1,b-1
    if a > b:
        a,b = b,a
    ans.append(hoge(a, b))

print(*ans, sep="\n")

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

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(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  string s;
  cin >> s;

  string s1, s2;
  s1 = "";
  s2 = "";
  int N = s.length();
  for(int i = 0; i < N/2; i++){
    s1 += s[i];
  }

  for(int i = 0; i < N/2; i++){
    s2 += s[i+(N+1)/2];
  }

  bool ok1, ok2, ok3;
  ok1 = true;
  ok2 = true;
  ok3 = true;

  for(int i = 0; i < s.length()/2; i++){
    if(s[i] != s[s.length()-1-i]){
      ok1 = false;
      break;
    }
  }
  for(int i = 0; i < s1.length()/2; i++){
    if(s1[i] != s1[s1.length()-1-i]){
      ok2 = false;
      break;
    }
  }
  for(int i = 0; i < s2.length()/2; i++){
    if(s2[i] != s2[s2.length()-1-i]){
      ok3 = false;
      break;
    }
  }

  if(ok1 && ok2 && ok3){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }


  return 0;
}


Measured memory_bytes: 256
N = int(input())
testimony = [[] for _ in range(N)]
ans = 0
for n in range(N):
    A = int(input())
    for _ in range(A):
        x,y = map(int,input().split())
        testimony[n].append([x-1,y]) # 人のナンバリングを0startにする
# print(testimony)
for bit in range(2**N):
#     print("bit",bit)
    honest_cnt = 0
    for j in range(N):
#         print("j",j)
        if (bit>>j) & 1:
            honest_cnt += 1
            for t in testimony[j]:
                if (bit>>t[0])&1 != t[1]:
#                     print("break")
                    break
            else:
#                 print("continue")
                continue
#             print("break")
            break
    else:
#         print("new_ans")
        ans = max(ans,honest_cnt)
print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
  int turi;
  int hara;
  int count;
  while(1){
    count=0;
    cin>>hara;
    if(hara==0) break;
    turi=1000-hara;
    while(turi!=0){
      if(turi>=500){
	turi=turi-500;
	count++;
      }
      else if(turi>=100){
	turi=turi-100;
	count++;
      }
      else if(turi>=50){
	turi=turi-50;
	count++;
      }

      else if(turi>=10){
	turi=turi-10;
	count++;
      }
      else if(turi>=5){
	turi=turi-5;
	count++;
      }
      else if(turi>=1){
	turi=turi-1;
	count++;
      }
    }
    cout<<count<<endl;
  }
}

Measured memory_bytes: 1160
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
using namespace std;
map<int,int> m;
vector<int> v;
int main(){
	int n,sum=0;
	cin>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		if(m[x]==0)v.push_back(x);
		m[x]++;
	}
	for(int i=0;i<v.size();i++){
		if(v[i]>m[v[i]])sum+=m[v[i]];
		else sum+=abs(m[v[i]]-v[i]);
	}
	cout<<sum;
}

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

int main()
{
  char s[4][11];

  rep(i,3) cin >> s[i];

  rep(i,3){
    char S = s[i][0]-32;
    cout << S;
  }

  cout <<  endl;
}

Measured memory_bytes: 256
//g++ t.cpp -o t && t < p.txt
//d>p.txt&&t<p.txt&&t2<p.txt

#include <iostream> // プログラムの耳と口
#include <vector> // 超有能配列秘書
#include <algorithm> // みんな大好きソートと二分探索
#include <queue> // きゅーちゃん、だいすき
#include <string> // to_string
#include <functional> // 関数を変数に入れる子
#include <set> // 値の取得・挿入・削除を高速に
#include <map> // setの妹 これまた優秀
#include <random> // 乱択さん
#include <cassert>

#define DB cerr<<"D"<<endl
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";};
using P=pair<ll,ll>;
const ll M = 1e9+7;
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; template<typename T, typename U> void chmax(T& x, U y) {if (x<y) x=y;}; template<typename T, typename U> void chmin(T& x, U y) {if (x>y) x=y;}
bool vaild(int x, int y, int hh, int ww){return 0<=x&&x<hh&&0<=y&&y<ww;}
int keta(ll a) {int res=0; while(a>0) res+=(a%10/5)+(a%5), a/=10; return res;}

int main() {
  int a,b,c,k; cin>>a>>b>>c>>k;
  while(a >= b) {
    b *= 2;
    k--;
  }
  while(b >= c){
    c *= 2; k--;
  }
  if (k >= 0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
// ・配列の大きさok？　・priority_queueはgreater？　・debug消した？
// ・落ち着いて。提出まで4分待ってね……WJ……1/10……2/10……

// Thank you for making problems and running the contest


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

int main() {
  int N, K, A=0, cnt=0;
  cin >> N >> K;
  while(A<N-1){
    A=A+K-1;
    cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3580
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

from collections import Counter

def solve():
    n = II()
    V = LI()
    
    even = V[::2]
    odd = V[1::2]
    harf = n // 2
    
    ec = Counter(even).most_common()
    oc = Counter(odd).most_common()
    #print(n)
    #print(ec[:3])
    #print(oc[:3])
    e1 = ec[0][1]
    o1 = oc[0][1]
    
    if ec[0][0] == oc[0][0]:
      # 小さい方を変える
      e2 = ec[1][1] if len(ec) > 1 else 0
      o2 = oc[1][1] if len(oc) > 1 else 0
      
      ans = min(n - e1 - o2, n - o1 - e2)
    else:
      ans = n - e1 - o1
    
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 21084
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var s = Console.ReadLine().Split();
        if (s[0] == "H")
        {
            Console.WriteLine(s[1]);
        }
        else
        {
            s[1] = (s[1] == "H" ? "D" : "H");
            Console.WriteLine(s[1]);
        }
    }
}

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

struct object {
	int number;
	int kazu;

	bool operator<(const object& right)const {
		return kazu > right.kazu;
	}
};

int main() {
	int size, answer;
	cin >> size;
	answer = size;
	vector<object> a(pow(10, 5)+1);
	for (int i = 0; i < size; i++) {
		int number;
		cin >> number;
		//cout << number << endl;
		if (a[number].number == 0) {
			a[number].number = number;
			a[number].kazu = 1;
		}
		else {
			a[number].kazu++;
		}
	}
	sort(a.begin(), a.end());
	/*cout << "1回目" << endl;
	for (int i = 0; i < size; i++) {
		cout << "number:" << a[i].number << "\tkazu:" << a[i].kazu << endl;
	}*/
	int index = 0;
	while (true) {
		if (a[index].kazu <= 2) {
			index = 0;
			break;
		}
		else {
			while (true) {
				a[index].kazu -= 2;
				answer -= 2;
				if (a[index].kazu <= 2) {
					index++;
					break;
				}
			}
		}
	}
	sort(a.begin(), a.begin() + size);
	/*cout << "2回目" << endl;
	for (int i = 0; i < size; i++) {
		cout << "number:" << a[i].number << "\tkazu:" << a[i].kazu << endl;
	}*/
	while (true) {
		if (a[index].kazu-- == 2) {
			a[index + 1].kazu--;
			index += 2;
			answer -= 2;
		}
		else {
			break;
		}
	}

	cout << answer << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define gc getchar()
inline int read(){
	int x=0;char c=gc;
	for(;c<48||c>57;c=gc);
	for(;c>47&&c<58;c=gc)
		x=x*10+c-48;
	return x;
}
#define io read()

int n,a[300005];
long long ans;

int main(){
	n=io*3;
	for(int i=1;i<=n;++i)a[i]=io;
	sort(a+1,a+n+1);
	for(int i=1,j=n;i<j;++i,j-=2)ans+=a[j-1];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1408
n = int(input())
numlist = []
for i in range(n):
    numlist.append(int(input()))
argmax = numlist.index(max(numlist))
maxnum = max(numlist)
del numlist[argmax]
secondnum = max(numlist)
                       
for i in range(argmax):
    print (maxnum)
print (secondnum)
for i in range(argmax+1,n):
    print (maxnum)

Measured memory_bytes: 12524
#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 n, m;
    cin >> n >> m;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    priority_queue<ll> pq;
    rep(i, n) pq.push(a[i]);
    rep(i, m) {
        ll v = pq.top(); pq.pop();
        v /= 2;
        pq.push(v);
    }
    ll ans = 0;
    while(!pq.empty()) {
        ans += pq.top(); pq.pop();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	long long t=0,i;
	cin>>s;
	for(i=0;i<s.length();i++)
	{
		if(i%2==0)
		{
			cout<<s[i];
		}
	}
	return 0;
}

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

const int mod = 998244353;
int dp[200010];
int main(){
  
  int n, k;
  cin >> n >> k;
  vector<P> act;
  vector<int> sum(n+1,0);
  rep(i,k){
    int l , r;
    cin >> l >> r;
    act.emplace_back(l,r);
  }  
  
  dp[0] = 0;
  dp[1] = 1;
  sum[0] = 0;
  sum[1] = 1;
  for(int i= 2; i< n+1; ++i){
    for(auto a : act){
      int l = a.first;
      int r = a.second;
      
      l = max(0, i-l);
      r = max(0, i-r-1);
      int p = (sum[l] - sum[r]) % mod;
      if(p < 0) p += mod;     
      dp[i] = (dp[i] + p) % mod;
    }
    sum[i] = (sum[i-1] + dp[i]) % mod;
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 4920
N = gets.to_i
a = gets.split.map(&:to_i)
a = [0, *a, 0]

sum = 0
a_size = a.size
(a_size - 1).times do |i|
  sum += (a[i] - a[i + 1]).abs
end

1.upto(a_size - 2) do |i|
  puts sum - ((a[i - 1] - a[i]).abs + (a[i] - a[i + 1]).abs) + (a[i - 1] - a[i + 1]).abs
end

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

int main(){
    int n; cin >> n;
    vector<int> ans(10010);
    for(int j = 1; j <= 100; j++){
        for(int k = 1; k <= 100; k++){
            for(int l = 1; l <= 100; l++){
                int tmp = j*j + k*k + l*l + j*k + k*l + l*j;
                if(tmp <= 10000){
                    if(j == k && k == l) ans.at(tmp-1)++;
                    else ans.at(tmp-1)++;
                }
            }
        }
    }
    for(int i = 0; i < n; i++){
        cout << ans.at(i) << endl;
    }
}

Measured memory_bytes: 3632
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

S = input()

if len(set(S)) == 0:
    print(0)
    exit()


"""
WWBBBWBBBBW

右から行くと、4
左から行くと、4

どちらからいってもおなじか？

WBWBWBWBWB
右から->9
左から->9
どちらからいってもかわらない？

右左両方から行く場合
WWBBBWBBBBW
WWBBBBWBW

WB, BWの数を数える？

"""
ans = 0

ans += S.count("WB")
ans += S.count("BW")

print(ans)


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N;
int sz;
vector<i64> a;

int main(){
  cin >> N;
  sz = 3 * N;
  a.resize(sz);
  rep(i,0,sz - 1){
    cin >> a[i];
  }

  vector<i64> left;

  vector<i64> right;

  {
    i64 sum = 0;
    priority_queue<i64,vector<i64>,greater<i64>> que;
    rep(i,0,N - 1){
      sum += a[i];
      que.push(a[i]);
    }
    left.push_back(sum);
    rep(i,N,2 * N - 1){

      sum += a[i];
      que.push(a[i]);
      sum -= que.top();
      que.pop();
      left.push_back(max(sum,left.back()));
    }
  }
  {
    i64 sum = 0;
    priority_queue<i64> que;
    for(int i = 3 * N - 1;i >= 2 * N;i--)
    {
      sum += a[i];
      que.push(a[i]);
    }
    right.push_back(sum);
    for(int i = 2 * N - 1;i >= N;i--)
    {
      sum += a[i];
      que.push(a[i]);
      sum -= que.top();
      que.pop();
      right.push_back(min(right.back(),sum));
    }
  }
  i64 ans = left[0] - right[N - 1];
  for(int i = 0;i < left.size();i++){
    ans = max(ans,left[i] - right[left.size() - 1 - i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 5992
#include<bits/stdc++.h>
using namespace std;
char a[110];
bool flag=0;
int main(){
	scanf("%s",&a);
	for(int i=0;i<strlen(a);i++){
		if(!flag&&a[i]=='C')
		flag=1;
		if(flag&&a[i]=='F'){
			printf("Yes\n");
			return 0;
		}		
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T& x, const T& y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T& x, const T& y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Mod-Int
constexpr int MOD = 1000000007;
struct ModInt {
    ll val;
    ModInt() = default;
    ModInt(ll x) : val(x % MOD + (x < 0 ? MOD : 0)) {}
    ModInt &operator+= (const ModInt &x) {if ((val += x.val) >= MOD) val -= MOD; return *this;}
    ModInt &operator-= (const ModInt &x) {if ((val -= x.val) < 0) val += MOD; return *this;}
    ModInt &operator*= (const ModInt &x) {(val *= x.val) %= MOD; return *this;}
    ModInt operator+ (const ModInt &x) const {return ModInt(*this) += x;}
    ModInt operator- (const ModInt &x) const {return ModInt(*this) -= x;}
    ModInt operator* (const ModInt &x) const {return ModInt(*this) *= x;}
    ModInt pow(ll t) const {
        if (!t) return ModInt(1);
        ModInt m = pow(t / 2);
        m *= m;
        if (t & 1) m *= *this;
        return m;
    }
    ModInt inv() const {return pow(MOD - 2);}
    ModInt &operator/= (const ModInt &x) {return *this *= x.inv();}
    ModInt operator/ (const ModInt &x) const {return ModInt(*this) /= x;}
    friend istream &operator>> (istream &is, ModInt &x) {is >> x.val; return is;}
    friend ostream &operator<< (ostream &os, const ModInt &x) {os << x.val; return os;}
};

// Main
int main() {
    int n;
    string s;
    cin >> n >> s;
    
    vector<ModInt> dp(n, ModInt(0));
    dp[0] = ModInt(1);
    per(i, n - 1) {
        vector<ModInt> sum(n + 1, ModInt(0));
        rep(j, n) sum[j + 1] = sum[j] + dp[j];
        rep(j, n - i) {
            if (s[i] == '<') dp[j] = (sum[n - 1] - sum[j]);
            else dp[j] = sum[j];
        }
    }
    
    ModInt ans(0);
    rep(i, n) ans += dp[i];
    cout << ans << "\n";
}


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

int main(void)
{
    using namespace std;

    int n;
    string taro, hanako;
    scanf("%d", &n);

    int score_taro = 0;
    int score_hanako = 0;

    for (int i = 0; i < n; i++) {
        cin >> taro >> hanako;
        if (taro > hanako) {
            score_taro += 3;
        } else if (taro == hanako) {
            score_taro += 1;
            score_hanako += 1;
        } else {
            score_hanako += 3;
        }
    }

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


Measured memory_bytes: 3304
import math

X = int(input())

power = [1]
for i in range(2, X):
    if pow(i, 2) > X:
        break
    k = i
    j = 2
    while k <= X:
        if pow(i, j) > X:
            break
        power.append(pow(i, j))
        k = pow(i, j)
        j += 1

print(max(power))

Measured memory_bytes: 3060
from sys import stdin

while(True):
    try:
        xa,ya,xb,yb,xc,yc,xd,yd = map(float, stdin.readline().split(","))
        ab = [xb-xa,yb-ya]
        bc = [xc-xb,yc-yb]
        cd = [xd-xc,yd-yc]
        da = [xa-xd,ya-yd]
        cr1 = ab[0]*bc[1] - ab[1]*bc[0]
        cr2 = bc[0]*cd[1] - bc[1]*cd[0]
        cr3 = cd[0]*da[1] - cd[1]*da[0]
        cr4 = da[0]*ab[1] - da[1]*ab[0]
        if (cr1<0 and cr2<0 and cr3<0 and cr4<0) or (cr1>0 and cr2>0 and cr3>0 and cr4>0):
            print("YES")
        else:
            print("NO")
    except:
        break



Measured memory_bytes: 5588
//実装が重そうな問題はある程度考えてから書く
//初期化を忘れずに（特に二分探索とか）
//コーナーケースを考えて（特に場合分けとか）
//不可解すぎるバグは配列外参照（配列の長さ）を検討
#include "bits/stdc++.h"
#define YES "YES"
#define Yes "Yes"
#define NO "NO"
#define No "No"
#define YESNO(x) OUT(three(x,YES,NO))
#define YesNo(x) OUT(three(x,Yes,No))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b-1,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB emplace_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int long long
#define zero 0LL
#define all ALL
#define pb PB
using namespace std;
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef LL ll;
typedef double ld;
typedef LL ut;
const LL INF = 1LL << 60;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<ppr, Vppr ,greater<ppr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
int dx[] = { 0,1,0,-1,1,1,-1,-1,0 }, dy[] = { 1,0,-1,0,1,-1,1,-1,0 };
const int SIZE1 =2e6 + 1000;
const int SIZE2 = 2010;
const int SIZE3 = 22;
const int SIZE = SIZE1;
const LL p = 7 + 1e9;const long double EPS = 1e-7;
ut N, M, K, X, L, Y,H,W,Q,D;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], nums[SIZE], maps[SIZE2][SIZE2], answer = zero;
LL A[SIZE], B[SIZE],I[SIZE];
LL solve() {
	string s;
	cin >> s;
	REP(i, s.size()) {
		A[s[i]]++;
	}
	N = s.size();
	answer = N * (N - 1) / 2;
	EFOR(i, 'a', 'z') {
		answer -= A[i] * (A[i] - 1) / 2;
	}
	cout << answer+1 << endl;
	return 0;
}
signed main() {
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	solve();
	//	cin >> N;
	return 0;
}

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(num) scanf("%d",&num)
#define sff(num1,num2) scanf("%d %d",&num1,&num2)
#define sfff(num1,num2,num3) scanf("%d %d %d",&num1,&num2,&num3)
#define sl(num) scanf("%lld",&num)
#define sll(num1,num2) scanf("%lld %lld",&num1,&num2)
#define slll(num1,num2,num3) scanf("%lld %lld %lld",&num1,&num2,&num3)
#define rep(i,n) for(i=1;i<=n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define pb push_back
#define mpp make_pair
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
#define TIME cerr<<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<"s\n";
typedef long long int ll;
using namespace std;
int main()
{
    int n;
    string a;
    cin>>n>>a;
    if(n>=3200)
        cout<<a;
    else
        puts("red");
}


Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    REP(i, n) cin >> x[i] >> y[i];
    
    vector<int> order(n);
    REP(i, n) order[i] = i;
    double sum = 0;
    int count = 0;
    do {
        double length = 0;
        REP(i, n-1) {
            length += sqrt(pow(x[order[i+1]]-x[order[i]], 2) + pow(y[order[i+1]]-y[order[i]], 2));
        }
        sum += length;
        count++;
    } while (next_permutation(order.begin(), order.end()));
    cout << setprecision(16) << sum / count << endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define GI(i) (scanf("%d",&i))
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define get0(x)     (get<0>(x))
#define get1(x)     (get<1>(x))
#define get2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       9223372036854775807LL
#define LLMIN       -9223372036854775808LL
#define IMAX        2147483647
#define IMIN        -2147483648
typedef long long LL;
using namespace std;

LL X,Y;

int main(void){
    cin>>X>>Y;
    LL ans=0;
    while(X<=Y){
        X*=2;
        ans++;
    }
    cout<<ans<<endl;

     return 0;
}

Measured memory_bytes: 256