akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
 
class Point implements Comparable<Point> {
  int a, b;
  Point (int a, int b) {
    this.a = a;
    this.b = b;
  }
 
  public int hashCode() {
    return a ^ b;
  }
 
  public boolean equals(Object object) {
    Point point = (Point)object;
    return this.a == point.a && this.b == point.b;
  }

  public int compareTo(Point p) {
    if (this.a != p.a) {
      return this.a - p.a;
    }
    return this.b - p.b;
  }
}
 
public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int h = s.nextInt();
    int w = s.nextInt();
    int n = s.nextInt();
//    HashMap<Point, Integer> map = new HashMap<Point, Integer>();
    TreeMap<Point, Integer> map = new TreeMap<Point, Integer>();
    for (int i = 0; i < n; i++) {
      int a = s.nextInt() - 1;
      int b = s.nextInt() - 1;
      for (int da = Math.max(0, a - 2); da <= Math.min(h - 3, a); da++) {
        for (int db = Math.max(0, b - 2); db <= Math.min(w - 3, b); db++) {
          Point p = new Point(da, db);
          if (map.get(p) == null) {
            map.put(p, 1);
          } else {
            map.put(p, map.get(p) + 1);
          }
        }
      }
    }
    long[] output = new long[10];
    output[0] = (long)(h - 2) * (long)(w - 2);
    for (int value : map.values()) {
      output[0]--;
      output[value]++;
    }
    for (long value : output) {
      System.out.println(value);
    }
  }
}


Measured memory_bytes: 133200
import sys

sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1


def II(): return int(input())


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


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


def LI(): return list(map(int, input().split()))


def LI1(): return list(map(int1, input().split()))


def LLI(rows_number): return [LI() for _ in range(rows_number)]


def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))


INF = float('inf')


def solve():
    n, k = MI()
    A = LI1()
    # print(A)
    memo = {0: 0}
    current = 0
    keiro = []
    for i in range(n):
        keiro.append(current)
        next = A[current]
        # print(i, current, next)
        if (i + 1) == k:
            print(next+1)
            return

        if memo.get(next, -1) == -1:
            memo[next] = i + 1
            current = next
        else:
            pre = current
            current = next
            keiro.append(current)
            # print(pre, current)
            left = k - i - 1
            # print('aaa', memo[pre], memo[current])
            loopsize = memo[pre] - memo[current] + 1
            # print('a', left, loopsize)
            r = left % loopsize
            # print(memo)
            # print(keiro)
            # print(keiro[memo[current] + r])
            ans = keiro[memo[current] + r] + 1
            print(ans)
            return


if __name__ == '__main__':
    solve()


Measured memory_bytes: 32416
L = input()
dp1 = [0] * 100001 #Lを超えるか不明
dp2 = [0] * 100001 #Lを超えないことが確定
MOD = 10**9 + 7
dp1[0] = 1
for i,d in enumerate(L):
    if int(d) == 1:
        dp1[i+1] = dp1[i]*2 #(1,0) or (0,1)
        dp2[i+1] = dp1[i] + dp2[i]*3 #(0,0)で1から降格 
    if int(d) == 0:
        dp1[i+1] = dp1[i] #(0,0)
        dp2[i+1] = dp2[i]*3 #確定しているから、(0,0)(0,1)(1,0)何でも良い
    dp1[i+1] %= MOD    
    dp2[i+1] %= MOD    
N = len(L)
ans = dp1[N]+dp2[N]
print(ans%MOD)

Measured memory_bytes: 11060
import numpy as np
import math
n = int(input())
distlist = []
for i in range(n):
    distlist.append(np.array(list(map(int,input().split()))))

distsum = 0
for i in range(n):
    for j in range(i,n):
        distsum += np.linalg.norm(distlist[i]-distlist[j])
        
n_kaizyo = math.factorial(n)
n1_kaizyo = math.factorial(n-1)

ans = (distsum*2*n1_kaizyo)/n_kaizyo

print(ans)

Measured memory_bytes: 12504
#include<stdio.h>

int main(){
	int height, fir=-1, sec=-2, thir=-3, i;

	for(i=0; i<10; i++){
		scanf("%d", &height);
		if(height > fir){
			thir = sec;
			sec = fir;
			fir = height;
		}else if(height > sec){
			thir = sec;
			sec = height;
		}else if(height > thir){
			thir = height; 
		}
	}

	printf("%d\n%d\n%d\n", fir, sec, thir);

	return 0;
}

Measured memory_bytes: 600
fun main(args: Array<String>)
{
    val a = readInt()
    val s = readString()

    println(if (a >= 3200) s else "red" )

}


// Read an integer
// Usage: val a = readInt()
private fun readInt() = readLine()!!.toInt()

// Read N integers separated by " "
// Usage: val (a, b, c) = readNInts()
private fun readNInts() = readLine()!!.split(" ").map(String::toInt)

