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

using ld = long double;

constexpr ld eps = 1e-8;

bool check(ld m, vector<ld>& s, vector<ld>& t, vector<ld>& u, ld L) {
    const int N = s.size();
    ld first = L;
    for(int i=0; i<N; ++i) {
        first -= (t[i] - s[i]) * (u[i] - m);
        if(first <= 0) {
            return false;
        }
        if(i != N-1) {
            first += (s[i+1] - t[i]) * m;
        } else {
            first += (86400 - t[i]) * m;
        }
        first = min(first, L);
    }
    ld second = min(first + s[0] * m, L);
    for(int i=0; i<N; ++i) {
        second -= (t[i] - s[i]) * (u[i] - m);
        if(second <= 0) {
            return false;
        }
        if(i != N-1) {
            second += (s[i+1] - t[i]) * m;
        } else {
            second += (86400 - t[i]) * m;
        }
        second = min(second, L);
    }
    return second - first >= 0;
}

int main() {
    int N, L;
    while(cin >> N >> L, N) {
        vector<ld> s(N), t(N), u(N);
        for(int i=0; i<N; ++i) {
            cin >> s[i] >> t[i] >> u[i];
        }
        ld lb = 0, ub = 1e12;
        while(ub - lb > eps) {
            ld m = (ub + lb) / 2;
            if(check(m, s, t, u, L)) {
                ub = m;
            } else {
                lb = m;
            }
        }
        cout << fixed << setprecision(10) << lb << endl;
    }
}


Measured memory_bytes: 6992
#include<bits/stdc++.h>
using namespace std;
int a=0;
string s; 
int main()
{
	getline(cin,s);
	int len=s.size();
	for(int i=2;i<len;i++)
		a++;
	if(a!=0) cout<<s[0]<<a<<s[len-1];
	else
	{
		for(int i=0;i<=len;i++)
			cout<<s[i];
	}
	return 0;
}

Measured memory_bytes: 256
f n (0:as) = f (n+1) as
f n (a:as) = n : f n (a-1:as)
g 0 _ _ = []
g h w xs = ys : g (h-1) w zs
  where (ys,zs) = splitAt w xs
main = do
  [h,w] <- map read . words <$> getLine
  getLine
  as <- map read . words <$> getLine
  mapM (putStrLn . unwords . map show) 
    $ zipWith ($) (cycle [id,reverse]) (g h w (f 1 as))

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

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

const int MAXN = 100005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n,m; cin>>n>>m;
	string s(n,'.');
	forn(i,0,m){
		int p,x; cin>>p>>x; p--;
		if(s[p]!='.' && x!=s[p]-'0'){
			cout<<-1<<'\n';
			return 0;
		}
		
		s[p]='0'+x;
	}
	
	if(s[0]=='0' && n!=1){
		cout<<-1<<'\n';
		return 0;
	}
	
	forn(i,0,n){
		if(s[i]=='.'){
			if(i==0 && n!=1) s[i]='1';
			else s[i]='0';
		}
	}
	
	cout<<s<<'\n';
	
	return 0;
}


Measured memory_bytes: 3636
N = gets.to_i
A = 2.times.map{ Array.new(N + 1, 0) }
2.times do |i|
  gets.split.map(&:to_i).each.with_index(1) do |v,j|
    A[i][j] = A[i][j - 1] + v
  end
