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

#define maxn 200010
#define INF 1e15
#define ff first
#define ss second
#define endl '\n'
typedef long long ll;

int n, q, ptr;
vector<int> adj[maxn];
ll ans[maxn];

void dfs(int u, int p) {
  ans[u] += ans[p];
  for (auto v: adj[u]) {
    if (v == p) continue;
    dfs(v, u);
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); 
  cin >> n >> q;
  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  while (q--) {
    ll p, x;
    cin >> p >> x;
    ans[p] += x;
  }
  dfs(1, 0);
  for (int i = 1; i <= n; ++i) cout << ans[i] << " ";
  cout << endl;
}


Measured memory_bytes: 24320
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    int x = Integer.parseInt(br.readLine());
    
    System.out.println(x * x * x);
  }
}



Measured memory_bytes: 24184
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 100005
#define M 200005
#define seed 23333
#define Mo 1000000007

using namespace std;
int i,j,m,n,p,k,cnt=0,a[N],ans=1;
int fac(int x)
{
		int sum=1;
		for (i=1;i<=x;++i) sum=1ll*sum*i%Mo;
		return sum;
}
int main()
{
	scanf("%d",&n); int now=1;
	for (i=1;i<=n;++i) 
	{
			scanf("%d",&a[i]);
			if (now<=a[i]) now+=2,cnt+=1; 
			else ans=1ll*ans*(cnt+1)%Mo;
	}
	printf("%d\n",1ll*ans*fac(cnt)%Mo);
}


Measured memory_bytes: 640
#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  for (int i = 0; i != N; ++i)
    cin >> S[i];
  sort(S.begin(), S.end());
  copy(S.begin(), S.end(), ostream_iterator<string>(cout));
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define d double
#define INF INT_MAX
#define output for(int i=0;i<sizex;i++) { for(int j=0;j<sizey;j++) { cout << moveChart[i][j] << " "; }cout<<endl; }cout<<endl;

int n;
int arr[3001];
ll dp[3][3001][3001];

inline int otherPlayer( int x ){
    if( x == 1 ) return 2;
                 return 1;
}

ll solve( int player, int L, int R ){

    if( L == R ){
        if( player == 1 ) return  arr[L];
                          return -arr[L];
    }

    if( dp[player][L][R] != -1 ) return dp[player][L][R];

    ll res;
    ll res1, res2;
    if( player == 1 ){
        res1 = solve( otherPlayer(player), L+1, R ) + arr[L];
        res2 = solve( otherPlayer(player), L, R-1 ) + arr[R];
        res = max( res1, res2 );
    }else{
        res1 = solve( otherPlayer(player), L+1, R ) - arr[L];
        res2 = solve( otherPlayer(player), L, R-1 ) - arr[R];
        res = min( res1, res2 );
    }

    return dp[player][L][R] = res;

}

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

    memset( dp, -1, sizeof dp ); 

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

    ll res = solve( 1, 0, n-1 );
    cout << res << endl;

}

Measured memory_bytes: 211456
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		HashMap<Integer, Integer> m = new HashMap<>();
		for(int i=0; i<N; i++) {
			int tmp = sc.nextInt();
			if(m.containsKey(tmp)) {
				m.put(tmp, m.get(tmp)+1);
			} else {
				m.put(tmp, 1);
			}
		}
		long ans = 0;
		for(Map.Entry<Integer, Integer> e : m.entrySet()) {
			int k = e.getKey();
			int v = e.getValue();
			if(v>=k) {
				ans += (v-k);
			} else {
				ans += v;
			}
		}
		System.out.println(ans);
	}
	
	static int binarySearch(int[] A, int x) {
		int l = 0;
		int r = A.length;
		while(l<r) {
			int mid = (l+r)/2;
			if(A[mid] == x) return mid;
			else if(x<A[mid]) r = mid;
			else l = mid+1;
		}
		return -1;
	}
	
	static long upper_bound(int[] A, int b) {
		// bよりおおきい値がはじめて出てくるindexを返す
		return lower_bound(A, b+1);
	}

	static long lower_bound(int[] A, int b) {
		// b以上の値がはじめて出てくるindexを返す
		int lb=0;
		int ub=A.length;
		while(ub>lb) {
			int mid = (lb+ub)/2;
			if(A[mid]>=b) ub = mid;
			else lb = mid+1;
		}
		return lb;
	}
	
	// union find lib
	// usage:
	// 最初にinitを呼ぶ
	// root: 直接は呼ばないで
	// unite: まとめる
	// same: グループ判定
	static void init(int par[], int N) {
		for(int i=0; i<N; i++) {
			par[i] = i;
		}
	}
	
	static int root(int x, int [] par) {
		if(par[x] == x) {
			return x;
		} else {
			return (par[x] = root(par[x], par));
		}
	}
	
	static boolean same(int x, int y, int[] par) {
		return root(x, par) == root(y, par);
	}
	
	static void unite(int x, int y, int[] par) {
		x = root(x, par);
		y = root(y, par);
		if(x == y) return;
		par[x] = y;
	}
	
	// end union find lib
	
	// number lib
	
	static int max(int...ls) {
		int ans = Integer.MIN_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.max(ans, ls[i]);
		}
		return ans;
	}
	
	static int min(int...ls) {
		int ans = Integer.MAX_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.min(ans, ls[i]);
		}
		return ans;
	}
	
	static long lcm(long a, long b) {
		return a*(b/gcd(a, b));
	}
	
	static long gcd(long a, long b) {
		long ta = Math.max(a, b);
		long tb = Math.min(a, b);
		long tmp;
		while((tmp = ta%tb) != 0) {
			ta = tb;
			tb = tmp;
		}
		return tb;
	}
	
	static long modcomb(long n, long k, long mod) {
		if(k==1) {
			return n;
		}
		
		long ans = 1;
		for(long i=n; i>=n-k+1; i--) {
			ans = (ans * i)%mod;
		}
		for(long i=k; 0<i; i--) {
			ans = (ans * modpow(i, mod-2, mod)) % mod;
		}
		return ans;
	}
	
	static long modpow(long a, long b, long mod) {
		if(b==0) return 1;
		if(b%2==0) {
			long d = modpow(a, b/2, mod);
			return (d*d)%mod;
		} else {
			return (a*modpow(a, b-1, mod))%mod;
		}
	}
	
	static int disit(long a, long d) {
		int count = 0;
		while(a!=0) {
			a = a/d;
			count++;
		}
		return count;
	}
	
	// end number lib
}

