akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var A = sc.ReadInt();
        var B = sc.ReadInt();
        if (A % 2 == 0 || B % 2 == 0)
        {
            Console.WriteLine("No");
        }
        else
        {
            Console.WriteLine("Yes");
        }
    }
    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


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

const int maxlog=62,maxn=200005;
int n;
long long k,pow2[maxlog+1]={1};
int d[maxn][maxlog+1];

int main()
{
	for(int i=1;i<=maxlog;i++) pow2[i]=pow2[i-1]+pow2[i-1];
	scanf("%d%lld",&n,&k);int q=1;
	for(int i=1;i<=n;i++)
		scanf("%d",&d[i][0]);
	for(int i=1;i<=maxlog;i++)
		for(int j=1;j<=n;j++)
			d[j][i]=d[d[j][i-1]][i-1];
	while(q--)
	{
		int p=maxlog,pos=1;
		while(k>0)
		{
			while(pow2[p]>k) p--;
			pos=d[pos][p];
			k-=pow2[p];
		}
		printf("%d\n",pos);
	}
	return 0;
}

Measured memory_bytes: 52928
#include <iostream>
using namespace std;
long long a,b,k;
int main()
{
    cin>>a>>b>>k;
    if (a<=k)
    {
        cout<<0<<" ";
        if (b-(k-a)>=0) cout<<b-(k-a);
        else cout<<0;
    }
    else cout<<a-k<<" "<<b;
}


Measured memory_bytes: 256
n= list(map(int, input()))
if sum(n) == 7:
    print(str(n[0]) + '+' +  str(n[1]) + '+' + str(n[2]) + '+' + str(n[3]) + '=' + str(7))
    exit()
if n[0] + n[1] + n[2] - n[3] == 7:
    print(str(n[0]) + '+' +  str(n[1]) + '+' + str(n[2]) + '-' + str(n[3]) + '=' + str(7))
    exit()
if n[0] + n[1] - n[2] - n[3] == 7:
    print(str(n[0]) + '+' +  str(n[1]) + '-' + str(n[2]) + '-' + str(n[3]) + '=' + str(7))
    exit()
if n[0] - n[1] - n[2] - n[3] == 7:
    print(str(n[0]) + '-' +  str(n[1]) + '-' + str(n[2]) + '-' + str(n[3]) + '=' + str(7))
    exit()
if n[0] - n[1] - n[2] + n[3] == 7:
    print(str(n[0]) + '-' +  str(n[1]) + '-' + str(n[2]) + '+' + str(n[3]) + '=' + str(7))
    exit()
if n[0] - n[1] + n[2] + n[3] == 7:
    print(str(n[0]) + '-' +  str(n[1]) + '+' + str(n[2]) + '+' + str(n[3]) + '=' + str(7))
    exit()
if n[0] - n[1] + n[2] - n[3] == 7:
    print(str(n[0]) + '-' +  str(n[1]) + '+' + str(n[2]) + '-' + str(n[3]) + '=' + str(7))
    exit()
if n[0] + n[1] - n[2] + n[3] == 7:
    print(str(n[0]) + '+' +  str(n[1]) + '-' + str(n[2]) + '+' + str(n[3]) + '=' + str(7))
    exit()

Measured memory_bytes: 3192
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<numeric>

using namespace std;

typedef long long LL;

struct edge {
	int to;
	int cost;
};

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

