akhauriyash/Code-Regression huggingface dataset:
N = int(input())
S = list(input())

key = []
for i in range(10):
    for j in range(10):
        for k in range(10):
            key.append([i,j,k])

ans=0
for i in range(1000):
    if str(key[i][0]) in S:
        ind_0=S.index(str(key[i][0]))
        if str(key[i][1]) in S[ind_0+1:]:
            ind_1=ind_0 + 1 + S[ind_0+1:].index(str(key[i][1]))
            if str(key[i][2]) in S[ind_1+1:]:
                ans+=1
print(ans)

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

void BubbleSort(int A[],int N){
int i,j,tmp,cnt=0;
for(i=0;i<N;i++){
for(j=N-1;j>0;j--){

if(A[j]<A[j-1]){
tmp=A[j];
A[j]=A[j-1];
A[j-1]=tmp;
cnt++;
}
}
}
for(i=0;i<N;i++){
if(i>0)cout<<" ";
cout<<A[i];
}
cout<<endl;
cout<<cnt<<endl;
}

int main(){
int N;
cin>>N;
int A[N];
for(int i=0;i<N;i++)cin>>A[i];
BubbleSort(A,N);
return 0;
}

Measured memory_bytes: 1160
//#include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
    ll N;
    cin >> N;
    vector<pair<ll, ll> >  vll(N);
    for(int i = 0; i < N; i++){
        ll x,y;
        cin >> x >> y;
        //vll.push_back(make_pair(x,y));
        vll[i].first = x;
        vll[i].second = y;
    }

    ll Combo=1;
    for(int i = 1; i <= N; i++){
        Combo*=i;
    }

    ll Combo2=1;
    for(int i = 1; i < N; i++){
        Combo2*=i;
    }
    Combo2*=2;
    
    //cout << Combo << endl;

    double ans=0.0;
    for(int i = 0; i < N; i++){
        for(int j = i+1; j < N; j++){
            ll X = abs(vll[i].first - vll[j].first);
            ll Y = abs(vll[i].second - vll[j].second);
            //cout << X << " " << Y << endl;
            double tmp = Combo2 * sqrt(X*X + Y*Y);
            ans+=tmp;
            //cout << ans << endl;
        }
    }

    //cout << ans/Combo << endl;
    printf("%.10f\n", ans/Combo);
    return 0;
}

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

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

int main()
{
    int A, B;
    cin >> A >> B;
    cout << max({2*A-1, 2*B-1, A+B}) << endl;
    return 0;
}


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

def calc(x):
    stack = []
    for _ in range(N):
        stack.append((3-x%3)%3)
        x //= 3
    res = 0
    for i in range(N-1, -1, -1):
        res *= 3
        res += stack[i]
    return res

N = int(readline())
P3 = [pow(3, i) for i in range(N+1)]

St = [1 if s == 'R' else 0 for s in readline().strip()]
LS = len(St)
ans = [None]*P3[N]
arr = [None]*P3[N]
ans[0] = 0
arr[0] = St[:]
REV = (0, 2, 1)
for l in range(N):
    p3l = P3[l]
    for i in range(p3l):
        k0, k1, k2 = 0, 1, 2
        r0, r1, r2 = [], [], []
        for s in arr[i]:
            if s:
                k0 += 1
                k1 += 1
                k2 += 1
                if k0 == 3:
                    k0 = 0
                    r0.append(1)
                if k1 == 3:
                    k1 = 0
                    r1.append(1)
                if k2 == 3:
                    k2 = 0
                    r2.append(1)
            else:
                k0 = REV[k0]
                k1 = REV[k1]
                k2 = REV[k2]
                if r0 and r0[-1] == 0:
                    r0.pop()
                else:
                    r0.append(0)
                if r1 and r1[-1] == 0:
                    r1.pop()
                else:
                    r1.append(0)
                if r2 and r2[-1] == 0:
                    r2.pop()
                else:
                    r2.append(0)
        arr[2*p3l+i] = r2[:]
        arr[p3l+i] = r1[:]
        arr[i] = r0[:]
        a = ans[i]
        ans[2*p3l+i] = k2*p3l+a
        ans[p3l+i] = k1*p3l+a
        ans[i] = k0*p3l+a
                
print(*ans)

Measured memory_bytes: 194996
freq = Array.new(6, 0)
n = gets.to_i
n.times{
    height = gets.to_f
    case height
    when 165.0 ... 170.0 then freq[1] += 1
    when 170.0 ... 175.0 then freq[2] += 1
    when 175.0 ... 180.0 then freq[3] += 1
    when 180.0 ... 185.0 then freq[4] += 1
    else
        freq[0] += 1 if height < 165.0
        freq[5] += 1 if height > 185.0
    end
}
freq.each_with_index{|f, i| puts "#{i + 1}:#{"*" * f}"}

Measured memory_bytes: 8556
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
#define mem(a, b) memset(a, b, sizeof(a))
#define REP(i, a) for (int i = 0; i < a; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(a) a.begin(), a.end()
 
inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << fixed << setprecision(10);
}
 
inline void print_vector(vector<int> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}
 
inline void print_array(const int A[], int n) {
    REP(i, n) {
        if (i < n - 1) {
            cout << A[i] << " ";
        } else {
            cout << A[i] << endl;
        }
    }
}
 
inline void solve() {
    int n;
    cin >> n;
 
    string s;
 
    REP(i, n) {
        s += "ACL";
    }
 
    cout << s << endl;
}
 