Measured memory_bytes: 63108
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

int main() {
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    vector<vector<double>> dist(n, vector<double>(n));
    double ans = 0.0;
    rep(i, n)rep(j, n){
        dist[i][j] = sqrt(((x[i]-x[j]) * (x[i]-x[j])) + ((y[i]-y[j]) * (y[i]-y[j])));
        ans += dist[i][j];
    }

    ans /= n;
    cout << setprecision(16) << ans << endl;
    return 0;
}

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

using namespace std;
#define ll long long int
#define rep(i,n) for(i=0;i<(n);i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
typedef pair< ll, ll > lpair;

vector< ll > a;
ll k;
bool poss(ll sz)
{
    ll cnt = 0;
    for(auto x : a) cnt += (x - 1) / sz;

    if(cnt <= k) return true;
    return false;
}

void solve()
{
    ll n, i;
    cin >> n >> k;

    a.clear(); a.resize(n);
    rep(i, n) cin >> a[i];

    ll ma = -1;
    for(auto x : a) ma = max(ma, x);

    ll left = 1, right = ma;

    ll ans = ma;

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

        if(poss(mid))
        {
            ans = mid;
            right = mid - 1;
        }
        else left = mid + 1;
    }
    cout << ans << endl;
}

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

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

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

int main(){
    int n, m;
    cin >> n >> m;
    int ans = 0;
    if(n > m){
        ans += n;
        n--;
    }else{
        ans += m;
        m--;
    }
    if(n > m){
        ans += n;
    }else{
        ans += m;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    long long int x,k,d,count = 0,a;
    scanf("%lld %lld %lld",&x,&k,&d);
    if(x < 0)
    {
        x = -x;
    }
    if(x/d >= k)
    {
        printf("%lld\n",x-d*k);
    }
    else
    {
        k = k - x/d;
        x = x - (x/d)*d;
        
        if(k % 2 == 0)
        {
            printf("%lld\n",x);
        }
        else
        {
            printf("%lld\n",d-x);
        }
        
    }
    
    return 0;
}

Measured memory_bytes: 1732
def scanning_area(grid, length, point_list, stride_x, stride_y):
    area = [[0 for _ in range(length + 1)] for __ in range(length + 1)]
    max_length = 0

    for row, col in point_list:
        if grid[row][col] == "1":
            area[row + stride_y][col + stride_x] = area[row][col] + 1
            max_length = max(max_length, area[row + stride_y][col + stride_x])

    return max_length


def create_point_list(length):
    points = []

    for count, r in enumerate(range(length - 1, 0, -1), 1):
        row = r
        for col in range(0, count, 1):
            points.append((row, col))
            row += 1

    for index in range(0, length):
        points.append((index, index))

    for lp in range(1, length):
        row = 0
        for col in range(lp, length):
            points.append((row, col))
            row += 1

    return points


while True:

    length = int(input())

    if length == 0:
        break

    grid = [input() for _ in range(length)]

    point_list = [[row, col] for row in range(length) for col in range(length)]

    line_length1 = scanning_area(grid, length, point_list, 1, 0)
    line_length2 = scanning_area(grid, length, point_list, 0, 1)

    point_list = create_point_list(length)
    line_length3 = scanning_area(grid, length, point_list, 1, 1)
    point_list.reverse()
    line_length4 = scanning_area(grid, length, point_list, -1, 1)

    max_length = max(line_length1, line_length2, line_length3, line_length4)
    print(max_length)



Measured memory_bytes: 16084
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int a[5];
int main()
{
	scanf("%d%d%d",&a[1],&a[2],&a[3]);
	swap(a[1],a[2]); swap(a[1],a[3]);
	printf("%d %d %d\n",a[1],a[2],a[3]);
return 0;
}

Measured memory_bytes: 256
import collections, atexit, math, sys, bisect 
 
def getIntList():
    return list(map(int, input().split()))    
 
 
N, = getIntList()
#print(N)
za = []
for i in range(N):
    a = input()
    a = int(a)
    za.append(a)

za.sort()

if N%2==0:
    t = N//2
    s0 = sum(za[:t])
    s1 = sum(za[t:])
    res = s1*2 - s0 *2  - za[t] + za[t-1]
else:
    t = N//2 + 1
    s0 = sum(za[:t])
    s1 = sum(za[t:])
    res0 = s1 *2 - s0*2 + za[t-1] + za[t-2]
    t = t - 1
    s0 = sum(za[:t])
    s1 = sum(za[t:])
    res1 = s1 *2 - s0*2 -  za[t] - za[t+1]
    res = max(res1, res0)

print(res)
        




Measured memory_bytes: 7860
#include <stdio.h>
int n, a[25];
int main() {
	while(true) {
		scanf("%d", &n);
		if(n == 0) break;
		for(int i = 0; i < n; i++) scanf("%d", &a[i]);
		int c = 0, d = 32;
		while(d > 0) {
			if(c++ % 2 == 0) {
				d -= (d - 1) % 5;
			}
			else {
				d -= a[(c - 1) / 2 % n];
			}
			printf("%d\n", d > 0 ? d : 0);
		}
	}
	return 0;
}

Measured memory_bytes: 2572
#!/usr/bin/env python3

import sys

def solve(n, l, ls_s):
    print(''.join(sorted(ls_s)))


def readQuestion():
    ws = sys.stdin.readline().strip().split()
    n = int(ws[0])
    l = int(ws[1])
    ls_s = [sys.stdin.readline().strip().split()[0] for j in range(n)]
    return (n, l, ls_s,)

def main():
    solve(*readQuestion())

# Uncomment before submission
main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

ll WEIGHTS[110], VALUE[110];
ll DP[110][100100] = {0};

int main()
{
    ll N, W; cin >> N >> W;
    rep (i, 0, N) {
        cin >> WEIGHTS[i] >> VALUE[i];
    }

    rep (i, 0, N) {
        rrep (sum_w, 0, W) {
            if (sum_w - WEIGHTS[i] >= 0) {
                DP[i+1][sum_w] = max(DP[i+1][sum_w], DP[i][sum_w-WEIGHTS[i]] + VALUE[i]);
            }
            DP[i+1][sum_w] = max(DP[i+1][sum_w], DP[i][sum_w]);
        }
    }

    cout << DP[N][W] << endl;
}

Measured memory_bytes: 79360
#include <cstdlib>
#include <iostream>
#include <string>


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

  std::string s;
  std::cin >> s;
  std::cout << (s.rfind('Z') - s.find('A') + 1) << std::endl;

  return EXIT_SUCCESS;
}


