akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int num[] = {1000, 100, 10, 1};
char chr[] = {'m', 'c', 'x', 'i'};

int frommcxi(string x){
    int res = 0, n = 1;
    for(int i=0; i<x.size(); i++){
        int j;
        for(j=0; j<4; j++){
            if(x[i] == chr[j]){
                res += n*num[j];
                n = 1;
                j = 10;
            }
        }
        if(j < 10)
            n = x[i] - '0';
    }
    return res;
}

string tomcxi(int n){
    string res = "";
    int m;
    for(int i=0; i<4; i++){
        m = n/num[i];
        if(m >= 2)
            res += (char)(m + '0');
        if(m >= 1)
            res += chr[i];
        n -= m*num[i];
    }
    return res;
}

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

    string a, b;
    for(int i=0; i<n; i++){
        cin >> a >> b;
        cout << tomcxi(frommcxi(a) + frommcxi(b)) << endl;
    }
    
    return 0;
}

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

int main() {
    int M, K;
    cin >> M >> K;
    if (M <= 1) {
        if (K == 0) {
            cout << 0 << " " << 0 << " ";
            if (M == 1) cout << 1 << " " << 1 << endl;
        } else
            cout << -1 << endl;
        return 0;
    }
    if (K < (1 << M)) {
        for (int i = 0; i < (1 << M); i++) {
            if (i == K) continue;
            cout << i << " ";
        }
        cout << K << " ";
        for (int i = (1 << M) - 1; i >= 0; i--) {
            if (i == K) continue;
            cout << i << " ";
        }
        cout << K << endl;
    } else
        cout << -1 << endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 100005;
const ll INF = 1001001001001001001;
const int MOD = 1000000007;

vector<int> G[MAX];
ll dp[MAX][3];

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

    rep(i, M) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        G[u].emplace_back(v);
    }

    int S, T;
    cin >> S >> T;
    S--, T--;

    rep(i, N)rep(j, 3) dp[i][j] = INF;

    priority_queue<
        tuple<ll, int, int>,
        vector<tuple<ll, int, int>>,
        greater<tuple<ll, int, int>>> q;
    dp[S][0] = 0;
    q.emplace(0, S, 0);

    while (q.size()) {
        auto [d, n, c] = q.top();
        q.pop();
        if (dp[n][c] < d) continue;
        for (auto next : G[n]) {
            int nc = c + 1;
            if (nc < 3) {
                if (chmin(dp[next][nc], d)) {
                    q.emplace(d, next, nc);
                }
            } else {
                if (chmin(dp[next][0], d + 1)) {
                    q.emplace(d + 1, next, 0);
                }
            }
        }
    }

    ll ans = dp[T][0];
    if (ans == INF) ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 11396
n=int(input())
mul10=1
mul9=1
mul8=1
mod=1e9+7
for i in range(n):
    mul10*=10
    mul10%=mod
    mul9 *= 9
    mul9 %= mod
    mul8*=8
    mul8%=mod

ans=mul10-2*mul9+mul8
ans%=mod
print(int(ans)//1)



Measured memory_bytes: 9172
import java.util.*;

public class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	int pMax = 0;
    	int pMin = Integer.MAX_VALUE;
    	int mMax = Integer.MIN_VALUE;
    	int mMin = Integer.MAX_VALUE;
    	for (int i = 0; i < n; i++) {
    	    int x = sc.nextInt();
    	    int y = sc.nextInt();
    	    pMax = Math.max(pMax, x + y);
    	    pMin = Math.min(pMin, x + y);
    	    mMax = Math.max(mMax, x - y);
    	    mMin = Math.min(mMin, x - y);
    	}
	    System.out.println(Math.max(pMax - pMin, mMax - mMin));
	}
}

Measured memory_bytes: 59432
def diff(n1, n2):
    return max(n1 - n2, n2 - n1)

n = int(input())
hs = list(map(int, input().split()))
dp = list()
dp.append(0)
dp.append(diff(hs[0], hs[1]))
for t in range(2, n):
    dp.append(min(diff(hs[t], hs[t - 1]) + dp[t - 1], diff(hs[t], hs[t - 2]) + dp[t - 2]))
print(dp[-1])


Measured memory_bytes: 13980
A, B, M = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ans = min(a) + min(b)
for _ in range(M):
    x, y, c = map(int, input().split())
    tmp = a[x - 1] + b[y - 1] - c
    ans = min(ans, tmp)
print(ans)


Measured memory_bytes: 18488
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

int N;
map<string,int> data;
int sum(int p) {
    int sum = 0;
    rep(i,p) {
        string s;
        cin>>s;
        sum += data[s];
    }
    return sum;

}
void solve() {
    data.clear();
    string s;
    rep(i,N) {
        int a;
        cin>>s>>a;
        data[s]=a;
    }
    int M;
    cin>>M;
    rep(i,M) {
        int p;
        cin>>s>>p;
        data[s] = min(data[s],sum(p));
    }

    cin>>s;
    cout<<data[s]<<endl;


}
int main() {
    while(cin>>N) {
        if(!N) break;
        solve();

    }
    return 0;
}

Measured memory_bytes: 1224
N=int(input())

