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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    for (;;) {
        int n, m, k; cin >> n >> m >> k; if (!n) break;
        vector<double> p(n * m + 1, 0), p2(n * m + 1, 0);
        p[0] = 1.0;
        rep(i, 0, n) {
            rep(j, 1, m + 1) {
                for (int k = n * m - j; k >= 0; k--) {
                    p2[k + j] += p[k] / m;
                }
            }
            p = p2;
            p2 = vector<double>(n * m + 1, 0);
            // rep(j, 0, n * m + 1) printf("%.3lf ", p[i]);
            // printf("\n");
        }
        double v = 0;
        rep(i, 0, n * m + 1) {
            v += max(i - k, 1) * p[i];
        }
        cout << fixed << setprecision(12) << v << endl;
    }
}


Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#define int long long
using namespace std;

signed main() {
	int X,Y;
	cin >> X >> Y;
	if(X < Y) {
		if(X >= 0 && Y >= 0 || X <= 0 && Y <= 0) {
          	cout << Y - X << endl;
        }
      	else{
          	if(abs(X) < Y) {
              	cout << 1 + Y - abs(X) << endl;
            }
          	else if(abs(X) == Y) {
              	cout << 1 << endl;
            }
          	else {
              	cout << 1 + abs(X) - Y << endl;
            }
        }
	}
	else {
		if(X >= 0 && Y >= 0) {
			cout << min(1 + X + Y,2 + X - Y) << endl;
		}
		else if(X >= 0 && Y < 0) {
			cout << 1 + abs(X + Y) << endl;
		}
		else {
			cout << X - Y + 2 << endl;
		}
	}
}


Measured memory_bytes: 256
x, k, d = [int(i) for i in input().split()]
x = abs(x)
if k * d <= x:
    print(x - k*d)
else:
    t = x
    x %= d
    k = k - (t - x)//d
    if k & 1:
        print(abs(d - x))
    else:
        print(x)

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

int main(int argc, const char * argv[]) {
    int n;
    long long sum=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        if(i%3==0||i%5==0){
            
        }else{
            sum+=i;
        }
    }
    printf("%lld",sum);
    return 0;
}


Measured memory_bytes: 1732
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

const int N_MAX = 1e4 + 1;

int num[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int dp[N_MAX];

int main() {
    int N, M;
    cin >> N >> M;

    vector< int > A(M);

    for (int i = 0; i < M; i++) {
        cin >> A[i];
    }

    for (int i = 0; i < N_MAX; i++) {
        dp[i] = -1;
    }
    sort(A.begin(), A.end(), greater< int >());

    dp[0] = 0, dp[1] = -1;
    for (int i = 2; i <= N; i++) {
        for (int j = 0; j < M; j++) {
            if (i >= num[A[j]] && A[i - num[A[j]]] >= 0) {
                dp[i] = max(dp[i], dp[i - num[A[j]]] + 1);
            }
        }
    }

    while (N > 0) {
        for (int i = 0; i < M; i++) {
            if (N >= num[A[i]] && dp[N - num[A[i]]] == dp[N] - 1) {
                printf("%d", A[i]);
                N -= num[A[i]];
                break;
            }
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <utility>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

int f[45] = {};

int fib(int i)
{
    if (f[i] > 0)
        return f[i];

    if (i == 0 || i == 1)
    {
        f[i] = 1;
    }
    else
    {
        f[i] = fib(i-1) + fib(i-2);
    }
    return f[i];
}

int main()
{
    int n;
    cin >> n;
    cout << fib(n) << "\n";
    return 0;
}


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

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};

using pint = pair<int,int>;
int main () {
    int N, M;
    cin >> N >> M ;
    vector<set<int> > dame(N);
    UnionFind uf(N);
    for (int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b; --a, --b;
        dame[a].insert(b);
        dame[b].insert(a);
        uf.merge(a, b);
    }
    int ans=0;
    for (int i = 0; i < N; ++i) {
        int mem = uf.size(i); // 同じ連結成分の「自分以外」の人数
        ans=max(mem,ans);
    }
    cout <<ans<< endl;
}


Measured memory_bytes: 32296
#include<iostream>
#include<algorithm>
using LL = long long;
LL n;
LL a[100000];
LL sum[100001];
LL costg, costk;
int main() {
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		std::cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		sum[i + 1] += sum[i] + a[i];
		if (i % 2 == 0) {
			if (sum[i + 1] <= 0) {
				costg += std::abs(1 - sum[i + 1]);
				sum[i + 1] = 1;
			}
		}
		else {
			if (sum[i + 1] >= 0) {
				costg += std::abs(-1 - sum[i + 1]);
				sum[i + 1] = -1;
			}
		}
	}
	for (int j = 1; j <= n; j++) {
		sum[j] = 0;
	}
	for (int i = 0; i < n; i++) {
		sum[i + 1] += sum[i] + a[i];
		if (i % 2 != 0) {
			if (sum[i + 1] <= 0) {
				costk += std::abs(1 - sum[i + 1]);
				sum[i + 1] = 1;
			}
		}
		else {
			if (sum[i + 1] >= 0) {
				costk += std::abs(-1 - sum[i + 1]);
				sum[i + 1] = -1;
			}
		}
	}
	std::cout << std::min(costg, costk) << std::endl;
	return 0;
}

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

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

    vector<vector<int>> s(m);
    for (size_t i = 0; i < m; i++)
    {
        int k;
        cin >> k;
        s[i] = vector<int>(k);
        for (size_t j = 0; j < k; j++)
        {
            cin >> s[i][j];
            s[i][j]--; // 0-indexed
        }
    }

    vector<int> p(m);
    for (size_t i = 0; i < m; i++)
    {
        cin >> p[i];
    }

    int ans = 0;
    for (int bit = 0; bit < (1 << n); bit++)
    {
        bool achievable = true;
        // 電球i
        for (size_t i = 0; i < m; i++)
        {
            int ct = 0;
            for (auto &&sw : s[i])
            {
                // スイッチがオンの場合
                if (bit & (1 << sw))
                {
                    ct++;
                }
            }
            if (ct % 2 != p[i])
            {
                achievable = false;
            }
        }
        if (achievable)
            ans++;
    }

    cout << ans << endl;

    return 0;
}

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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cerr << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define debug(...) CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) (__VA_ARGS__)