// Read a string
// Usage: val a = readString()
private fun readString() = readLine()!!


Measured memory_bytes: 33716
let parent i = int_of_float (floor (float_of_int i) /. 2.)

let left i = 2*i

let right i = 2*i + 1

let build_max_heap (t : int array) h =
  let rec max_heapify i =
    let l = left i in
    let r = right i in
    let m = if l <= h && t.(l) > t.(i) then l else i in
    let m = if r <= h && t.(r) > t.(m) then r else m in
    if i = m then ()
    else
      let tmp = t.(i) in
      t.(i) <- t.(m);
      t.(m) <- tmp;
      max_heapify m in
  for i = parent h downto 1 do
    max_heapify i
  done

let () =
  let h = read_int () in
  let t = Array.make (h + 1) 0 in
  for i = 1 to h do
    t.(i) <- Scanf.scanf "%d " (fun i -> i)
  done;
  build_max_heap t h;
  for i = 1 to h do
    print_string " "; print_int t.(i)
  done;
  print_newline ()

Measured memory_bytes: 8564
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;
        double area = pi*r*r;
        double length = 2*pi*r;
        System.out.printf("%f %f",area,length);
    }
}


Measured memory_bytes: 28256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif
#define LDcout(x,n) fixed<<setprecision(n)<<x

#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
vector<double> dp(2*1e5);
void mainmain(){
	int n;
	cin>>n;
	vector<double> a(n);
	rep(i,n) cin>>a[i];
	int m=2*1e5;
	rep(i,m){
		dp[i]=1e200;
	}
	// cout<<m<<endl;
	rep(i,m){
		dp[i]=(double)abs(a[0]-(double)i)/(double)a[0];
		// if(i<20) cout<<i<<" "<<abs(a[0]-i)<<" "<<1.*dp[i]<<endl;
	}
	// cout<<endl;
	reep(i,1,n){
		vector<double> tmp(m,(double)1e200);
		reep(j,1,m){
			if(dp[j]==1e200) continue;
			for(int k=j;k<m;k+=j){
				tmp[k]=min(tmp[k],max(dp[j],abs((double)k-a[i])/a[i]));
			}
		}
		tmp.swap(dp);
	}
	double ans=1e200;
	rep(i,m){
		ans=min(ans,dp[i]);
	}
	cout<<fixed<<setprecision(10)<<ans<<endl;
}


signed main() {
	ios_base::sync_with_stdio(false);
  	cout<<fixed<<setprecision(10);
    mainmain();
}

Measured memory_bytes: 4320
from sys import stdin
def main():
    n = int(stdin.readline())
    a = map(int, stdin.readline().split())
    a.sort()
    s = a[0]
    u = 0
    for i, x in enumerate(a[1:], 1):
        if x > s * 2:
            u = i
        s += x
    print n - u
main()


Measured memory_bytes: 11320
import heapq

def g(LS):
    Q = [];
    QLen = 0
    SC = 0

    for k,sc in sorted(LS):
        heapq.heappush(Q, sc)
        QLen += 1
        SC += sc

        if  QLen > k:
            SC -= heapq.heappop(Q)
            QLen -= 1

    return SC
            


def f():
    N = int(input())
    LS = []
    RS = []
    SC0 = 0

    for _ in range(N):
        K,L,R = map(int, input().split())
        SC = abs(L - R)
        SC0 += min(L, R)

        if L >= R:
            LS.append((K, SC))
        else:
            RS.append((N-K, SC))

    
    print(SC0 + g(LS) + g(RS))


T = int(input())
for _ in range(T):
    f()






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

using ll = long long int;
using P = pair<ll, ll>;
using P3 = pair<double,P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9) + 7;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr double EPS = 1e-8;