Measured memory_bytes: 720
def get_prime_set(ub):
    from itertools import chain
    from math import sqrt

    if ub < 4:
        return ({}, {}, {2}, {2, 3})[ub]

    ub, ub_sqrt = ub+1, int(sqrt(ub))+1
    primes = {2, 3} | set(chain(range(5, ub, 6), range(7, ub, 6)))
    du = primes.difference_update
    for n in chain(range(5, ub_sqrt, 6), range(7, ub_sqrt, 6)):
        if n in primes:
            du(range(n*3, ub, n*2))

    return primes

def get_totient_count_range(ub, prime_set):
    ub, totient_count = ub+1, list(range(ub+1))

    for prime in prime_set:
        totient_count[prime] -= 1
        for m in range(prime*2, ub, prime):
            totient_count[m] = totient_count[m] * (prime-1) // prime
    return totient_count


import sys
from itertools import accumulate
ub = 10**6
primes = get_prime_set(ub)
a = get_totient_count_range(ub, primes)
a[1] = 2
a = list(accumulate(a))
input()
print(*(a[int(n)] for n in sys.stdin), sep="\n")


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

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

	string s;

	cin >> s;

	if(s=="ABC")
	{
		cout << "ARC" << '\n';
	}
	else
	{
		cout << "ABC" << '\n';
	}
	
	return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)