int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    int t = 1;
    // cin >> t;
 
    for (int _ = 0; _ < t; _++) {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>
int gcd(int,int);

int gcd(int x, int y) {
  int r;
  r = x % y;
  while (r > 0) {
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

int main() {
  int a, b;
  scanf("%d %d",&a,&b);
  printf("%d\n",gcd(a, b));
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  int aa[n];
  int max = 0;

  for (int k = 0; k < n; k++) cin >> aa[k];
 
  for (int k = 0; k < n; k++) {
    for (int l = k; l < n; l++) {
      int diff = (aa[k] > aa[l] ? aa[k] - aa[l] : aa[l] - aa[k]);
      if (max < diff) max = diff;
    }
  }

  cout << max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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;
}

int main(){
  int i,j;
  int a[3][3];
  bool b[3][3];
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      cin>>a[i][j];
      b[i][j]=0;
    }
  }
  int n;
  cin>>n;
  for(i=0;i<n;i++){
    int x;
    cin>>x;
    for(j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(a[j][k]==x) b[j][k]=1;
      }
    }
  }
  int ok=0;
  for(i=0;i<3;i++){
    if(b[i][0]&&b[i][1]&&b[i][2]) ok=1;
    if(b[0][i]&&b[1][i]&&b[2][i]) ok=1;
  }
  if(b[0][0]&&b[1][1]&&b[2][2]) ok=1;
  if(b[0][2]&&b[1][1]&&b[2][0]) ok=1;
  
  if(ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc161
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm  = Console.ReadLine().Split().Select(s=>int.Parse(s)).ToArray();
            var a = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            var border = (float)(a.Sum()) /(float) (4 * nm[1]) ;
            var select = a.OrderByDescending(o=>o).Take(nm[1]);
            var num = select.Where(x => x >= border).Count();
            var ans = num == nm[1] ? "Yes" : "No"; 

            Console.WriteLine(ans);

        }
    }
}

Measured memory_bytes: 13524
H,W=gets.split.map &:to_i
N=gets.to_i
a=gets.split.map &:to_i

c=Array.new(H+2){Array.new(W+2){0}}
(H+2).times{|i| c[i][0]=c[i][-1]=-1}
(W+2).times{|j| c[0][j]=c[-1][j]=-1}

dy=[1,0,-1,0]
dx=[0,1,0,-1]
d=0
n=1
y,x=0,1
until a.empty?
  ny=y+dy[d%4]
  nx=x+dx[d%4]
  next d+=1 if c[ny][nx]!=0
  y=ny
  x=nx
  c[y][x]=n
  a[0]-=1
  if a[0].zero?
    n+=1
    a.shift
  end
end

puts c[1..H].map{|i|i[1..W]*" "}


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

int alpha[28];