name_dic={}
for i in range(N):
  S=input()
  if S[0]!="M" and S[0]!="A" and S[0]!="R" and S[0]!="C" and S[0]!="H":
    continue
  
  if S[0] in name_dic:
    name_dic[S[0]]+=1
  else:
    name_dic[S[0]]=1
#print(name_dic)

name_list=list(name_dic.values())
#print(name_list)
answer=0
for i in range(len(name_list)):
  for j in range(i+1,len(name_list)):
    for k in range(j+1,len(name_list)):
      answer+=name_list[i]*name_list[j]*name_list[k]

print(answer)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
long long int N,s=0;
    cin>>N;
    for(int i=0;i<=N;i++){
        if(i%5!= 0 && i%3 !=0){
            s+=i;
        }
    }
    cout<<s<<endl;



    }


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdint>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin >> a[i];
    }

    sort(a.begin(),a.end());

    int ans=0;

    auto it=a.begin();
    while(it!=a.end()){
        auto upp=std::upper_bound(it,a.end(),*it);
        int count=upp-it;
        ans+=(count>=*it)?count-*it:count;
        it=upp;
    }

    cout << ans << endl;

    return 0;
}



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

int main(){
  string s, t;
  cin >> s >> t;
  
  string sx = "";
  char a;
  int l = s.size();
  bool ok = false;
  for(int i = 0; i < l; i++){
    a = s.at(l-1);
    s.pop_back();
    sx = a + s;
    s = sx;
    if(s == t) ok = true;
  }
  
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
A,B= map(int,input().split())

if A==1:
  if B==1:
    print("Draw")
  else:
    print("Alice")
elif B==1:
  if A==1:
    print("Draw")
  else:
    print("Bob")  
else:
  if A>B:
    print("Alice")
  elif A==B:
    print("Draw")
  else:
    print("Bob")

Measured memory_bytes: 3060
#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;

int n,m,q;
vi a,b,c,d;
int ans;

void dfs(vi A){
	if (A.size() == n+1){
		int now = 0;
		rep(i,q){
			if(A[b[i]]-A[a[i]] == c[i]) now += d[i];
		}
		ans = max(now,ans);
		return ;
	}

	A.push_back(A.back());
	while(A.back() <= m){
		dfs(A);
		A.back()++;
	}
}


int main(){
	cin >> n >> m >> q;
	a = b = c = d = vi (q);
	rep(i,q) cin >> a[i] >> b[i] >> c[i] >> d[i];
	dfs(vi (1,1));
	cout << ans << endl;
}

Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>

using ll = long long;
using P = std::pair<ll, ll>;


#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(),i.end()
#define debug(i) std::cout << i << "\n"



const int INF = 100000000;
const ll MOD = 1000000007;

ll pow_mod(ll x, ll y, ll mod)
{
	if (y == 0)
		return 1;
    if(y%2){
        return (x*pow_mod(x,y-1,mod))%mod;
    }else{
        return pow_mod(x*x,y/2,mod);
    }
}

int main()
{
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	//問題文中の添え字が0-indexか1-indexか確認!

  ll n;
  std::cin>>n;
  ll now=-1,flag=1;
  rep(i,0,n){
    ll temp;
    std::cin>>temp;
    if(temp<now){
      flag=0;
      break;
    }else if(now!=temp){
      now=temp-1;
    }
  }
  if(flag){
    std::cout<<"Yes";
  }else{
    std::cout<<"No";
  }
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

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

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

    int a[60]={0},b[60] = {0};
    for(int i=1;i<=m;i++) cin >> a[i] >> b[i];

    int num[60] = {0};

    for(int i=1;i<=m;i++){

        num[a[i]]++;
        num[b[i]]++;

    }

    for(int i=1;i<=n;i++){
        cout << num[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = [int(a) for a in input().split()]
A = [0 if a >= K else a for a in A]
X = [1] * N
Y = [1] * N
m = (1<<K*8) - 1
for i in range(N-1):
    X[i+1] = (X[i] | X[i] << 8 * A[i]) & m if A[i] else X[i]
for i in range(1, N)[::-1]:
    Y[i-1] = (Y[i] | Y[i] << 8 * A[i]) & m if A[i] else Y[i]

ans = N
for i in range(N):
    if A[i] == 0 or ((X[i] * Y[i] & m) >> 8 * (K - A[i])) & ((1 << 8 * A[i]) - 1):
        ans -= 1
print(ans)

Measured memory_bytes: 103516
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int s;
    int m;
    int h;
    int S;
    
    scanf("%d" ,&S);
    h=S/3600;
    m=(S-h*3600)/60;
    s=S-(h*3600+m*60);
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}

Measured memory_bytes: 592
import sys, io, os, re
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from pprint import pprint
from math import sin, cos, pi, radians, sqrt, floor, ceil
from copy import copy, deepcopy
from collections import deque
from fractions import gcd
from functools import reduce
from itertools import groupby
from heapq import heapify, heappush, heappop

# sys.setrecursionlimit(5000)

n1 = lambda: int(sys.stdin.readline().strip())
nn = lambda: list(map(int, sys.stdin.readline().strip().split()))
f1 = lambda: float(sys.stdin.readline().strip())
fn = lambda: list(map(float, sys.stdin.readline().strip().split()))
s1 = lambda: sys.stdin.readline().strip()
sn = lambda: list(sys.stdin.readline().strip().split())
nl = lambda n: [n1() for _ in range(n)]
fl = lambda n: [f1() for _ in range(n)]
sl = lambda n: [s1() for _ in range(n)]
nm = lambda n: [nn() for _ in range(n)]
fm = lambda n: [fn() for _ in range(n)]
sm = lambda n: [sn() for _ in range(n)]

def array1(n, d=0): return [d] * n
def array2(n, m, d=0): return [[d] * m for x in range(n)]
def array3(n, m, l, d=0): return [[[d] * l for y in xrange(m)] for x in xrange(n)]
def linc(A, d=1): return map(lambda x: x + d, A)
def ldec(A, d=1): return map(lambda x: x - d, A)

N, M, K = nn()
A = nn()
B = nn()

a = [0]
sum_a = 0
for i in A:
    sum_a += i
    a.append(sum_a)

b = [0]
sum_b = 0
for i in B:
    sum_b += i
    b.append(sum_b)

ans = 0
for i in range(len(a)):
    ai = a[i]
    if ai > K:
        break

    tmp = K - ai
    j = bisect_right(b, tmp) - 1
    r = i + j

    #print(i, j, a, b, ai)   
    if r > ans:
        ans = r

if ans >= 0:
    print(ans)
else:
    print(0)


Measured memory_bytes: 137952
n,m = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
res=0
total = sum(arr)
for x in arr:
  if x>=(1/(4*m))*total:
    res+=1
if res>=m:
  print('Yes')
else:
  print('No')
    

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define N 100010

using namespace std;
int main(){
	int n, a[N],b[N],c[N], vacation[N][3];

	//input
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i] >> c[i];
	}

	//alg
	vacation[n+1][0] = 0;
	vacation[n+1][1] = 0;
	vacation[n+1][2] = 0;

	for(int i=n;i>=0;i--){
		vacation[i][0] = max(vacation[i+1][1],vacation[i+1][2]) + a[i];
		vacation[i][1] = max(vacation[i+1][0],vacation[i+1][2]) + b[i];
		vacation[i][2] = max(vacation[i+1][1],vacation[i+1][0]) + c[i];
	}

	cout << max(vacation[0][0],max(vacation[0][1],vacation[0][2])) << '\n';

	return 0;
}

Measured memory_bytes: 2560
package main

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

func main() {
	N := nextInt()
	d := map[string]int{}

	for i := 0; i < N; i++ {
		var t text = nextBytes()
		sort.Sort(t)
		s := string(t)

		before, ok := d[s]

		if !ok {
			d[s] = 1
		} else {
			d[s] = before + 1
		}
	}

	count := int64(0)
	for _, c := range d {
		count += int64(c) * int64(c-1) / 2
	}

	fmt.Println(count)
}

type text []byte

func (a text) Len() int           { return len(a) }
func (a text) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a text) Less(i, j int) bool { return a[i] < a[j] }

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


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

