akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
//using Edge = Pair<long, int>;
using System.Text;
class Program
{ 
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var str = ReadLine();
        var ct = 0;var res = 0L;
        for (var i = 0; i < str.Length-1; i++)
        {
            if (str[i] == 'A') ct++;
            else if (str[i] == 'B' && str[i + 1] == 'C')
            {
                res += ct;
                i++;
            }
            else ct = 0;
        }
        WriteLine(res);
    }
    
}

public class Input
{
    public static string read => ReadLine().Trim();
    public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
    public  static int num => ToInt32(read);
    public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(_ => read.ToCharArray()).ToArray();
    public static int[] ar1D(int n)
        => Enumerable.Repeat(0, n).Select(_ => num).ToArray();
    public static long[] arL1D(int n)
        => Enumerable.Repeat(0, n).Select(_ => numL).ToArray();
    public static int[][] ar2D(int n)
        => Enumerable.Repeat(0, n).Select(_ => ar).ToArray();
    public static long[][] arL2D(int n)
        => Enumerable.Repeat(0, n).Select(_ => arL).ToArray();
    public static T getValue<T>(string g)
    {
        var t = typeof(T);
        if (t == typeof(int))
            return (T)(object)int.Parse(g);
        if (t == typeof(long))
            return (T)(object)long.Parse(g);
        if (t == typeof(string))
            return (T)(object)g;
        if (t == typeof(char))
            return (T)(object)char.Parse(g);
        if (t == typeof(double))
            return (T)(object)double.Parse(g);
        if (t == typeof(bool))
            return (T)(object)bool.Parse(g);
        return default(T);
    }
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}

Measured memory_bytes: 11616
w_map = {}

for i in range(0, int(input())):
    s = input()
    if s in w_map:
        w_map[s] += 1
    else:
        w_map[s] = 1

for i in range(0, int(input())):
    t = input()
    if t in w_map:
        w_map[t] -= 1
    else:
        w_map[t] = -1

print(max(max(w_map.values()), 0))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef pair<int,ii> iii;
typedef pair<int, iii> iiii;
typedef pair<double, ii> dii;
typedef long long ll;
typedef pair<ll, ii> lii;
const int INF = 1000000000;
const double EPS = 1e-9;
#define LSOne(S) (S & (-S))
int mods(int a, int b) { return (b + (a%b)) % b; }

int n, k, h[100005], dp[100005]; 
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    cin >> n >> k;

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

    for (int i = 1; i < n; i++)
        dp[i] = INF;
    
    for (int i = 1; i < n; i++)
        for (int j = max(0, i-k); j < i; j++)
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));

    cout << dp[n-1] << '\n';

    return 0;
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
tmp=[]
ans=""
for i in range(n-1,-1,-1):
  num = i+1
  total=0
  j=1
  while (i+1)*j <= n:
    total+=b[((i+1)*j)-1]
    j+=1  
  if total%2==a[i]:
    b[i]=0
  else:
    b[i]=1
    tmp.append(i+1)

print(sum(b))
print(str(sorted(tmp)).replace(',','').replace('[','').replace(']',''))

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