int solve(){
    int n, m;
    cin >> n >> m;
    vector<vector<double> > a(n,vector<double>(3));
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin >> a[i][j];
        }
    }
    double ans = 0.0;
    for(int S=0;S<1<<n;S++){
        int cnt = 0;
        for(int i=0;i<n;i++) cnt += (S>>i)&1;
        if(cnt == m){
            vector<int> ls;
            for(int i=0;i<n;i++){
                if((S>>i)&1) ls.push_back(i);
            }
            double sum = 0.0;
            for(int i=0;i<m;i++){
                for(int j=i+1;j<m;j++){
                    for(int k=0;k<3;k++)
                        sum += pow(a[ls[i]][k]-a[ls[j]][k],2);
                }
            }
            ans = max(ans, sum);
        }
    }
    printf("%.8lf\n",ans);
    return 0;
}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 3348
// Problem : B - Around Square
// Contest : AtCoder - AtCoder Beginner Contest 077
// URL : https://atcoder.jp/contests/abc077/tasks/abc077_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
	int ans=1;int n;cin>>n;
	for(int i=2;i*i<=n;i++)
	ans=i*i;
	cout<<ans;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  string S0, S1, S2;
  int num = 0;
  for (int i=0; i < H; i++){
    if (i==0){
      cin >> S1 >> S2;
    }
    for (int j = 0; j < W; j++){
      if (S1.at(j) == '#'){
        cout << '#';
      }
      else {
        if (i > 0){
          if (j > 0 && S0.at(j-1) == '#'){
            num += 1;
          }
          if (S0.at(j) == '#'){
            num += 1;
          }
          if ( j < W - 1 && S0.at(j+1) == '#'){
            num += 1;
          }
        }
        if (j > 0 && S1.at(j-1) == '#'){
          num += 1;
        }
        if (j < W -1 && S1.at(j+1) == '#'){
          num += 1;
        }
        if (i < H - 1){
          if (j > 0 && S2.at(j-1) == '#'){
            num += 1;
          }
          if (S2.at(j) == '#'){
            num += 1;
          }
          if (j < W -1 && S2.at(j+1) == '#'){
            num += 1;
          }
        }
        cout << num;
        num = 0;
      }
    }
    cout << endl;
    S0 = S1;
    S1 = S2;
    if (i < H -1){
      cin >> S2;
    }
  }
}

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

int main(){
    int N;
    cin >> N;
    int a[N],sum=0,max_element=0;
    for(int i=0;i<N;i++){
        cin >> a[i];
        max_element=max(a[i],max_element);
        sum+=a[i];
    }
    sum=sum-max_element/2;
    printf("%d\n",sum);


}

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

int main(){
	int a, b, i, ans=0;
	cin>>a>>b;
	for(i=a; i<=b; i++){
		i=i;
		if((i%10)==(i/10000)%10 && (i/10)%10==(i/1000)%10) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.algorithm;
import std.string;

int main(string[] args) {
	uint i;
	uint[] hills;
	hills.length = 10;

	uint t;
	string buf;
	uint count = 0;
    while ((buf = readln()) != null) {
    	hills[count] = to!(uint)(strip(buf));
    	count++;
    }

	sort!("a > b")(hills);

	for (i = 0; i < 3; i++) {
		writeln(hills[i]);
	}

	return 0;
}

Measured memory_bytes: 1084
n = int(input())
A = list(map(int,input().split()))

groups = []
prev = A[0]
for i in range(1,n):
    if A[i] != prev:
        groups.append(prev)
        prev = A[i]
groups.append(prev)

if len(groups) == 1:
    print(1000)
    exit()

money = 1000
stock = 0
if groups[0] < groups[1]:
    buy = money//groups[0]
    stock += buy
    money -= groups[0]*buy
    
for i in range(1,len(groups)-1):
    if groups[i-1] < groups[i] and groups[i] > groups[i+1]:# 周辺の最高値
        money += stock*groups[i]
        stock = 0
    elif groups[i-1] > groups[i] and groups[i] < groups[i+1]:# 周辺の最安値
        buy = money//groups[i]
        stock += buy
        money -= groups[i]*buy

money += stock*groups[-1]

print(money)

Measured memory_bytes: 62032
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <iomanip>
using namespace std;

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    VI a(n * 3);
    REP(i, n * 3) cin >> a.at(i);
    sort(ALL(a), greater<int>());
    ll ans = 0;
    REP(i, n) ans += a.at(i * 2 + 1);
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
    ll A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    ll m = 999999999999;
    for (int i = 0; i <= X; i++) {
        ll k = (X - i) * 2;
        ll j;
        if (B < 2 * C) {
            // buy B
            j = max(ll(0), Y - (X - i));
        } else {
            k = max(k, Y*2);
        }
        ll cost = i * A + j * B + k * C;
        m = min(m, cost);
    }

    cout << m << endl;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  bool x=true;
  for(int i=0;i<N;i++){
  int a; cin>>a;
    if(a%2==1){x=false; break;}
  }if(x)
    cout<<"second"<<endl;
  else
    cout<<"first"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int dp[200005];
int n;
long long int a[200005], h[200005];

void insert(int x, long long int val){
      //cout<<x<<' ';
      int index=x;
      //cout<<index<<' '<<val<<'\n';
      while(index<=n){
            if(dp[index]<val){
                  dp[index]=val;
            }
            else break;
            //cout<<index<<' ';
            int p=index&(-index);
            //cout<<index<<' ';
            index+=p;
            //cout<<p<<'p'<<index<<' ';
      }
      //cout<<'\n';
      //cout<<'\n'<<' '<<x<<'a'<<'\n';
}

long long int get(int x){
      int index=x;
      long long int val=0;
      while(index>0){
            val=max(val, dp[index]);
            index-=(index&(-index));
      }
      return val;
}

int main(){
      cin>>n;
      memset(dp, 0, sizeof(dp));
      for(int i=0; i<n; i++){
            cin>>h[i];
      }
      for(int i=0; i<n; i++){
            cin>>a[i];
      }
      long long int curr, prev;
      for(int i=0; i<n; i++){
            prev=get(h[i]-1);
            curr=get(h[i]);
            //cout<<prev<<' ';
            if(prev+a[i]>curr){
                  //cout<<a[i]<<' ';
                  insert(h[i], prev+a[i]);
                  //cout<<prev+a[i]<<' '<<i<<'\n';
            }
      }
      //for(int i=0; i<=n; i++)
      //cout<<get(n)<<'\n';
      cout<<get(n);
}

Measured memory_bytes: 8300
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		
        long price = 0;
        long price1 = 0;
        long price2 = 0;
        
        if(X<=Y){
            price1 = 2*C*X + B*(Y-X);
            price2 = 2*C*Y;
            price = Math.min(price1,price2);
        }else{
            price1 = 2*C*Y + A*(X-Y);
            price2 = 2*C*X;
            price = Math.min(price1,price2);
        }
        
        if(A*X+B*Y>=price){
            System.out.println(price);
        }else{
            System.out.println(A*X+B*Y);
        }
        
    }
}

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