#define REP(i,N) for (int i=0;i<(N); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

ll N;
ll ans=0;
ll sum=0;
ll B[100];

int main()
{
cin >> N;
 for(int i=1;i<N;i++){
    cin >> B[i];
  } 
  
  if(N==2){
    ans = 2*B[1];
  }else{
    for(int k=1;k<=N-2;k++) sum += min(B[k],B[k+1]);
  	ans = B[1]+B[N-1]+sum;
  }

cout << ans << endl;
  
return 0;
}

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

using namespace std;

int sum(int num) {
  if( num < 10 ) return num;
  int a = num % 10;
  int b = num / 10;
  return sum(b) + a;
};

int main(void)
{
  int N,A,B;
  cin >> N >> A >> B;
  
  int anser = 0;
  for(int i = A;i<=N;++i) {
    int some = sum(i);
    if( some < A ) continue;
    if( B < some ) continue;
    // cout << "i:" << i << ",some:" << some << endl;
    anser += i;
  }
  
  cout << anser << endl;
  
  return 0;
}

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

#define int long long
#define uint unsigned int
#define pii pair<int, int>
#define fi first
#define se second

#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 REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) ((int)(a).size())

#define PF(a) push_front(a)
#define PB(a) push_back(a)
#define EMPF(...) emplace_front(__VA_ARGS__)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, -1, sizeof(a))

#define PW(n) (1LL << (n))
#define NUM(x) char(x + '0')
#define ALP(x) char(x + 'a')

using namespace std;