using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF = 1e14;

void Main() {
  int n, m;
  cin >> n >> m;
  vector<int> M(m, 0);
  rep(i, n) {
    int k;
    cin >> k;
    rep(i, k) {
      int a;
      cin >> a; a--;
      M[a]++;
    }
  }
  int ans = 0;
  rep(i, m) if (M[i] == n) ans++;
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a; long long b;long long k;
    cin>>a;
    cin>>b;

        k=((a+b)/2);
        if((a+b)%2==0)
        {
            cout<<k<<endl;
        }
        else
        {
            cout<<"IMPOSSIBLE"<<endl;
        }

}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<int,int> p;

int n,a,b;
ll k;
std::map<int, ll> mp;

int main(){
  cin >> n >> k;
  rep(i,0,n){
    cin >> a >> b;
    mp[a] += b;
  }
  ll count =0;
  ll ans;
  for(auto itr: mp){
    // cout << itr.first << ' ' << itr.second << endl;
    count += itr.second;
    if(count >= k){
      ans = itr.first;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4224
S = input()
N = len(S) + 1

# 左に<がいくつ連続しているか
dai = [None] * N
dai[0] = 0

c = 0
for i, si in enumerate(S):
    if si == '<':
        c += 1
    else:
        c = 0
    dai[i+1] = c


# 右に>がいくつ連続しているかを実装を簡単にするためにSをひっくり返して調べる
S = S[::-1]
sho = [None] * N
sho[0] = 0  # 

c = 0
for i, si in enumerate(S):
    if si == '>':
        c += 1
    else:
        c = 0
    sho[i+1] = c

sho = sho[::-1]  # 元に戻す

# print(dai)
# print(sho)

a = [None] * (N)
for i in range(N):
    a[i] = max(dai[i], sho[i])

# print(a)
ans = sum(a)
print(ans)

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

using namespace std;

int main()
{
    long long n,a=0,b;
    cin>>n;
    b=n;
    while(b)
    {
        a+=(b%10);
        b/=10;
    }
    if(n%a==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    std::ios::sync_with_stdio(false);
    int n, m, d;
    cin >> n >> m >> d;
    int ans = 0;
    for(int i = n;i <= m;i++){
        if(i % d == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3644
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define setbitc(x) __builtin_popcount(x)
#define init(x,a) memset(x,a,sizeof(x))
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 1000005
//Variables Start
ll inf=1e18,MOD=1e9+7;
ll n,m,k,ar[N],dp[1005][1005];
string s[1005],s1;
//Variables End

ll sub(ll a, ll b){return (a-b+MOD)%MOD;}
ll add(ll a, ll b){return (a+b)%MOD;}
ll mul(ll a, ll b){return (a*b)%MOD;}
int main()
{
    ios
    int ti=1;
    //cin>>ti;
    while(ti--)
    {
		cin>>n>>m;
		rep(i,0,n)
		{
			cin>>s[i];
		}  
		dp[0][0]=1;
		rep(i,0,n)
		{
			rep(j,0,m)
			{
				if(i==0 && j==0)continue;
				if(s[i][j]=='#')
				{
					dp[i][j]=0;
				}
				else
				{
					if(i>0)dp[i][j]=add(dp[i][j],dp[i-1][j]);
					if(j>0)dp[i][j]=add(dp[i][j],dp[i][j-1]);
				}
			}
		}      

		cout<<dp[n-1][m-1]<<endl;
    }
    return 0;
        
}

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

int main() {
  int N;
  bool pro;
  string col;
  cin >> N;
  pro = false;
  for (int i = 0; i < N; i++){
  cin >> col;
   if (col == "Y"){
     pro = true;
     break;
   }
  }
  if (pro)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}


Measured memory_bytes: 256
N = int(input())
alpha ='abcdefghijklmnopqrstuvwxyz'
keta = 1
judge = 26

while True:
    if N<=judge:
        break
    else:
        judge = judge + 26**(keta+1)
        keta += 1
M = N - (judge-26**keta)-1
answer = ''
import copy
ket = copy.copy(keta)

for i in range(keta):
    num = M//(26**(ket-1))
    amari = M%(26**(ket-1))
    #print(M,ket,num,amari)
    answer += alpha[num]
    ket -= 1
    M = amari
print(answer)

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

int abs(int x, int y){
  if(x>=y){
    return x-y;
  }else{
    return y-x;
  }
}

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(abs(a, b)>abs(a, c)){
    cout << 'B' << endl;
  }else{ 
   cout << 'A' << endl;
  }
}


Measured memory_bytes: 256
N, M = input().split()
view = [int(i) for i in input().split()]
remove = set()
for _ in range(int(M)):
  A, B = [int(i) for i in input().split()]
  if view[A-1] > view[B-1]:
    remove.add(B)
  elif view[A-1] < view[B-1]:
    remove.add(A)
  else:
    remove.add(A)
    remove.add(B)
print(int(N)-len(remove))


Measured memory_bytes: 19960
n,k=gets.split.map(&:to_i)
a,b,c=gets.split.map(&:to_i)
point = Hash[?r,c,?s,a,?p,b]

p gets.chomp.chars.each_slice(k).to_a.tap{|*,la|
  la[k-1]=la[k-1]
}.transpose.flat_map{|l|
  pre = nil
  l.map{|i|
    if pre == i
      pre = nil
      0
    else
      pre = i
      point[i]
    end
  }
}.compact.inject(:+)

Measured memory_bytes: 19068
/**
 * Title: D - Knapsack 1
 * Url: https://atcoder.jp/contests/dp/tasks/dp_d
 */
#include<bits/stdc++.h>

using namespace std;

#define ll long long

const int MAX_N = 100;
const int MAX_W = 100000;

ll dp[MAX_N+1][MAX_W+1];

int N, W;
int w[MAX_N+1], v[MAX_N+1];

// i番目の荷物 残りjの重さまでもてる
// 返り値は i番目以降の選択で得られる最大価値
ll rec(int i, int j) {
    if(dp[i][j]!=-1) return dp[i][j];
    if(i==N) return dp[i][j] = 0;
    if(j-w[i]<0) return dp[i][j] = rec(i+1, j);
    return dp[i][j] = max(rec(i+1, j), rec(i+1, j-w[i])+v[i]);
}

int main() {
    cin >> N >> W;
    for(int i=0; i<N; i++) cin >> w[i] >> v[i];
    memset(dp, -1, sizeof(dp));
    cout << rec(0, W) << endl;

    return 0;
}

Measured memory_bytes: 79104
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)

	a := nextInt()
	b := nextInt()
	c := nextInt()

	can := false

	sum := 0
	for i := 1; ; i++ {
		sum += a
		// fmt.Println(sum)
		if sum%b == c {
			can = true
		}

		if sum%b == 0 {
			break
		}
	}

	if can {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  vll A(999);
  A[0]=1;
  FOR(i,1,999){
    A[i]+=A[i-1]+i+1;
  }
  ll a,b;
  	ci(a>>b);
  co(A[b-a-1]-b)
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int,in,){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_DEF(bool, scan, int &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);} _OUT(const char *s){while(*s)pcu(*s++);} _OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

#define all(o) begin(o), end(o)

int main() {
	const int N {1000000};
	vector<int> v;
	for (int i = 1; i <= N; i *= 2)
		for (int j = 1; i * j <= N; j *= 3)
			for (int k = 1; i * j * k <= N; k *= 5)
				v.push_back(i * j * k);
	sort(all(v));
	for (int m; (m = in());)
		outl((int) (upper_bound(all(v), in()) - lower_bound(all(v), m)));
}


Measured memory_bytes: 2436
import java.util.*

fun main(args: Array<String>) {
    val argList = Scanner(System.`in`)


    val n = argList.nextLine().toInt()
    val d = argList.nextLine().split(" ").map { it.toInt() }

    val executor = DivideTheProblems()
    val result = executor.execute(n, d)
    println(result)
}

class DivideTheProblems {
    fun execute(n: Int, d: List<Int>): Int {
        val sorted = d.sorted()
        val middle = n / 2

        if (sorted[middle - 1] == sorted[middle]) return 0

        val beforeK = sorted[middle] - 1

        return (sorted[middle - 1]..beforeK).toList().size
    }
}

Measured memory_bytes: 57412
s = input()

if s == 'SUN':
    print(7)
elif s == 'MON':
    print(6)
elif s == 'TUE':
    print(5)
elif s == 'WED':
    print(4)
elif s == 'THU':
    print(3)
elif s == 'FRI':
    print(2)
else:
    print(1)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N,M;
  cin >> N >> M;
  vp ab(M);
  rep(i,M) {
    int a,b;
    cin >> a >> b;
    ab[i] = P(b,a);
  }
  sort(rng(ab));
  int cnt = 0;
  int i = 0;
  while(i < M) {
    cnt++;
    int b = ab[i].first;
    int a = ab[i].second;
    while(i < M && ab[i].second < b) {
      i++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=998244353;
const int size=1e3;
const int inf=1e9;
int main(){
  int N;cin>>N;
  int D[N+1]={};D[N]=-1;
  rep(i,0,N) cin>>D[i];
  long cnt[N]={};cnt[0]=1;
  long ans=1;
  if(D[0]!=0){ cout<<0<<endl; return 0; }
  sort(D,D+N);
  if(D[1]==0){ cout<<0<<endl; return 0; }
  rep(i,1,N){
    (ans*=cnt[D[i]-1])%=mod;
    cnt[D[i]]++;
  }cout<<ans<<endl;
}

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

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

using namespace std;

template<class T>
class Fenwick_tree{
	vector<T> a;
public:
	Fenwick_tree(int n):a(n){}
	void add(int i,T val){
		for(;i<a.size();i|=i+1) a[i]+=val;
	}
	T sum(int i,int j){
		if(i==0){
			T res{};
			for(j--;j>=0;j=(j&(j+1))-1) res+=a[j];
			return res;
		}
		return sum(0,j)-sum(0,i);
	}
};

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

	vector<pair<int,int>> Event[500];
	pair<int,int> I[200000],Q[100000];
	rep(i,m){
		scanf("%d%d",&I[i].first,&I[i].second);
		I[i].first--; I[i].second--;
		Event[I[i].first].emplace_back(0,i);
	}
	rep(i,q){
		scanf("%d%d",&Q[i].first,&Q[i].second);
		Q[i].first--; Q[i].second--;
		Event[Q[i].first].emplace_back(1,i);
	}

	int ans[100000];
	Fenwick_tree<int> F(n);
	for(int i=n-1;i>=0;i--) if(!Event[i].empty()) {
		for(auto a:Event[i]){
			int id=a.second;
			if(a.first==0){
				F.add(I[id].second,1);
			}
			else{
				ans[id]=F.sum(Q[id].first,Q[id].second+1);
			}
		}
	}

	rep(i,q) printf("%d\n",ans[i]);

	return 0;
}


Measured memory_bytes: 7296
N, C = map(int, input().split())
T = [[0 for k in range(100001)] for l in range(C)]

for k in range(N):
    s, t, c = map(int, input().split())
    T[c-1][s-1] += 1
    T[c-1][t] -= 1
for l in range(C):
    for k in range(1,100001):
        T[l][k] += T[l][k-1]

ans = 0
for k in range(100001):
    t = 0
    for l in range(C):
        if T[l][k] >= 1:
            t += 1
    ans = max(ans, t)

print(ans)


Measured memory_bytes: 26728
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

struct rest{
  string S;
  int P;
  int idx;
 };

int main(){
  
  int N; cin >> N;

  vector <struct rest> vec;
  for(int i = 0; i < N; i++){
    struct rest a;
    cin >> a.S >> a.P;
    a.idx = i + 1;
    vec.push_back(a);
  }

  for(int i = 0; i < N - 1; i++){
    for(int j = N - 1; j > i; j--){
      if(vec[j - 1].P < vec[j].P){
	struct rest temp = vec[j];
	vec[j] = vec[j-1];
	vec[j-1] = temp;
      }
    }
  }

  for(int i = 0; i < N - 1; i++){
    for (int j = N - 1; j > i; j--){
      if(vec[j-1].S > vec[j].S){
	struct rest temp = vec[j];
	vec[j] = vec[j-1];
	vec[j-1] = temp;
      }
    }
  }

  for(int i = 0; i < N; i++){
    cout << vec[i].idx << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int n, m, a[1024][1024], b[1024][1024], x[1024], y[1024];
inline int f(int i, int j) { return (a[i][j]+b[i][j]+x[i]+y[j]) % 2; }

int main() {
    scanf("%d%d", &n, &m);
    rep (i, n) rep (j, m) scanf("%d", a[i]+j);
    rep (k, n-1) {
        int c = 0;
        rep (i, m) c += f(k, i) != f(k+1, i);
        if (c%2) {
            rep (i, m) if (f(k, i) == f(k+1, i)) b[k+1][i]++, y[i]++;
        }
        else {
            rep (i, m) if (f(k, i) != f(k+1, i)) b[k+1][i]++, y[i]++;
        }
        x[k+1] = c;
    }
    int s = 0;
    rep (i, m) if (f(0, i)) s++;
    if (s%2) {
        rep (i, m) if (f(0, i)) rep (k, n) b[k][i]++;
    }
    else {
        rep (i, m) if (!f(0, i)) rep (k, n) b[k][i]++;
    }
    rep (i, n) rep (j, m) printf("%d%c", b[i][j]%2, "\n "[j+1<m]);
    return 0;
}

Measured memory_bytes: 9224
main :: IO ()
main = do
    [_,a,b] <- (map read . words) <$> getLine
    xs <- (map read . words) <$> getLine
    print $ solve (a, b) xs

solve :: (Int, Int) -> [Int] -> Int
solve (a,b) xs = sum [min (d*a) b | d <- ds]
    where ds = zipWith (-) (tail xs) (init xs)

Measured memory_bytes: 36220
#include <stdio.h>


int main(){
int n,count;
int i,p[51];

  scanf("%d\n",&n);

  for(i=0;i<n;i++){
    scanf("%d",&p[i]);
  }

  for(i=0;i<n;i++){
    if(p[i]!=i+1){
      count++;
    }
  }

  if(count>2){
    printf("NO");
  }else{
    printf("YES");
  }
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include<unordered_map>
#include <set>
#include<unordered_set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <math.h>

#define lli long long int
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);


using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void pre() {
    return ;
}

void solve()
{
    lli n, k;
    cin>>n>>k;
    lli a[n];
    for(int i = 0; i < n; i ++) {
        cin>>a[i];
    }
    sort(a, a + n);
    reverse(a, a + n);
    lli s = 0;
    for(int i = k; i < n; i ++) {
        s += a[i];
    }
    cout<<s;
    cout<<'\n';
    return ;
}

/*
*/

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

//    pre();

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;

int main(void)
{
    int d,g;
    cin >> d >> g;
    vector<pii> p;
    REP(i, d){
        int pi,ci;
        cin >> pi >> ci;
        p.pb(make_pair(pi,ci));
    }

    int ans = INF;

    vector<int> v(d);
    iota(ALL(v), 1);
    reverse(ALL(v));
    do{
        int tmp = 0;
        int t_ans = 0;
        for (auto j : v) {
            if(p[j-1].fi * 100 * j + tmp + p[j-1].se >= g){
            }else{
                tmp += (p[j-1].fi * 100 * j + p[j-1].se);
                t_ans += p[j-1].fi;
                continue; 
            }
            bool flag = false;
            bool finish = false;
            REP(k, p[j-1].fi){
                tmp += j*100;
                if(++t_ans >= ans) {
                    finish = true;
                    break;
                }
                if(tmp>=g){
                    flag = true;
                    break;
                }
                
            }
            if(finish) break;
            if(flag){
                ans = min(ans, t_ans);
            }else{
                tmp += p[j-1].se;
                if(tmp>=g) ans = min(ans, t_ans);
            }
        }
    }while(prev_permutation(ALL(v)));
    
    pr(ans);
}

Measured memory_bytes: 256
A=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
B=[int(input())for i in range(n)]

hantei=[False]*9

for b in B:
    for i in range(9):
        if A[i%3][i//3]==b:
            hantei[i]=True
OK=[True, True, True]
flag=0
if hantei[0:3]==OK or hantei[3:6]==OK or hantei[6:9]==OK:
    flag=1
elif hantei[0::3]==OK or hantei[1::3]==OK or hantei[2::3]==OK:
    flag=1
elif hantei[0]==True and hantei[4]==True and hantei[8]==True:
    flag=1
elif hantei[2]==True and hantei[4]==True and hantei[6]==True:
    flag=1
print('Yes' if flag else 'No')

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
int n,m,i,j,k,a[205][205],col[205],vis[205],ans;
char c;
void dfs(int i)
{
	if(vis[i]) return;vis[i]=1;
	int j;fz1(j,n){
		if(a[i][j]){
			if(col[j]==col[i]){
				puts("-1");
				exit(0);
			}
			col[j]=3-col[i];
			dfs(j);
		}
	}
}
int main()
{
	scanf("%d",&n);
	fz1(i,n){
		scanf(" ");
		fz1(j,n){
			scanf("%c",&c);
			a[i][j]=c-'0';
		}
	}
	col[1]=1;
	dfs(1);
	fz1(i,n)fz1(j,n)if(i!=j&&a[i][j]==0) a[i][j]=0x3f3f3f3f;
	fz1(k,n)fz1(i,n)fz1(j,n){
		a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
	}
	fz1(i,n)fz1(j,n) ans=max(ans,a[i][j]+1);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
from random import choice
from random import random
from time import time


class Optimizer:
    def __init__(self, C, S):
        self.C = C
        self.S = S
        X = []
        L = [-1] * 26
        for i in range(365):
            max_diff = -10**10
            best_j = 0
            for j in range(26):
                memo = L[j]
                L[j] = i
                diff = self.S[i][j] - \
                    sum([self.C[jj] * (i - L[jj]) for jj in range(26)])
                if diff > max_diff:
                    max_diff = diff
                    best_j = j
                L[j] = memo
            L[best_j] = i
            X.append(best_j)
        self.X = X

    def calc_score(self):
        score = 0
        L = [-1 for j in range(26)]
        A = [0 for j in range(26)]
        for i in range(365):
            score += self.S[i][self.X[i]]
            A[self.X[i]] += (i - L[self.X[i]]) * \
                (i - L[self.X[i]] - 1) // 2
            L[self.X[i]] = i
        for j in range(26):
            A[j] += (365 - L[j]) * (365 - L[j] - 1) // 2
            score -= self.C[j] * A[j]
        return score

    def optimize(self, temp, threp, interval, start_time, lim=1.8):
        max_score = self.calc_score()
        while True:
            t = (time() - start_time) / 2
            if random() < threp:
                i = choice(range(365))
                j = choice(range(26))
                memo = self.X[i]
                self.X[i] = j
                new_score = self.calc_score()
                if new_score > max_score:
                    max_score = new_score
                elif random() < pow(2.7, (new_score - max_score) / pow(2000, 1 - t)):
                    max_score = new_score
                else:
                    self.X[i] = memo
            else:
                a = choice(range(interval))
                i0 = choice(range(365 - a))
                i1 = i0 + a
                self.X[i0], self.X[i1] = self.X[i1], self.X[i0]
                new_score = self.calc_score()
                if new_score > max_score:
                    max_score = new_score
                elif random() < pow(2.7, (new_score - max_score) / pow(2000, 1 - t)):
                    max_score = new_score
                else:
                    self.X[i0], self.X[i1] = self.X[i1], self.X[i0]
            if time() - start_time > lim:
                break
        return max(max_score + 10**6, 0)


if __name__ == "__main__":
    d = int(input())
    *C, = map(int, input().split())
    S = [list(map(int, input().split())) for i in range(d)]
    start_time = time()
    opt = Optimizer(C, S)
    opt.optimize(400, 0.8, 10, start_time)
    for x in opt.X:
        print(x + 1)
    # print(opt.calc_score())


Measured memory_bytes: 90644
#include <bits/stdc++.h>
using namespace std;
int main(){
  string n;
  cin>>n;
if((n[0]==n[1]&&n[1]==n[2])||(n[1]==n[2]&&n[2]==n[3])) cout<<"Yes"<<endl;
 else cout<<"No"<<endl;
return 0;
}


Measured memory_bytes: 256
/*
   一行目にnが与えられる。二行目にn個の要素を持つ数列Sが与えられる。
   三行目にqが与えられる。四行目にq個の要素を持つ数列Tが与えられる。

   Tに含まれる整数の中で、Sに含まれるものの個数Cを出力する。

   ※　Sの要素は昇順であるため、二文探索を行って高速化する。

   input:
   5
   1 2 3 4 5
   3
   3 4 1

   output:
   3
*/

#include <stdio.h>

int binarysearch(int S[], int key, int right)
{
   int left = 0;
   int mid;

   while (left < right) {
     mid = (left + right) / 2;

     if (S[mid] == key)
        return 1;
     else if (key < S[mid])
        right = mid;
     else if (key > S[mid])
        left = mid + 1;

   }

   return 0;
}

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

   int S[n];
   for (int i = 0; i < n; i++)
      scanf("%d", &S[i]);

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

   int T[q];
   for (int i = 0; i < q; i++)
      scanf("%d", &T[i]);

   int count = 0;

   for (int i = 0; i < q; i++)
      if (binarysearch(S, T[i], n)) count++;

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

   return 0;
}


Measured memory_bytes: 2272
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        int K=cin.nextInt();
        if(K%2==0)Console.WriteLine(K/2*K/2);
        else Console.WriteLine(K/2*(K/2+1));
        
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public static void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }//Answer.IntArrayAns(x);
    public static void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}



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


int main () {
  int d,g;
  cin >> d >> g ;
  g/=100;
  

  unordered_map<int,P> list;
  for (int i = 0; i < d; i++) {
    cin >> list[i].first >> list[i].second;
    list[i].second/=100;
  }
  //ひとまず、上から解いた時の点数求めてみるか
  //コンプボーナス無しで、最高ランクを全問解いた点数が目標点数より大きいなら
  //最高ランクすら全問とく必要がない
  //その時に何問解けばいいかはこの式ででる
  int anscount= 1e9;


  // すべての選び方を試して、最小を探す
  for (int tmp = 0; tmp < (1 << d); tmp++) {
    bitset<12> s(tmp);  // 最大10ランクなので10ビットのビット列として扱う
    //bitset<12> s(0);
    // ビット列の1のビットに対応する整数を選んだとみなして総和を求める
    int counter = 0;
    int score = 0;
    //それぞれの問題ランクを、全問解くかどうかをみる
    rep(i,d)
    {     //その桁の数字が1、つまり全問解くということなら
       if (s.test(i)) {
         int mondaisu =list[i].first;//iは0始まり
         int compbonus = list[i].second;
         counter+=mondaisu;
         score+=((i+1)*mondaisu+compbonus);
       }
    }
      
      //もし、それぞれの列をコンプしても点数が足りなければ足す
    int i=d;
    //cout <<"     ________i:"<< i<<" score:"<<score<<" goal:"<<g << endl;
  while (score<g)
  {
    if(s.test(i-1)==0)
    {
     int mondaisu =list.at(i-1).first;//iはd始まり
     int compbonus = list.at(i-1).second;
     int nokori = g-score;
     if((i* mondaisu)+compbonus > nokori)
      {//cout <<"     ________________in ifsta"<<"atonankai"<<(i + nokori - 1) / i<<"nokori"<<nokori<<" score:"<<score<<" goal:"<<g << endl;
      int atonankai=(i + nokori - 1) / i;
        counter+=atonankai;
       score+=atonankai*i ;
       //cout <<"     ________________in ifend"<< i<<" score:"<<score<<" goal:"<<g << endl;
      break;}
     else
       {
      score+=(i)*mondaisu+compbonus;
      counter+=mondaisu;
       }
    } 
      //cout <<"     _________i"<< i<<" score:"<<score<<" goal:"<<g << endl;
    i--;
    
    }
   //足し終わった状態
   //カウンターの数を比べてみる。少ないほうを答えに。
   anscount=min(anscount,counter);
  //cout <<tmp<<" counter:" <<counter<<" score:"<<score <<" goal:"<<g<< endl;
  }
  
  cout << anscount << endl;
  
  return 0;
  
}



Measured memory_bytes: 256
n = int(input())
dic = {}
for i in range(10, 100): dic[str(i)]=0
for i in range(1, n+1):
    s = str(i)
    dic[s[0]+s[-1]] += 1

ans = 0
for i in range(1, n+1):
    s = str(i)
    if s[-1]=="0": continue
    ans += dic[s[-1]+s[0]]
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <limits>
#include <cfenv>
#include <cmath>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <tuple>
#include <queue>
#include <vector>
#include <cmath>
#include <random>
#include <math.h>
#include <list>
#include <random>
#include <functional>


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

using lli = long long int;
using pii = std::pair<int, int>;

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


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


constexpr int ALPHA_SIZE = 'z' - 'a' + 1;
constexpr int N = 2e5;
char str[N+1];
std::array<std::bitset<ALPHA_SIZE>, N+1> P;
std::array<int, N+1> length;

int main(void){
    scanf("%s", str);
    const int n = strlen(str);
    length[n] = 1;
    rREP(i, n){
        P[i] = P[i + 1];
        P[i][str[i] - 'a'] = true;
        if(P[i].all()){ P[i].reset(); length[i] = length[i + 1] + 1;}
        else length[i] = length[i + 1];
    }
    int l = length[0];
    int idx = 0;
    while(idx < n){
        int i; for(i=0;i<ALPHA_SIZE;++i) if(not P[idx][i]) break;
        char c = i + 'a'; putchar(c);
        while(idx < n and str[idx] != c) idx++;
        idx++;
    }
    putchar('\n');

    
    return 0;
}

Measured memory_bytes: 2816
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        long h = scanner.nextLong();

        long result = 0;

        long hnum = 1;
        while(h > 0){
            h = h / 2;
            result += hnum;
            hnum = hnum * 2;
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 21844
// C++ code to find number of distinct numbers 
// in a subarray 
#include<bits/stdc++.h> 
using namespace std; 

const int MAX = 1000001; 

// structure to store queries 
struct Query 
{ 
	int l, r, idx; 
}; 

// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
	return x.r < y.r; 
} 

// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
	for (; idx <= n; idx += idx&-idx) 
		bit[idx] += val; 
} 

// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
	int sum = 0; 
	for (; idx>0; idx-=idx&-idx) 
		sum += bit[idx]; 
	return sum; 
} 

void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
	// initialising bit array 
	int bit[n+1]; 
	memset(bit, 0, sizeof(bit)); 

	// holds the rightmost index of any number 
	// as numbers of a[i] are less than or equal to 10^6 
	int last_visit[MAX]; 
	memset(last_visit, -1, sizeof(last_visit)); 

	// answer for each query 
	int ans[q]; 
	int query_counter = 0; 
	for (int i=0; i<n; i++) 
	{ 
		// If last visit is not -1 update -1 at the 
		// idx equal to last_visit[arr[i]] 
		if (last_visit[arr[i]] !=-1) 
			update (last_visit[arr[i]] + 1, -1, bit, n); 

		// Setting last_visit[arr[i]] as i and updating 
		// the bit array accordingly 
		last_visit[arr[i]] = i; 
		update(i + 1, 1, bit, n); 

		// If i is equal to r of any query store answer 
		// for that query in ans[] 
		while (query_counter < q && queries[query_counter].r == i) 
		{ 
			ans[queries[query_counter].idx] = 
					query(queries[query_counter].r + 1, bit, n)- 
					query(queries[query_counter].l, bit, n); 
			query_counter++; 
		} 
	} 

	// print answer for each query 
	for (int i=0; i<q; i++) 
		cout << ans[i] << endl; 
} 

// driver code 
int main() 
{ 
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	int n,q;
	cin>>n>>q;
	int a[n];
	for(int i = 0;i<n;i++){
		cin>>a[i];
	}
	int idx = 0;
	Query queries[q];
	for(int i = 0;i<q;i++){
		int l,r;
		cin>>l>>r;
		queries[idx].l = l-1;
		queries[idx].r = r-1;
		queries[idx].idx = idx;
		idx++;
	}
	sort(queries, queries+q, cmp); 
    answeringQueries(a, n, queries, q); 
	return 0; 
} 


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

int main() {
  int N, Y = 0;
  double s = 0;
  cin >> N;
  vector<double> X(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> X[i];
    s += X[i];
  }
  int p = round(s / N);
  
  for (int i = 0; i < N; i++) {
    Y += pow(X[i] - p, 2);
  }
  cout << Y << endl;
}
  

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

int main(){
  long long a, b, c;
  cin >> a >> b >> c;

  long long ans = b;

  if(a + b >= c){
    ans += c;
  }else{
    ans += (a+b)+1;
  }

  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 256
def main():
    N = int( input())
    ANS = []
    now = 0
    for i in range(1,N+1):
        now += i
        ANS.append(i)
        if now == N:
            break
        if N < now:
            ANS.remove(now-N)
            break
    print("\n".join( map( str, ANS)))
if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include <stdio.h>

int main(int argc,char* argv[]){
  int i,j,x,y,s;
  int array[14][14];
  int blunk = 0,max = -99999;

  for(i = 0; i < 14; i++){
    for(j = 0; j < 14; j++){
      if(i <= 1 || i >= 12 || j <= 1 || j >= 12){
	array[i][j] = -99999999;
      }else{
	array[i][j] = 0;
      }
    }
  }
  
  while(scanf("%d,%d,%d",&y,&x,&s) != EOF){
    x += 2;
    y += 2;
    if(s == 1){
                      array[x][y+1]++;
      array[x-1][y]++;array[x][ y ]++;array[x+1][y]++;
                      array[x][y-1]++;
    }else if(s == 2){
      array[x-1][y-1]++;array[x][y-1]++;array[x+1][y-1]++;
      array[x-1][ y ]++;array[x][ y ]++;array[x+1][ y ]++;
      array[x-1][y+1]++;array[x][y+1]++;array[x+1][y+1]++;
    }else{
                                          array[x][y-2]++;
                        array[x-1][y-1]++;array[x][y-1]++;array[x+1][y-1]++;
      array[x-2][ y ]++;array[x-1][ y ]++;array[x][ y ]++;array[x+1][ y ]++;array[x+2][ y ]++;
                        array[x-1][y+1]++;array[x][y+1]++;array[x+1][y+1]++;
                                          array[x][y+2]++;
    }
    /*
    for(i = 2; i < 12; i++){
      for(j = 2; j < 12; j++){
	printf("[%3d]",array[i][j]);
      }
      printf("\n");
    }
    */
    
    
  }
  
  for(i = 0; i < 14; i++){
    for(j = 0; j < 14; j++){
      if(array[i][j] == 0){blunk++;}
      if(array[i][j] > max){
	max = array[i][j];
      }
    }
  }

  printf("%d\n%d\n",blunk,max);

  return 0;
  
}

Measured memory_bytes: 0
var i:Longint;
s:String;
begin
readln(s);
i:=1;
while s[i]<>' 'do inc(i);
if s[i-1]<>s[i+1]then begin writeln('NO');exit;end;
inc(i);
while s[i]<>' 'do inc(i);
if s[i-1]<>s[i+1]then begin writeln('NO');exit;end;
writeln('YES');
end.

Measured memory_bytes: 128