bool check(string s,int i,int j){
	int cnt = 0;
	for(int k=i+1;k<=j;++k){
	 	if(s[k] == '#' && s[k-1] == '#')
	        return false;	   
	}
	return true;
}
int32_t main() {
	int n;
	cin>>n;
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	string s;
	cin>>s;

	
	if(c<b || (b<c && c<d)){
		if(check(s,a-1,c-1) && check(s,b-1,d-1)){
			 cout<<"Yes";
			 return 0;
		}
	}else if(b<d && d<c){
		if(check(s,a-1,c-1)){
			for(int i = b-1;i<d;++i){
				if(s[i-1] =='.' && s[i] == '.' && s[i+1] == '.'){
					cout<<"Yes";
					return 0;
				}
			}
		}
		
	}
    cout<<"No";
	
	return 0;
}

Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,c;
    while(cin>>n)
    {
        c=0;
        while(n!=0)
        {
            int x= n%10 ;
            if(x==7)
                c++ ;
            n=n/10 ;
        }
        if(c>=1)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}


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

struct point{
    int x, y;
}p[90005];

int main(){
    int b[90005];
    memset(b, 0, sizeof b);
    int h, w, d, q, l, r, a[N][N];
    scanf("%d %d %d", &h, &w, &d);
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            scanf("%d", &a[i][j]);
            point po = {i, j};
            p[a[i][j]] = po;
        }
    }
    for (int i = d + 1; i < h * w + 1; i++)
        b[i] = b[i - d] + abs(p[i - d].x - p[i].x) + abs(p[i - d].y - p[i].y);
    scanf("%d", &q);
    for (int i = 0; i < q; i++){
        scanf("%d %d", &l, &r);
        printf("%d\n", b[r] - b[l]);
    }
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>                                                         
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int64_t> L(N+1);
  L.at(0)=2;
  L.at(1)=1;
  for(int i=2; i<N+1; i++){
    L.at(i)=L.at(i-2)+L.at(i-1);
  }
  cout << L.at(N) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define P pow(4,j++)
main(){
  int i,j,n,c; char m[7],o,d[262145];
  for(i=0,scanf("%d %s",&n,m);i<n;i++,scanf("%s",m)){
    for(j=c=o=0;o!='\n';scanf("%c",&o))
      if(o=='A')c+=1*P;
      else if(o=='C')c+=2*P;
      else if(o=='G')c+=3*P;
      else if(o=='T')c+=4*P;
    m[0]=='i'?d[c]=1:(d[c]?printf("yes\n"):printf("no\n"));
  }
  return 0;
}