template <class T> inline bool CHMIN(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline void SORT(T &a) { sort(a.begin(), a.end()); }
template <class T> inline void REV(T &a) { reverse(a.begin(), a.end()); }
template <class T> inline void UNIQUE(T &a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }

template <class S, class T> ostream& operator << (ostream& os, const pair<S, T> v) {
  os << "(" << v.first << ", " << v.second << ")"; return os;
}

const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

/* ---------------------------------------------------------------------------------------------------- */

struct UF {
  int n;
  vector<int> p;
  UF() {}
  UF(int n) : n(n), p(n,-1) {}
  int find(int x) {
    return p[x] < 0 ? x : p[x] = find(p[x]);
  }
  void unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return;
    if (p[x] > p[y]) swap(x, y);
    p[x] += p[y];
    p[y] = x;
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  int size(int x) {
    return -p[find(x)];
  }
};

int N, M;
int A[100010], B[100010];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  REP(i, M) {
    cin >> A[i] >> B[i];
    A[i]--; B[i]--;
  }
  int num = N*(N-1)/2;
  UF uf(N);
  vector<int> ans;
  REPR(i, M-1) {
    ans.PB(num);
    int pre = uf.size(A[i]);
    uf.unite(A[i], B[i]);
    int nxt = uf.size(A[i]);
    num -= pre*(nxt-pre);
  }
  REV(ans);
  REP(i, SZ(ans)) {
    cout << ans[i] << endl;
  }

  return 0;
}

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

int main(){

  int n,m;
  cin >> n >> m;

  int dis[100001];
  for(int i=0;i<n-1;i++) cin >> dis[i];

  int a;
  int ima=-1;
  long long sum = 0;
  for(int i=0;i<m;i++) {
    cin >> a;
    int flg = 1;
    if(a < 0) flg =-1,a*=-1;
    for(int j=0;j<a;j++) {
      if(flg > 0) sum += dis[ima+j+1];
      else sum += dis[ima-j];
    }
    ima += flg*a;
    //   cout <<"a = "<<flg*a << " sum = "<<sum <<" ima = "<<ima <<endl;
  }

  //  cout << sum << endl;
  cout << sum%100000 <<endl;

}