int main(){
	int K;
	string S;
	cin >> K;
	cin >> S;
	if(K < S.size()){
		rep(i,K) cout << S[i];
		cout << "..." << endl;
	}else{
		cout << S << endl;
	}
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	int n;
	cin >> n;
	vll a(n, 0);
	rep(i, n) cin >> a[i];
	ll ans = a[n-1];
	if(n == 1 && ans != 0) ans = -1;
	for(int i = n-2; i >= 0; i--) {
		if(a[i] > i) {
			ans = -1;
			break;
		}
		if(a[i] + 1 < a[i+1]) {
			ans = -1;
			break;
		}
		else if(a[i] + 1 == a[i+1]) {
			continue;
		}
		else {
			ans += a[i];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main{
    public static void main(String[] args){
        start();
    }
    public static void start(){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(),
            b = sc.nextInt();
        System.out.println((int)Math.ceil((a+b)/2.0));
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])
        cout<<"Yes\n";
    else
        cout<<"No\n";

    
    
    return 0;   
}


 
 


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli k;
    vi w={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin>>k;
    k--;
    out(w[k]);
}

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

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int a[n];
    int dist[n];
    int sum =0;
    int i;
    for(i=0; i<n; i++){
        cin >> a[i];
        if(abs(a[i] - k) > abs(a[i])){
            dist[i] = abs(a[i]);
        } else {
            dist[i] = abs(a[i] - k);
        }

        sum += dist[i];
    }

    cout << sum * 2 << endl;
}



Measured memory_bytes: 3576
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<string>

using namespace std;
#define ll long long

int main(){
    string S;
    ll N, M;
    ll a,b;
    ll ans = 0;
    cin >> S;
    for(int i = 0; i < S.size()-1; i++){
        if(S[i] == S[i+1]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}

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

int main(void){

    string str;
    cin >> str;
    int a = 0, b = 0, c = 0;
    int l = 0;
    for(int i = 0; str[i] != '\0'; i++){
        if(str[i] == 'a') a++;
        if(str[i] == 'b') b++;
        if(str[i] == 'c') c++;
    }
    l = a + b + c;
    if(a < b){
        int temp = a;
        a = b;
        b = temp;
    }
    if(a < c){
        int temp = a;
        a = c;
        c = temp;
    }
    if(b < c){
        int temp = b;
        b = c;
        c = temp;
    }
    
    a -= l/3;
    b -= l/3;
    c -= l/3;
    if(l % 3 == 1){
        a--;
    }else if(l % 3 == 2){
        a--;
        b--;
    }
    if(a == 0 && b == 0 && c == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}


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

int main() {
  int s;
  cin >> s;
  vector<int> a(1000000);
  a.at(0) = s;
  for (int i = 1; i < 500; ++i) {
    if (a.at(i - 1) % 2 == 0) {
      a.at(i) = a.at(i - 1) / 2;
    }
    else {
      a.at(i) = 3 * a.at(i - 1) + 1;
    }
  }

  for (int i = 0; i < 500; ++i) {
    for (int j = i + 1; j < 500; ++j) {
      if (a.at(i) == a.at(j)) {
        cout << j + 1 << endl;
        return 0;
      }

    }
  }
  return 0;
}



Measured memory_bytes: 4096
from itertools import product


def check_odd(i, j):
    return (i + j) % 2 == 0


def check_even(i, j):
    return i % 2 == 0


def solve(n, d1, d2):
    s1, s2 = 0, 0
    while d1 % 4 == 0:
        d1 >>= 2
        s1 += 1
    while d2 % 4 == 0:
        d2 >>= 2
        s2 += 1

    f1 = check_odd if d1 % 2 else check_even
    f2 = check_odd if d2 % 2 else check_even
    lim = n ** 2

    buf = []
    cnt = 0
    for i, j in product(range(2 * n), repeat=2):
        if f1(i >> s1, j >> s1) and f2(i >> s2, j >> s2):
            buf.append('{} {}'.format(i, j))
            cnt += 1
            if cnt == lim:
                break
    return buf


n, d1, d2 = map(int, input().split())
print('\n'.join(solve(n, d1, d2)))


Measured memory_bytes: 9524
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

long long N, M;

long long WC[100005];
bool AC[100005];

int main(){
	cin >> N >> M;
	long long ac = 0;
	long long wc = 0;
	rep(i, M) {
		long long num;
		string res;
		cin >> num >> res;
		if(res == "WA") {
			if(!AC[num]) {
				WC[num]++;
			}
		} else {
			if(!AC[num]) {
				ac++;
				AC[num] = true;
			}
		}
	}
	rep(i, N+2) {
		if(AC[i]) wc += WC[i];
	}


	cout << ac << " " << wc << endl;

}

Measured memory_bytes: 4460
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<=(end);i++)
#define REP(i, n) FOR(i,1,n)
#define IFOR(i, begin, end) for(int i=(end);i>=(begin);i--)
#define IREP(i, n) IFOR(i,1,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())

#define ll long long
using namespace std;

bool is_prime(int k)
{
    for(int j=2;j*j<=k;j++){
        if(k%j==0) {
            return false;
        }
    }
    return true;
}

int main()
{
	stringstream ss;
    // 入力
    int N,T;
    cin>>N>>T;
    int c[N+1],t[N+1];
    int cmin=-1;
    FOR(i,1,N){
        cin>>c[i]>>t[i];

        if(t[i]<=T && cmin==-1) cmin=c[i];
        else if(t[i]<=T && cmin>c[i]) cmin=c[i];
    }
    if(cmin==-1) cout<<"TLE"<<endl;
    else cout<<cmin<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef std::pair<ll,ll> P;

#define rep(i,n) for(int i = 0; i < int(n); i++)
using namespace std;



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

template <class T> struct fenwick_tree {
    using U = ll;

public:
    fenwick_tree() : _n(0) {}
    fenwick_tree(int n) : _n(n), data(n) {}

    void add(int p, T x) {
        assert(0 <= p && p < _n);
        p++;
        while (p <= _n) {
            data[p - 1] += U(x);
            p += p & -p;
        }
    }

    T sum(int l, int r) {
        assert(0 <= l && l <= r && r <= _n);
        return sum(r) - sum(l);
    }

private:
    int _n;
    std::vector<U> data;

    U sum(int r) {
        U s = 0;
        while (r > 0) {
            s += data[r - 1];
            r -= r & -r;
        }
        return s;
    }
};

int main() {
	int n, q;
	cin >> n >> q;
    vector<ll> as(n);
    fenwick_tree<ll> tree(n);
    rep(i, n) {
        ll a;
        cin >> a;
        tree.add(i, a);
    }
    rep(i, q) {
        ll a, b, c;
        cin >> a >> b >> c;
        if (a == 0) {
            tree.add(b, c);
        }
        else {
            cout << tree.sum(b, c) << endl;
        }
    }
	return 0;
}


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

typedef long long ll;
#define MOD1 1000000007
#define MOD2 1000000009
#define fr(a,b) for(ll i=a;i<b;i++)

const ll mod=1000000007;

ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}

int32_t main(){
#ifdef _MSC_VER
    _CRT_SECURE_NO_WARNINGS
#endif
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
#pragma warning(suppress: 4101) srand(time(nullptr));
    cout << setprecision(20) << fixed;
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
        ll n,d;
        cin>>n>>d;
    ll count=0;
        while(n--)
        {
            ll x,y;
            cin>>x>>y;
            if(sqrt(x*x+y*y)<=d)
                count++;
        }
        cout<<count<<endl;
    }

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define endl '\n'
typedef long long LL;
using namespace std;

int n, m, q;
int a[55], b[55], c[55], d[55];
int ans = 0;

void bfs(int p, int val[], int Max){
  if (p > n){
    int cur = 0;
    for (int i = 1; i <= q; i++){
      if (val[b[i]] - val[a[i]] == c[i]){
        cur += d[i];
      }
    }
    ans = max(ans, cur);
    //for (int i = 1; i <= n; i++) cout << val[i] << ' ';cout << endl;
    return;
  }
  for (int i = Max; i <= m; i++){
    val[p] = i;
    bfs(p + 1, val, i);
  }
}

int val[55];

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

  int t = 1; //cin >> t;
  while (t--){
    cin >> n >> m >> q;
    for (int i = 1; i <= q; i++){
      cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    bfs(1, val, 1);
    cout << ans << endl;
  }
}


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

int main(){
    long double N,K;cin>>N>>K;
    long double ans=0,kaku=0;
    for(int i=1;i<=N;i++){
        int tmp=i;
        kaku=1/N;
        while(tmp<K) {
            kaku = kaku /2;
            tmp=tmp*2;
        }
        ans=ans+kaku;
    }
    cout<<setprecision(15)<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int si,dj;
    for(int i=0;i<s.length()-1;i++){
    	if(s[i]=='A'){
    		si=i;
    		break;
		}
	}
	for(int j=s.length();j>0;j--){
		if(s[j]=='Z'){
			dj=j;
			break;
		}
	}
	cout<<dj-si+1<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,i,j;
    cin>>n;
    ll ans=0;
    int a[n];
    for (i=0;i<n;i++)
        cin>>a[i];
    for (i=0;i<n-1;i++)
    {
        for (j=i+1;j<n;j++)
            ans+=(a[i]*a[j]);
    }
    cout<<ans;
}

Measured memory_bytes: 256
// 解き直し.
// https://img.atcoder.jp/data/arc/060/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
LL x[101010];
int r[31][101010]; // i番目 の ホテル から (2 の k乗)以内に到達可能な, 最も右のホテル番号.
int pow2[31];

int main(){
    
    // 1. 入力情報.
    int N;
    scanf("%d", &N);
    rep(i, N) scanf("%lld", &x[i]);
    x[N] = 2020202020; // 番兵.
    LL L;
    int Q;
    scanf("%lld %d", &L, &Q);
    
    // 2. 2 の 冪乗 を 保存.
    pow2[0] = 1;
    rep(i, 30) pow2[i + 1] = pow2[i] * 2;
    
    // 3. 二次元配列を更新(解説通り).
    rep(i, N){
        int at = lower_bound(x + i, x + N + 1, x[i] + L) - x;
        if(x[at] > x[i] + L) at--;
        r[0][i] = at;
    }
    rep(k, 31) rep(i, N) r[k + 1][i] = r[k][r[k][i]];
    // rep(k, 31){
    //     rep(i, N) printf("%d ", r[k][i]);
    //     puts("");
    // }
    
    // 4. クエリ回答.
    rep(i, Q){
        // 4-1. 入力情報.
        int a, b;
        scanf("%d %d", &a, &b);
        a--, b--;
        if(a > b) swap(a, b);
        
        // 4-2. 探索.
        int ans = 0, idx = a;
        while(idx < b){
            int l = 0, h = 30, m;
            while(l + 1 < h){
                m = (h + l) >> 1;
                if(r[m][idx] >= b) h = m;
                else               l = m;
                // printf("l=%d h=%d m=%d\n", l, h, m);
            }
            ans += pow2[l];
            idx = r[l][idx];
        }
        printf("%d\n", ans);
    }
    return 0;
    
}

Measured memory_bytes: 16684
#include <iostream>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;

int main()
{
	double a, b, x;
	cin >> a >> b >> x;
	double V = a * a * b;
	if (2 * x == V) {
		cout << "45" << endl;
	}
	else if (2 * x < V)
	{
		printf("%.9lf\n", atan(a * b * b / (2 * x)) * (180.0 / M_PI));
	}
	else if (2 * x > V)
	{
		printf("%.9lf\n", atan(2 * (V - x) / (a * a * a)) * (180.0 / M_PI));
	}

	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}


int main(void){
  ll N, M, A, B, C, D, W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >> N;
  cin >> D >> X;
  ll a[N];
  rep(i, N) cin>>a[i];
  ans = X;
  rep(i,N){
    ans++;
    ans+= (D-1)/a[i];
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
 
int main()
{
    char a[101][101];
    int h, w;
    std::cin >> h >> w;
    for(int i = 0;i < h;i++){
        std::cin >> a[i];
    }

    for(int i = 0;i <= w + 1;i++){
        std::cout << '#';
    }
    std::cout << '\n';
    for(int i = 0;i < h;i++){
        std::cout << '#' << a[i] << '#' << '\n';
    }
    for(int i = 0;i <= w + 1;i++){
        std::cout << '#';
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,d[5010],i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&d[i]);
  for(i=0;i<n;i++){
    int ans=0,a[5010]={};
    for(j=i+1;j--;){//printf("%d ",j);
      if(a[j+1])continue;
      ans+=1-a[d[j]];
      a[d[j]]=1;
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 1860
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }



signed main(){

    int H, W, K; cin >> H >> W >> K;
    K--;
    int mod = 1000000007;

    mat dp2(W, vec(2, 0));
    dp2[0][0] = 1;
    FOR(i, 1, W){
        dp2[i][0] = (dp2[i - 1][0] + dp2[i - 1][1]) % mod;
        dp2[i][1] = dp2[i - 1][0];
    }
    vec dp3(W);
    REP(i, W) dp3[i] = (dp2[i][0] + dp2[i][1]) % mod; 

    mat dp(H + 1, vec(W, 0));
    dp[0][0] = 1;

    REP(i, H){
        REP(j, W){
            if(j >= 1){
                int p = (dp2[j - 1][0] * dp2[W - 1 - j][0]) % mod;
                dp[i + 1][j] += dp[i][j - 1] * p;
                dp[i + 1][j] %= mod;
            }
            if(j < W - 1){
                int p = (dp2[j][0] * dp2[W - 2 - j][0]) % mod;
                dp[i + 1][j] += dp[i][j + 1] * p;
                dp[i + 1][j] %= mod;
            }
            int p = (dp2[j][0] * dp2[W - 1 - j][0]) % mod;
            dp[i + 1][j] += dp[i][j] * p;
            dp[i + 1][j] %= mod;
        }
    }
    cout << dp[H][K];
    
    return 0;
}

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

int gcd(int a, int b)
{
	int tmp;
	while(b!=0)
	{
		tmp=b;
		b=a%b;
		a=tmp;
	}
	return a;
}

int main(void)
{
	int a, b;
	while(cin >> a >> b)
		cout << gcd(a,b) << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define print(x) cout << x << endl;
using namespace std;
typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<double> v(N);
    rep(i, N) cin >> v[i];

    sort(v.begin(), v.end());
    
    double m = v.at(0);

    for (int i = 1; i < N; i++) {
        m = (m + v.at(i)) / 2;
    }

    cout << m << endl;

    return 0;
}

Measured memory_bytes: 256
//できるだけmainを短くする試み
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int w = sc.nextInt();
      	int h = sc.nextInt();
      	int n = sc.nextInt();
      	boolean[][] squ = new boolean[w][h];
      	squ = beTrue(squ, w, h);
      	int[] x = new int[n];
	    int[] y = new int[n];
      	int[] a = new int[n];
      	
      	for(int i = 0; i < n; i++){
        	x[i] = sc.nextInt();
          	y[i] = sc.nextInt();
          	a[i] = sc.nextInt();
        }
      	
      	for(int i = 0; i < n; i++){
        	squ = changeSqu(squ, w, h, x[i], y[i], a[i]);
        }
      	
      	System.out.println(countTrue(squ, w, h));
    }  
//配列全部trueにする  
  	public static boolean[][] beTrue(boolean[][] squ, int w, int h){
    	for(int i = 0; i < w; i++){
        	for(int j = 0; j < h; j++){
            	squ[i][j] = true;
            }
        }
      	return squ;
    }
//マス目の塗りつぶし  
  	public static boolean[][] changeSqu(boolean[][] squ, int w, int h, int x, int y, int a){
    	if(a == 1){
          for(int j = 0; j < x; j++){
            for(int k =0; k < h; k++){
              squ[j][k] = false;
            }
          }
        }else if(a == 2){
          for(int j = x; j < w; j++){
            for(int k = 0; k < h; k++){
              squ[j][k] = false;
            }
          }
        }else if(a == 3){
          for(int j = 0; j < w; j++){
            for(int k = 0; k < y; k++){
              squ[j][k] = false;
            }
          }
        }else if(a == 4){
          for(int j = 0; j < w; j++){
            for(int k = y; k < h; k++){
              squ[j][k] = false;
            }
          }
        }
    	return squ;
    }
//trueの個数カウント  	
  	public static int countTrue(boolean[][] squ, int w, int h){
    	int count = 0;
      	for(int i = 0; i < w; i++){
        	for(int j = 0; j < h; j++){
            	if(squ[i][j] == true) count++;
            }
        }
      	return count;
    }
}

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

N=int(input())
C=[0]+list(map(int,input().split()))
E=[[] for i in range(N+1)]

for i in range(N-1):
    a,b=map(int,input().split())
    E[a].append(b)
    E[b].append(a)
        
from collections import deque
QUE = deque([1])
QUE2 = deque()
EULER=[0] # これが1からツアーで辿った点
USED=[0]*(N+1)
Parent=[-1]*(N+1)
TOP_SORT=[1]
Children=[[] for i in range(N+1)]

while QUE:
    x=QUE.pop()
    EULER.append(x)
    
    if USED[x]==1:
        continue
    
    for to in E[x]:

        if USED[to]==0:
            QUE2.append(to)
            Parent[to]=x
            Children[x].append(to)
            TOP_SORT.append(to)
        else:
            QUE.append(to)
    QUE.extend(QUE2)
    QUE2=deque()

    USED[x]=1

CE=[[] for i in range(N+1)]
CTOP_SORT=[[] for i in range(N+1)]

for x in TOP_SORT:
    CTOP_SORT[C[x]].append(x)

EFIRST=[-1]*(N+1)
ELAST=[-1]*(N+1)
for i in range(len(EULER)):
    if EFIRST[EULER[i]]==-1:
        EFIRST[EULER[i]]=i
    ELAST[EULER[i]]=i
        
    CE[C[EULER[i]]].append(i)

Size=[1]*(N+1)
for i in TOP_SORT[1:][::-1]:
    Size[Parent[i]]+=Size[i]

Size[0]=N+1


LEN=len(EULER)

BIT=[0]*(LEN+1) # 1-indexedなtree

def update(v,w): # index vにwを加える
    while v<=LEN:
        BIT[v]+=w
        v+=(v&(-v)) # 自分を含む大きなノードへ. たとえばv=3→v=4

def getvalue(v): # [1,v]の区間の和を求める
    ANS=0
    while v!=0:
        ANS+=BIT[v]
        v-=(v&(-v)) # 自分より小さい2ベキのノードへ. たとえばv=3→v=2へ
    return ANS

for i in range(1,N+1):
    update(EFIRST[i],1)

for color in range(1,N+1):
    if CE[color]==[]:
        print(0)
        continue

    EULER2=CE[color]
    TOP_SORT2=CTOP_SORT[color]
    HISTORY=[]

    #print(EULER2,TOP_SORT2)
    #print(BIT)

    ANS=0
    for x in TOP_SORT2[::-1]:
        for to in Children[x]:
            sc=getvalue(ELAST[to])-getvalue(EFIRST[to]-1)
            update(EFIRST[x],-sc)
            HISTORY.append((EFIRST[x],sc))
            ANS+=sc*(sc+1)//2
        update(EFIRST[x],-1)
        HISTORY.append((EFIRST[x],1))

    #print(ANS)

    sc=getvalue(len(EULER))
    ANS+=sc*(sc+1)//2

    print(N*(N+1)//2-ANS)
    for x,y in HISTORY:
        update(x,y)
        

    


Measured memory_bytes: 226768
#include<iostream>
#include<queue>

using namespace std;

long long Del[60][200005],Lastpoz[200005],Ap[200005];
int A[200005];

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

    long long n,k;
    cin>>n>>k;
    for(int i=1; i<=n; i++)
        cin>>A[i];

    for(int i=n; i>=1; i--)
        Lastpoz[A[i]]=n+i;
    for(int i=n; i>=1; i--)
    {
        Del[0][i]=Lastpoz[A[i]]-i+1;
        Lastpoz[A[i]]=i;
    }

    long long l=n*k;
    for(int i=1; i<=57; i++)
        for(int j=1; j<=n; j++)
            Del[i][j]=min(Del[i-1][j]+Del[i-1][(j+Del[i-1][j]-1)%n+1],l);

    long long poz=1;
    for(int i=57; i>=0; i--)
    {
        if(poz+Del[i][(poz-1)%n+1]<=l)
            poz+=Del[i][(poz-1)%n+1];
    }

    deque<int> Q;
    while(poz<=l)
    {
        if(Ap[A[(poz-1)%n+1]])
        {
            while(!Q.empty() && Ap[A[(poz-1)%n+1]])
            {
                Ap[Q.back()]=0;
                Q.pop_back();
            }
        }
        else
        {
            Ap[A[(poz-1)%n+1]]=1;
            Q.push_back(A[(poz-1)%n+1]);
        }
        poz++;
    }

    while(!Q.empty())
    {
        cout<<Q.front()<<" ";
        Q.pop_front();
    }
    cout<<"\n";
    return 0;
}


Measured memory_bytes: 98560
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int MAX_N = (int)1e5 + 5;

int cnt[MAX_N];

const ll MOD = (int)1e9 + 7LL;

int main()
{
	memset(cnt, 0, sizeof(cnt));
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	vector<int> A(N, 0);
	rep (i, N) cin >> A[i];

	rep (i, N) ++cnt[A[i]];

	bool ok = true;
	if (N % 2 != 0){
		if (cnt[0] != 1) ok = false;
		for (int i = 2; i < N; i += 2){
			if (cnt[i] != 2) ok = false;
		} // end for
	}else{ // if (N % 2 == 0)
		for (int i = 1; i < N; i += 2){
			if (cnt[i] != 2) ok = false;
		} // end for
	} // end if

	ll res = 0LL;
	if (ok){
		res = 1LL;
		rep (i, N/2){
			res = (res * 2LL) % MOD;
		} // end rep
	} // end if
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1148
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		while (true) {
			int n = scan.nextInt();
			int x = scan.nextInt();
			if (n == 0 && x == 0)
				break;
			System.out.println(run(n, x));
		}
		System.exit(0);
	}

	private static int run(int n, int x) {
		int result = 0;
		for (int a = 1; a <= n; a++)
			for (int b = a + 1; b <= n; b++)
				for (int c = b + 1; c <= n; c++)
					if (a + b + c == x)
						++result;
		return (result);

	}
}

Measured memory_bytes: 26576
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
#define INF 0x3f3f3f3f
const int maxn=2e5+10,mod=998244353;
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
int n,R[maxn],L[maxn];
int b[maxn]={0},c[maxn],d[maxn];
long long f[maxn];
struct Node
{
    int x,d;
}a[maxn];
bool operator <(Node A,Node B) { return A.x<B.x;}

int lowbit(int x) {return x&-x;}
void add(int x,int k)
{
    while(x<=n)
        b[x]=max(b[x],k),x+=lowbit(x);
}
int query (int L, int R) 
{
	int ret = 0, len = R-L+1;
	while (len && R)
    { 
		if (len < lowbit(R)) 
        {
			ret = max (ret, b[R]);
			R--; len--;
		} 
        else 
        {
			ret = max (ret, b[R]);
			len -= lowbit(R); 
			R -= lowbit(R); 
		}
	}
	return ret;
}

int query1 (int L, int R) 
{
	int ret = 0;
	while (L<=R)
    { 
		ret = max (ret, b[R]);
		R -= lowbit(R); 
	}
	return ret;
}

int main()
{
    #ifdef __LOCAL__
        freopen("1.in","r",stdin);
        freopen("1.out","w",stdout);
    #endif
    scanf("%d",&n);
    _rep(i,1,n)
        scanf("%d%d",&a[i].x,&a[i].d);
    sort(a+1,a+n+1);

    // R[n]=n;
    // for(int i=1;i<n;i++)
    // {
    //     int j=i,far=a[i].x+a[i].d;
    //     while(far>a[j+1].x&&j<n)
    //     {
    //         far=max(far,a[j+1].x+a[j+1].d);    
    //         j++;
    //     }                
    //     R[i]=j;
    // }

    _rep(i,1,n)
        b[i]=lower_bound(a+1,a+1+n,(Node){a[i].x+a[i].d,0})-a-1;    

    //i~b[i]-1
    // _rep(i,1,n)
    // {
    //     int mx=b[i];
    //     for(int j=i;j<=mx;j++)
    //     {
    //         d[i]=max(d[i],b[j]);
    //         if(b[j]>mx)
    //             mx=b[j];
    //     }
    // }
    // for(int i=1;i<=n;i++)
    //     cout<<R[i]<<" "<<d[i]<<endl;

    for(int i=n;i>=1;i--)
    {
        L[i]=max(i,query(i,b[i]));
        add(i,L[i]);
    }

    // for(int i=n;i>=1;i--)
    //     cout<<i<<" "<<R[i]<<" "<<L[i]<<endl;

    f[n+1]=1;
    for(int i=n;i>=1;i--)
        f[i]=(f[i+1]+f[L[i]+1])%mod;

    cout<<f[1]<<endl;
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()
#define pi					3.14159265359
ll INF=1e18+10;
ll MOD=1000000007;

int main()
{
    ll n;cin>>n;
    vector<pair<ll,ll>> v(n);
    rep(i,0,n)
    {
        cin>>v[i].F;
        v[i].S=i+1;
    }
    sort(all(v));
    rep(i,0,n)
    cout<<v[i].S<<" ";

}


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

using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using f64 = double;
using f80 = long double;

#define FOR(v, a, b) for(i64 v = (a); v < (b); ++v)
#define FORE(v, a, b) for(i64 v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(i64 v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void pout(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void pout(const T &value, const Args&... args){std::cout << value << " ";pout(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}


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



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

  while(cin >> k >> a >> b){
    bool ok = false;

    FORE(i,a,b){
      if(i % k == 0) ok = true;
    }

    pout(ok ? "OK" : "NG");
  }

  return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
int main(){
    ll n,k;cin >> n >>k;
    ll ans=0;
    vl cnt(k+1,0);
    per(i,k){
        ll g=i+1;
        ll p=k/g;
        ll tmp=g;
        ll rp=modpow(p,n,MOD)%MOD;
        tmp*=(rp-cnt[g])%MOD;
        tmp%=MOD;
        ans+=tmp;
        ans%=MOD;
        vl x=divisor(g);
        for(auto z:x){
            cnt[z]+=rp-cnt[g];
        }
    }
    if(ans<0)cout <<ans+MOD <<endl;
    else cout <<ans <<endl;
}

Measured memory_bytes: 4052
N, M = [int(i) for i in input().split()]
valid = True
ans = [-1]*N
for a in range(M):
    s,c = [int(i) for i in input().split()]
    if ans[s-1] == -1:
        ans[s-1] = c
    elif ans[s-1] != c:
        valid = False

for a in range(len(ans)):
    if ans[a] == -1:
        if a == 0:
            if len(ans) == 1:
                ans[a] = 0
            else:
                ans[a] = 1
        else:
            ans[a] = 0
if valid:
    n = "".join(map(str, ans))
    if len(n) != 1 and n[0] == "0":
        print(-1)
    else:
        print(int(n))
else:
    print(-1)

Measured memory_bytes: 3064
def g;gets.split.map &:to_i;end
r=1..n=g[0]
w=[0]+r.map{[0]+[1e9]*n}
r.map{f,_,*t=g;t.map{|i|w[f][i]=1}}
r.map{|k|r.map{|i|r.map{|j|(a=(b=w[i])[k]+w[k][j])<b[j]&&b[j]=a}}}
g[0].times{s,d,v=g;puts v<(c=w[s][d]+1)?:NA:c}

Measured memory_bytes: 16760
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int n, k;
	char s[50];
	cin >> n >> k;
	for(int i=0; i<n; i++){
		cin >> s[i];
	}
	for(int i=0; i<n; i++){
		if(i==k-1){
			if(s[i]=='A'){
				cout << "a";
			} else if(s[i]=='B'){
				cout << "b";
			} else {
				cout << "c";
			}
		} else {
			cout << s[i];
		}
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
 
int main(){
	int N;
	cin >> N;
	int  A[N+1];
	rep(i, N)
		cin >> A[i];
	sort(A, A + N);
	rep(i, N-1) {
		if (A[i] == A[i + 1]) {
			cout << "NO";
			return 0;
		}
    }
	cout << "YES";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
#define pb push_back
#define mp make_pair
#define ms memset
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define lower_bound lb
#define upper_bound ub

int main()
{
    int D; cin >> D;
    int C[27]; FOR(i,1,26) cin >> C[i];
    int S[D+1][27];
    FOR(i,1,D){
        FOR(j,1,26) cin >> S[i][j];
    }
    int T[D+1]; FOR(i,1,D) cin >> T[i];
    int last[27]; ms(last,0,sizeof(last));
    ll sat = 0;
    FOR(i,1,D){
        last[T[i]] = i;
        sat += S[i][T[i]];
        FOR(j,1,26) sat -= C[j] * (i - last[j]);
        cout << sat << '\n';
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// floating
typedef long double Real;
const Real EPS = 1e-9;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int T,n;
int x[125252], l[125252], h[125252];

int main(){
  scanf("%d%d",&T,&n);
  REP(i,n)scanf("%d%d%d",x+i,l+i,h+i);
  Real ans = 0.0;
  
  Real minimum = T / 2.0;
  // DEBUG(minimum);
  typedef pair<Real,Real> prr;

  // 1. find max low > minimum, fly at v^2 = low (high desc order)
  set<prr> S1, S2;
  REP(i,n){
    Real X = x[i];
    Real L = l[i];
    Real H = h[i];
    Real low = X*(T-X) / (2.0*H);
    Real high = X*(T-X) / (2.0*L);
    // printf("low: %.18Lf, high: %.18Lf\n",low,high);
    S1.insert(prr(low,high));
    S2.insert(prr(high,low));
  }
  while(S1.size()){
    prr P1 = *S1.rbegin();
    Real p = P1.first;
    if(p < minimum+EPS)break;
    // printf("1. %.18Lf\n",p);
    ans += sqrt(p + 0.25*T*T/p);
    S1.erase(P1);
    S2.erase(prr(P1.second, P1.first));
    while(S2.size()){
      prr P2 = *S2.rbegin();
      Real low = P2.second;
      Real high = P2.first;
      if(p <= high+EPS){
        S1.erase(prr(low,high));
        S2.erase(prr(high,low));
      }else{
        break;
      }
    }
  }

  // 2. find min high < minimum, fly at v^2 = high (low asc order)
  while(S2.size()){
    prr P2 = *S2.begin();
    Real p = P2.first;
    if(p > minimum-EPS)break;
    // printf("2. %.18Lf\n",p);
    ans += sqrt(p + 0.25*T*T/p);
    S2.erase(P2);
    S1.erase(prr(P2.second, P2.first));
    while(S1.size()){
      prr P1 = *S1.begin();
      Real low = P1.first;
      Real high = P1.second;
      if(p >= low-EPS){
        S1.erase(prr(low,high));
        S2.erase(prr(high,low));
      }else{
        break;
      }
    }
  }

  // 3. assert low <= minimum <= high, fly at v^2 = minimum
  if(S1.size()){
    Real p = minimum;
    ans += sqrt(p + 0.25*T*T/p);
    // printf("3. %.18Lf\n",p);
  }

  printf("%.18Lf\n", ans);

  return 0;
}



Measured memory_bytes: 19540
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
LL N;
int main(){
	scanf("%lld",&N);
	LL ans = 0;
	if(N % 11 == 0)ans = N/11*2;
	else{
		ans = N/11;
		N = N-ans*11;
		ans = ans*2; 
		if(N <= 6)ans++;
		else ans = ans + 2;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import math


def gcd(a, b, c):
    temp = math.gcd(a, b)
    return math.gcd(temp, c)


def main():
    k = int(input())

    total = 0
    temp = {}
    for i in range(1, k + 1):
        for j in range(1, k + 1):
            for l in range(1, k + 1):
                # join_str = "".join(sorted([str(i).zfill(3), str(j).zfill(3), str(l).zfill(3)]))
                # gcd_val = temp.get(join_str, 0)
                # if gcd_val == 0:
                gcd_val = gcd(i, j, l)
                total += gcd_val

    return total


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 68012
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

s = 0
num = 0
if x>sum(a):
  print(len(a)-1)
else:
  for i in range(len(a)):
      if x >= a[i]:
          x -= a[i]
          num += 1
      else:
          break

  print(num)


Measured memory_bytes: 9100
#include<bits/stdc++.h>
using namespace std;
#define M 998244353
struct node{
	int x,y;
}n[200001];
int Su[200001],A[200001],T[200001],a,w,t,i;
void Add(int &x,int y){
	x+=y;
	if(x<0)x+=M;
	else if(x>=M)x-=M;
}
void JR(int x){
	while(x<=a)T[x]++,x+=x&-x;
}
int TJ(int x){
	int w=0;
	while(x)w+=T[x],x-=x&-x;
	return w;
}
struct cmp{
	bool operator()(node a,node b)const{
		return a.y<b.y;
	}
};
int main(){
	cin>>a,Su[0]=1;
	for(i=1;i<=a;i++)scanf("%d%d",&A[i],&n[i].y),n[i].x=A[i],Su[i]=(Su[i-1]<<1)%M;
	sort(n+1,n+a+1,cmp()),sort(A+1,A+a+1),w=1ll*a*(Su[a]-1)%M;
	for(i=1;i<=a;i++){
		n[i].x=lower_bound(A+1,A+a+1,n[i].x)-A;
		Add(w,-Su[i-1]+1),Add(w,-Su[a-i]+1),Add(w,-Su[i-1]+1),Add(w,-Su[a-i]+1);
		t=TJ(n[i].x),Add(w,Su[t]-1),Add(w,Su[i-t-1]-1),JR(n[i].x);
	}
	memset(T,0,sizeof T);
	for(i=a;i;i--)t=TJ(n[i].x),Add(w,Su[t]-1),Add(w,Su[a-i-t]-1),JR(n[i].x);
	cout<<w;
}

Measured memory_bytes: 4096
alpha1='abcdefghijklmnopqrstuvwxyz'
alpha2='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
n,k = list(map(int,input().split(" ")))
s = list(input())

for i in range(26):
  if alpha2[i] == s[k-1]:
    t = i
    break
s[k-1]=alpha1[t]
for i in range(n):
  print(s[i],end="")


Measured memory_bytes: 3060
import java.util.*;

class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		double B = sc.nextDouble();
		
		long ans = 0;
		ans = A * (Math.round(B * 100)) / 100 ;
		
		System.out.println(ans);

		
	}

}




Measured memory_bytes: 37304
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;

int main() {
  int N,T,A,num;
  float a,min = 10000;
  cin >> N;
  int H[N];
  cin >> T >> A;
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  for ( int i = 0; i < N; i++) {
    a = abs(A - (T - H[i]*0.006));
    if (a < min) {
      min = a;
      num = i+1;
    }
  }
  cout << num << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
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 int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = (1 << 30);

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<int>> dist(h, vector<int>(w, INF));
  vector<string> grid(h);
  int sx, sy, gx, gy;
  cin >> sx >> sy >> gx >> gy;
  sx--, sy--, gx--, gy--;
  rep(i, h) cin >> grid[i];
  dist[sx][sy] = 0;
  queue<P> que;
  que.push(P(sx, sy));
  while (!que.empty()){
    P p = que.front();
    que.pop();
    rep(i, 4){
      for (int j = 1; j <= k; j++){
        int nx = p.first + j * dx[i], ny = p.second + j * dy[i];
        if(nx < 0 || ny < 0 || nx >= h || ny >= w)break;
        if(grid[nx][ny] == '@')break;
        if(dist[nx][ny] != INF && dist[p.first][p.second] >= dist[nx][ny])break;
        if(dist[nx][ny] != INF)continue;
        dist[nx][ny] = dist[p.first][p.second] + 1;
        que.push(P(nx, ny));
      }
    }
  }
  if(dist[gx][gy] == INF){
    cout << -1 << endl;
  }else{
    cout << dist[gx][gy] << endl;
  }
}


Measured memory_bytes: 11112
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<map>
#define ll long long
using namespace std;
bool a[3000000];
ll n,p;
int main()
{
    ll ans=1;
    scanf("%lld",&n);
    scanf("%lld",&p);
    if (n==1) 
    {
        cout<<p<<endl;
        return 0;
    }
    ll m=(sqrt(p))+1;
    for (int i=2; i<=m; ++i)
        if (!a[i])
        for (int j=i+i; j<=m; j+=i)
            a[j]=1;
    for (int i=2; i<=m; ++i)
        if (!a[i])
        {
            if (!p) break;
            int t=0;
            while ((p%i)==0)
            {
                p/=i;
                t++;
            }
            while (t>=n)
            {
                ans*=i;
                t-=n;
            }
        }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1280