end
puts (1 .. N).map{|i| A[0][i] + A[1][N] - A[1][i - 1] }.max



Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
int main()
{
    int k,x;
    cin >> k >> x;
    if(k*500 >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
	string s;
	cin >> s;
	
	ll dp[100005][13];
	for(int i = 0; i < 13; ++i) dp[0][i] = 0;
	dp[0][0] = 1;

	int len = s.length();
	for(int i = 0; i < len; ++i)
	{
		for(int j = 0; j < 13; ++j) dp[i + 1][j] = 0;

		int num = ((s[i] == '?') ? -1 : s[i] - '0');
		for(int j = 0; j < 10; ++j)
		{
			// num が数字の時はその数のみ、? のときは0~9について計算
			if (num != -1 && num != j) continue;
			for(int k = 0; k < 13; ++k)
			{
				dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
			}
		}
		for (int j = 0; j < 13; ++j)
		{
			dp[i + 1][j] %= MOD;
		}
	}
	cout << dp[len][5];

}

int main()
{
	fastio;
	solve();

	return 0;
}

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

using namespace std;
using ll=long long;

int main()
{
    int n,k;cin >>n>>k;
    n--;k--;
    for(int i=0;i<n;i++){
        int a;cin >>a;
    }
    cout << (n+k-1)/k<< endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll p = 100;
    ll X; cin >> X;
    int cnt = 0;
    while (p < X) {
        cnt++;
        ll q = p/100;
        p += q;
    }

    cout << cnt << ln;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long int

signed main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n-1;i++){
        if(a[i] == a[i+1]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>

#define div1 1000000007

using namespace std;

int main(void)
{
    long long N, X[100001], L[100001], i, S[100001], T[100001], ans=0, t=-10000000000;

    cin >> N;

    for(i=1; i<=N; i++){
        cin >> X[i] >> L[i];
        
        S[i] = X[i] - L[i];
        T[i] = X[i] + L[i];
    }

    pair<int, int> itv[100001];

    for(i=1; i<=N; i++){
        itv[i].first = T[i];//終
        itv[i].second = S[i];//始
    }

    sort(itv+1, itv+N+1);

    for(i=1; i<=N; i++){
        if(t <= itv[i].second){
            ans++;
            t = itv[i].first;
        }
    }

    cout << ans << endl;

    return 0;
}

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

//関数


    
    
    
//main関数
int main() {
    
    
    //入力
    long a,b;
    cin>>a>>b;
    
    
    
    
    
    
    //計算
    
    //出力
    if(0<a){
        cout <<"Positive"<<endl;
    }else if(a<=0 && 0<=b){
        cout<<"Zero"<<endl;
    }else{
        if((b-a)%2==1){
            cout <<"Positive"<<endl;
        }else{
            cout <<"Negative"<<endl;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
using namespace std;

int LCM(int a, int b) {
	int result = 1;
	int i = 2;
	while(i <= a && i <= b) {
		if (a % i == 0 && b % i == 0) {
			result *= i;
			a /= i;
			b /= i;
		}
		else i++;
	}
	return result;
}

int GCD(int a, int b) {
	int result = 1;

	int lcm = LCM(a, b);

	a /= lcm;
	b /= lcm;

	return a * b*lcm;


}

int main() {
	int a, b, lcd;

	while (cin >> a >> b) {




		printf("%d %d\n", LCM(a, b),GCD(a,b));

	}

	//system("pause");
	return 0;
}


Measured memory_bytes: 3204
#include <stdio.h>

int main(void)
{
	int n, a, b;
	scanf("%d", &n);
	if(n == 1)
		printf("Hello World\n");
	else {
		scanf("%d", &a);
		scanf("%d", &b);
		printf("%d\n", a + b);
	}

	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int sum;
        for (String str = sc.next(); !str.equals("0"); str = sc.next()){
            sum = 0;
            char[] ch = str.toCharArray();
            
            for (int i = 0; i < str.length(); i++){
                sum += ch[i] - '0';
            }
            System.out.println(sum);
        }
    }
}

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

int main()
{
    int n, l;
    cin >> n >> l;
    vector<string> v;
    while (n--)
    {
	string s;
	cin >> s;
	v.push_back(s);
    }
    string result = "";
    sort(v.begin(), v.end());
    for (auto s : v)
    {
	result += s;
    }
    cout << result;
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <iomanip>
#include <iostream>
#include <vector>    
#include <cstdlib>
#include <set>
#define fast_io()                \
    ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define mod 998244353
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    fast_io();
    int k, n, a[200001];
    cin >> k >> n;
    int m = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if(i>=1)
        if(m<abs(a[i]-a[i-1]))
            m=abs(a[i]-a[i-1]);
    }
    
    if(m<abs(k-a[n-1])+a[0])
            m=abs(k-a[n-1])+a[0];
    cout << k - m;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
//typedef vector<vector<char> > nums( h , vector<char> (w, 'a'));

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy

int main() {
  ll k;
  cin >> k;
  if (k%2==0 || k%5==0) {
    cout << -1;
    return 0;
  }

  ll m = 7 % k;
  FOR(i,1,MOD+1){
    if(m==0){
      cout << i;
      return 0;
    }
    m = (m % k * 10 % k + 7 % k) % k;
  }
  return 0;
}

Measured memory_bytes: 3608
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

ll arr[100010];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    //cout << fixed << setprecision(15);

    int N;
    cin >> N;
    int ans = 0;
    for (int i = 0; i < N; ++i)
    {
        int a;
        cin >> a;
        a--;
        ans += a;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define FOR(i, a, b) for (int i=(a); i<(b); i++)

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

int main() {
  long long A,B;
  cin >> A >> B;
  long long gcdab = gcd(A,B);
  //cout << gcdab << endl;
  long long sum = 1; //最初に1
  for (long long i=2; i*i <= gcdab; i++) {
    if (gcdab % i != 0) continue;
    sum++;
    //cout << i << " " << gcdab << endl;
    while (gcdab%i == 0) {
      gcdab /= i;
    } 
  }
  if (gcdab != 1) sum++;
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3608
s = input()
tmp = len(s) - 7
if s[tmp:] == "keyence" or s[:tmp] == "keyence":
    print("YES")
    exit()

for i in range(len(s) - tmp):

    if s[:i + 1] + s[i + 1 + tmp:] == "keyence":
        print("YES")
        exit()
print("NO")


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>

using namespace std;

int m, n;
double prob[16][16];
double dp[16][1<<16];

double search(int pos, int cat){
	if(dp[pos][cat] > -0.5) return dp[pos][cat];
	double& res = dp[pos][cat];
	res = 0.0;
	for(int i=0;i<m;i++){
		if(cat&(1<<i)) continue;
		double pSum = 0.0;
		double pCur = 1.0;
		for(int j=pos;j<n;j++){
			pSum += (1-prob[i][j])*pCur*search(j, cat|(1<<i));
			pCur *= prob[i][j];
		}
		pSum += pCur;
		res = max(res, pSum);
	}
	return res;
}

int main(){
	while(cin >> m >> n){
		for(int i=0;i<m;i++){
			for(int j=0;j<n;j++) cin >> prob[i][j];
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<(1<<m);j++) dp[i][j] = -1.0;
		}
		printf("%.10lf\n", search(0, 0));
	}
}

Measured memory_bytes: 9440
#include<bits/stdc++.h>
#include<vector>
#include<string>
using namespace std;
#define l long long
#define pb push_back
#define mem(a,n) memset(a,n,sizeof(a))
#define find(v,n) find(v.begin(),v.end(),n)
#define sort1(v) sort(v.begin(),v.end())
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mod 998244353
#define reverse(s) reverse(s.begin(),s.end())
//#define pi pair<l,l> 
const double pi=3.141592653589793;
bool isprime(l n)
{
	for(l i=2;i<=n;i++)
	{
		if(n%i==0)
			return false;
	}
	return true;
}
/*bool fact(l n)
{
	vector<l> v;
	for(l i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			if(i%2==1||(n/i)%2==1)
			{
				return true;
			}
		}
	}
	return false;
}*/
l power(l a,l b)
{
	l ans=1;
	while(b>0)
	{
		if(b&1)
		{
			ans=(ans*a)%mod;
		}
		b>>=1;
		a=(a%mod*a%mod)%mod;
	}
	return ans;
}//prefixsums
void frooty()
{
	char c;
	cin>>c;
	if(c>='a'&&c<='z')
		cout<<'a'<<"\n";
	else
		cout<<'A'<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int q=1;
//	cin>>q;
	while(q--)
	{
		frooty();
	}
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>
#include <bitset>
#include <queue>

using namespace std;

using ll = long long;

template <typename T>
class UnionFind
{
	std::vector<T> parents;
	T uf_size;

  public:
	UnionFind(std::vector<T> nodes)
	{
		uf_size = max(nodes);
		parents = std::vector<T>(uf_size + 1, -1);
		parents[0] = 0; // 0は使わない
	}

	UnionFind(T s)
	{
		uf_size = s;
		parents = std::vector<T>(uf_size + 1, -1);
		parents[0] = 0; // 0は使わない
	}

	T root(T node)
	{
		T p = parents[node];
		return (p < 0) ? node : root(p);
	}

	// O(1)
	bool isConnected(T a, T b)
	{
		T root_of_a = root(a);
		T root_of_b = root(b);
		return root_of_a == root_of_b;
	}

	// O(1)
	void connect(T a, T b)
	{
		T root_a = root(a);
		T root_b = root(b);

		if (root_a == root_b)
			return;

		if (parents[root_a] < parents[root_b])
			swap(root_a, root_b);

		parents[root_a] += parents[root_b];
		parents[root_b] = root_a;
	}

	// O(1)
	T size(T node)
	{
		shallow(node);
		return -parents[root(node)];
	}

	// O(N)
	void shallow(T node)
	{
		if (parents[node] < 0)
			return;

		T root_node = root(node);
		if (root_node != parents[node])
		{
			T current = node;
			while (current != root_node)
			{
				T parent = parents[current];
				parents[current] = root_node;
				current = parent;
			}
		}
	}

	void printRow()
	{
		for (int i = 1; i <= uf_size; i++)
		{
			std::cout << i << " => " << parents[i] << std::endl;
		}
	}

	void print()
	{
		for (int i = 1; i <= uf_size; i++)
		{
			if (parents[i] < 0)
			{
				std::cout << i << "(" << -size(i) << ") => ";
				for (int j = 1; j <= uf_size; j++)
				{
					if (parents[j] == i || i == j)
					{
						std::cout << j << " ";
					}
				}
				std::cout << std::endl;
			}
		}
	}
};

struct bridge
{
	int from;
	int to;
};

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

	// O(N)
	UnionFind<ll> uf = UnionFind<ll>(n);

	vector<bridge> bridges(m);

	//O(M)
	for (int i = 0; i < m; i++)
	{
		bridge b;
		cin >> b.from >> b.to;
		bridges[i] = b;
	}

	vector<ll> inconvinience_scores(m + 1, 0); // i本の橋があるときの不便さ
	ll current_score = n * (n - 1) / 2;
	inconvinience_scores[0] = current_score;

	// O(M)
	for (int i = 0; i < m; i++)
	{
		bridge b = bridges[m - 1 - i];

		// O(1)
		if (!uf.isConnected(b.from, b.to))
		{
			current_score = current_score - (uf.size(b.from) * uf.size(b.to));
			uf.connect(b.from, b.to);
		}

		if (current_score == 0)
			break;

		inconvinience_scores[i + 1] = current_score;
	}

	for (auto itr = inconvinience_scores.rbegin() + 1; itr != inconvinience_scores.rend(); itr++)
	{
		cout << *itr << endl;
	}
}

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

using namespace std;

#define int long long

using cd = complex<double>;
const double PI = acos(-1);

struct Template_FFT
{
	void fft(vector<cd> &a, bool invert)
	{
	    int n = a.size();
	
	    for (int i = 1, j = 0; i < n; i++)
	    {
	        int bit = n >> 1;
	        for (; j & bit; bit >>= 1)
	            j ^= bit;
	        j ^= bit;
	
	        if (i < j)
	            swap(a[i], a[j]);
	    }
	                                                   
	    for (int len = 2; len <= n; len <<= 1)
	    {
	        double ang = 2 * PI / len * (invert ? -1 : 1);
	        cd wlen(cos(ang), sin(ang));
	        for (int i = 0; i < n; i += len)
	        {
	            cd w(1);
	            for (int j = 0; j < len / 2; j++)
	            {
	                cd u = a[i + j], v = a[i + j + len / 2] * w;
	                a[i + j] = u + v;
	                a[i + j + len / 2] = u - v;
	                w *= wlen;
	            }
	        }
	    }
	
	    if (invert)
	        for (cd &x : a)
	            x /= n;
	}
	
	vector<int> multiply(vector<int> const& a, vector<int> const& b)
	{
		vector<cd> fa(a.begin(), a.end()), fb(b.begin(), b.end());
		int n = 1;
		while(n < a.size() + b.size())
			n <<= 1;
		fa.resize(n);
		fb.resize(n);
	
		fft(fa, false);
		fft(fb, false);
	
		for (int i = 0; i < n; i++)
			fa[i] *= fb[i];
		fft(fa, true);
	
		vector<int> result(n);
		for (int i = 0; i < n; i++)
			result[i] = long(fa[i].real() + 0.5);
		return result;
	}
}FFT;	

const int mod = 200003;

int val_pow[200011], org[200011];

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

	int g = 1;
	val_pow[1] = 0;
	org[0] = 1;
	for (int i = 1; i <= 200001; i++)
	{
		(g *= 2) %= mod;
		val_pow[g] = i;
		org[i] = g;
	}	

	int n;
	cin >> n;
	vector<int> a(200003), arr(200001);
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
		if (arr[i])
			a[val_pow[arr[i]]]++;
	}	
	vector<int> res = FFT.multiply(a, a); 	
	for (int i = 0; i < n; i++)
		if (arr[i])
			res[val_pow[arr[i]] + val_pow[arr[i]]]--;
	int ans = 0;
	for (int i = 0; i < 200003; i++)
		ans += org[i] * (res[i] + res[i + 200002]);
	cout << ans / 2;
}

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

int main(){
  	int N, l[1010], r[1010], num_people = 0;
  
  	cin >> N;
  	for(int i = 0;i < N; i++)	cin >> l[i] >> r[i];
  
  	for(int i = 0;i < N; i++)	num_people += (r[i]-l[i]+1);
  
  	cout << num_people << endl;
  
  	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		long N = sc.nextLong();
		long min = N-1;
      
		/*for(long i=2; i<(long)N/2; i++){
			if((long)N%i==0){
				long d = (long)N/i;
				long ans = d+i-2;
				if(ans<min){
					min = ans;
                }
            }
        }*/
		long i = 2L;
		long j = N/2L;
		while(i<=Math.sqrt(N)){
			if(N%i==0){
				j = N/i;
				long ans = j+i-2;
				if(ans<min){
					min = ans;
                }
            }
			i++;
		}
		System.out.println(min);
    }
}

Measured memory_bytes: 22996
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define REP(i,a) for(int i=0;i<(a);i++)
#define REPR(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
// using ll = long long;
// using vi = vector<int>;
// using vvi = vector<vi>;
// using vl = vector<long long>;
// using vvl = vector<vl>;
// using vs = vector<string>;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

int main () {
  int a[5],num=0,min=100,b[5],min_num=100;
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
  for (size_t i = 0; i < 5; i++) {
    b[i] = a[i]%10 == 0? 10 : a[i]%10;
    // cout << i << " : " << b[i] << endl;
    if(min > b[i]){
      min = b[i];
      min_num = i;
    }
  }
  for (size_t i = 0; i < 5; i++) {
    if(i== min_num) {
      num+= a[i];
      // cout << num << endl;
    } else {
      if(b[i]==10){
        num+=a[i];
        // cout << num << endl;
      } else {
        int c = a[i]/10;
        c++;
        c*=10;
        num+= c;
        // cout << num << endl;
      }
    }
  }



  pi(num); br();
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scanner =new Scanner(System.in);
		String symbols = scanner.nextLine();
		String[] arr_split = symbols.split("",0);
		scanner.close();
		int ans = 0;
		for (String string : arr_split) {
			if (string.equals("+")) {
				ans++;
			} else {
				ans--;
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 22868
N = int(input())
A = sorted(list(map(int, input().split())))

if N == 2:
  print(max(A))
  exit()
  
#A0, A1, A2の約数のリストをとって和集合にする
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    divisors.reverse()
    return divisors
rawcdivisors = set(make_divisors(A[0]))|set(make_divisors(A[1]))|set(make_divisors(A[2]))

#各ループで、これが答えとなるかチェック
#初期値は、答えとなる可能性のある整数のうち最大のもの
cnum = A[1]

cdivisors = set(list(rawcdivisors))
#これより大きいものをcdivisorsから省く
for divnum in list(rawcdivisors):
  if divnum > cnum: cdivisors.remove(divnum)

ans = 0
for i in sorted(list(cdivisors),reverse=True): #secminaから1までチェック
  ngcnt = 0 #各iでngcntを初期化
  for a in A:
#    print('i, a: '+str(i)+', '+str(a))
    if a % i != 0: #公約数じゃなければ+1
      ngcnt += 1
      if ngcnt >= 2: break #2になったら望みなし
  if ngcnt >= 2: continue #2だったら望みなし
  else:
    ans = i #1以下ならiが答え
    break
  
  
print(ans)

Measured memory_bytes: 14436
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

void solve() {
  string s;
  cin >> s;
  bool yymm = 1 <= (10*(s[2]-'0') + s[3]-'0') && (10*(s[2]-'0') + s[3]-'0') <= 12;
  bool mmyy = 1 <= (10*(s[0]-'0') + s[1]-'0') && (10*(s[0]-'0') + s[1]-'0') <= 12;
  if(yymm && mmyy) cout << "AMBIGUOUS\n";
  if(!yymm && mmyy) cout << "MMYY\n";
  if(yymm && !mmyy) cout << "YYMM\n";
  if(!yymm && !mmyy) cout << "NA\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
  solve();
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
#define szxb 12
#define P putchar
using namespace std;
string s[12];
int main()
{
	getline(cin,s[1]);getline(cin,s[0]);
	int len(min(s[1].length(),s[0].length()));bool flag(s[1].length()>s[0].length());
	for(register int i(0);i<=(len-1);i++){P(s[1][i]);P(s[0][i]);}
	for(register int i(len);i<=(s[flag].length()-1);i++){P(s[flag][i]);}
	return P(10),0;
}

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

//型定義
typedef long long ll;

//定数
const ll INF=1e+18;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//省略
using vi  = vector<int>;
using vii = vector<vector<int>>;
using vl  = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
    ll N;
    cin>>N;
    vector<ll> A(N);
    REP(i,N) cin>>A[i];
    
    ll ans=0;
    REP(i,N-1){
        if(A[i+1]<A[i]){
            ans+=(A[i]-A[i+1]);
            A[i+1]+=(A[i]-A[i+1]);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4744
#include <bits/stdc++.h>
using namespace std;
/*
int main (){
	double a;
	double b = 7;
	double c = 48;
	a = b / c;
	cout << setprecision(11) << a << endl;
	return 0;
}*/
double ans = 0, n, k;
double i, j, l;

int main (){
	cin >> n >> k;
	for (i = 1; i <= n; i++){
		j = 0;
		while(pow(2, j) < k / i) j++;
		ans += pow(0.5, j) / n;
	}
	cout << setprecision(11) << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int, D: int):
    print(len(set(range(A, B)) & set(range(C, D))))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(A, B, C, D)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import Data.List
import Control.Monad

getVals :: Read a => IO [a]
getVals = getLine >>= (return . map read . words)
getStrs = getLine >>= (return . words)

solve' n k vs = [(calc a b k vs, (a, b)) | a <- [0..m], b <- [0..m-a]]
    where
        m = min n k
solve n k vs = fst $ maximum $ solve' n k vs 
calc a b k vs = sum largest
    where
        largest = take (max n_positive $ 2*a+2*b-k) $ reverse $ sort full
        n_positive = length $ filter (\x -> x >= 0) full
        full = (take a vs) ++ (take b $ reverse vs)

main = do
    [n, k] <- getVals :: IO [Int]
    vs <- getVals :: IO [Integer]
    print $ solve n k vs

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second



int main(){
    string s;
    cin >> s;
    ll memo = 0;
    ll k;
    cin >> k;
    rep(i,0,min((ll)s.size(),k)){
        if(s[i] != '1'){
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << 1 << endl;
}




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

long long dp[200];

int main(void){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0;i < n;i++)cin >> a[i];
    
    dp[0] = 1000;
    for(int i = 0;i < n;i++){
        dp[i+1] = dp[i-1];
        for(int j = 0;j <= i;j++){
            long long b = dp[j] / a[j];
            dp[i+1] = max(dp[i+1],dp[j] - b * a[j] + b * a[i]);
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 3608
#include<stdio.h>
int main(void)
{
    long int a,b,x,s=0,i=1;
    scanf("%ld%ld",&a,&b);
    while(i!=b-a){
        s+=i;
        i++;
    }
    x=s-a;
    printf("%ld\n",x);
    return 0;
}

Measured memory_bytes: 128
S = list(str(input()))
KEY = ["k","e","y","e","n","c","e"]
num = 0
endY = False
endN = False
cnt = 0
for i in range(len(S)):
	cnt += 1
	if(num == 6):
		print("YES")
		break
	elif(endY == True):
		print("YES")
		break
	elif(endN == True):
		print("NO")
		break
	elif(len(S)<7):
		print("NO")
		break		
	elif(len(S)==7 and S[0]!="k"):
		print("NO")
		break

	elif(S[i]==KEY[num]):
		num += 1

	elif(num>=0 and S[i]!=KEY[num]):
		num2 = 0
		for j in range(len(S)):
			if(num+num2 == 7):
				endY = True
				break
			
			elif((num+num2 <7) and S[len(S)-(j+1)] == KEY[7-(j+1)]):
				num2 += 1
			
			else:
				endN = True
				break


Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl

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

  int k,a,b;
  cin>>k>>a>>b;

  for(int i=a;i<=b;i++){
    if(i%k==0){
      cout<<"OK"<<endl;
      return 0;
    }
  }
   cout<<"NG"<<endl;
  
     
  return 0;
}


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

long long under[110][5];

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s; int k; cin >> s >> k;
    int n = s.size(); int cnt = 0;
    for (int i = 0; i < n; i++) {
        int sn = s[i] - '0';
        for (int u = 0; u <= 3; u++) {
            for (int d = 0; d < 10; d++) {
                under[i+1][u+(d!=0)] += under[i][u];
            }
        }
        for (int d = 0; d < sn; d++) {
            if ((cnt + (d!=0)) < 5) under[i+1][(d!=0)+cnt] += 1;
        }
        cnt += (sn != 0);
    }
    cout << under[n][k] + (cnt == k) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int s[100];
bool dp[101][50001];
signed main() {
	int n; scanf("%d", &n);
	rep(i, n)scanf("%d", &s[i]);
	dp[0][0] = 1;
	rep(i, n)rep(j, 10001) {
		if (j + s[i])dp[i + 1][j + s[i]] |= dp[i][j];
		dp[i + 1][j] |= dp[i][j];
	}
	int Max = 0;
	rep(i, 10001) {
		if (dp[n][i] == 1 && (i % 10 != 0))Max = i;
	}
	printf("%d\n", Max);
}

Measured memory_bytes: 3072
import sys
import random
import time
import numpy as np

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def prob(e1,e2,T):
    if e2 < e1:
        return 1
    else:
        return np.exp((e1-e2)/T)

def solve():
    D = ni()
    c = nl()
    s = [nl() for _ in range(D)]
    m = 26
    start = time.time()
    dT = 0.995
    T = 200

    def calc(sche, m=26):
        last = [-1] * m
        ans = 0
        for i in range(D):
            t = sche[i]
            ans += s[i][t]
            last[t] = i
            for j in range(m):
                ans -= c[j] * (i - last[j])
        return ans

    def change(d, q, sc):
        b = sche[d]
        fq, bq = -1, D
        fb, bb = -1, D
        for i in range(d):
            if sche[i] == q:
                fq = i
            if sche[i] == b:
                fb = i
        for i in range(D-1, d, -1):
            if sche[i] == q:
                bq = i
            if sche[i] == b:
                bb = i
        sc += ((bb - d) * (bb - d - 1) // 2 + (d - fb) * (d - fb - 1) // 2) * c[b]
        sc += ((bq - fq) * (bq - fq - 1) // 2) * c[q]
        sc -= s[d][b]
        sc -= ((bq - d) * (bq - d - 1) // 2 + (d - fq) * (d - fq - 1) // 2) * c[q]
        sc -= ((bb - fb) * (bb - fb - 1) // 2) * c[b]
        sc += s[d][q]
        return sc

    sche = [0] * D
    for i in range(D):
        sche[i] = s[i].index(max(s[i]))
    sc = calc(sche)
    bestst = sche[:]
    best = sc

    while time.time() - start < 1.8:
        for _ in range(300):
            d = random.randint(0, D-1)
            q = random.randint(0, m-1)
            nsc = change(d, q, sc)
            if best < nsc:
                bestst = sche[:]
                best = nsc
            if random.random() < prob(-sc, -nsc, T):
                sche[d] = q
                sc = nsc
        T *= dT
    prn([1 + x for x in bestst])
    return

solve()


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

using namespace std;

using ll = long long; 

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n, x;
    cin >> n >> x;
    int pre, cur;
    cin >> pre;
    long long total = 0;
    for (int i = 1; i < n; ++i) {
        cin >> cur;
        int diff = pre + cur - x;
        if (diff > 0) {
            total += diff;
            cur -= min(cur, diff);
        }
        pre = cur;
    }

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

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN=105;
int a[MAXN]; 
int main () {
    int n,cnt=0;
    scanf ("%d",&n);
    for (int i=0;i<n;i++) {
    	scanf ("%d",&a[i]);
	}
	for (int i=0;i<n;i++) {
		int mn=i;
		for (int j=i+1;j<n;j++) {
			if (a[j]<a[mn]) mn=j;
		}
		if (mn!=i) {
			swap (a[mn],a[i]);
			cnt++;
		}
	}
	printf ("%d",a[0]);
	for (int i=1;i<n;i++) {
		printf (" %d",a[i]);
	}
	printf ("\n%d\n",cnt);
    return 0;
}


Measured memory_bytes: 2716
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i = (m); i < (n); i++)
#define rrep(i,m,n) for(int i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

const ll max_N = 200000;
ll fac[max_N + 10], facinv[max_N + 10];

ll power(ll x, ll n){ // xのn乗 % MOD
    if(n == 0) return 1LL;
    ll res = power(x * x % MOD, n/2);
    if(n % 2 == 1) res = res * x % MOD;
    return res;
}

ll nck(ll n, ll k){
    if(k == 0 || n == k) return 1;
    return fac[n] * facinv[k] % MOD * facinv[n-k] % MOD;
}

ll npk(ll n, ll k){
    if(k == 0 || n == k) return 1;
    return fac[n] * facinv[n-k] % MOD;
}

void comb_setup(){
    fac[0] = 1; fac[1] = 1;
    rep(i,2,max_N+1) fac[i] = (fac[i-1] * i) % MOD;
    rep(i,0,max_N+1) facinv[i] = power(fac[i], MOD - 2);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll a[100010];
    cin >> N;
    rep(i,0,N+1) cin >> a[i];
    ll p = -1;
    map<ll,ll> mp;
    rep(i,0,N+1){
        if(mp[a[i]] == 1){
            p = a[i];
        }
        mp[a[i]]++;
    };
    ll p1 = 0, p2 = 0, cnt = 0;
    rep(i,0,N+1){
        if(a[i] == p){
            if(cnt == 0){
                p1 = i;
                cnt++;
            }else{
                p2 = i;
            }
        }
    }
    p2 = N - p2;
    comb_setup();
    rep(i,1,N+2){
        // if(i == 1){
        //     print(N);
        //     continue;
        // }
        // if(i == N+1){
        //     print(1);
        //     continue;
        // }
        ll ans = nck(N+1, i);
        if(p1+p2 >= i-1){
            ans -= nck(p1+p2, i-1);
        }
        ans = (ans + MOD) % MOD;
        print(ans);
    }
}


Measured memory_bytes: 11392
#include <stdio.h>

int main(void){
	long n, k;

	scanf("%ld%ld", &n, &k);

	n %= k;
	if(((n-k<0) ? k-n : n-k) < n)
		n = (n-k<0) ? k-n : n-k;
	printf("%ld", n);

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
char s[205];
vector <int> c[205],h[205];
bool vis[205],flag;
int n,ans,color[205];
void dfs0(int u,int x){
    vis[u]=1; color[u]=x;
    for (auto v:h[u]){
        if (vis[v]) flag|=(color[u]==color[v]);
        else dfs0(v,x^1);
    }
}
int work(int x){
    memset(vis,0,sizeof(vis));
    for (int i=1;i<=n;i++) c[i].clear();
    int pos=1; color[x]=1; vis[x]=1; c[1].pb(x);
    while (1){
        for (auto u:c[pos]){
            for (auto v:h[u]){
                if (vis[v]){
                    if (abs(pos-color[v])!=1) return -1;
                } else {
                    c[pos+1].pb(v);
                    color[v]=pos+1;
                    vis[v]=1;
                }
            }
        }
        if (c[pos+1].size()) ++pos; else break;
    }
    return pos;
}
int main(){
    scanf("%d",&n);
    for (int i=1;i<=n;i++){
        scanf("%s",s+1);
        for (int j=1;j<=n;j++) if (s[j]=='1') h[i].pb(j);
    }
    dfs0(1,0);
    if (flag){puts("-1");return 0;}
    ans=2;
    for (int i=1;i<=n;i++) ans=max(ans,work(i));
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>

#define MAX 100

int main(void) {
  char str[MAX];
  int i, j;
  int length;

  while(scanf("%s", str) != EOF) {
    length = strlen(str);
    for(i=0; i<length; ++i) {
      if(str[i] == '@') {
        for(++i, j=0; j<str[i]-'0'; ++j) {
          printf("%c", str[i+1]);
        }
        i += 1;
        continue;
      }
      else {
        printf("%c", str[i]);
      }
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  int n;
  cin >> n;
  vector<int> a(n),b(n);
  REP(i,n) cin >> a[i];
  REP(i,n) cin >> b[i];
  set<int> s(b.begin(), b.end());
  REP(i,n) if(s.find(i+1) == s.end()) {
    cout << "No" << endl;
    REP(j,n) {
      if(j) cout << ' ';
      cout << ((a[j]==i+1) ? 2 : 1);
    }
    cout << endl;
    REP(j,n) {
      if(j) cout << ' ';
      cout << 1;
    }
    cout << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}



Measured memory_bytes: 8356
//ITP1_7_A
#include<iostream>
using namespace std;

int main()
{
	int m,f,r,c=0,i;
	char score;
	
		for(;;){
			cin>>m>>f>>r;
			if(m==-1&&f==-1&&r==-1)
				break;
			else if(m==-1||f==-1)
				score = 'F';
			else if(m+f>=80)
				score = 'A';
			else if(m+f<80&&m+f>=65)
				score = 'B';
			else if(m+f>=50&&m+f<65)
				score = 'C';
			else if(m+f>=30&&m+f<50){
				if(r>=50)
				score = 'C';
				else
				score = 'D';
				}
			else
				score='F';
			cout<<score<<endl;
		}	
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
char st[500005];
int n;
int main()
{
	scanf("%s",st+1);
	scanf("%d",&n);
	for (int i=0;i<(strlen(st+1)-1)/n+1;i++)
		cout<<st[i*n+1];
	cout<<endl;
	return 0;
}

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


void solve(long long N){
  cout << (double)((N+1)/2)/N << endl;

}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
x,k,d=map(int,input().split())
if x>=0:
  a=1
else:
  a=-1
if x*a-k*d>0:
  print(x*a-k*d)
else:
  b=x//d
  if (k-b)%2==0:
    print(x%d)
  else:
    print(d-x%d)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 2e18;
const ll fact_table = 1200008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define endl "\n"
#ifdef ENJAPMA
    #undef endl
#endif
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
#define rep(i,n) for (ll i = 0; i < (n); i++)
 
const ll mod = 998244353ll;
// const ll mod = 1000000007ll;
  
ll mypow(ll number1,ll number2, ll mod){
    if(number2 == 0){
        return 1ll;
    }else{
        ll number3 = mypow(number1,number2 / 2, mod);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
void YES(bool condition){
    if(condition){ p("YES"); }else{ p("NO"); }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

ll mygcd(ll a, ll b){
    if(b > a)swap(a, b);
    if(a == b || b == 0)return a;
    return mygcd(b, a % b);
}
/*

ll fact[fact_table + 5],rfact[fact_table + 5]; 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table],mod - 2, mod);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    assert(n >= r);
    assert(n >= 0);
    assert(r >= 0);
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/

// auto res = NTT::conv(mod, 3ll, atable, btable);

bool multicase = false;

ll n,m,num,a,b,c,d,e,q, w, ans ;
ll x[500005], y[500005];
ll sum, r, k;
string s;

void solve(){
    cin >> s;
    ll white = 0;
    n = s.size();
    ll ans = 0;
    for(ll i=n-1;i>=0;i--){
        if(s[i] == 'B'){
            ans += white;
        }else{
            white ++;
        }
    }
    p(ans);
    return;
}

int main(){
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;
    if(multicase){
        cin >> q;
    }else{
        q = 1; 
    }
    while(q--){
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    // solve();
    return 0;
}
















Measured memory_bytes: 720
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;


constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
	template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
	template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
	template<typename T> void chadd(T& a, T b) { a = a + b; }

	void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
	template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
	template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

	void CCout(long long x, const char* end = "\n") { std::cerr << x << end; }
	template <typename T> void CCout(const T& x, const char* end = "\n") { std::cerr << x << end; }
	template <typename T> void CCout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cerr << x[i] << (i == sz - 1 ? end : sep); } }

	// 標準入出力
	struct inp {
		std::size_t sz;
		inp(std::size_t _sz = 1) : sz(_sz) {}
		template <typename T> operator T () const { T a; std::cin >> a; return a; }
		template <typename T> operator std::vector<T>() const { vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
		template <typename T, typename U> operator std::pair<T, U>() const { T f; U s; std::cin >> f >> s; return std::pair<T, U>(f, s); }
	};

	inp inp1; // input one
}

int main() {

	size_t n = inp1;
	vector<string> s = inp(n);

	// 10文字

	map<string, ll> mp;

	rep(i, n) {
		sort(allof(s[i]));
		mp[s[i]]++;
	}

	ll ans = 0;
	for (const auto& m : mp) {
		ans += (m.second - 1) * m.second / 2;
	}

	Cout(ans);

	return 0;
}

Measured memory_bytes: 18176
#include<stdio.h>


int main(void){
	int n,k,x,y;
	int i;
	int ret;


	scanf("%d %d %d %d",&n,&k,&x,&y);

	ret = 0;

	for(i=1;i<=n;i++){
		if(i<=k){
			ret += x;
		}
		else{
			ret += y;
		}
	}

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


	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main() {
  
  int N, j, max, sum = 0;
  int L[200];
  
  scanf("%d", &N);
  
  for(j = 0; j < N; ++j){
    scanf("%d", &L[j]);
  }
  
  max = L[0];
  
  for(j = 0; j < N; ++j){
    sum += L[j];
    if(max < L[j]) {
      max = L[j];
    }
  }
  
  if(max < sum - max){
    printf("Yes\n");
  }
  else if(max >= sum - max) {
    printf("No\n");
  }
  
  return 0;
}


Measured memory_bytes: 128