Measured memory_bytes: 496
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int N, M, s, t;
    cin >> N >> M >> s >> t;
    --s, --t;
    vvi graph(N);
    REP(i, M) {
        int u, v; cin >> u >> v; --u, --v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    vi distS(N, INF), distT(N, INF);
    {
        queue<int> que;
        que.push(s);
        distS[s] = 0;
        while (!que.empty()) {
            int v = que.front(); que.pop();
            for (int u : graph[v]) {
                if (chmin(distS[u], distS[v] + 1)) {
                    que.push(u);
                }
            }
        }
    }
    {
        queue<int> que;
        que.push(t);
        distT[t] = 0;
        while (!que.empty()) {
            int v = que.front(); que.pop();
            for (int u : graph[v]) {
                if (chmin(distT[u], distT[v] + 1)) {
                    que.push(u);
                }
            }
        }
    }

    map<int,ll> cntS, cntT;
    for (int d : distS) ++cntS[d];
    for (int d : distT) ++cntT[d];

    int D = distS[t];
    ll ans = 0;
    for (auto &tp : cntS) {
        ans += tp.second * cntT[D - 2 - tp.first];
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 10236
#include <algorithm>
#include <array>
#include <cassert>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <unordered_map>
using namespace std;

constexpr int NUMBER_OF_CELL = 9;
constexpr array<int, 4> d{1, 3, 8, 6};

typedef array<int, NUMBER_OF_CELL> field;
typedef pair<int, long long> state;

long long encode(const field &f) {
	long long res = 0;
	for(const auto &cell : f) {
		res = res * NUMBER_OF_CELL + cell;
	}
	return res;
}

field decode(long long code) {
	field res;
	for(auto &cell : res) {
		cell = code % NUMBER_OF_CELL;
		code /= NUMBER_OF_CELL;
	}
	reverse(res.begin(), res.end());
	return res;
}

int ch, cv;

int dijkstra(const long long s, const long long g) {
	priority_queue<state, vector<state>, greater<state>> que;
	unordered_map<long long, int> dist;
	que.emplace(0, s);
	dist[s] = 0;

	while(!que.empty()) {
		const int current_dist = que.top().first;
		const long long code = que.top().second;
		que.pop();

		if(dist[code] < current_dist) continue;
		if(code == g) return current_dist;

		const field current = decode(code);
		const int current_empty = find(current.begin(), current.end(), 0) - current.begin();

		for(int i = 0; i < 4; ++i) {
			field next(current);
			const int next_empty = (current_empty + d[i]) % NUMBER_OF_CELL;
			swap(next[current_empty], next[next_empty]);
			const long long next_code = encode(next);
			const int next_dist = current_dist + (i & 1 ? cv : ch);
			if(!dist.count(next_code) || dist[next_code] > next_dist) {
				dist[next_code] = next_dist;
				que.emplace(next_dist, next_code);
			}
		}
	}
	assert(false);
}

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

	while(cin >> ch >> cv && ch) {
		field start, goal;
		for(auto &cell : start) cin >> cell;
		for(auto &cell : goal)  cin >> cell;
		cout << dijkstra(encode(start), encode(goal)) << endl;
	}
	return EXIT_SUCCESS;
}

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


//うまくいかなかった（原因は24行目）
int main() {
    int n;
    ll k;
    cin >> n>>k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
        a.at(i)--;
    }
    vector<int> flag(n);
    vector<int> anslst(n);
    int count=0;
    int now= 0;
    while (flag[now] == 0) {
        if(count>=k){
            cout << now+1 << endl; //ミスの原因，ここのnowを+1していなかった！！！！！！！！
            return 0;
        }
        flag[now] = 1;
        anslst[count] = now;
        now = a[now];
        count++;
    }
    int start=0;
    for(int i=0;i<count;i++){
        if(anslst[i]==now) {
            start = i;break;
        }else{continue;}
    }
    int loop = count-start;
    if (loop == 0) {
        cout << now <<endl;
    }else{
        int mod = (k-start)%loop;
        cout << anslst[mod+start]+1 << endl;
    }

    return 0;
}


Measured memory_bytes: 5644
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

#define LL long long
string s;
int W, H, x, y, r, a, b, c, num[5];