typedef long long ll;
int H, W, K;
string C[30];
//-----------------------------------------------------------------
char CC[30][31];
ll calc(int sx, int sy) {
	rep(i, 0, H) rep(j, 0, W + 1) CC[i][j] = C[i][j];

	ll ret = 0;
	int t = 0;
	CC[sy][sx] = '#';
	bool ok = true;
	while (ok) {
		ok = false;

		// 落とす
		rep(x, 0, W) {
			vector<char> c;
			rep(y, 0, H) {
				if (CC[y][x] != '#') {
					c.push_back(CC[y][x]);
					CC[y][x] = '#';
				}
			}
			reverse(c.begin(), c.end());
			rep(y, 0, c.size()) CC[H - 1 - y][x] = c[y];
		}

		// 消す
		rep(y, 0, H) {
			char pre = CC[y][0];
			int prei = 0;
			rep(x, 1, W + 1) {
				if (pre != CC[y][x]) {
					int d = x - prei;
					if (K <= d && pre != '#') {
						ret += (pre - '0') * (x - prei) * (1 << t);
						//cout << (pre - '0') * (x - prei) * (1 << t) << endl;
						rep(xx, prei, x) CC[y][xx] = '#';
						ok = true;
					}
					pre = CC[y][x];
					prei = x;
				}
			}
		}

		t++;
	}

	/*rep(i, 0, H) {
		rep(j, 0, W + 1) cout << CC[i][j];
		cout << endl;
	}*/

	return ret;
}
//-----------------------------------------------------------------
int main() {
	cin >> H >> W >> K;
	rep(i, 0, H) cin >> C[i];
	rep(i, 0, H) C[i] = C[i] + "@";

	ll ans = 0;
	rep(sy, 0, H)
	rep(sx, 0, W) ans = max(ans, calc(sx, sy));
	cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int P = N*N*N;

		System.out.println(P);

	}

}

Measured memory_bytes: 23252
import sys
s = input() + chr(96)

for j in range(len(s) - 1, -1, -1):
    sets = set(list(s[:j]))
    for i in range(ord(s[j]) + 1, ord('z') + 1):
        if chr(i) not in sets:
            print(s[:j] + chr(i))
            sys.exit(0)
print(-1)

Measured memory_bytes: 3060
use v5.18;
use warnings;
use List::Util qw( sum min );
sub read_line { chomp( my $str = <STDIN> ); $str }
sub splited_read_line { split / /, read_line }
use Data::Dumper;

my $n         = read_line;
my @orig_nums = splited_read_line;
my @nums =
  sort { $a->{num} <=> $b->{num} } map { +{ num => $orig_nums[$_], orig_index => $_ } } 0 .. $n - 1;
my %table = map { $nums[$_]->{orig_index} => $_ } 0 .. $n - 1;

sub medium_index {
  my $remove_index = shift;
  state $medium = int $n / 2;
  $remove_index < $medium ? $medium : $medium - 1;
}

for my $remove_index (0 .. $n - 1) {
  my $sorted_remove_index = $table{$remove_index};
  my $medium_index = medium_index $sorted_remove_index;
  say $nums[$medium_index]->{num}
}


Measured memory_bytes: 143424
from collections import deque

def bfs(que,d): #幅優先探索
  #いつもはここで定義
  #入力のグラフを初期化
  #d = [[float("inf")] * w for i in range(h)] 
  #que = deque([])
  #que.append((sx,sy))
  #d[sx][sy] = 0
  
  dx = [-1,0,0,1]
  dy = [0,-1,1,0]
  
  while que:
    lead_h,lead_w = que.popleft()
    lead = d[lead_h][lead_w]
    #lead == queの先頭にある要素を取り出す
    for i in range(4):
      nx = lead_w + dx[i]
      ny = lead_h + dy[i]
      if ny<0 or h<=ny or nx<0 or w<=nx:
        #範囲外の場合
        continue
      if d[ny][nx]==float("inf"):
        d[ny][nx] = lead + 1
        que.append((ny,nx))
  return lead

h, w = map(int, input().split())
maze = [list(input()) for i in range(h)]

#多点スタートなのでbfs()内で定義して初期化しない
d = [[float("inf")] * w for i in range(h)] 

#キューも同様
que = deque([])
for i in range(h):
  for j in range(w):
    if maze[i][j] == "#":
      que.append((i,j))
      #各"#"を入れる
      d[i][j] = 0

#print(bfs())
lead = bfs(que,d)
print(lead)

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