Measured memory_bytes: 1544
#include <stdio.h>
int main(void){
  int a,b,d,r,i=0,Count=0;
	double f;
	scanf("%d %d",&a,&b);
	
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;
	printf("%d %d %lf\n",d,r,f);
  
  return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  
  string a;
  vector<char> s(W+2, '#');
  
  for (int i = 0; i < W+2; i++) {
    cout << s.at(i);
  }
  
  cout << endl;
  
  for (int i = 0; i < H; i++) {
    cin >> a;
    cout << '#' << a << '#' << endl;
  }
      
  for (int i = 0; i < W+2; i++) {
    cout << s.at(i);
  }
  
  cout << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t % 2019;
    } else {
        return modpow(m, n - 1) * m % 2019;
    }
}
long long n;
vector<bool> visited(100, false);
vector<int> t1(100);
vector<int> t2(100);
vector<vector<long long>> graph(100);
int ts = 1;
void dfs(int cur) {
    visited[cur] = true;
    t1[cur] = ts;
    ts++;
    for (int i = 0; i < graph[cur].size(); i++) {
        if (visited[graph[cur][i]] == false) {
            dfs(graph[cur][i]);
        }
    }
    t2[cur] = ts;
    ts++;
}
signed main() {
    cin >> n;
    for (long long i = 0; i < n; i++) {
        long long s, k;
        cin >> s >> k;
        for (int j = 0; j < k; j++) {
            int l;
            cin >> l;
            graph[s - 1].push_back(l - 1);
        }
    }
    REP(i, n) {
        if (!visited[i]) {
            dfs(i);
        }
    }
    REP(i, n) { cout << i + 1 << " " << t1[i] << " " << t2[i] << endl; }
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pl pair<ll, ll>
#define vl vector<ll>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define N 100005

int main()
{
    ll a;cin>>a;
    ll x=pow(a,2);
    ll y=pow(a,3);
    cout<<a+x+y<<"\n";
}


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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll(x);cin >> (x);
#define stin(x) str(x);cin >> (x);
#define vllin(x,n) vll(x)(n);FOR(i,0,n-1){cin >> (x)[i];}
#define vllin2(a,b,n) vll(a)(n);vll(b)(n);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i];}
#define vllin3(a,b,c,n) vll(a)(n);vll(b)(n);vll(c)(n);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i] >> (c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >> (x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i] >> (c)[i];}
#define vpl4in(x,n) vpl4(x)((n),mp(0,0));FOR(i,0,n-1){cin >> x[i].fi >> x[i].se;}
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define rFOR(i,b,a) for(ll i=a;i>=b;i--)
#define SORT(x) sort(x.be,x.en)
#define rSORT(x) sort(x.rbegin(),x.rend())
#define say(x) cout << (x);
#define sal(x) cout << (x) << endl;
#define says(x) cout << (x) << (' ');
#define sas cout << (' ');
#define sayR(x) cout << fixed << setprecision(10) << (x);
#define salR(x) cout << fixed << setprecision(10) << (x) << endl;
#define yn(a) cout << ((a) ? "yes" : "no") << endl;
#define Yn(a) cout << ((a) ? "Yes" : "No") << endl;
#define YN(a) cout << ((a) ? "YES" : "NO") << endl;
#define Imp(a) cout << ((a) ? "Possible" : "Impossible") << endl;
#define IMP(a) cout << ((a) ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll MOD = 1000000007;

signed main()
{
    llin(n);
    vll xy(2);
    char d;
    vll smi(2,800000001);
    vll sma(2,-800000001);
    vll mi(4,800000001);
    vll ma(4,-800000001);
    map<char,ll> dd;
    dd['D']=0;dd['U']=1;dd['L']=2;dd['R']=3;
    FOR(i,0,n-1){
        cin >>xy[0]>>xy[1]>>d;
        xy[0]=xy[0]*2;
        xy[1]=xy[1]*2;
        smi[dd[d]/2]=min(smi[dd[d]/2],xy[dd[d]/2]);
        sma[dd[d]/2]=max(sma[dd[d]/2],xy[dd[d]/2]);
        mi[dd[d]]=min(mi[dd[d]],xy[1-dd[d]/2]);
        ma[dd[d]]=max(ma[dd[d]],xy[1-dd[d]/2]);
    }
    vll t(1,0);
    ll e[]={-1,1,-1,1};
    FOR(i,0,3){
        if(smi[1-i/2]<200000001&mi[i]<200000001) t.pb(e[i]*(smi[1-i/2]-mi[i]));
        if(sma[1-i/2]>-200000001&ma[i]>-200000001) t.pb(e[i]*(sma[1-i/2]-ma[i]));
    }
    FOR(i,0,1){
        if(mi[i*2]<200000001&mi[i*2+1]<200000001) t.pb((mi[i*2]-mi[i*2+1])/2);
        if(ma[i*2]>-200000001&ma[i*2+1]>-200000001) t.pb((ma[i*2]-ma[i*2+1])/2);
    }
    ll s=160000000000000001;
    for(auto l:t){
        if(l>=0){
            s=min(s,(max(sma[0],max(ma[2]-l,ma[3]+l))-min(smi[0],min(mi[2]-l,mi[3]+l)))*(max(sma[1],max(ma[0]-l,ma[1]+l))-min(smi[1],min(mi[0]-l,mi[1]+l))));
        }
    }
    cout << fixed << setprecision(10) << double(s)/4.0 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,a=0,w=0,t=0,r=0;
  cin>>n;
  while(n--){
  string s;
    cin>>s;
    if(s=="AC") a++;
    else if(s=="WA") w++;
    else if(s=="TLE") t++;
    else if(s=="RE") r++;
  }
  cout<<"AC x "<<a<<"\n";
  cout<<"WA x "<<w<<"\n";
  cout<<"TLE x "<<t<<"\n";
  cout<<"RE x "<<r<<"\n";
}

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

int N, M, K;

int tc[114514];
int* ts[114514];

int bc[114514];
int* bs[114514];

void ae(int* c, int** s, int t) {
	*s = realloc(*s, sizeof(int) * (*c + 1));
	if (*s == NULL) exit(2);
	(*s)[(*c)++] = t;
}

int tu[114514];
int bu[114514];

void ui(int* u) {
	int i;
	for (i = 0; i < 114514; i++) u[i] = -1;
}

int ur(int* u, int n) {
	if (u[n] < 0) return n;
	return u[n] = ur(u, u[n]);
}

int us(int* u, int n) {
	return -u[ur(u, n)];
}

void um(int* u, int n1, int n2) {
	int r1 = ur(u, n1);
	int r2 = ur(u, n2);
	if (r1 != r2) {
		int s1 = us(u, n1);
		int s2 = us(u, n2);
		if (s1 <= s2) {
			u[r2] += u[r1];
			u[r1] = r2;
		} else {
			u[r1] += u[r2];
			u[r2] = r1;
		}
	}
}

int main(void) {
	int i;
	if (scanf("%d%d%d", &N, &M, &K) != 3) return 1;
	ui(tu);
	ui(bu);
	for (i = 0; i < M; i++) {
		int A, B;
		if (scanf("%d%d", &A, &B) != 2) return 1;
		ae(&tc[A], &ts[A], B);
		ae(&tc[B], &ts[B], A);
		um(tu, A, B);
	}
	for (i = 0; i < K; i++) {
		int C, D;
		if (scanf("%d%d", &C, &D) != 2) return 1;
		ae(&bc[C], &bs[C], D);
		ae(&bc[D], &bs[D], C);
		um(bu, C, D);
	}

	for (i = 1; i <= N; i++) {
		int kaunto = us(tu, i) - 1 - tc[i];
		int j;
		int tr = ur(tu, i);
		for (j = 0; j < bc[i]; j++) {
			if (ur(tu, bs[i][j]) == tr) kaunto--;
		}
		printf(" %d" + (i == 1), kaunto);
	}
	putchar('\n');

	return 0;
}


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

using namespace std;

typedef long long ll;

#ifdef iq
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

const int N = 18;

ll arr[N];

map <pair <int, int>, ll> dp[N][N][N][N];

ll func(int l, int r, int x, int y, int ca, int cb) {
  if (dp[l][r][x][y].count({ca, cb})) {
    return dp[l][r][x][y][{ca, cb}];
  }
  if (r - l == 1) {
    return arr[x] * ca + arr[y] * cb;
  }
  ll best = 1e18;
  for (int z = x + 1; z <= y - 1; z++) {
    ll ret = func(l, z, x, z, ca, ca + cb);
    ret += func(z, r, z, y, ca + cb, cb);
    best = min(best, ret - ca * arr[z] - cb * arr[z]);
  }
  return dp[l][r][x][y][{ca, cb}] = best;
}

int main() {
#ifdef iq
  freopen("a.in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  cout << func(0, n - 1, 0, n - 1, 1, 1) << '\n';
}


Measured memory_bytes: 21632
import java.util.*;


public class Main{
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();
        sc.close();
        int x = 0;
        int y = 0;
        int z = 0;
        int count = 0;

        for(x = 0; x <= k; x++) {
            for(y = 0; y <= k; y++){
                z = s - (x+y);
                if (z <= k && z >= 0) {
                    count++;
                }
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 23764
// #includes {{{
#include <bits/stdc++.h>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

const int mod = 1000000007;

//{{{ modular algebra
struct Num{
	int v;
	Num(int n):v(n){}
	Num(){}
	operator int() const {return v;}
	operator long long() const {return v;}
	void operator =(int n){v=n;}

	template<class T>
		inline void operator *=(const T &a) {
			v = (v*(long long)a)%mod;
		}
	template<class T>
		inline Num operator *(const T &a) {
			Num n(*this);n*=a;
			return n;
		}
	template<class T>
		inline void operator+=(const T &a){
			v+=(int)a;
			if(v>=mod)v-=mod;
			//	assert(0<=v and v<mod);
		}
	template<class T>
		inline Num operator+(const T &a){
			Num n(*this);n+=a;
			return n;
		}
	inline Num operator -(){
		if(v==0)return v;
		else return Num(mod-v);
	}
	template<class T>
		inline void operator -=(const T &a){
			v-=(int)a;
			if(v<0)v+=mod;
		}
	template<class T>
		inline Num operator -(const T &a){
			Num n(*this);n-=a;
			return n;
		}
#ifdef __GCD_H
	inline Num inv(){
		return invMod(this->v,mod);
	}
	template<class T>
		inline void operator /=(const T &a){
			(*this)*=invMod((int)a,mod);
		}
	template<class T>
		inline Num operator /(const T &a){
			Num n(*this);n/=a;
			return n;
		}
#endif
};

ostream& operator <<(ostream &os,const Num &n){
	os<<(int)n.v;
	return os;
}

istream& operator >>(istream &is, const Num &n){
	is>>(int)n.v;
	return is;
}
//}}}

int N;
int x[100010], p[100010];

int main(){
	cin>>N;
	REP(i,N)cin>>x[i];
	Num ans(1);
	int cur = -1, cur_num = 0;
	REP(i,N){
		int t = 0;
		if(i>0){
			t = i - 1 - p[i-1];
		}
		ans*=(i+1-t);
		if(cur+2<=x[i]){
			p[i] = cur_num;
			cur+=2;cur_num++;
		}else{
			p[i] = p[i-1];
		}
//		cerr<<i<<" "<<p[i]<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int inp,inp_;
  int div=0;
  
  cin >> inp;
  inp_ = inp;
  while (0 < inp_) {
    div += inp_ % 10;
    inp_ /= 10;
  }

  if (inp % div) cout << "No" << endl;
  else cout << "Yes" << endl;
}


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

int main(){
  int n;
  cin >> n;
  ll mult=1;
  vector<ll> a(n);
  rep(i,n){
    cin >> a[i];
  }
  rep(i,n){
    if(a[i]==0){
      cout << 0 << endl;
      return 0;
    }
  }

  rep(i,n){
    if(a[i]<=1000000000000000000/mult){
    mult *=a[i];
    }
    else{
      cout << -1 << endl;
      return 0;
    }
  }

  cout << mult << endl;
  return 0;
}


Measured memory_bytes: 4020
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     makep        make_pair
#define     maket        make_tuple
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const ld pi=acos(-1);
const int inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    vector<int> v={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 k;
    cin>>k;

    cout<<v[k-1];
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<iomanip>
#include<algorithm>
#include<list>
using namespace std;

int main()
{
	int n;
	int a[101];

	//入力
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}

	//出力
	for (int j = 0; j < n; j++){
		if (j < n - 1){
			cout << a[j] << " ";
		}
		else{
			cout << a[j] << endl;
		}
	}

	for (int i = 1; i < n; i++){

		//ソート
		for (int j = 0; j < n; j++){
			if (a[j] > a[i]){
				int tmp = a[i];
				for (int k = i - 1; k > j - 1; k--){
					a[k + 1] = a[k];
				}
				if (j < i){
					a[j] = tmp;
				}
				break;
			}
		}

		//出力
		for (int j = 0; j < n; j++){
			if (j < n - 1){
				cout << a[j] << " ";
			}
			else{
				cout << a[j] << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include<iomanip>
using namespace std;
using P = pair<int, int>;
int MOD = 1000000007;

int main()
{
	char c;
	cin >> c;
	cout << (char)(c + 1) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n;
int mat[300][300];
void ExistAllWin() {
  vector<pair<int, int> > points;
  REP(y, n) {
    int s = 0;
    REP(x, n) {
      s += mat[y][x];
    }
    points.push_back(make_pair(s, y));
  }
  sort(points.rbegin(), points.rend());
  if (points[0].first == 1 + (n - 1) * 3) { points.resize(1); }
  vector<int> candidate;
  REP(i, min(3, (int)points.size())) {
    candidate.push_back(points[i].second);
  }
  if (candidate.size() == 1) {
    REP(i, 1000) {
      printf("%d\n", candidate[0] + 1);
      fflush(stdout);
    }
    exit(0);
  }
}

int main() {
  int v = scanf("%d", &n);
  assert(v == 1);
  REP(y, n) {
    REP(x, n) {
      char c;
      int v = scanf(" %c", &c);
      assert(v == 1);
      mat[y][x] = c == 'o' ? 3 : 0;
    }
    mat[y][y] = 1;
  }

  ExistAllWin();
  int prev = 0;
  REP(i, 1000) {
    printf("%d\n", rand() % n + 1);
    fflush(stdout);
    int v = scanf("%d", &prev);
    assert(v == 1);
  }
}

Measured memory_bytes: 0
// All Heil Fire Lord Zuko

#include <bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define PB push_back
#define debug(x) cerr << #x << " = " << x << endl

#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef long double ld;

const int N = 2 * 100 * 1000 + 19;

int32_t main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    int ans = c - (a - b);
    if (ans < 0)
        ans = 0;
    cout << ans;
    return 0;
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    Vi a(m),b(m);
    vin(a,b);

    map<int,int> ma;
    REP(i,0,m){
        ma[a[i]]++;
        ma[b[i]]++;
    }
    bool flag=true;
    for(auto x : ma){
        if(x.second%2==1) flag=false;
    }
    YESNO(flag);
    return 0;
}


Measured memory_bytes: 7296
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int lli;
typedef unsigned long long int ulli;

typedef map<string,int> msi; 
typedef map<int,int> mii;

typedef stack<int> si;
typedef stack<string> ss;
typedef stack<bool> sb;

typedef queue<int> qi;
typedef queue<string> qs;
typedef queue<bool> qb;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;

void f3(){

}


void f2(){

}

void f1(){

}
 

int main(){
	char a[10], b[10];
	scanf("%s%s", a, b);

	int ans = 0;
	for(int i = 0; i < 3; ++i) if( a[i] == b[i] ) ans++;
	printf("%d\n", ans);
	
	return 0;
}




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

int main(){
    long long a, b, c;
    cin >> a >> b >> c;
    long long ans;
    if(c <= a + b + 1)ans = c + b;
    else ans = 2 * b + a + 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		int K = in.nextInt();
		
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		for (int i = 0; i < N; i++) {
			int n = in.nextInt();
			int count = 0;
			if (map.containsKey(n)) {
				count = map.get(n);
			}
			map.put(n, count + 1);
		}
		
		ArrayList<Integer> arr = new ArrayList<Integer>();
		for (int n : map.keySet()) {
			arr.add(map.get(n));
		}
		arr.sort(null);
		
		int answer = 0;
		for (int i = 0; i < arr.size() - K; i++) {
			answer += arr.get(i);
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 100736
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    ll n,w;
    cin>>n>>w;
    vector<ll> c(n);
    vector<ll> v(n);
    rep(i,n)cin>>c[i]>>v[i];
    ll maxv=0;
    rep(i,n)maxv+=v[i];

    ll dp[101][100001];
    
    rep(i,maxv+1)dp[0][i]=-1;
    dp[0][0]=0;
    rep(i,n){
        for(int j=0;j<=maxv;j++){
            if(j<v[i]){
                dp[i+1][j]=dp[i][j];
            }else{
                if(dp[i][j-v[i]]!=-1){
                  //cout<<i+1<<" "<<j<<" "<<dp[i][j-v[i]]+c[i]<<endl;
                    dp[i+1][j]=(dp[i][j]==-1)?dp[i][j-v[i]]+c[i]:min(dp[i][j-v[i]]+c[i],dp[i][j]);
                }else{
                    dp[i+1][j]=dp[i][j];
                }
            }
        }
    }
    

    for(int i=maxv;i>=0;i--){
        if(dp[n][i]!=-1 && dp[n][i]<=w){
            cout<<i<<endl;
            break;
        }
    }

    
    return 0;
}

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

long long N;
long long A[100005];
long long R[100005];

int main(){
	cin >> N;
	for(long long i = 0; i < N; i++){
		cin >> A[i];
		R[0] +=  A[i];
	}
	for(long long i = 1; i < N; i+=2){
		R[0] -= 2*A[i];
	}

	for(long long i = 1; i < N; i++){
		R[i] = 2*(A[i-1] - R[i-1]/2);
	}

	for(long long i = 0; i < N; i++){
		cout << R[i] << endl;
	}
}

Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <math.h>
#include <map>
#include <stack>
using namespace std;
static const int INF = 1e9+7;
// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i =a; i < b; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define PI 3.14159265359

ll digit_sum(ll num){
    if(num < 10) return num;
    return digit_sum(num / 10) + num%10;
}


int main(){
    int n, a, b;
    cin >> n >> a >> b;
    ll result = 0;
    repr(i, 1, n+1){
        ll tmp = digit_sum(i);
        if(tmp >= a and tmp <= b) result += i;
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define INF (1LL<<59)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	int n;
	cin>>n;
	set<string> S;
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		S.ins(s);
	}	
	cout<<(int)S.sz()<<"\n";
	return;
}

int main(void)
{
	FLASH();
	int T;
	T = 1;

// #ifndef ONLINE_JUDGE
// 	time_t time_t1, time_t2;
// 	time_t1 = clock();
// #endif

	//cin>>T;
	while(T--)
	solve(T);

// #ifndef ONLINE_JUDGE
// 	time_t2 = clock();
// 	SETF();
// 	cout<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
// 	UNSETF();
// #endif

	return 0;
}

Measured memory_bytes: 19264
#include<stdio.h>
#include<stdlib.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void initialize(int n)//初期化
{
	head=0;
	tail=n+1;
}

int isEmpty(){//キューが空か判定
	if(head == tail) return 0;
	else return 1;
}

int isFull()//キューが満杯か判定
{
	if(head == (tail + 1) % LEN) return 0;
	else return 1;
}

void enqueue(P x)//キューの最後にxを挿入
{
	if (isFull()==0)printf("1error\n");
	Q[tail]=x;
	if(tail+1==LEN) tail=0;
	else tail++;
}

P dequeue(){//キューの先頭を返り値として処理
	P x;
	if(isEmpty()==0) printf("2error\n");
	else{
		x=Q[head];
		if(head+1==LEN) head=0;
		else head++;
	}
	return x;
}


int main(void){
  int elaps = 0, c;//処理時間の合計
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  initialize(n);
  for(i=0;;i++){
  	u=dequeue();//キューの先頭を格納
  	if(u.t>q){//qより大きい場合
  		elaps+=q;
  		u.t-=q;
  		enqueue(u);
    }else{//qより小さい場合
    	elaps+=u.t;
    	if(i!=0)printf("%s %d\n",u.name,elaps);
    	if(isEmpty()==0) break;
    }
  }
  
  return 0;
}


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

int main() {
    int n=0;
    scanf("%d\n", &n);
    int buf = 0;
    int max = 0, min = 0;
    for (int i=0; i<n; i++) {
        scanf("%d", &buf);
        if (i == 0) {
            max = buf;
            min = buf;
        }
        else {
            if (buf > max) max = buf;
            if (buf < min) min = buf;
        }
    }
    printf("%d\n", abs(max - min));
    return 0;
}


Measured memory_bytes: 128
import itertools 
n = int(input())
f = [list(map(int,input().split())) for _ in range(n)]
p = [list(map(int,input().split())) for _ in range(n)]
data = list(itertools.product(range(2), repeat = 10))[1:]
ans = -10**9
for d in data:
    a = 0
    for i in range(n):
        c = 0
        for j in range(10):
            if f[i][j] and d[j]: c+=1
        a+=p[i][c]
    ans = max(ans,a)
print(ans)

Measured memory_bytes: 42092
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);

	void run(){

		int n=Integer.valueOf(sc.nextLine());

		for(int i =0; i < n;i++){

			System.out.println(sc.nextLine().replace("Hoshino", "Hoshina"));

		}		

	}

	public static void main(String[] args){

		Main m = new Main();

		m.run();

	}

}

Measured memory_bytes: 12000
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
mod=10**9+7
b,w=map(int,input().split())
n=b+w

def power(x,n):
    if n==0:
        return 1
    elif n%2:
        return power(x,n//2)**2*x%mod
    else:
        return power(x,n//2)**2%mod
def modinv(n):
    return power(n,mod-2)

factorial=[1]
for i in range(1,n+1):
    factorial.append(factorial[i-1]*i%mod)
inverse=[0]*(n+1)
inverse[-1]=modinv(factorial[-1])
for i in range(n)[::-1]:
    inverse[i]=inverse[i+1]*(i+1)%mod
def comb(n,r):
    if n<r or r<0:
        return 0
    return factorial[n]*inverse[r]*inverse[n-r]%mod

Pb,Pw=[0]*n,[0]*n
inv2=modinv(2)
P=[1]*(n+1)
for i in range(1,n+1):
    P[i]=P[i-1]*inv2%mod
for i in range(1,n):
    Pb[i]=(Pb[i-1]+comb(i-1,b-1)*P[i])%mod
    Pw[i]=(Pw[i-1]+comb(i-1,w-1)*P[i])%mod
for i in range(n):
    print((1-Pb[i]+Pw[i])*inv2%mod)

Measured memory_bytes: 102484
import sys
n, m = map(int, input().split())
paths = {i: [] for i in range(n)}
for _ in range(m):
    a, b = map(int, input().split())
    paths[a - 1].append(b - 1)
for i in paths[0]:
    if n - 1 in paths[i]:
        print('POSSIBLE')
        sys.exit()
print('IMPOSSIBLE')

Measured memory_bytes: 46140
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());

        double result = 0;
        for (int i = 0; i < n; i++) {
            String[] line = scanner.nextLine().split(" ", 2);
            if (line[1].equals("JPY")) {
                result += Integer.parseInt(line[0]);
            } else {
                result += Double.parseDouble(line[0]) * 380000.0;
            }
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 22740