int main() {
	cin >> a >> b;
	cout << a / b << " " << a % b << " " << fixed << setprecision(8) << (double)((double)a / (double)b) << endl;

	return 0;
}


Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<b;i++)
#define f(i,n) for(int i=0;i<n;i++)
typedef unsigned long long ull;
typedef long long ll;
#define pb(a) push_back(a);

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	// int dp[]
	int choice[n];
	int a[n][3],dp[n][3];
	// int maxA,maxB,maxC,total=0,na,nb,nc;
	f(i,n){
		cin>>a[i][0]>>a[i][1]>>a[i][2];
		if(i==0) {
			dp[i][0]=a[i][0];
			dp[i][1]=a[i][1];
			dp[i][2]=a[i][2];
			// total = max(maxA,max(maxB,maxC));
		}
		else{
			dp[i][0] = a[i][0] + max(dp[i-1][1],dp[i-1][2]);
			dp[i][1] = a[i][1] + max(dp[i-1][0],dp[i-1][2]);
			dp[i][2] = a[i][2] + max(dp[i-1][1],dp[i-1][0]);
			
		}
		
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


long long M = 1000000007;


int main(int argc, char const *argv[]) {
    long long n,l,t;
    cin>>n>>l>>t;
    vector<long long> x(n),w(n),tmp(n),res(n);
    for(int i=0;i<n;++i)cin>>x[i]>>w[i];
    for(int i=0;i<n;++i)x[i] = x[i] * n + i;
    l *= n;
    t *= n;
    for(int i=0;i<n;++i){
        if(w[i]==1)res[i] = (x[i] + t)%l;
        else res[i] = (x[i] - t)%l;
        res[i] = (res[i] + l) % l;
    }
    long long b = res[0];
    for(int i=0;i<n;++i){
        res[i] -= b;
        res[i] %= l;
        res[i] += l;
        res[i] %= l;
    }
    sort(res.begin(),res.end());
    for(int i=0;i<n;++i)res[i] = (res[i]+b)%l;
    if(w[0]==1){
        long long k = 0;
        for(int i=1;i<n;++i)if(w[i]==2){
            k += 2 * (t / l);
            long long tt = t % l;
            if(2 * tt >= x[i] - x[0])k++;
            if(2 * tt >= l + x[i] - x[0])k++;
        }
        k %= n;
        long long b = res[0];
        for(int i=0;i<n;++i){
            cout<<res[(i-k+n)%n]/n<<endl;
        }
    }
    else{
        long long k = 0;
        for(int i=1;i<n;++i)if(w[i]==1){
            k += 2 * (t / l);
            long long tt = t % l;
            if(2 * tt >= l - x[i] + x[0])k++;
            if(2 * tt >= 2 * l - x[i] + x[0])k++;
        }
        k %= n;
        for(int i=0;i<n;++i){
            cout<<res[(i+k)%n]/n<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define N 100100
using namespace std;
int a[N];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	sort(a,a+n,greater<int>());
	int x=0,y=0;
	for(int i=1;i<n;i++){
		if(a[i]==a[i-1]){
			if(!x) x=a[i];
			else if(!y) y=a[i];
			i++;
		}
	}
	printf("%lld\n",1LL*x*y);
	return 0;
}

Measured memory_bytes: 640
from heapq import*
(N,M),*t=[map(int,s.split())for s in open(0)]
v=[[]for _ in'_'*M]
z=0
for a,b in t:
	if a<=M:v[a-1]+=[b]
q=[0]*M
for i in v:
	for j in i:heappush(q,-j)
	z-=heappop(q)
print(z)

Measured memory_bytes: 57060
fn main() {
    let s: String = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };
    let x = {
        let mut ws = s.split_whitespace();
        let a: i64 = ws.next().unwrap().parse().unwrap();
        a
    };

    let five_hundreds_num = x / 500;
    let five_num = (x - five_hundreds_num * 500) / 5;
    println!("{}", five_hundreds_num * 1000 + five_num * 5);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
     int i,n,t=0,p=0,m,l,q=0;
    cin>>n>>m;
    l=max(n,m);
    p=min(m,n);
    for(i=0;i<l;i++){
        cout<<p;
    }



}




Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
    static MyReader in = new MyReader();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args){
        int N = in.i();
        ArrayList<Integer> L = in.ii();
        L.sort((x, y) -> -x+y);
        
        ArrayList<Integer>[] s = new ArrayList[N-1];
        for(int i = 1; i < N-1; i++){
            s[i] = new ArrayList<>();
            int Li = L.get(i);
            for(int j = i+1; j < N; j++){
                s[i].add(0, Li+L.get(j));
            }
        }

        long ans = 0;
        for(int i = 0; i < N-2; i++){
            int Li = L.get(i);
            for(int j = i+1; j < N-1; j++){
                int k = Collections.binarySearch(s[j], Li);
                int size = s[j].size();
                if(k < 0){
                    k = -k-1;
                    ans += size-k;
                } else {
                    while(k < size && s[j].get(k) == Li){
                        k++;
                    }
                    ans += size-k;
                }
            }            
        }

        out.println(ans);
        out.flush();
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        ArrayList<Integer> ii(){
            String[] ss = ss();
            ArrayList<Integer> ii = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) ii.add(Integer.parseInt(ss[j]));
            return ii;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 111800
#include <iostream>
#include <map>

const int MAXN = (int)2e5;

int a[MAXN];

void solve(int n) {
  std::map<int, int> num_count;
  for (int i = 0; i < n; ++i) {
    ++num_count[a[i]];
  }
  int64_t ans = 0;
  for (const auto& cur : num_count) {
    int val = cur.first, cnt = cur.second;
    ans += (int64_t)(cnt - 1) * cnt / 2;
  }
  for (int i = 0; i < n; ++i) {
    std::cout << ans - (num_count[a[i]] - 1) << std::endl;
  }
}

int main() {
  int n;
  std::cin >> n;
  for (int i = 0; i < n; ++i) std::cin >> a[i];
  solve(n);
  return 0;
}


Measured memory_bytes: 8320
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;
 
void Main()
{
	int R;
  
  	cin >> R;
    
    printf("%lf", 2.0 * R * 3.1415);
	
	
}
 
int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 3744
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

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

  vector <int> l(n);
  for(int i = 0; i < n; i++) {
    cin >> l[i];
  }

  int max = *max_element(l.begin(), l.end());
  int sum = accumulate(l.begin(), l.end(), 0);

if(max < (sum - max)) cout << "Yes" << endl;
else cout << "No" << endl;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        d: i64,
        a: [(i64, i64); n],
    }
    let mut res = 0;
    for (x, y) in a {
        if x * x + y * y <= d * d {
            res += 1;
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 7832
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }

int A[3];
int K;


void check(int a, int b, int c)
{
	if (b > a&& c > b)
	{
		cout << "Yes" << endl;
		exit(0);
	}
}

void func(int depth)
{
	if (depth == K)
	{
		for (int i = 0; i < 3; i++)
		{
			check(A[0], A[1], A[2]);
		}
		return;
	}

	for (int i = 0; i < 3; i++)
	{
		A[i] *= 2;
		func(depth + 1);
		A[i] /= 2;
	}
}




signed main()
{
	cin >> A[0] >> A[1] >> A[2];
	cin >> K;

	func(0);

	cout << "No" << endl;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

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

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}


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

    int r = l + n -1;
    int eat;
    if (r<=0) eat = r;
    else if (l>=0) eat = l;
    else eat = 0;

    int ans = (r + l) * (r - l + 1) / 2 - eat;

    cout << (ans) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define all(x) (x).begin(), (x).end()

int main() {
  int n;
  cin >> n;
  vector<int> v(n), odd(110000, 0), even(110000, 0);
  int cnt = 0;
  for (int i = 0; i < n; i++) cin >> v[i];
  for (int i = 0; i < n; i += 2) {
    odd[v[i]] += 1;
    even[v[i + 1]] += 1;
  }
  auto maxO = max_element(all(odd));
  auto maxE = max_element(all(even));
  bool sameNum = false;
  if (distance(odd.begin(), maxO) == distance(even.begin(), maxE))
    sameNum = true;

  sort(all(odd), greater<int>());
  sort(all(even), greater<int>());

  if (sameNum) {
    cout << n - odd[0] - max(odd[1], even[1]);
    return 0;
  }
  cout << n - odd[0] - even[0] << endl;
  return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>

using namespace std;

int main(void) {
	long long N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
	}
	cout << (N - K + (K - 2)) / (K - 1) + 1 << endl;
	system("pause");
	return 0;
}


Measured memory_bytes: 504
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    map<int, int> d, t;
    cin >> n; rep (i, n) { int a; cin >> a; d[a]++; }
    cin >> m; rep (i, m) { int a; cin >> a; t[a]++; }
    bool ok = true;
    for (auto p : t) ok &= p.second <= d[p.first];
    cout << (ok ? "YES" : "NO") << "\n";
    return 0;
}

Measured memory_bytes: 19072
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll DP[200005];

int main() {
  int N;
  cin>>N;
  vector<int> C;
  int tmp;
  cin>>tmp;
  C.push_back(tmp);
  for(int i=1;i<N;++i) {
    cin>>tmp;
    if(C[C.size()-1]!=tmp) C.push_back(tmp);
  }
  map<int, int> amap;
  map<int, int> bmap;
  for(int i=C.size()-1;i>=0;--i) {
    if(bmap[C[i]]!=0) {
      amap[i] = bmap[C[i]];
    }
    bmap[C[i]] = i;
  }
  for(int i=0;i<C.size();++i) {
    if(i==0) DP[i] = 1;
    else {
      DP[i] += DP[i-1];
      DP[i] %= mod;
    }
    if(i<amap[i]) {
      DP[amap[i]] += DP[i];
      DP[amap[i]] %= mod;
    }
  }
  cout<<DP[C.size()-1]<<endl;
}



Measured memory_bytes: 24240
#include <stdio.h>

int main(void)
{
	int a, b;
	char op;

	do {
		scanf("%d %c %d", &a, &op, &b);

		if (op == '+')
			printf("%d\n", a + b);
		else if (op == '-')
			printf("%d\n", a - b);
		else if (op == '*')
			printf("%d\n", a * b);
		else if (op == '/')
			printf("%d\n", a / b);

	} while (op != '?');

	return 0;

}

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

// P1(x1, y1)とP1(x2, y2)の距離を出力
int main()
{
	double iInputX1, iInputY1,  iInputX2, iInputY2;
	scanf("%lf %lf %lf %lf", &iInputX1, &iInputY1, &iInputX2, &iInputY2);


	printf("%.8lf",sqrt( pow(iInputX1 - iInputX2, 2) + pow(iInputY1 - iInputY2, 2)));
	return 0;
}


Measured memory_bytes: 2104
import scala.io.StdIn.{readInt,readLine}

object Main {

  def main(args:Array[String]) = {
    val n = readInt
    val s = readLine.split(" ").map(_.toInt).toList

    var list:List[Int] = s
    for(i<-2 to n) {
      list ++= s.combinations(i).map(_.sum)
    }

    readInt
    val t = readLine.split(" ").map(_.toInt)
    t.foreach{ i=>
      if(list.contains(i)) println("yes")
      else println("no")
    }
  }
}

Measured memory_bytes: 306796
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main() {
	int N;
	lli H;
	cin >> N >> H;
	vector<lli>a(100000, 0);
	vector<lli>b(100000, 0);
	for (int i = 0;i<N;i++) cin >> a[i] >> b[i];

	lli Min = 0;

	//振るのの最大を出す
	lli SwMax = 0;
	for (int i = 0;i<N;i++) {
		if (SwMax<a[i]) SwMax = a[i];
	}
	//振る最大より強い投げ刀の本数とそのダメージの和を出す

	lli AcThSum = 0;
	lli AcThTi = 0;
	for (int i = 0;i<N;i++) {
		if (b[i]>SwMax) {
			AcThSum += b[i];
			AcThTi += 1;
		}
	}
	//AcThSumがH未満なら、振り最大で振ってからそいつらを全部投げるとよい
	if (AcThSum<H) Min = AcThTi + (H - AcThSum - 1) / SwMax + 1;
	//AcThSumがH以上なら、大きい方から投げていって削ればよいので,bをソート.
	else {
		sort(b.begin(), b.end());
		reverse(b.begin(), b.end());
		for (int i = 0;i<N;i++) {
			Min += 1;
			H -= b[i];
			if (H <= 0) i = N;
		}
	}
	cout << Min;
}

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

int main(){
  int n;
  ll ans=0;cin>>n;
  vector<ll> a(n,0);
  REP(i,n) cin>>a.at(i);
  sort(a.rbegin(),a.rend());
  ans+=a.at(0);
  REP(i,((n-1)/2)){
    ans+=a.at(i+1)*2;
    if(n%2 && i==((n-1)/2)-1) ans-=a.at(i+1);
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 4832
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  ll h,w,c;
  cin >> h >> w >> c;
  ll o=__gcd(h,w);
  ll ans=h/o*w/o*c;
  cout << ans << endl;
}



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

using namespace std;

#define DIM 300009
#define INF ((long long)1e18+9ll)
#define pairll pair<long long,long long>
#define fi first
#define se second
#define ld long double
#define amen exit(0)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define endl '\n'
#define MODULO 1000000007

long long i,j,k,l,n,m;

vector<long long>a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main()
{   
    fast;

    cin>>n;
    cout<<a[n-1]<<endl;

    amen;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

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

  int n; cin >> n;
  n*=2;
  vector<int> vec(n);
  rep(i, n) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  int ans = 0;
  rep(i, n) {
    if (i%2 == 0) {
      ans += vec.at(i);
      //debugln(ans);
    }
  }
  cout << ans << endl;
}

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

const int MOD = 1000000000 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    long long acm = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        acm += A[i];
        acm %= MOD;
    }

    long sum = 0;

    //i について全探索する
    for (int i = 0; i < N; i++)
    {
        //A[i+1] ... A[N] の値を更新する
        acm -= A[i];
        if (acm < 0) acm += MOD;

        sum += A[i] * acm;
        sum %= MOD;
    }

    cout << sum << endl;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static final long mod = (long)1e9+7;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		long lcm = 1; long ans = 0; int max = 0;

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			max = Math.max(max, a[i]);
		}
		int[] a2 = a.clone();

		int[] fact = new int[max+1];
		for (int i = 0; i < n; i++) {
			for (int j = 2; j*j <= a[i]; j++) {
				int count = 0;
				while(a[i]%j==0) {
					a[i] /= j;
					count++;
				}
				fact[j] = Math.max(fact[j], count);
			}
			if(a[i] != 1) fact[a[i]] = Math.max(fact[a[i]], 1);
		}

		for (int i = 2; i <= max; i++) {
			lcm *= pow(i, fact[i]);
			lcm %= mod;
		}

		for (int i = 0; i < n; i++) {
			long t = lcm*pow(a2[i], mod-2)%mod;
			ans += lcm*pow(a2[i], mod-2);
			ans %= mod;
		}

		System.out.println(ans);
		sc.close();
	}
	public static long pow(long x, long n) {
	    long sum = 1;
	    while (n > 0) {
	        if ((n & 1) == 1) {
	            sum = sum * x % mod;
	        }
	        x = x*x%mod;
	        n >>= 1;
	    }
	    return sum;
	}
}

Measured memory_bytes: 36160
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int N, M, Q;
  cin >> N >> M >> Q;
  V L(M), R(M);
  int x[501][501] = {};
  for (int i = 0; i < M; i++) {
    cin >> L[i] >> R[i];
    x[L[i]][R[i]]++;
  }
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N-1; j++) {
      x[i][j+1] += x[i][j];
    }
  }
  for (int i = 0; i <= N-1; i++) {
    for (int j = 0; j <= N; j++) {
      x[i+1][j] += x[i][j];
    }
  }
  for (int i = 0; i < Q; i++) {
    int p, q;
    cin >> p >> q;
    //cout << x[q][q] << " " << x[p-1][q] << endl;
    dump(x[q][q]-x[p-1][q]);
  }
  return 0;
}


Measured memory_bytes: 3456