int main()
{
    string S;
    cin >> S;
    for(int i = 0; i < S.size(); ++i) {
        int j = S[i] - 'a';
        if(0 <= j && j <= 'z' - 'a') ++alpha[j];
    }

    for(int i = 0; i <= 'z' - 'a'; ++i) {
        if(alpha[i] == 0) {
            cout << (char)(i + 'a') << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

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

map<ll,int> prime_factor(ll n){
    map<ll,int> ret;
    for(ll i=2;i*i<= n;i++){
        while(n%i==0){
            ret[i]++;
            n/=i;
        }
    }
    if(n!=1)ret[n]=1;
    return ret;
}

int main(){
    ll n;cin>>n;
    cout<<n<<":";
    for(auto p:prime_factor(n)){
        while(p.second--)cout<<" "<<p.first;
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3120
def floor_sum(n, m, a, b):
    res = 0
    while True:
        res += (n - 1) * n * (a // m) // 2
        a %= m
        res += n * (b // m)
        b %= m
        y_max = (a * n + b) // m
        if y_max == 0: break
        x_max = y_max * m - b
        res += (n - (x_max + a - 1) // a) * y_max
        n, m, a, b = y_max, a, m, -x_max % a
    return res

import sys
input = sys.stdin.buffer.readline

T = int(input())
res = [None] * T

for i in range(T):
    n, m, a, b = map(int, input().split())
    res[i] = str(floor_sum(n, m, a, b))

print('\n'.join(res))

Measured memory_bytes: 78176
#include <stdio.h>
#include <stdlib.h>

int main() {
  long N, t, x, y, n;
  long t0, x0, y0;
  long dist, dt;

  t0 = 0;
  x0 = 0;
  y0 = 0;

  scanf("%ld", &N);
  //N = 1;

  for(n = 0;n < N;n++){
    scanf("%ld %ld %ld", &t, &x, &y);
    // t = 5;
    // x = 1;
    // y = 1;
    dist = abs(x - x0) + abs(y - y0);
    dt = t - t0;

    if(dt < dist){
      printf("No");
      return 0;
    }

    if(dt%2 != dist%2){
      printf("No");
      return 0;
    }

    t0 = t;
    x0 = x;
    y0 = y;
  }

  printf("Yes");
  return 0;
}

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

const int dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};

int d[510][510];
int p[250010],n;
bool bo[510][510];

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline void gao(int x,int y)
{
	for (int i=0;i<4;i++)
	{
		int t1=x+dx[i],t2=y+dy[i];
		if (t1<1||t1>n||t2<1||t2>n) continue;
		if (d[t1][t2]>d[x][y]+bo[t1][t2]) d[t1][t2]=d[x][y]+bo[t1][t2],gao(t1,t2);
	}
}

int main()
{
	n=rd();
	for (int i=1;i<=n*n;i++) p[i]=rd();
	for (int i=1;i<=n;i++) for (int j=1;j<=n;j++) d[i][j]=min(min(i,n-i+1),min(j,n-j+1));
	memset(bo,true,sizeof(bo));
	int ans=0;
	for (int i=1;i<=n*n;i++)
	{
		int x=(p[i]-1)/n+1,y=p[i]-(x-1)*n;
		ans+=d[x][y]-1;bo[x][y]=false;
		d[x][y]--;gao(x,y);
	}
	printf("%d\n",ans);
	return 0;
}

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

constexpr int MOD = 1e9 + 7;

int main()
{
    std::string S;
    std::cin >> S;

    int N = S.size();
    std::vector<std::vector<long long>> dp(N + 1, std::vector<long long>(4, 0));
    dp[0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 4; j++)
            if (S[i] != '?')
                dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
            else
                dp[i + 1][j] = (dp[i + 1][j] + dp[i][j] * 3) % MOD;


        if (S[i] == 'A' || S[i] == '?')
            dp[i + 1][1] = (dp[i + 1][1] + dp[i][0]) % MOD;
        if (S[i] == 'B' || S[i] == '?')
            dp[i + 1][2] = (dp[i + 1][2] + dp[i][1]) % MOD;
        if (S[i] == 'C' || S[i] == '?')
            dp[i + 1][3] = (dp[i + 1][3] + dp[i][2]) % MOD;
    }
    std::cout << dp[N][3] << std::endl;
    return 0;
}

Measured memory_bytes: 7424
#include <stdio.h>

int main(void)
{
  int i,j,n[5][14],maisuu,num;
  char mark,dummy;
  
  scanf("%d",&maisuu);
  
  for(i=0; i < 5; i++){
    for(j=0; j < 14; j++){
      n[i][j]=0;
    }
  }
  
  for(i=0; i < maisuu; i++){
    
    scanf("%*c%c %d",&mark,&num);
    
    if(mark == 'S'){
      n[0][num] = 1;
    }
    if(mark == 'H'){
      n[1][num] = 1;
    }
    if(mark == 'C'){
      n[2][num] = 1;
    }
    if(mark == 'D'){
      n[3][num] = 1;
    }
  }
  for(i = 0; i < 4; i++){
    for(j=1; j < 14; j++){
      
      if(n[i][j]==0 && i == 0) printf("S %d\n",j);
      if(n[i][j]==0 && i == 1) printf("H %d\n",j);
      if(n[i][j]==0 && i==2) printf("C %d\n",j);
      if(n[i][j]==0 && i==3) printf("D %d\n",j);
    }
  }
  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <string>
#include <stack>
#include <tuple>

using namespace std;
typedef long long ll;

int main()
{
    int n;int k;
    cin >> n >> k;
    vector<char> d(k);
    for (int i = 0; i < k; i++) cin >> d[i];
    auto ok = [&](int num)
    {
        for (auto& c : to_string(num))
        {
            if(find(d.begin(), d.end(), c) != d.end()) return false;
        }
        return true;
    };
    int ans = n;
    while (!ok(ans)) ans++;
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n),b(n),c(n-1),d(n-1,0);
  int i,s;
  s=0;
  for(i=0;i<n;i++){
    cin >> a.at(i);
    if(i>=1&&a.at(i-1)+1==a.at(i)){
      d.at(a.at(i-1)-1)=1;
    }
  }
  for(i=0;i<n;i++){
    cin >> b.at(i);
    s += b.at(i);
  }
  for(i=0;i<n-1;i++){
    cin >> c.at(i);
    s += c.at(i)*d.at(i);
  }
  cout << s << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N,W;
  cin >> N >> W;
  ll w[110],v[110];
  for(int i=0;i<N;i++){
    cin >> w[i] >> v[i];
  }
  ll dp[110][100010]={0};
  for(int j=0;j<=W;j++){
    dp[0][j]=0;
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<=W;j++){
      if(j-w[i]<0)dp[i+1][j]=dp[i][j];
      else dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
    }
  }
  cout << dp[N][W] << endl;
  return 0;
}

Measured memory_bytes: 86272
import java.util.Scanner;

public class Main {

public static void main(String args[]) {
Scanner in = new Scanner(System.in);
String changeWord="";
char no = 3;
String word = in.next();
for(int i=0; i<word.length(); i++) {
if((word.charAt(i))=='A'||(word.charAt(i))=='B'||(word.charAt(i))=='C') {
changeWord = changeWord + String.valueOf((char)(word.charAt(i)+(char)23));
continue;
}

changeWord = changeWord + String.valueOf((char)(word.charAt(i)-no));
}
System.out.println(changeWord);
}
}

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

int main(){
  int m,n,i,j,l,sum,month,flag=0;

  while(1){
    flag=0;
    sum=0;
    l=0;
    cin >> l;
    if(l == 0)break;
    for(i=1;i<=12;i++){
      cin >> m >> n;
      sum=sum+(m-n);
      if(sum>=l && flag==0){
	month=i;
	flag=1;
      }
    }
    // cout << "sum=" << sum << endl;
    //cout << "l=" << l << endl;

    if(sum>=l)cout << month << endl;
    else{cout<<"NA"<<endl; }


  }

}

Measured memory_bytes: 0
#![allow(non_snake_case)]
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;
use std::cmp::min;

fn main() {
    let N: usize = read();
    let T: u64 = read();
    let t:Vec<u64> = (0..N).map(|_| read()).collect();

    let mut ans = T;
    for i in 1..N {
        ans += min(t[i] - t[i-1], T);
    }

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

int n;
string s;
int k[30];
int w[] = {0, 2, 7, 12, 17};

int main () {

	cin >> n;
	for (int i = 0; i < n; i ++) {
		cin >> s;
		k[ s[0]-'A' ] ++;
		//cout << s[0]-'A' << "\n";
	}
	
	long long int sol = 0;
	for (int i = 0; i < 5; i ++) {
		for (int j = i+1; j < 5; j ++) {
			for (int l = j+1; l < 5; l ++) {
				sol += 1LL * k[ w[i] ] * k[ w[j] ] * k[ w[l] ];
			}
		}
	}
	cout << sol;

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 100000002;
//const int mod = 1000000007;
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

vi to[200005];

mint dfs(int v){
	mint res = 1;
	for(int u: to[v]){
		res *= dfs(u);
	}
	return res + 1;
}

int main(){
	int n; cin >> n;
	vector<pi> p(n); rep(i,n) cin >> p[i].first >> p[i].second;
	sort(p.begin(), p.end());
	set<pi> s;
	for(int i = n-1; i>=0; i--){
		int x = p[i].first, d = p[i].second;
		while(s.size() && s.begin()->first < x+d){
			to[i].push_back(s.begin()->second);
			s.erase(s.begin());
		}
		s.emplace(x, i);
	}
	mint ans = 1;
	for(auto x : s){
		int v = x.second;
		ans *= dfs(v);
	}
	cout << ans.x << endl;
}

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

const int N = 100005;
const int MOD = 1000000007;
typedef pair<int, int> pii;
#define mp(a,b) make_pair(a,b)
#define se second
#define fi first

struct Point {
	double x, y;
	Point() {}
	Point(double x, double y) : x(x), y(y) {}
	void read() {scanf("%lf%lf", &x, &y);}
	Point operator - (const Point& c) const {
		return Point(x - c.x, y - c.y);
	}
} p[3];

double Dot(Point a, Point b) {return a.x * b.x + a.y * b.y;}
double len(Point A) {return sqrt(Dot(A, A));}
double ang(Point a, Point b) {return acos(Dot(a, b) / len(a) / len(b));}

bool ck(Point a, Point b, Point c, double r) {
	double r1 = ang(c - a, b - a) / 2;
	double r2 = ang(c - b, a - b) / 2;
	double d1 = r / tan(r1), d2 = r / tan(r2);
	return d1 + d2 + r * 2 <= len(b - a);
}

bool judge(double r) {
	for (int i = 0; i < 3; i++)
		for (int j = i + 1; j < 3; j++)
			if (ck(p[i], p[j], p[3 - i - j], r)) return true;
	return false;
}

int main() {
	for (int i = 0; i < 3; i++) p[i].read();
	double l = 0, r = 1e9;
	for (int i = 0; i < 100; i++) {
		double mid = (l + r) / 2;
		if (judge(mid)) l = mid;
		else r = mid;
	}
	printf("%.12f\n", l);
	return 0;
}


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

int main(){
  int r, g, b;
  cin >> r >> g >> b;
  
  if((r * 100 + g * 10 + b) % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> X(N);
  for(int i=0;i<N;i++){
    cin >> X.at(i);
  }
  int sum=0;
  int min=100000000;
  for(int i=1;i<101;i++){
    sum=0;
    for(int j=0;j<N;j++){
      sum+=(X.at(j)-i)*(X.at(j)-i);
    }
    if(min>sum){
      min=sum;
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using  namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n,k;
	cin>>n>>k;
	int ar[n];
	int dp[n];
	for(int i=0;i<n;i++){
		cin>>ar[i];
		dp[i]=INT_MAX;
	}
	dp[0]=0;
	for(int i=1;i<n;i++)
		for(int j=1;j<=min(i,k);j++)
			dp[i]=min(dp[i],abs(ar[i]-ar[i-j])+dp[i-j]);
	cout<<dp[n-1];
	return 0;
}

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

int main(){
  int N,M;
  cin >> N >>M;
  vector<int> food(M);
  
  for (int i=0;i<N;i++){
   int Ki;
   cin >>Ki;
   vector<int> like(Ki);
   
   for(int j=0;j<Ki;j++){
    cin >> like.at(j);
    food.at(like.at(j)-1)++;
   }
  }
  int count=0;
  for (int i=0;i<M;i++){
   if (food.at(i)==N){
    count++;
   }
  }
 cout <<count<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using ll = long long;
using namespace std;
 

void solveCase() {
   map <char, int> m = {{'N', 1}, {'S', -1}, {'E', 100}, {'W', -100}};
   string s;
   cin >> s;
   set <char> t(s.begin(), s.end());
   int ans = 0;
   for(auto &c: t)  {
      ans += m[c];
   }
   cout << ((ans == 0)?"Yes": "No") << endl;
}
 
int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   
   int testcase = 1;
   // cin >> testcase;
 
   for(int i = 0; i < testcase; i++) {
      solveCase();
   }
 
   return 0;
}

Measured memory_bytes: 3608
-- {-# LANGUAGE TypeApplications #-}
-- {-# LANGUAGE BlockArguments #-}
import Control.Monad
import Data.Maybe
import Data.Char (isSpace)
import Data.List (unfoldr)
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS

tuplify2 (x:y:_) = (x,y)
tuplify2 _ = undefined

--Input functions with ByteString
readInt = fst . fromJust . BS.readInt
readIntTuple = tuplify2 . map readInt . BS.words
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntN n = map readInt <$> replicateM (fromIntegral n) BS.getLine
getIntList = readIntList <$> BS.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine
getIntMatrix = map readIntList . BS.lines <$> BS.getContents
getIntTuple = readIntTuple <$> BS.getLine
getIntNTuples n = map readIntTuple <$> replicateM (fromIntegral n) BS.getLine
getIntTuples = map readIntTuple . BS.lines <$> BS.getContents

permutation :: [a] -> Int -> [[a]]
permutation [] _    = [[]]
permutation ns size = perm size (length ns - 1) [(ns, [])]
    where
      perm 0 _ xs = [a | (_, a) <- xs]
      perm c n xs = perm (c - 1) (n - 1) $ concatMap (f n) xs
      f n (xs, ys) = [(as ++ bs, ys ++ [b]) |
                      x <- [0 .. n], let (as, b : bs) = splitAt x xs]

getIndex x (a:as) = if (snd a) == x
                    then (fst a)
                    else getIndex x as

main = do
  n <- getInt
  ps <- getIntList
  qs <- getIntList

  let ansList = zip [0,1..] (permutation [ 1 .. n ] n)
      a = getIndex ps ansList
      b = getIndex qs ansList
  print $ abs (a - b)

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll n;
    cin >> n;
    vector<vector<ll>> cnt(n, vector<ll>(26, 0));

    REP(i, n){
    	string s;
    	cin >> s;
    	REP(j, s.size()){
    		cnt[i][s[j]-'a']++;
    	}
    }

    //REP(i, n) cout << cnt[i] << endl; 

    REP(i, 26){
    	ll mi = (1ll<<60);
    	REP(j, n){
    		chmin(mi, cnt[j][i]);
    	}
    	REP(j, mi) cout << char(i+'a');
    }
    cout << endl;
    return 0;
}

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

int main() {
    string str;
    int n;
    cin >> str >> n;
    
    for (int i = 0; i < n; i++) {
        string op;
        int a, b;
        cin >> op >> a >> b;
        
        if (op == "print") {
            cout << str.substr(a, b - a + 1) << endl;
        } else if (op == "reverse") {
            string s;
            s = str.substr(a, b - a + 1);
            reverse(s.begin(), s.end());
            str = str.replace(a, b - a + 1, s);
        } else if (op == "replace") {
            string s;
            cin >> s;
            str = str.replace(a, b - a + 1, s);
        }
    }
}


Measured memory_bytes: 3204
from collections import defaultdict
              
N = int(input())
              
v2c = defaultdict(int)
for x in range(1, 101):
    for y in range(x, 101):
        for z in range(y, 101):
            v = x*x+y*y+z*z+x*y+y*z+z*x
            if x==y and y==z:
                v2c[v] += 1
            elif (x==y or y==z):
                v2c[v] += 3
            else:
                v2c[v] += 6
              
for i in range(1, N+1):
    print(v2c[i])
              


Measured memory_bytes: 11812
import Data.Char
import Control.Monad

mydiv :: Int->Int->Int
mydiv x y 
    | x<0 && y>0 = (((-1)*x)`div`y)*(-1)
    | x>0 && y<0 = (x`div`((-1)*y))*(-1)
    | otherwise  = x`div`y

expression :: String->(String,Int)
expression expr = expression' $ term expr

expression' :: (String,Int)->(String,Int)
expression' ([], n) = ([], n)
expression' (x:xs, n)
    | x=='+'    = expression' (expr', n+n')
    | x=='-'    = expression' (expr', n-n')
    | otherwise = (x:xs, n)
        where (expr', n') = term xs

term :: String->(String,Int)
term expr = term' $ factor expr

term' :: (String,Int)->(String,Int)
term' ([], n) = ([], n)
term' (x:xs, n)
    | x=='*'     = term' (expr', n*n')
    | x=='/'     = term' (expr', n`mydiv`n')
    | otherwise  = (x:xs, n)
        where (expr', n') = factor xs

factor :: String->(String, Int)
factor (x:xs)
    | x=='('    = (tail $ expr1, n1) --ignore ')'
    | otherwise = (expr2, n2)
        where (expr1, n1) = expression xs --ignore '('
              (expr2, n2) = number (x:xs, 0)

number :: (String, Int)->(String, Int)
number ([], n)   = ([], n)
number (x:xs, n) = if isDigit x then number (xs, n*10+(digitToInt x)) else (x:xs, n)

solve :: String->IO ()
solve expr = do
    print (snd $ expression $ takeWhile (/='=') expr)

main :: IO ()
main = do
    n <- readLn
    lexpr <- replicateM n getLine
    mapM_ solve lexpr

Measured memory_bytes: 3808
/*
 It's better to sleep happy and tired rather than disappointed and frustrated
 There's only 1 thing that's impossible and that is defeating a man who doesn't give up
*/
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mx2 102
#define mx3 1003
#define mx4 10004
#define mx5 100005
#define mx6 1000006
#define mod 1000000007
#define PI 3.14159265
#define deb(x) cout << #x << " " << x << endl;
#define fo(i,n) for(int i=0 ; i<n ; i++)
#define Fo(i,k,n) for(int i=k ; i<n ; i++)
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pair<int,int>,int> piii;

const int inf=0x3f3f3f3f;
int n , ans , sum ,k , c, cnt, L[2*mx5], R[2*mx5];
string str;
 
int main() {
	ios::sync_with_stdio(false);
	//int t;cin>>t;while(t--)
	{
		cin>>n>>k>>c>>str;
		for(int i = 0 ; i < n ; i++) {
			if(str[i] == 'o') {
				L[cnt++] = i;
				i+=c;
			}
		}
		cnt = 0;
		for(int i = n-1; i >= 0; i--) {
			if(str[i] == 'o') {
				R[cnt++] = i;
				i-=c;
			}
		}
		
		for(int i = 0; i < k; i++) {
			if(L[i] == R[k-i-1]) {
				cout << L[i]+1 << "\n";
			}
		}
		
	}
	return 0;
}


Measured memory_bytes: 3348
#include <iostream>
#include <string>
#include <cctype>

using namespace std;

int main()
{
	string taro, hanako;
	int tarop = 0, hanakop = 0;

	int n;
	cin >> n;
	
	for (int i = 0; i < n; i++) {
		cin >> taro >> hanako;
		if (taro < hanako) hanakop += 3;
		else if (taro > hanako) tarop += 3;
		else {
			tarop++;
			hanakop++;
		}
	}
	
	cout << tarop << " " << hanakop << endl;

	return 0;
}

Measured memory_bytes: 1208
// https://ei1333.github.io/luzhiled/
// http://beet-aizu.hatenablog.com/entry/2017/01/04/113233
// http://www.prefield.com/algorithm/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
const ll tl= 1000000007;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s)){in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------
int main(){
    init();
    ind(n); 
    ld ans=n*6.2831;
    out(ans);
}

Measured memory_bytes: 3868
#include <bits/stdc++.h>
using namespace std;
template< typename T > class fenwick_tree{
private:
	static const int default_size = 600100;
	int my_size;
	vector<T> fenwick;
public:
	fenwick_tree(){
		my_size = default_size;
		clear();
	}
	fenwick_tree(int size){
		my_size = size;
		clear();
	}
	void clear(){
		fenwick.assign(my_size, T());
	}
	void add(int pos, T v){
		for(;pos < my_size; pos += pos & - pos)
			fenwick[pos] = fenwick[pos] + v;
	}
	T sum(int pos){
		T ans = T();
		for(;pos; pos -= pos & - pos)
			ans = ans + fenwick[pos];
		return ans;
	}
};
const int maxn = 200200;
const int mod = 998244353;
int mul(long long a, long long b){
	return a * b % mod;
}
int x[maxn], y[maxn], o[maxn], pw2[maxn];
int main(){
	pw2[0] = 1;
	for(int i = 1; i < maxn; i++) pw2[i] = mul(2, pw2[i - 1]); 
	int n; cin >> n;
	if(n == 1){
		cout << 1 << endl;
		return 0;
	}
	vector<int> v;
	for(int i = 0; i < n; i++){
		cin >> x[i] >> y[i];
		v.push_back(x[i]);
		v.push_back(y[i]);
	}
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	for(int i = 0; i < n; i++){
		x[i] = lower_bound(v.begin(), v.end(), x[i]) - v.begin();
		y[i] = lower_bound(v.begin(), v.end(), y[i]) - v.begin();
		x[i]++;
		y[i]++;
	}
	iota(o, o + n, 0);
	sort(o, o + n, [&](int a, int b){
		return x[a] < x[b];
	});
	int usz = v.size() + 100;
	fenwick_tree<int> a, b;
	for(int i = 0; i < n; i++) b.add(y[i], 1);
	int ans = 0;
	for(int e = 0; e < n; e++){
		int i = o[e];
		int p0 = a.sum(y[i] - 1);
		int p1 = a.sum(usz) - p0;
		int p2 = b.sum(y[i] - 1);
		int p3 = b.sum(usz) - p2 - 1;
		ans += mul(pw2[p0] - 1, mul(pw2[p3] - 1, pw2[p1 + p2])); if(ans >= mod) ans -= mod;
		ans += mul(pw2[p1] - 1, mul(pw2[p2] - 1, pw2[p0] + pw2[p3] - 1)); if(ans >= mod) ans -= mod;
		ans += pw2[n - 1]; if(ans >= mod) ans -= mod;
		a.add(y[i], 1);
		b.add(y[i], -1);
	}
	cout << ans << endl;
	return 0;
}


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

int main() {

    int N; cin >> N;

    vector<int> d(N);
    for (int i = 0; i < N; i++) cin >> d[i];

    sort(d.begin(), d.end());
    reverse(d.begin(), d.end());

    int counter = 1;

    for (int i = 0; i < N-1; i++) {
        if (d[i+1] < d[i]) counter++;
    }

    cout << counter << endl;

}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()

def main():
    s = input()
    t = input()

    ans = len(t)
    for start in range(len(s) - len(t)+1):
        tmp = s[start:(start+len(t))]
        diff = 0
        for i in range(len(t)):
            if tmp[i] != t[i]:
                diff += 1
        ans = min(ans, diff)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 73572
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){
    string s; cin >> s;
    int n = s.size();
    vector<int> a(26,0);
    int ans = INF;
    for(int i=0;i<26;i++){
        int x = -1;
        int mem = 0;
        char c = 'a' + i;
        for(int j=0;j<n;j++){
            if(s.at(j)==c){
                mem = max((int)mem,j-x-1);
                x=j;
            }
        }
        mem=max(mem,n-x-1);
        ans = min(ans,mem);
        //cout << c <<" "<<ans << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N,W = map(int,input().split())
w,v = [], []
for _ in range(N):
    w_, v_ = map(int,input().split())
    w.append(w_)
    v.append(v_)

V = sum(v)

# dp[i+1][j] : i番目までの商品を使い、総価値jとなる場合の最小重み
dp = [[float('inf')]*(V+1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(N):
    for j in range(V+1):
        if j>=v[i]:
            dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]]+w[i])
        else:
            dp[i+1][j] = dp[i][j]
res = 0
for j in range(V+1):
    if dp[N][j] <= W:
        res = j
print(res)

Measured memory_bytes: 307776
# -*- coding: utf-8 -*-
import sys
from datetime import date
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    y,m,d = map(int, lines.pop(0).split('/'))
    d = date(y,m,d)
    heisei_end = date(2019,4,30)
    if heisei_end >= d:
        print('Heisei')
    else:
        print('TBD')


#
# main
#
lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Measured memory_bytes: 3312
#ifndef __cplusplus
    cat << EOF
#endif
#include <bits/stdc++.h>
using namespace std;

#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define rep_0(i, end) for(int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for(int i = (fr); i <= (ba); ++i)
#define overload_rep(arg0, arg1, arg2, name, ...) name
#define all(box) box.begin(), box.end()

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

template <class Sg, class Op>
struct disjoint_sparse_table {
private:

    std::vector<std::vector<Sg>> table;
    const Op oper;

public:

    disjoint_sparse_table(const Op& oper_) : 
        oper(oper_)
    { }
    disjoint_sparse_table(const std::vector<Sg>& table_, const Op& oper_) : 
        oper(oper_) 
    { build(table_); }

    void build(const std::vector<Sg>& table_) {
        int height = 0, size = table_.size();
        while ((1 << height) < size) {
            ++height;
        }
        table.resize(height, std::vector<Sg>(size));
        for (int i = 0; i < size; ++i) {
            table[0][i] = table_[i];
        }
        for (int i = 1; i < height; ++i) {
            int bit = (1 << i);
            for (int sc = 0; sc < size; sc += (bit << 1)) {
                int md = std::min(sc + bit, size);
                table[i][md - 1] = table_[md - 1];
                for (int j = md - 2; j >= sc; --j) {
                    table[i][j] = oper(table_[j], table[i][j + 1]);
                }
                if (md >= size) {
                    break;
                }
                table[i][md] = table_[md];
                int rd = std::min(md + bit, size);
                for (int j = md + 1; j < rd; ++j) {
                    table[i][j] = oper(table[i][j - 1], table_[j]);
                }
            }
        }
    }

    Sg fold(const int& l, int r) {
        if (l >= --r) return table[0][l];
        int hei = 31 - __builtin_clz(l ^ r);
        return oper(table[hei][l], table[hei][r]);
    }

};

constexpr int fir = 1000000000;

int main() {

    int N;
    cin >> N;
    vector<int> t(N);
    vector<long double> A(N);
    rep(i, N) {
        cin >> t[i];
        long double x;
        cin >> x;
        A[i] = 1.0 - x / 10;
    }

    const auto f = [](long double x, long double y) {return x * y; };
    disjoint_sparse_table<long double, decltype(f)> st(A, f);

    int Q;
    cin >> Q;
    cout << fixed << setprecision(20);
    while(Q--) {
        int l, r;
        cin >> l >> r;
        int p1 = lower_bound(all(t), l) - t.begin();
        int p2 = lower_bound(all(t), r) - t.begin();
        if(p1 == p2) cout << fir << '\n';
        else cout << fir * st.fold(p1, p2) << '\n';
    }


}



Measured memory_bytes: 33104
#include "bits/stdc++.h"
using namespace std;
int main()
{
	int n, k, mi = 1 << 30;
	scanf("%d%d", &n, &k);
	vector<int> a(n);
	for(int i = 0; i < n; scanf("%d", &a[i++])){}
	sort(a.begin(), a.end());
	for(int i = k - 1; i < n; ++i)
	{
		mi = min(mi, a[i] - a[i - k + 1]);
	}
	printf("%d\n", mi);
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;

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

  vector<int> h(N);
  vector<int> c(N + K+1, -1);
  rep(i, N) { cin >> h[i]; }

  c[0] = 0;
  for (int i = 0; i < N - 1; ++i) {
    for(int j=1; j <= K; ++j) {
      c[i + j] = c[i + j] == -1 ? c[i] + abs(h[i] - h[i + j])
                              : min(c[i + j], c[i] + abs(h[i] - h[i + j]));
    }
  }


  cout << c[N - 1] << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 1e9
#define LINF 1e18
#define mod 1000000007
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 (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};


int main() {
    ll n,d; cin >> n >> d;
    vector<LP> p(n);
    rep(i,n) {
        ll x,y; cin >> x >> y;
        p[i] = LP(x,y);
    }
    int ans = 0;
    rep(i,n) {
        ll tmp = p[i].first*p[i].first+p[i].second*p[i].second;
        if (tmp <= d*d) ans++;
    }
    cout << ans << endl;
}

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

int main(void){
    int n,k;
    cin >> n >> k;
    vector<int> vec(n,0);
    for(int i=0;i<n;i++){
        int p;
        cin >> p;
        vec.at(p-1)++;
    }

    int count=0;
    priority_queue<int,vector<int>,greater<int>> pq;
    for(int i=0;i<vec.size();i++){
        if(vec.at(i)!=0)
            pq.push(vec.at(i));
    }
    while(k<pq.size()){
        count += pq.top();
        //cout << pq.top() << endl;
        pq.pop();
    }
    cout << count << endl;
}

Measured memory_bytes: 2168
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   int n;
   cin >> n;
   cout << 800*n - 200 * (n/15) << endl;


   return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int DP[101][101];
int p[101];

int rec(int r,int c){
  int i,x;
  int Min = 1000000;
  int n = c-r;

  for(i=0;i<n;i++){
    x=DP[r][r+i] + DP[r+i+1][c] + p[r-1]*p[r+i]*p[c];
    if(Min>x) {Min = x;}
    //else {return x;}
							     
    //Min=(int)fmin((double)Min,(double)x);	   
  }
  return Min;
}

int main(){

  int i,j,n;
  
  scanf("%d",&n);
 
  scanf("%d %d",&p[0],&p[1]);

  int ga;
  for(i=2;i<=n;i++){
    scanf("%d %d",&ga,&p[i]);
  }
  for(i=1;i<=n;i++) DP[i][i]=0;
  
  for(i=1;i<n;i++) DP[i][i+1] = p[i-1]*p[i]*p[i+1];

  for(j=0;j<=n-3;j++){
    for(i=3+j;i<=n;i++){
      DP[i-2-j][i] = rec(i-2-j,i);
     
    }
  }

  printf("%d\n",DP[1][n]);
  /*for(i=1;i<=n;i++){
    for(j=1;j<=n;j++)
      printf(" %d",DP[i][j]);
    printf("\n");
  }
  printf("\n");*/
}



Measured memory_bytes: 2112
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <iomanip>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  //cout<<fixed<<setprecision(10);
  ll n,ans=0;
  string s,t,u;
  cin>>s>>t;
  ll a,b;
  cin>>a>>b;
  cin>>u;
  if(s==u)a--;
  if(t==u)b--;
  cout<<a<<" "<<b<<endl;
}


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

int n,tot,fst[N],pnt[N<<1],nxt[N<<1],fa[N];
void add(int x,int y){
	pnt[++tot]=y; nxt[tot]=fst[x]; fst[x]=tot;
}
int dfs(int x){
	int i,y,tg=0;
	for (i=fst[x]; i; i=nxt[i]){
		y=pnt[i];
		if (y!=fa[x]){
			fa[y]=x; tg^=dfs(y)+1;
		}
	}
	return tg;
}
int main(){
	scanf("%d",&n);
	int i,x,y;
	for (i=1; i<n; i++){
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	puts(dfs(1)?"Alice":"Bob");
	return 0;
}


Measured memory_bytes: 7296
import scala.io.StdIn

object Main extends App {
  val s = Array(StdIn.readLine)

  val res = s
    .map(_.toCharArray)
    .filter(_.head == 'A')
    .filter(_.count(_.isUpper) == 2)
    .map(a => a.slice(2,a.length-1))
    .exists(a => a.count(_ == 'C') == 1)

  println(if (res) "AC" else "WA")
}


Measured memory_bytes: 27188
s = []
h = []
c = []
d = []
for i in range(1, 14):
    s.append('S ' + str(i))
    h.append('H ' + str(i))
    c.append('C ' + str(i))
    d.append('D ' + str(i))

n = int(input())
i = 1
while i <= n:
    a = str(input())
    if (a in s):
        s.remove(a)
    elif (a in h):
        h.remove(a)
    elif (a in c):
        c.remove(a)
    elif (a in d):
        d.remove(a)
    i += 1

if (len(s) > 0):
    print('\n'.join(s))
if (len(h) > 0):
    print('\n'.join(h))
if (len(c) > 0):
    print('\n'.join(c))
if (len(d) > 0):
    print('\n'.join(d))

Measured memory_bytes: 7712
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var s = Console.ReadLine().Trim();
        getAns(s, n);
    }
    static void getAns(string s, int n)
    {
        var t = ' ';
        var count = 0;
        for (int i = 0; i < n; i++)
            if (s[i] != t)
            {
                count++;
                t = s[i];
            }
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 11232
import java.util.PriorityQueue
import java.util.Comparator
import scala.io.StdIn.{readLine,readInt}
import scala.collection.mutable.ArrayBuffer

object Main {

  class Node(val cost:Int, val id:Int) { }

  class NodeComparator extends Comparator[Node] {
    def compare(node1:Node,node2:Node) = { node1.cost-node2.cost }
  }

  def main(args:Array[String]) = {
    val comp:Comparator[Node] = new NodeComparator()
    val n = readInt
    val pq = new PriorityQueue[Node](n, comp)
    val g = for(i<-0 until n) yield { readLine.trim.split(" ").map(_.toInt) }
    val dist = new Array[Int](n)
    val nodes = new Array[Node](n)
    pq.add(new Node(0,0))
    for(i<-1 until n) {
      dist(i) = 1000000
      nodes(i) = new Node(1000000, i)
      pq.add(nodes(i))
    }
    dist(0) = 0

    while(!pq.isEmpty()) {
      val nd = pq.poll()
      val v = g(nd.id)

      for(i<-0 until v(1)) {
        val j = i*2+2
        val k = i*2+3
        val alt = v(k) + dist(v(0))
        if(alt < dist(v(j))) {
          dist(v(j)) = alt
          pq.remove(nodes(v(j)))
          pq.add(new Node(dist(v(j)), v(j)))
        }
      }
    }

    println{
      { for(i<-0 until n) yield (i.toString + " " + dist(i).toString) }.mkString("\n")
    }
  }
}

Measured memory_bytes: 182728