int main(void) {
	int n;
	cin >> n;
	vector<int>a(n);
	LL ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		while (a[i] % 2 == 0) {
			a[i] /= 2;
			ans++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

enum Direction {R, L, U, D};

bool input(char b[][5])
{
	char dummy;
	for (int i=0; i<9; i++) {
		for (int j=0; j<5; j++) {
			if ((i&1)==0 && j==4) continue;
			if ( !(cin >> b[i][j]) ) return false;
		}
		//cin >> dummy;
	}
	return true;
}

int main()
{
	char board[9][5];
	input(board);
	
	pair<int, int> curr_pos(0,0);
	enum Direction curr_dir = R;
	cout << "R";
	
	do {
		switch (curr_dir) {
		case R:
			// priority : U > R > D > L
			if ( curr_pos.first > 0 && board[curr_pos.first-1][curr_pos.second+1] == '1' ) {
				curr_dir = U; cout << "U"; curr_pos.first--; curr_pos.second++;
			} else if ( curr_pos.second < 3 && board[curr_pos.first][curr_pos.second+1] == '1' ){
				curr_dir = R; cout << "R"; curr_pos.second++;
			} else if ( curr_pos.first < 8 && board[curr_pos.first+1][curr_pos.second+1] == '1' ) {
				curr_dir = D; cout << "D"; curr_pos.first++; curr_pos.second++;
			} else {
				curr_dir = L; cout << "L";
			}
			break;
		case L:
			// priority : D > L > U > R
			if ( curr_pos.first < 8 && board[curr_pos.first+1][curr_pos.second] == '1' ) {
				curr_dir = D; cout << "D"; curr_pos.first++;
			} else if ( curr_pos.second > 0 && board[curr_pos.first][curr_pos.second-1] == '1' ) {
				curr_dir = L; cout << "L"; curr_pos.second--;
			} else if ( curr_pos.first > 0 && board[curr_pos.first-1][curr_pos.second] == '1' ) {
				curr_dir = U; cout << "U"; curr_pos.first--;
			} else {
				curr_dir = R; cout << "R";
			}
			break;
		case U:
			// priority : L > U > R > D
			if ( curr_pos.second > 0 && board[curr_pos.first-1][curr_pos.second-1] == '1' ) {
				curr_dir = L; cout << "L"; curr_pos.first--; curr_pos.second--;
			} else if ( curr_pos.first > 2 && board[curr_pos.first-2][curr_pos.second] == '1' ) {
				curr_dir = U; cout << "U"; curr_pos.first-=2;
			} else if ( curr_pos.second < 4 && board[curr_pos.first-1][curr_pos.second] == '1' ) {
				curr_dir = R; cout << "R"; curr_pos.first--;
			} else {
				curr_dir = D; cout << "D";
			}
			break;
		case D:
			// priority : R > D > L > U
			if ( curr_pos.second < 4 &&  board[curr_pos.first+1][curr_pos.second] == '1' ) {
				curr_dir = R; cout << "R"; curr_pos.first++;
			} else if ( curr_pos.first < 6 && board[curr_pos.first+2][curr_pos.second] == '1' ) {
				curr_dir = D; cout << "D"; curr_pos.first+=2;
			} else if ( curr_pos.second > 0 && board[curr_pos.first+1][curr_pos.second-1] == '1' ) {
				curr_dir = L; cout << "L"; curr_pos.first++; curr_pos.second--;
			} else {
				curr_dir = U; cout << "U";
			}
			break;
		}
	} while ( curr_pos.first != 0 || curr_pos.second != 0 );
	
	cout << endl;
	
	return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int X=in(),Y=in(),A=in(),B=in(),C=in();
	vector<ll> P=vecin<ll>(A),Q=vecin<ll>(B),R=vecin<ll>(C);
	sort(ALL(P),greater<ll>());
	sort(ALL(Q),greater<ll>());
	sort(ALL(R),greater<ll>());
	
	priority_queue<ll> RQ;
	priority_queue<ll,vector<ll>,greater<ll>> PQ,QQ;
	ll S=0;
	REP(i,X) PQ.push(P[i]),S+=P[i];
	REP(i,Y) QQ.push(Q[i]),S+=Q[i];
	REP(i,C) RQ.push(R[i]);

	while(!RQ.empty()){
		auto PV=PQ.top(),RV=RQ.top(),QV=QQ.top();
		RQ.pop();
		if(PV<=QV){
			if(PV<RV){
				PQ.pop();
				S += RV-PV;
				PQ.push(RV);
			}
			else break;
		}
		else{
			if(QV<RV){
				QQ.pop();
				S += RV-QV;
				QQ.push(RV);
			}
			else break;
		}
	}

	out(S);
	return 0;
}


Measured memory_bytes: 5620
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

const ld pi = 3.141592653589793;

int w[4];

int main() {
  for (int i = 0; i < 4; i++) {
    cin >> w[i];
  }

  if (w[0] + w[1] > w[2] + w[3]) {
    cout << "Left" << endl;
    return 0;
  }
  if (w[0] + w[1] == w[2] + w[3]) {
    cout << "Balanced" << endl;
    return 0;
  }

  if (w[0] + w[1] < w[2] + w[3]) {
    cout << "Right" << endl;
    return 0;
  }
}

Measured memory_bytes: 3612
R,G,B,N = [int(c) for c in input().split()]
cnt = 0
for r in range(N//R+1):
    for g in range((N-r*R)//G+1):
        if r*R+g*G <= N and (N-r*R-g*G)%B == 0:
            cnt += 1
print(cnt)

Measured memory_bytes: 67368
// type a
//a...AC狙い
//b...自信がない
//c...お試し
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
// ===============================================================
//using系
#pragma region header
using namespace std;
using ll = long long;
using lint = long long;
using ld = long double;
using ulint = unsigned long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr lint mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#define INF (lint)10000000000000000
#define mod = (int)1000000007;
#pragma endregion

int n;
vector<vector<pair<int, int>>> d;
void input() {
	cin >> n;
	d.resize(n);
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		d[i].resize(x);
		for (int j = 0; j < x; j++) {
			int y; cin >> y;
			int z; cin >> z;
			d[i].push_back({ y,z });
		}
	}
	return;
}
bool s[20];
int ans;
int cnt;
int solve() {
	ans = 0;
	for (int a = 0; a < (1 << n); a++) {
		cnt = 0;
		for (int i = 0; i < n; i++) {
			if ((a >> i) & 1) {
				s[i] = 1;
				cnt++;
			}
			else 
				s[i] = 0;
		}
		bool h = true;
		for (int i = 0; i < n; i++) {
			if (s[i]) {
				for (int j = 0; j < (int)d[i].size(); j++) {
					if (s[d[i][j].first - 1] != (bool)d[i][j].second) {
						h = false;
						goto kaage;
					}
				}
			}
		}
		if (h) 
			ans = max(ans, cnt);
	kaage:;
	}
	return ans;
}

int main(void) {
	input();
	printf("%d\n", solve());

	return 0;
}

Measured memory_bytes: 3752
// #pragma GCC optimize "trapv" Uncomment when dealing with huge numbers
/*<----------PBDS---------->
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
template <typename T>
using order_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
 
order_set<datatype>oset;
Kth smallest : *oset.find_by_order(k-1); // 0 based index
No of elements less than k : oset.order_of_key(k);
Erase X : oset.erase(x)
<----------PBDS---------->*/
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define lcm(a,b) (a*b)/gcd(a,b)
#define int long long
#define bits(x) __builtin_popcountll(x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int power(int x, int y, int p)  
{  
    int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
int32_t main()
{
    #ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
    int n;
    cin >> n;
    string s;
    cin >> s;
    int r = 0,g = 0,b = 0;
    for(int i = 0 ; i < n ; i++ ){
      if(s[i]=='R'){
        r++;
      }
      else if(s[i]=='G'){
        g++;
      }
      else{
        b++;
      }
    }
    int ans = r*g*b;
    for(int i = 0 ; i < n ; i++ ){
      for(int j = 0 ; j < i ; j++ ){
        int diff = i-j;
        if(i+diff < n && s[i]!=s[j] && s[j]!=s[i+diff] && s[i+diff]!=s[i]){
          ans--;
        }
      }
    }
   cout << ans;
}


Measured memory_bytes: 3628
#include<stdio.h>

int ip[20000], a[20000], b[20000];

int main(void){
    int i, N, p;
    
    scanf("%d", &N);
    
    for(i = 0; i < N ; i++){
        scanf("%d", &p);
        ip[p - 1] = i;
    }
    
    for(i = 0; i < N; i++){
        a[i] = b[N - i - 1] = 20000 * i + 1;
    }
    
    for(i = 0; i < N; i++) a[i] += ip[i];
    
    
    printf("%ld", a[0]);
    for(i = 1; i < N; i++) printf(" %ld", a[i]);
    printf("\n%ld", b[0]);
    for(i = 1; i < N; i++) printf(" %ld", b[i]);
    printf("\n");

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
     int n;
     cin >> n;
     
     set<int> st;
     while (n--) {
         char c;
         cin >> c;
         st.insert(c);
     }
     
     if (SZ(st) == 3) {
         cout << "Three\n";
     } else {
         cout << "Four\n";
     }
}


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


int main() {
    int n, k;
    cin >> n >> k;
    int count = 0;
    rep (i, n) {
        int h;
        cin >> h;
        if (h >= k) {
            count++;
        }
    }
    cout << count << "\n";
}

Measured memory_bytes: 256
def swap(s, t) :
  for i in range(L) : 
    if (s[i] < t[i]) : 
      return True
    elif (s[i] > t[i]) :
      return False
  return True

def strsort(s) : 
  for i in range(N) : 
    j = N - 1
    while j > i :
      if swap(s[j], s[j - 1]) : 
        tmp = s[j - 1]
        s[j - 1] = s[j]
        s[j] = tmp
      j -= 1


str = input()
lis = str.split(" ")
N = int(lis[0])
L = int(lis[1])
s = list()

for i in range(N) :
  s.append(input())
  
strsort(s)

print("".join(s))

Measured memory_bytes: 3064
#[allow(dead_code)]
fn main() {
    let nn= i::u();
    let mm= i::u();
    let xxyy = i::iv(mm*2);

    let mut boxespos:Vec<i32> = vec![0; nn+1];
    let mut boxesnum:Vec<i32> = vec![0; nn+1];
    boxespos[1]=1;//個目
    boxesnum[1]=1;
    for num in 1..nn {
        boxespos[num+1]=0;
        boxesnum[num+1]=1;
    }
    let mut count=0;
    for num in 0..mm {
        let xx=xxyy[num*2];
        let yy=xxyy[num*2+1];

        if (boxespos[xx as usize]==0){
            //eikyounashi
        }else{
            if (boxesnum[xx as usize]==1){
                boxespos[xx as usize]=0;
            }else{

            }
            boxespos[yy as usize ]=1;
        }
        boxesnum[xx as usize]=boxesnum[xx as usize]-1;
        boxesnum[yy as usize]=boxesnum[yy as usize]+1;
    }
    let mut count=0;
    for num in 0..nn {
        if (boxespos[num+1]!=0){
            count+=1;
        }
    }
    println!("{}",count);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;


#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i32() -> i32 {
        read()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}

Measured memory_bytes: 6396
///******* In the name of Allah *******///

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

int main()
{
  int m,n,i,j,k,a[13],sum = 0;
  cin>>n;
  for(i=1;i<=n;i++)
  {
     cin>>a[i];
  }
  sort(a+1,a+n+1);
  for(i=1;i<n;i++)
  {
     sum = sum + a[i];
  }
  if(a[n]<sum)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
// ITP2_1_A Vector

import java.util.Arrays;
import java.util.Scanner;

class Vector {
  int[] A;
  int length = 0;

  Vector() {
    A = new int[20];
  }

  void add(int x) {
    if (length == A.length) {
      A = Arrays.copyOf(A, length * 2);
    }
    A[length] = x;
    length++;
  }

  // pre : length > 0
  void deleteBack() {
    length--;
  }

  public String toString() {
    StringBuilder sb = new StringBuilder();
    if (length > 0) sb.append(A[0]);
    for (int i = 1; i < length; ++i) {
      sb.append(" ");
      sb.append(A[i]);
    }
    return sb.toString();
  }
}

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt(), q = sc.nextInt();
    Vector[] v = new Vector[n];
    boolean[] active = new boolean[n];

    for (int i = 0; i < q; ++i) {
      int req = sc.nextInt(), t = sc.nextInt();
      switch (req) {
        case 0:
          if (!active[t]) {
            v[t] = new Vector();
            active[t] = true;
          }
          v[t].add(sc.nextInt());
          break;
        case 1:
          if (active[t]) System.out.println(v[t]);
          else System.out.println();
          break;
        case 2:
          active[t] = false;
          break;
      }
    }
  }
}


Measured memory_bytes: 295596
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static void WriteLine(object obj) {
#if DEBUG
        Debug.WriteLine(obj.ToString());
#else
        Console.WriteLine(obj.ToString());
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var n     = int.Parse(spl[0]);
        var m     = int.Parse(spl[1]);

        var list = new List<Store>();

        for(int i=0; i<n; i++) {
            var s = new Store();

            spl   = input.ReadLine().Split(' ');
            s.a   = int.Parse(spl[0]);
            s.b   = int.Parse(spl[1]);

            list.Add(s);
        }

        list.Sort((x, y) => x.a.CompareTo(y.a));

        var c = 0L;
        var mo = 0L;
        foreach(var s in list) {
            mo += s.a * Math.Min(s.b, m - c);
            c += s.b;
            if (c >= m) break;
        }

        return mo;
    }

    class Store
    {
        public int a;
        public int b;
    }
}

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

int N, S;

int main(){
   while ( cin >> N && N>0){
      int M, m, addup, i;
      M = -1;
      m = 1001;
      addup = 0;
      for ( i = 0; i<N; i++){
         cin >> S;
         addup += S;
         if ( S > M) M = S;
         if ( S < m) m = S;
      }
   cout << (addup - M - m)/(N-2)  << endl;
   }
}

Measured memory_bytes: 1160
def bellman_ford(num, start):
    dist = [float("inf") for i in range(num)]
    path = [float("inf") for i in range(num)]
    dist[start] = 0
    while 1:
        update = False
        for i, j, k in adj:
            if dist[j-1] > dist[i-1] + k:
                dist[j-1] = dist[i-1] + k
                path[j-1] = [i, j]
                update = True
            if dist[i-1] > dist[j-1] + k:
                dist[i-1] = dist[j-1] + k
                path[i-1] = [j, i]
                update = True
        if not update:
            break
    return path

n, m = map(int, input().split(" "))
adj = []
all_path = []
for i in range(m):
    a, b, c = map(int, input().split(" "))
    adj.append([a, b, c])
    all_path.append([a, b])
    all_path.append([b, a])
for i in range(n):
    p = bellman_ford(n, i)
    for j in range(n):
        if p[j] in all_path:
            m -= 1
            all_path.remove(p[j])
            all_path.remove([p[j][1], p[j][0]])
print(m)

Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main(){

    for(int n, m; cin >> n >> m, n;){
        vll A(n);
        ll ans = -1;
        for(int i = 0; i < n; i++)cin >> A[i];
        for(int i = 0; i < n; i++){
            for(int j = i + 1; j < n; j++){
                if(A[i] + A[j] <= m)ans = max(ans, A[i]+A[j]);
            }
        }
        if(ans < 0)cout <<"NONE"<<endl;
        else cout << ans << endl;
    }    

    return 0;
}


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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
 ll gcd(ll a,ll b){
 if(b == 0) return a;
 return gcd(b,a%b);
 }

//最小公倍数
 ll lcm(ll a,ll b){
 ll g = gcd(a,b);
 return a / g * b; // Be careful not to overflow  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 

#define INF 1LL<<60



  int main(){
    int N, K;
    cin >> N >> K;
    vector<int>a(N);
    REP(i, N) cin >> a.at(i);

    vector<ll>v(N + 1, 0);
    REP(i, N) v.at(i + 1) = v.at(i) + a.at(i);
    vector<ll>w(N + 1, 0);
    REP(i, N) w.at(i + 1) = w.at(i) + max(a.at(i), 0);
    ll ans = - INF;
    for(int i = 0; i + K <= N; i++){
      ll tmp = w.at(N);
      tmp -= w.at(i + K) - w.at(i);
      tmp += max(v.at(i + K) - v.at(i), 0ll);
      ans = max(ans, tmp);
    }
    print(ans);
  }


Measured memory_bytes: 2176
#include <stdio.h>

int main(void){
    char s[80];
    char t[80];
    int i;
    scanf("%s",s);
    scanf("%s",t);
    
    for(i = 0; s[i] != '\0'; i++){
        if(s[i] != t[i]){
           printf("No\n");
           return(0);
        }
    }
    if(t[i+1] == '\0'){
        printf("Yes\n");
    }
    else printf("No\n");
    return(0);
}

Measured memory_bytes: 1664
use std::io::stdin;

fn main() {
    let mut s = String::new();

    stdin().read_line(&mut s).ok();
    let n: i32 = s.trim().parse().ok().unwrap();
    s.clear();

    let mut mochis: Vec<i32> = Vec::new();
    for _ in 0..n {
        stdin().read_line(&mut s).ok();
        let mochi: i32 = s.trim().parse().ok().unwrap();
        mochis.push(mochi);
        s.clear();
    }
    mochis.sort();

    let mut cnt = 0;
    let mut temp_mochi = -1;
    for mochi in mochis {
        if mochi != temp_mochi {
             cnt += 1;
        }
        temp_mochi = mochi;
    }

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


Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

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

// 最大公約数
ll gcd(ll a, ll b) {
    if (a % b == 0) {
        return (b);
    } else {
        return (gcd(b, a % b));
    }
}

ll dp[100010][2];
ll n, a[100010];

int main() {
    scanf("%lld", &n);
    rep(i, n) scanf("%lld", &a[i]);

    rep(i, n) {
        if (i == 0) {
            dp[i][0] = a[i];
            continue;
        }
        dp[i][0] = gcd(dp[i - 1][0], a[i]);
        if (i == 1) {
            dp[i][1] = a[i];
        } else {
            dp[i][1] = max(gcd(dp[i - 1][1], a[i]), gcd(dp[i - 2][0], a[i]));
        }
    }

    printf("%lld\n", max(dp[n - 1][1], dp[n - 2][0]));

    /* --------------------------------- */
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define CLR(a) memset(a,0,sizeof(a))
#define DBG(x) cout<<(#x)<<"="<<x<<endl
#define FOR(i,a,b)  for(int i=(a);i<(b);i++)
#define REP(i,a,b)  for(int i=(a);i<=(b);i++)
#define DOWN(i,a,b) for(int i=(a);i>=(b);i--)

using namespace std;

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

const double eps=1e-8;
const int INF=0x3f3f3f3f;
const ll LL_INf=0x3f3f3f3f3f3f3f3f;
const ll mod=1000000009;
const int N=100000+10;

int n;
string str;
ll ans,a[N];

int main(){

	cin>>n;
	FOR(i,0,n) {
		cin>>str;
		if (str[0]=='M') a[0]++;
		if (str[0]=='A') a[1]++;
		if (str[0]=='R') a[2]++;
		if (str[0]=='C') a[3]++;
		if (str[0]=='H') a[4]++;
	}

	FOR(i,0,5){
		FOR(j,i+1,5){
			FOR(k,j+1,5){
				ans+=a[i]*a[j]*a[k];
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#East[north][top] -> E
class Dice():
 East = [ [0,3,5,2,4,0]
		 ,[4,0,1,6,0,3]
		 ,[2,6,0,0,1,5]
		 ,[5,1,0,0,6,2]
		 ,[3,0,6,1,0,4]
		 ,[0,4,2,5,3,0]
		 ]
 def __init__(self,N):
  self.label = N
  self.top = 1
  self.north = 5
 def move(self,ori):
  #print(self.top,self.north,ori)
  if ori=='S':
   t = self.top
   self.top = self.north
   self.north = 7-t
  elif ori=='N':
   t = self.top
   self.top = 7-self.north
   self.north = t
  elif ori=='E':
   east = self.East[self.north-1][self.top-1]
   self.top = 7-east
  elif ori=='W':
   east = self.East[self.north-1][self.top-1]
   self.top = east
# Clockwise
  elif ori=='C': 
   east = self.East[self.north-1][self.top-1]
   self.north = east
 def gettop(self):
  return( self.label[self.top-1] )
 def getbottom(self):
  return( self.label[6-self.top] )
 def getnorth(self):
  return( self.label[self.north-1] )
 def getsouth(self):
  return( self.label[6-self.north] )
 def geteast(self):
  east = self.East[self.north-1][self.top-1]
  return( self.label[east-1] )
 def getwest(self):
  east = self.East[self.north-1][self.top-1]
  return( self.label[6-east] )

label = list(map(int, input().split() ))
D = Dice(label)
label = list(map(int, input().split() ))
E = Dice(label)

# outer loop: put all 6 faces to the top to check
sMove = 'NNNEEE'
for mi in range(len(sMove)+1):
 if D.gettop() == E.gettop() and D.getbottom() == E.getbottom():
  sRot = 'CCCC'
  for ri in range(len(sRot)):
   if D.getnorth() == E.getnorth() and D.geteast() == E.geteast() and D.getsouth() == E.getsouth() and D.getwest() == E.getwest():
    print('Yes')
    exit()
   if ri<len(sRot):
    E.move(sRot[ri])
 if mi<len(sMove):
  E.move(sMove[mi])
print('No')



Measured memory_bytes: 5620
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
template<typename T>
void vprint(std::vector<T>& vector)
{
  int len = int(vector.size());
  for(int i =0;i<len;i++){
    cout << vector[i] <<",";
  }
  cout <<endl;
}

double mean(double x,double y){
  return (x +y)/2;
}

int main(){
  int N;
  cin >> N;
  std::vector<double> v(N);
  for(int i = 0;i<N;i++)cin >>v[i];
  // vprint(v);
  // sort(v.begin(),v.end());
  // vprint(v);
  // remove(v,0);
  // vprint(v);
  // double x,y;
  // for(int i = 0;i<N-1;i++){
  //   x = v[0];
  //   y = v[1];
  //   v[1] = (x + y)/2.0;
  //   remove(v,0);
  // }
  sort(v.begin(),v.end());
  double val = 0.0;
  int index;
  for(int i =1;i <= N-1;i++){
    index = N - i;
    if(i == 1){
      val = (v[0] +v[1]) /pow(2,index);
    }else{
      val += v[i]/pow(2,index);
    }
  }
//   vprint(v);
  printf("%f",val);
  return 0;
}

Measured memory_bytes: 256
'''input
7
1 1 1 1 2 3 4
'''
n = input()
arr = map(int,raw_input().split())
for i in range(n):
	arr[i] = (arr[i]-(i+1))
arr.sort()
mean = float(arr[n//2])
ans = 10**30
for i in range(int(mean)-30,int(mean)+30):
	q = 0
	for j in range(n):
		q += abs(arr[j]-i)
	ans = min(q,ans)
print ans

Measured memory_bytes: 56028
s = str(input())
n = len(s)
for i in range(n-1):
    if s[i] == s[i+1]:
        print(i+1, i+2)
        exit()

for i in range(n-2):
    if s[i] == s[i+2]:
        print(i+1, i+3)
        exit()

print(-1, -1)


Measured memory_bytes: 3188
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

vector<int> snacks;

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

    snacks.resize(N);
    for (int i = 0; i < K; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int a;
            cin >> a;
            a--;
            snacks[a]++;
        }
    }

    int cnt = 0;
    for (int i = 0; i < (int) snacks.size(); i++) {
        if (snacks[i] == 0) {
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>
int main(){
    int h,n;
    scanf("%d%d",&h,&n);
    int i,a[n],total=0;
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        total+=a[i];
    }
    if(h-total<=0){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
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;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

    double f;
	while (cin >> f) {
		double cnt = f;
		for (int i = 2; i <= 10; i++) {
			if (i & 1)f /= 3;
			else f *= 2;
			cnt += f;
		}
		fcout << cnt << endl;
	}
    return 0;
}


Measured memory_bytes: 3288
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    bool ok = true;
    vector<int> cnt(N);
    rep(i,N) cnt[A[i]]++;
    int M = *max_element(all(A));
    if (M%2==0) {
        if (cnt[M/2] != 1) ok = false;
        for (int i = M; i > M/2; i--) {
            if (cnt[i] < 2) ok = false;
        }
    } else {
        if (cnt[(M+1)/2] != 2) ok = false;
        for (int i = M; i > (M+1)/2; i--) {
            if (cnt[i] < 2) ok = false;
        }
    }

    cout << (ok ? "Possible" : "Impossible") << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
  int K;
  cin >> K;
  int i;
  int a = 7;
  for(i=0;i<K;i++) {
    if(a % K == 0) {
      cout << i+1 << endl;
      return 0;
    }
    a = (a*10+7)%K;
  }
  cout << -1 << endl;
}

Measured memory_bytes: 3636
S = list(input())
tmp = 0
for i in range(2**(len(S) - 1)):
    s = '0'
    for j in range(len(S)):
        s += S[j]
        if i & (1 << j):
            tmp += int(s)
 #           print(tmp)
            s = '0'
    tmp += int(s)
print(tmp)


Measured memory_bytes: 39536
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	string str;
	map<char,int> mp;
	map<char,int> :: iterator it;
	cin>>str;
	for(int i=0;i<str.length();i++)
	{
		mp[str[i]]++;
	}
	int c=0;
	for(it=mp.begin();it!=mp.end();it++)
	{
		n=it->second;
		if(n%2!=0)
		{
			c=1;
			break;
		}
	}
	if(c==0)
	{
		cout<<"Yes"<<endl;
	}
	else
	cout<<"No"<<endl;
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k,a=1,b=1;
	cin>>n>>k;
	if(n==k){
		for(ll i=1;i<n;i++){
			a+=a*i;
			a=a%1000000007;
		}
		for(ll i=1;i<k;i++){
			b+=b*i;
			b=b%1000000007;
		}
		cout<<(2*a*b)%1000000007<<endl;
	}else if(abs(n-k)<=1){
	for(ll i=1;i<n;i++){
			a+=a*i;
			a=a%1000000007;
		}
		for(ll i=1;i<k;i++){
			b+=b*i;
			b=b%1000000007;
		}
		cout<<(a*b)%1000000007<<endl;
	}else{
		cout<<0<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
n, t = map(int, input().split())
dishes = []

for _ in range(n):
    time, point = map(int, input().split())
    dishes.append([time, point])

dishes.sort()

DP = [0] * t

candidates = []
for time, point in dishes:
    candidates.append(max(DP) + point)

    for i in range(t-1, time-1, -1):
        DP[i] = max(DP[i], DP[i-time]+point)

print(max(candidates))

Measured memory_bytes: 45416
using System;

class MainClass {
  public static void Main (string[] args) {
    string s = Console.ReadLine();
    string t = Console.ReadLine();

    Console.WriteLine(Convert.ToInt32(s[0] == t[0]) +
                      Convert.ToInt32(s[1] == t[1]) + Convert.ToInt32(s[2] == t[2]));
  }
}

Measured memory_bytes: 11220
using System;
using System.Linq;

namespace id_0276cs
{
    class Program
    {
        static void Main(string[] args)
        {
            foreach( var i in Enumerable.Range(0,7))
            {
                var vs = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                var maxTemperature = vs[0];
                var minTemperature = vs[1];
                Console.WriteLine(maxTemperature - minTemperature);
            }


        }
    }
}



Measured memory_bytes: 9588
a, b = map(int, input().split())

def accum_xor(n):
  case = n % 4
  if case == 0:
    return n
  elif case == 1:
    return 1
  elif case == 2:
    return n+1
  elif case == 3:
    return 0

print(accum_xor(a-1) ^ accum_xor(b))

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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

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

   vi a(n);
   f(i,0,n) cin >> a[i];

   sort(all(a));

   f(i,0,n-1) a.pb(a[i]);

   sort(a.rbegin() , a.rend());

   int sum = 0;
   f(i,0,n-1) sum += a[i];
   cout << sum << "\n";
}

Measured memory_bytes: 6368
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e3+7;
map<int,int> mp;
int n;int a[maxn];
pair<double,double> b[maxn];
double cal()
{
	double ans=0;
	for(int j=1;j<n;j++)
	{
		int x=a[j],y=a[j+1];
		ans+=sqrt((b[x].first-b[y].first)*(b[x].first-b[y].first)+(b[x].second-b[y].second)*(b[x].second-b[y].second));
	}
	return ans;
}
int main()
{
	cin>>n;ll cnt=1;
	for(int i=1;i<=n;i++)
	{
		double x,y;scanf("%lf%lf",&x,&y);
		b[i]=make_pair(x,y);a[i]=i;cnt*=i;
	}
	double ans=0;
	do
	{
		ans+=cal();
	}while(next_permutation(a+1,a+1+n));
	printf("%.10lf\n",ans/(double)cnt);
 } 

Measured memory_bytes: 256
d=int(input())
C=[int(i) for i in input().split()]
s=[[int(i) for i in input().split()] for q in range(d)]

sco=0
L=[0 for i in range(26)]
ans=[]

#calc
for i in range(d):
    mayou=0
    est=s[i][0]+C[0]*(i+1-L[0])
    for p in range(1,26):
        if s[i][p]+C[p]*(i+1-L[p]) > est:
            mayou=p
            est=s[i][p]+C[p]*(i+1-L[p])
    ans.append(mayou)
    print(mayou+1) #output


##以下表示
"""
L=[0 for i in range(26)]
for q in range(d):
    t=ans[q]
    sco+=s[q][t]
    
    
    L[t]=q+1
    for i in range(26):
        if L[i]!=-1:
            sco-=C[i]*(q+1-L[i])
    
    print(sco)
"""


Measured memory_bytes: 68536
import java.util.Scanner;

class Main {
    public static void main(String[] args){
    	Scanner in = new Scanner(System.in);
    	int i = 0;
    	while(in.hasNext()) {
    		int x = in.nextInt();
    		if (x == 0) {
    			break;
    		}
    		i++;
    		System.out.printf("Case %d: %d\n", i, x);
    	}
    }
}

Measured memory_bytes: 55668
#include<bits/stdc++.h>
using namespace std;
int main() {

    int n,k;
    cin>>n>>k;
    bool dp[k+1];
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];

    }
    memset(dp,0,sizeof(dp));
    dp[0]=false;
     for(int i=1;i<=k;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i-arr[j]>=0&&!dp[i-arr[j]])
                dp[i]=true;
        }

    }
   /* for(int i=0;i<=k;i++)
        //cout<<dp[i]<<" ";
    cout<<endl;*/
    cout<<(dp[k] == true ? "First" : "Second")<<endl;



}



Measured memory_bytes: 384
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let n = read::<usize>();
    let b = read_vec::<u32>();
    let mut ans = 0;
    for i in 0..n {
        if i == 0 {
            ans += b[i];
        } else if i == n - 1 {
            ans += b[n-2];
        } else {
            ans += std::cmp::min(b[i-1], b[i]);
        }
    }

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


Measured memory_bytes: 4352
N,K = list(map(int,input().split()))

D = []

for i in range(K):
    l,r = list(map(int,input().split()))
    D.append((l,"l"))
    D.append((r,"r"))

D.sort(key=lambda x:x[0])
mod = 998244353

DP = [0]*N

DP[0] = 1
DPP = [0]*(N+1)
DPP[1] = 1

def max(a,b):
    if a>b:
        return a
    else:
        return b

def S(x,y):
    return DPP[max(y,0)] - DPP[max(x-1,0)]


for i in range(N-1):
    a = 0
    for j in range(len(D)//2):
        a += S(i+2 - D[2*j+1][0], i+2 - D[2*j][0])
        a %= mod
    DP[i+1] = a
    DPP[i+2] = (a + DPP[i+1])%mod

print(DP[-1])

Measured memory_bytes: 72224
N = int(input())
string = {}
ans = []

for _ in range(N):
    S = input()
    try:
        string[S] += 1
    except KeyError:
        string[S] = 1

most_frequent = max(string.values())

for s,num in string.items():
    if num == most_frequent:
        ans.append(s)

ans.sort()
print(*ans, sep="\n")

Measured memory_bytes: 34012
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
#define _(_1,_2,_3,N,...)N
#define pr(...) _(__VA_ARGS__,pr3,pr2,pr1)(__VA_ARGS__)
template<C T>void pr1(T a){cout<<a;ln;}
template<C T,C T2>void pr2(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr3(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n;
  while(R n && n) {
    string s[n];
    rep(i,n) R s[i];
    string dp[1<<n][n];
    rep(i,1<<n)rep(j,n)dp[i][j]="*";
    rep(i,n)dp[1<<i][i]=s[i];
    rep(r,1<<n)rep(k,n){
      if(dp[r][k]=="*") continue;
      rep(i,n) {
        if(r&(1<<i)) continue;
        string t=dp[r][k];
        int ss=s[i].size(),tt=t.size();
        rep(j,tt+1) {
          string x=t.substr(j,min(ss,tt-j)),y=s[i].substr(0,min(ss,tt-j));
          if(x==y) {
            t+=s[i].substr(min(ss,tt-j));
            break;
          }
        }
        if(dp[r|(1<<i)][i]=="*") dp[r|(1<<i)][i]=t;
        else if(dp[r|(1<<i)][i].size()>t.size()) dp[r|(1<<i)][i]=t;
        else if(dp[r|(1<<i)][i].size()==t.size()&&dp[r|(1<<i)][i]>t) dp[r|(1<<i)][i]=t;
      }
    }
    string ans=dp[(1<<n)-1][0];
    REP(i,1,n) {
      if(ans.size()>dp[(1<<n)-1][i].size()) ans=dp[(1<<n)-1][i];
      else if(ans.size()==dp[(1<<n)-1][i].size()&&ans>dp[(1<<n)-1][i]) ans=dp[(1<<n)-1][i];
    }
    pr(ans);
  }
}
 
int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  Main();return 0;
}


Measured memory_bytes: 2096
#include "bits/stdc++.h"
using namespace std;

int main()
{
	int n;
	string s, t;
	cin >> n >> s >> t;

	string ans = "";
	for (int i = 0; i < n; i++) {
		ans += s.at(i);
		ans += t.at(i);
	}

	cout << ans << endl;
}


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

using namespace std;

int a, b;

int main(){
    cin >> a >> b;

    if(a < b){
        swap(a, b);
    }

    // a > b
    
    for(int i=0;i<a;i++){
        cout << b;
    }
    cout << endl;


    return 0;
}


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

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int ta,ao;
  if(c%b==0) ta=c/b;
  else ta=c/b+1;
  if(a%d==0) ao=a/d;
  else ao=a/d+1;
  if(ta<=ao) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3636