int N, K;
int64_t ans;

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

    ans = 0;
    int R = min(N, K);
    for(int A=0;A<=R;A++){
        for(int B=0;B<=R-A;B++){
            vector<int> v;
            int64_t res = 0;
            for(int i=0;i<A;i++)    v.push_back(V[i]);
            for(int i=0;i<B;i++)    v.push_back(V[N-1-i]);
            sort(v.begin(), v.end());
            int del = K - (A+B);
            for(int i=0;i<v.size();i++){
                if( del <= i || 0 < v[i] )   res += v[i];
            }
            ans = max(ans, res);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int[] tn = in.nextIntArray(n);
			int[] vn = in.nextIntArray(n);
			int T = 0;
			for (int i = 0;i < n; i++) T += tn[i];

			int m = 2 * T + 1;

			double[] maxV = new double[m];
//			int prt = 1;
//			for (int i = 0; i < n; i++) {
//				for (int k = 0 ; k < 2 * tn[i]; k++, prt++) {
//					maxV[prt] = vn[i];
//				}
//			}
			Arrays.fill(maxV, Double.MAX_VALUE);
			maxV[0] = maxV[m - 1] = 0;

			int tmpSum = 0;
			for (int i = 0; i < n; i++) {
				for (int j = 0; j <= 2 * tn[i]; j++) {
					maxV[tmpSum + j] = Math.min(maxV[tmpSum + j], vn[i]);
				}
				tmpSum += 2 * tn[i];
			}

			maxV[0] = 0;
			for (int i = 0; i < m - 1; i++) {
				maxV[i+1] = Math.min(maxV[i] + 0.5, maxV[i+1]);
			}

			maxV[m - 1] = 0;
			for (int i = m - 1; i > 0; i--) {
				maxV[i-1] = Math.min(maxV[i] + 0.5, maxV[i-1]);
			}

			double sum = 0;
			for (int i = 0; i < m - 1; i++) {
				sum += (maxV[i+1] + maxV[i]) * 0.5 / 2;
			}
			out.println(String.format("%.12f", sum));

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 23380
def f(S):
	x,u = S.split(" ")
	x = float(x)
	return x if u=="JPY" else x*380000.0
	

def main():
	N = input()
	print sum(f(raw_input()) for _ in range(N))
	
	return 0

if __name__ == '__main__':
	main()



Measured memory_bytes: 2568
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    W, H, x, y = map(int, input().split())
    # y = a * x + b
    try:
        a = (y - H / 2) / (x - W / 2)
        b = y - a * x
        X = -b / a
    except ZeroDivisionError:
        a, b = 0, 0
        X = x

    cnt = (1 if W / 2 == x and H / 2 == y else 0)
    area = (X + W - X) * H / 2

    print(area, cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

char mp[100];

int main()
{
	string str;cin >> str;
	int now = 0;
	REP(i,str.size())
	{
		if(str[i] == 'B')
		{
			if(now > 0)now--;
		}
		else
		{
			mp[now] = str[i];
			now++;
		}
	}
	
	REP(i,now)
	{
		cout << mp[i];
	}cout << endl;
	
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0027
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();

            int N = int.Parse(str);

            str = Console.ReadLine();

            var nums = str.Split(' ');

            for (int i = 0; i < nums.Length; i++)
            {
                int n = int.Parse(nums[i]);

                if (n % 2 == 0)
                {
                    if (n % 3 != 0 && n % 5 != 0)
                    {
                        Console.WriteLine("DENIED");
                        return;
                    }
                }
            }

            Console.WriteLine("APPROVED");
        }
    }
}


Measured memory_bytes: 27496
#![allow(non_snake_case, unused_macros, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,BTreeMap};

// Main
fn main(){
    input!{
        a: i32,
        op: String,
        b: i32,
    }
    let ans;
    if op=="+"{
        ans = a+b;
    }else{
        ans = a-b;
    }
    println!("{}", ans);
}




Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define fr(i1,m) for(int i1=0;i1<m;i1++)
using namespace std;
int main()
{
   long a,b;
   string s;
   while(cin>>a>>s>>b)
   {
      if(s[0]=='+')
        cout<<a+b<<"\n";
      else
        cout<<a-b<<"\n";

   }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b[10],x,k,i,j;
	scanf("%d",&a);
	for(i=0;i<a;i++){
		for(j=0;j<3;j++){
			scanf("%d",&b[j]);
		}
		x=0;
		for(j=0;j<3;j++){
			for(k=j+1;k<3;k++){
				if(b[j]>b[k]){
					x=b[j];
					b[j]=b[k];
					b[k]=x;
				}
			}
		}
		if(b[0]*b[0]+b[1]*b[1]==b[2]*b[2]){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    String s;
    String sl[];
    s = r.readLine();
    sl = s.split(" ");

    int a = Integer.parseInt(sl[0]);
    int b = Integer.parseInt(sl[1]);
    int c = Integer.parseInt(sl[2]);
    
    System.out.println((a <= c && b <= c) ? (a + b) : ((b <= a && c <= a) ? (b + c) : (a + c)));

  }

}

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

#define llint long long int

using namespace std;

int main(){
    string S;

    cin >> S;

    if(S[2] == S[3] && S[4] == S[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int x, y;
    cin >> x;
    cin >> y;
    cout << x + (y / 2) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N, K;
  cin>>N>>K;
  vector<Int> A(N);
  cin>>A;

  Int numA = 0;
  for(Int i=0;i<N;i++)
    for(Int j=i+1;j<N;j++) if(A[i] > A[j]) numA++;

  Int numB = 0;
  for(Int i=0;i<N;i++)
    for(Int j=0;j<N;j++) if(A[i] > A[j]) numB++;

  Int a = numA * K;
  Int b = numB * ((K * (K - 1) / 2) % mod);
  Int ans = (a + b)%mod;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <fstream>
#include <queue>
#include <math.h>
#include <set>
#include <stdlib.h>
#include <time.h>
#include <list>

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define chk(a) rep(i, a.size()) cout << a[i] << " "
#define SORT(c) sort((c).begin(),(c).end())
#define ll long long
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)


using namespace std;
typedef pair<int, int> pii;

int main(void) {

	int N;
	cin >> N;
	vector<int> v(2*N);
	rep(i, 2* N) {
		cin >> v[i];
	}

	int result = 0;
	SORT(v);
	rep(i, 2*N) {
		result += v[i];
		i++;
	}
	cout << result << endl;




	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


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

    ll N ;
    cin >> N ;
    ll ans = 0 ;
    ll m = 0;
    rep(i,N){
        ll inp;
        cin >> inp;
        ans += inp;
        m = max(m, inp);
    }
    cout << ans - m/2 << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>
 
// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std
 
Jehian Norman Saviero;
 
// MACROS TYPE
typedef long l;
typedef unsigned long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;
 
// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")
 
// MACROS FOR ATTRIBUTE
#define fi first
#define se second
 
// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))
 
// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

int main() {
	int N, M;
	sci(N), sci(M);
	int start;
	int finish;
	if (N == 1) {
		start = 0;
		finish = 9;
	} else {
		string s;
		s.resize(N, '0');
		s[0] = '1';
		sscanf(s.c_str(), "%d", &start);
		s.assign(N, '9');
		sscanf(s.c_str(), "%d", &finish);
	}
	vector<pi> rules(M);
	for (int i = 0; i < M; ++i) {
		sci(rules[i].fi), sci(rules[i].se);
		--rules[i].fi;
	}
	bool found = 0;
	for (int i = start; i <= finish && !found; ++i) {
		string s;
		ostringstream oss;
		oss << i;
		s = oss.str();
		bool valid = 1;
		for (int j = 0; j < M && valid; ++j) {
			valid = s[rules[j].fi] == (rules[j].se + '0');
		}
		if (valid) {
			found = 1;
			printf("%d\n", i);
		}
	}
	if (!found) {
		printf("%d\n", -1);
	}
	return 0;
}

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

int main(){
  int n;
  int k;
  cin >> n;
  cin >> k;
  int p[n]={};
  int x;
  for(int i=0;i<n;i++){
  	cin >> p[i];  
  }
  
  int v;
  for(int j=0;j<n;j++){
    for(int z=j+1;z<n;z++){
      if(p[j]>p[z]){
      	v=p[j];
        p[j]=p[z];
        p[z]=v;
      }
      
    }
  }
  int s=0;
  for(int l=0;l<k;l++){
  	s=s+p[l];
  }
  cout << s;

}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int x[105], y[105];

int main()
{
	int N;
	cin >> N;
	REP(i, N)
	{
		cin >> x[i];
	}
	REP(i, N)
	{
		cin >> y[i];
	}

	double d = 0;
	REP(i, N)
	{
		d += abs(x[i] - y[i]);
	}
	cout << OF64 << d << endl;
	d = 0;
	REP(i, N)
	{
		d += pow(x[i] - y[i], 2);
	}
	cout << OF64 << sqrt(d) << endl;

	d = 0;
	REP(i, N)
	{
		d += pow(abs(x[i] - y[i]), 3);
	}
	cout << OF64 << cbrt(d) << endl;

	d = 0;
	REP(i, N)
	{
		d = std::max((double)abs(x[i] - y[i]), d);
	}
	cout << OF64 << d << endl;
	return 0;
}


Measured memory_bytes: 3532
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#define N 110
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define inf 99999999
int n,GMatrices[N][N]={0};
int color[N],d[N];
struct queue
{
	int q[N];
	int head;
	int tail;
};
struct queue Q;
void bfs()
{
	Q.head=1;
	Q.tail=1;
	for(int i=1;i<=n;i++)
		color[i]=WHITE;
	for(int i=1;i<=n;i++)
		d[i]=inf;
	color[1]=GRAY;
	d[1]=0;
	Q.q[Q.tail]=1;
	Q.tail++;
	while(Q.head!=Q.tail)
	{
		for(int v=1;v<=n;v++)
			if(GMatrices[Q.q[Q.head]][v] && color[v]==WHITE)
			{
				color[v]=GRAY;
				d[v]=d[Q.q[Q.head]]+1;
				Q.q[Q.tail]=v;
				Q.tail++;
			}
		color[Q.q[Q.head]]=BLACK;
		Q.head++;
	}
	return;
}
int main()
{
	
	int u,k,v;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d %d",&u,&k);
		for(int j=1;j<=k;j++)
		{
			scanf("%d",&v);
			GMatrices[u][v]=1;
		}
	}
	bfs();
	for(int i=1;i<=n;i++)
		if(d[i]!=inf)
			printf("%d %d\n",i,d[i]);
		else
			printf("%d %d\n",i,-1);
	return 0;
}


Measured memory_bytes: 2148
#include<iostream>
#include<string>
using namespace std;
using ll = long long;
ll INF = 1000000007;

int main() {
	int n, now = 0;
	cin >> n;
	string s, t;
	cin >> s >> t;
	ll ans = 0;
	int pat = 0;
	if (s[0] == s[1]) {
		ans = 6;
		now = 2;
	}
	else {
		ans = 3;
		now = 1;
		pat = 1;
	}
	for (int i = now;i < n;i = now) {
		if(s[i]==t[i]) {//
			if(pat==1)ans *= 2;
			ans %= INF;
			pat = 1;
			now++;
		}else {
			if (pat == 0) {
				ans *= 3;
				ans %= INF;
			}
			else {
				ans *= 2;
				ans %= INF;
			}
			pat = 0;
			now += 2;
		}
	}
	cout << ans << endl;
}

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

int n,a[100010],ans;
bool b[100010];

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	
	for(int t=0;t<2;t++)
		for(int i=1;i<=n;i++)
		{
			int cur=0;bool f=0;
			while(i<=n&&a[i]==i&&a[i+1]!=i&&a[i]!=i+1) swap(a[i],a[i+1]),i++,cur++,f=1;
			if(f) i--,ans=ans+(cur==1?1:cur-1);
		}
	
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n; cin >> n;
	set<vi> s;
	rep(i, n){
		vi v(3); rep(j, 3) cin >> v[j];
		sort(all(v));
		s.insert(v);
	}
	cout << n - s.size() << endl;
	return 0;
}


Measured memory_bytes: 3296
#include <iostream>
#include <cmath>

int main(){
  int n;
  double t, a, hoge, min = 1e+5;
  double h[100000];
  std::cin >> n >> t >> a;
  for(int i = 0; i < n; i++){
    std::cin >> h[i];
    if(min > abs(a - (t - h[i] * 0.006))){
      min = abs(a - (t - h[i] * 0.006));
      hoge = i;
    }
  }
  std::cout << hoge + 1 << std::endl;
}

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


typedef struct node {
    int key;
    struct node *left;
    struct node *right;
} Tree;

Tree *root = NULL;

Tree *make1node(int key) {
    Tree *tree = malloc(sizeof(struct node));
    tree->key = key;
    tree->left = NULL;
    tree->right = NULL;
    return tree;
}

void insert(Tree *tree) {
    Tree *x, *y;
    y = NULL;
    x = root;
    while (x != NULL) {
        y = x;
        if (tree->key < x->key) x = x->left;
        else x = x->right;
    }
    if (y == NULL) root = tree;
    else if (tree->key < y->key) y->left = tree;
    else y->right = tree;
}

int find(Tree *tree, int key) {
  if (tree == NULL) return 0;
  if (tree->key == key) return 1;
  if(key < tree->key) return find(tree->left, key);
  else return find(tree->right, key);
}

void printleft(Tree *tree) {
    if (tree->left != NULL) printleft(tree->left);
    printf(" %d", tree->key);
    if (tree->right != NULL) printleft(tree->right);
}

void printmid(Tree *tree) {
    printf(" %d", tree->key);
    if (tree->left != NULL) printmid(tree->left);
    if (tree->right != NULL) printmid(tree->right);
}

void printtree(Tree *tree) {
    printleft(tree);
    printf("\n");
    printmid(tree);
    printf("\n");
}

int main(void){
  int n, key, i, j, find_key[500000], find_key_num = 0, before = 0;
    char command[7];
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        scanf("%s", command);
        if (!strcmp(command, "insert")) {
            scanf("%d", &key);
            insert(make1node(key));
	} else if (!strcmp(command, "find")) {
            scanf("%d", &key);
            find_key[find_key_num] = key;
	    find_key_num++;
        } else {
	  for (j = before; j < find_key_num; j++) {
	    if (find(root, find_key[j])) {
	      printf("yes\n");
	    } else {
	      printf("no\n");
	    }
	  }
	  before = find_key_num;
            printtree(root);
        }
    }
    	  for (j = before; j < find_key_num; j++) {
	    if (find(root, find_key[j])) {
	      printf("yes\n");
	    } else {
	      printf("no\n");
	    }
	  }
	  return 0;
}


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

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

using namespace std;

int main(){
  int n;
  cin>>n;
  if(n/10==9 || n%10==9){
    cout<<"Yes";
  }else{
    cout<<"No";
  }

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <functional>

long long v[4][101];

int main()
{
  int n;
  long long W;
  long long w1;
  long long count[4] = {1, 0, 0, 0};
  scanf("%d%lld%lld%lld", &n, &W, &w1, &v[0][1]);
  for (int i = 1; i < n; ++i)
  {
    long long a, b;
    scanf("%lld%lld", &a, &b);
    count[a - w1]++;
    v[a - w1][count[a - w1]] = b;
  }
  for (int i = 0; i < 4; ++i)
  {
    std::sort(v[i] + 1, v[i] + 1 + count[i], std::greater<long long>());
    for (int j = 1; j <= count[i]; ++j)
    {
      v[i][j] += v[i][j - 1];
    }
  }
  
  long long ans = 0;
  for (long long a = 0; a <= count[0]; ++a)
  {
    for (long long b = 0; b <= count[1]; ++b)
    {
      for (long long c = 0; c <= count[2]; ++c)
      {
        if (a * w1 + b * (w1 + 1) + c * (w1 + 2) > W) break;
        long long d = (W - (a * w1 + b * (w1 + 1) + c * (w1 + 2))) / (w1 + 3);
        ans = std::max(ans, v[0][a] + v[1][b] + v[2][c] + v[3][d]);
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
using namespace std;

struct Node{
	Node *left,*right;
	Node(){
		left = right = NULL;
	}
};

Node *getTree(string line){
	if(line=="" || line=="(" || line==")")return NULL;
	Node *newNode = new Node();
	int b = 0;
	stack<int> cnt;
	while(line[b]!=0){
		if(line[b]=='('){
			cnt.push(1);
		}else if(line[b]==')'){
			cnt.pop();
		}else{
			if(cnt.size()==1)break;
		}	
		b++;
	}
	string S_R = "", S_L = "";
	for(int x=1;x<b;++x){
		S_L += line[x];
	}
	for(int x=b+1;x<line.size()-1;++x){
		S_R += line[x];
	}
	newNode->left = getTree(S_L);
	newNode->right = getTree(S_R);
	return newNode;
}

Node *unionT(Node* treeA,Node* treeB){
	if(treeA == NULL && treeB==NULL)return NULL;
	Node *newNode = new Node();
	Node *ll,*rl,*lr,*rr;
	if(treeA == NULL){
		ll = NULL;
		lr = NULL;
	}else{
		ll = treeA->left;
		lr = treeA->right;
	}
	if(treeB == NULL){
		rl = NULL;
		rr = NULL;
	}else{		
		rl = treeB->left;
		rr = treeB->right;
	}
	newNode->left = unionT(ll,rl);
	newNode->right = unionT(lr,rr);
	return newNode;
}

Node *interT(Node* treeA,Node* treeB){
	if(treeA == NULL || treeB == NULL)return NULL;
	Node *newNode = new Node();	
	Node *ll = treeA->left, *lr = treeA->right, *rl = treeB->left, *rr = treeB->right;
	newNode->left = interT(ll,rl);
	newNode->right = interT(lr,rr);
	return newNode;
}

string imp(Node *root){
	if(root==NULL)return "";
	stringstream buf;
	buf<<"("<<imp(root->left)<<","<<imp(root->right)<<")";
	return buf.str();
}

int main(){
	char c;
	string s1,s2;
	while(scanf(" %c ",&c)!=EOF){
		cin>>s1>>s2;
		Node *treeA,*treeB,*treeC=NULL;
		treeA = getTree(s1);
		treeB = getTree(s2);
		if(c=='u'){
			treeC = unionT(treeA,treeB);
		}else{
			treeC = interT(treeA,treeB);
		}
		cout<<imp(treeC)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1380
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template <typename T> struct Segtree {
    inline T merge(T a, T b) { return a.first > b.first ? a : b; }
    inline void act(T &a, T b) { a = b; }
    vector<T> dat;
    int n;
    T e;
    Segtree(int n_, T e) : e(e) {
        n = 1;
        while (n < n_) {
            n <<= 1;
        }
        dat.resize(2 * n, e);
    }
    void set(const int &a, const int &b, const T &x, int k, int l, int r) {
        if (b <= l || r <= a) {
            return;
        }
        if (a <= l && r <= b) {
            act(dat[k], x);
            return;
        }
        set(a, b, x, k << 1, l, (l + r) >> 1);
        set(a, b, x, k << 1 | 1, (l + r) >> 1, r);
    }
    inline void set(const int &a, const int &b, const T &x) {
        if (a >= b) {
            return;
        }
        set(a, b, x, 1, 0, n);
    }
    T get(int k) {
        k += n;
        T res = dat[k];
        k >>= 1;
        while (k > 0) {
            res = merge(res, dat[k]);
            k >>= 1;
        }
        return res;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    Segtree<P> seg(n, P(-1, (1LL << 31) - 1LL));
    for (int k = 0; k < q; k++) {
        int t;
        cin >> t;
        if (t == 0) {
            int l, r, x;
            cin >> l >> r >> x;
            ++r;
            seg.set(l, r, P(k, x));
        } else {
            int i;
            cin >> i;
            cout << seg.get(i).second << "\n";
        }
    }
}


Measured memory_bytes: 4904
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int t = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        Integer[] h = new Integer[n];
        for (int i = 0; i < n; i++) {
            h[i] = Integer.parseInt(sc.next());
        }

        Double[] temperature = new Double[n];
        double min = 100000.0;
        int result = 0;
        for (int i = 0; i < n; i++) {
            temperature[i] = ((double) t - (h[i] * 0.006));
            double difference = Math.abs((double) a - temperature[i]);
            if (min > difference) {
                min = difference;
                result = i + 1;
            }
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 21972