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

int main(void){
	int n;
	int dp[3][2]={0};
	int input,ans;
	cin>>n;

	for(int i=1;i<=n;i++){
		for(int j=0;j<3;j++){
			dp[j][i%2]=0;
			for(int k=0;k<3;k++){
				if(j!=k){
					dp[j][i%2]=max(dp[j][i%2],dp[k][(i-1)%2]);
				}
			}
			cin>>input;
			dp[j][i%2]+=input;
		}
	}
	ans=0;
	for(int i=0;i<3;i++){
		ans=max(ans,dp[i][n%2]);
	}
	cout<<ans<<endl;


	return 0;
}


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

const double PI = acos(-1);

int main() {
    double r; cin >> r;
    double circumference = 2.0 * PI * r;
    double area = PI * r * r;
    printf("%.6lf %.6lf\n", area, circumference);
    return 0;
}


Measured memory_bytes: 3208
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;
int n,m;
int main()
{
    scanf("%d",&n);
    m=n%10*100+(n%100)/10*10+(n%1000/100);
    if(n==m) printf("Yes");
    else printf("No");
    return 0;
}

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


Measured memory_bytes: 4024
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 998244353, N = 2e5 + 11;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;

int n, a[N];	

main () {
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];

	sort(a + 1, a + 1 + n);
	reverse(a + 1, a + 1 + n);

	int sum = a[1], cnt = n - 2;
	for (int i = 2; i <= n; ++i) {
		if (!cnt)
			break;
		--cnt;
		sum += a[i];
		if (!cnt)					
			break;
		--cnt;
		sum += a[i];
	}
	cout << sum << endl;
}
	
        	
//check for the constants

                                                                                   	



Measured memory_bytes: 5192
use std::io;
use std::usize::MAX;

type Range = (usize, usize);

fn input_char_vec() -> Vec<char> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.chars().collect()
}

fn input_tuple() -> (usize, usize) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<usize> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn count(row_idx: usize, column_idx: usize, row_range: &Vec<Vec<Range>>, column_range: &Vec<Vec<Range>>) -> usize {
    let mut sum = 0;
    // row
    for r in &row_range[row_idx] {
        // print!("{} {} ", r.0, r.1);
        if column_idx < r.1 {
            sum += r.1 - r.0;
            break;
        }
    }
    // print!("{} ", sum);

    // column
    for r in &column_range[column_idx] {
        if row_idx < r.1 {
            sum += r.1 - r.0;
            break;
        }
    }
    // print!("{} ", sum);
    sum - 1
}
fn main() {
    let (h, w) = input_tuple();
    // let h = 2000;
    // let w = 2000;
    let mut map: Vec<Vec<char>> = Vec::new();
    for _ in 0..h {
        let row = input_char_vec();
        // let row = vec!['.'; 2000];
        map.push(row);
    }

    let mut row_range: Vec<Vec<Range>> = vec![Vec::new(); h];
    let mut column_range: Vec<Vec<Range>> = vec![Vec::new(); w];

    for i in 0..h {
        let mut start = MAX;
        for j in 0..w {
            if map[i][j] == '#' {
                if start != MAX {
                    row_range[i].push((start, j));
                    start = MAX
                }
            } else {
                if start == MAX {
                    start = j;
                }
            }
        }
        if start != MAX {
            row_range[i].push((start, w));
        }
    }

    for i in 0..w {
        let mut start = MAX;
        for j in 0..h {
            if map[j][i] == '#' {
                if start != MAX {
                    column_range[i].push((start, j));
                    start = MAX
                }
            } else {
                if start == MAX {
                    start = j;
                }
            }
        }
        if start != MAX {
            column_range[i].push((start, h));
        }
    }

    // for i in 0..h {
    //     println!("{}", i);
    //     for r in &row_range[i] {
    //         println!("({}, {})", r.0, r.1);
    //     }
    // }

    // for i in 0..w {
    //     println!("{}", i);
    //     for r in &column_range[i] {
    //         println!("({}, {})", r.0, r.1);
    //     }
    // }

    let mut max = 0usize;
    for i in 0..h {
        for j in 0..w {
            if map[i][j] != '#' {
                let num = count(i, j, &row_range, &column_range);
                // println!("{}, {}, {}", i, j, num);
                if num > max {
                    max = num;
                }
            }
        }
    }
    println!("{}", max);
}


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

int main(){
  int n, m, aux;
  float sum = 0;
  cin >> n >> m;
  vector<int> nums;
  while(n--){
    cin >> aux;
    sum += aux;
    nums.push_back(aux);
  }
  sum *= (float)1 / (4 * m);
  sort(nums.begin(),nums.end());
  int distance = nums.end() - lower_bound(nums.begin(),nums.end(),sum);
  if(distance < m)
      cout << "No";
  else
      cout << "Yes";
  
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

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

    vector<lint> A(N+1);
    for_(i,0,N+1) cin >> A[i];

    if (N == 0 and A[0] != 1) {
        puts("-1");
        return 0;
    }

    lint sum = accumulate(ALL(A), lint(0));
    vector<lint> B(N+1, 0);

    for_(i,0,N+1) {
        sum -= A[i];
        if (i == 0) {
            B[i] = 1 - A[i];
        }
        else {
            lint mn = B[i-1] - A[i], mx = 2 * B[i-1] - A[i];
            lint x = min(sum, mx);
            if (x < mn or x < 0) {
                puts("-1");
                return 0;
            }
            B[i] = x;
        }
    }

    cout << accumulate(ALL(A), lint(0)) + accumulate(ALL(B), lint(0)) << endl;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n;
vector <pair <int, int> > a;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    a.resize(n);
    for(auto &i : a) cin >> i.first >> i.second;
    sort(a.begin(), a.end(), [&](pair <int, int> &l, pair <int, int> &r){
        return atan2(l.second, l.first) < atan2(r.second, r.first);
    });
    ll ans = 0;
    for(int i = 0 ; i < n ; i++){
        int x = 0, y = 0;
        for(int j = 0 ; j < n ; j++){
            x += a[(i + j) % n].first;
            y += a[(i + j) % n].second;
            ans = max(ans, 1LL * x * x + 1LL * y * y);
        }
    }
    cout << setprecision(12) << sqrtl(ans) << endl;
}


Measured memory_bytes: 256
package main

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

func main() {

	N := oneInt()
	moji := strconv.Itoa(N)
	if strings.Contains(moji, "7") {
		fmt.Print("Yes")
	} else {
		fmt.Print("No")
	}

}

func exp(val int) float64 {
	var temp float64
	for index := 1; index <= val; index++ {
		temp += float64(index)
	}
	return temp / float64(val)
}

func searchAbove(slice []int, target int, index int) int {
	for i := index + 1; i < len(slice); i++ {
		v := slice[i]
		if v >= target {
			return i
		}
	}
	return -1
}

var sc = bufio.NewScanner(os.Stdin)

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}


Measured memory_bytes: 1820
from collections import Counter
import sys

def input():
    return sys.stdin.readline().strip()

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            yield i
            if i != n // i:
                yield n//i
        i += 1

n,*A = get_all_int()
A.sort()



C = dict(Counter(A))
keys = C.keys()
# log(C)

checks = [False] * (1000009)

B = []
for i,a in enumerate(A):
    if C[a] == 1:
        B.append(a)
    elif not checks[a]:
        for j in range(a, 1000009, a):
            checks[j] = True

# log(B)

ans = 0

for i,a in enumerate(B):
    if not checks[a]:
        ans += 1
        for j in range(a, 1000009, a):
            checks[j] = True

print(ans)


Measured memory_bytes: 161384
#define deb 123321
#define fi first
#define se second
#define mp make_pair
#define pb push_back

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

typedef long long ll;
typedef unsigned long long ull;
constexpr int R=5e7+69, INF=2e9+6969;

string s;

int main()
{
	cin>>s;
	for(int i=0;i<s.size();++i)
	{
		if(s[i]=='?') s[i]='D';
	}
	cout<<s<<"\n";
	return 0;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rt return 0
#define endln "\n"
#define for1(i, a, b) for (long long int i = a; i < b; i++)
#define for2(i, a, b) for (long long int i = a; i > b; i--)
//  cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;typedef long long int i;
typedef long long int lli;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli t;
    cin >> t;
    lli x = t / 500;
    lli ans = x * 1000;
    lli y = t - 500 * x;
    lli z = y / 5;
    ans += 5 * z;
    cout << ans << endl;
    // vector<lli> v;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int N;
    int[] L;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        N = sc.nextInt();
        L = new int[N];
        for (int i=0; i<N; i++) {
        	L[i] = sc.nextInt();
        }
    }
    
    //解答処理
    private boolean solve() {
        boolean judge = false;
        Arrays.sort(L);
        int max = L[N-1];
        int total = 0;
        for (int i=0; i<L.length-1; i++) {
        	total += L[i];
        }
        
        if (max < total) {
        	judge = true;
        }
        
        return judge;
    }
    
    //出力
    public void show(boolean answer) {
    	if (answer) {
        	System.out.println("Yes");
        } else {
        	System.out.println("No");
        }
    }

}

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

int main() {
    string s; cin >> s;
    const int n = s.size();
    bool ans = s == "keyence";
    for(int i = 0; i < n; ++i) {
        for(int j = i + 1; j <= n; ++j) {
            auto s1 = (i == 0 ? "" : s.substr(0, i));
            auto s2 = (j == n ? "" : s.substr(j));
            if(s1 + s2 == "keyence") {
                ans = true;
            }
        }
    }

    cout << (ans ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int W,H,x,y;
  cin>>H>>W>>x>>y;
  cout<<fixed<<setprecision(1)<<H*W*0.5<<' ';
  cout<<(x*2==H && y*2==W?1:0)<<endl;
}

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

public class Main {
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        double d = sc.nextDouble();
        double t = sc.nextDouble();
        double s = sc.nextDouble();
        double timereq = (d / s);
        if (timereq <= t)
            System.out.println("Yes");
        else
            System.out.println("No");
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 33240
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <climits>
#include <ctime>
#include <random>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-9
#define inf 0x3f3f3f3f
#define mod 1000000007
using namespace std;

int main() {
	speed;
	int n, a, b, c;
	cin >> n;
	map<int, int>m;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		m[a]++;
	}
	ll ans = 0;
	for (auto i : m)
		ans += i.second * 1ll * i.first;
	int q;
	cin >> q;
	for (int t = 0; t < q; ++t) {
		cin >> b >> c;
		ans -= m[b] * b;
		ans += m[b] * c;
		m[c] += m[b];
		m[b] = 0;
		cout << ans << '\n';
	}
}

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

int main()
{
    //入力を受け取る
    int D, T, S;
    cin >> D >> T >> S;

    //高橋君の移動時間を計算する
    double time = (double)D / S;

    //Tとtimeの大小関係に応じて出力をする
    if (T >= time)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3596
def main():
    import math
    x=int(input())
    stop=False
    #(a,b)==(+,-)
    for a in range(int(math.pow(10**9,1/5))+1):
        for b in range(int(math.pow(10**9,1/5))+1):
            if a**5-(-b)**5==x:
                print(a,-b)
                stop=True
                break
        if stop:
            break
    else:
        #(a,b)==(+,+)
        a_range_num=int(math.pow(10**9+(math.pow(2,1/4)*10**2)**5,1/5))
        for b in range(int(math.pow(10**9,1/4))+1):
            for a in range(b,a_range_num+1):
                if a**5-b**5==x:
                    print(a,b)
                    stop=True
                    break
            if stop:
                break
if __name__=="__main__":
    main()

Measured memory_bytes: 9496
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
#define SET(a,c) memset(a,c,sizeof(a))
#define DEBUG(x) cout<<"#x"<<": "<<x<<endl

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll INF = INT_MAX/3;
const ll MOD = 1000000007;
const double EPS = 1e-14;
const int dx[] = {1,0,-1,0} , dy[] = {0,1,0,-1};

int main(){
    while(true){
	int n;
	cin >> n;
	if(n==0) break;
	vector< pair<ll,ll> > v;
	REP(i,n){
	    pair<ll,ll> temp;
	    cin >> temp.second >> temp.first;
	    v.PB(temp);
	}
	sort(ALL(v));
	ll sum = 0;
	bool flg = true;
	REP(i,n){
	    sum += v[i].second;
	    if(sum > v[i].first){
		flg = false;
		break;
	    }
	}
	if(flg)
	    cout << "Yes" << endl;
	else
	    cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
  string s, ans;
  cin >> s;
  rep(i, s.size()){
    if((i+1) % 2 == 1) ans+=s[i];
  }
  cout << ans;
}


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

using namespace std;

int main(void)
{
    int n, a, cnt = 0, ful = 0, col[13];
    memset(col, 0, sizeof(col));
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        for (int j = 0; j < 13; j++) {
            if (a < 400 * (j + 1)) {
                col[j]++;
                break;
            }
        }
    }
    for (int i = 0; i < 8; i++)
        if (col[i]) cnt++;
    for (int i = 8; i < 13; i++)
        ful += col[i];
    cout << max(cnt, 1) << ' ' << cnt + ful << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;

int N, A[200000];
ll res;

int main() {
	cin >> N;
	for (int i = 0; i != N; ++i) {
		cin >> A[i];
		A[i] -= i + 1;
	}
	sort(A, A + N);
	for (int i = 0; i != N; ++i) {
		res += abs(A[i] - A[N / 2]);
	}
	cout << res << endl;
	return 0;
}

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

void Main()
{
    char a;
    cin >> a;
    if(a < 'a') cout << 'A' << endl;
    else cout << 'a' << endl;
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


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

int main()
{
    int N;
    cin >> N;
    
    vector<pair<string,int>> pair;
    
    for(int i=0;i<N;i++)
    {
        string a;
        int b;
        cin >> a >> b;
        pair.push_back(make_pair(a,b));
    }
    
    vector<int> rank;
    for(int i=0;i<N;i++)
    {
        rank.push_back(i);
    }
    
    
    for(int i=0;i<N;i++)
    {
        for(int j=i+1;j<N;j++)
        {
            if(pair[rank[i]].first > pair[rank[j]].first || ((pair[rank[i]].second < pair[rank[j]].second) && (pair[rank[i]].first == pair[rank[j]].first)))
            {
                swap(rank[i],rank[j]);
            }
        }
    }
    
    for(int i=0;i<N;i++)
    {
        cout << rank[i] + 1 << endl;;
    }
    
    
    return 0;
}



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

int main(){

  char c;
  cin >> c;
  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant"	<< endl;
  }

}



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

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


template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

const int INF = INT_MAX / 2;

int main() {
  int N; cin>>N;
  vector<vector<int> > f(N, vector<int>(3,0));
  vector<vector<int> > dp(N, vector<int>(3,0));
  REP(i,N) REP(j,3) cin>>f[i][j];
  REP(j,3) dp[0][j] = f[0][j];
  for(int i = 1; i < N; i++) {
    REP(j,3) {
      REP(k,3) {
	if(j == k) continue;
	chmax(dp[i][j], dp[i-1][k]+f[i][j]);
      }
    }
  }
  int ans = 0;
  REP(j,3) chmax(ans, dp[N-1][j]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11136
import java.math.BigInteger;
import java.util.*;
import java.util.Scanner;

class Main {
    static final long limit = 1000000000;

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        BigInteger S = new BigInteger(sc.next());
        BigInteger b = BigInteger.valueOf(1000000000);
        BigInteger[] sov = S.divideAndRemainder(b);
        System.err.println(Arrays.toString(sov));
        BigInteger x = b.subtract(sov[1]).mod(b);
        BigInteger y = S.add(x).divide(b);
        System.out.println("0 0 1000000000 1 " + x + " " + y);
    }
}

Measured memory_bytes: 39248
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void) {
  int n, w, h, ans;

  if(scanf("%d %d %d", &n, &w, &h) == 1);

  ans = (n - w + 1) * (n - h + 1);

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod.m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while(b){
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>=1;
    }
    return res;
}


int main(){
    int n, x, t;
    cin >> n >> x >> t;
    int tmp = ceil((double)n/x);
    cout << t*tmp << endl;
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    int X, Y;
    cin >> X >> Y;
    cout << (X%Y==0?-1:X) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
using namespace std;

const int INF = 1e9;
int main() {
    int h, w;
    cin >> h >> w;
    string s[h];
    vector<pii> v;
    for (int i = 0; i < h; i++) cin >> s[i];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == 'B') {
                v.push_back(pii(i, j));
            }
        }
    }
    int ans = -1;
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v.size(); j++) {
            if (i == j) continue;
            int dx = abs(v[i].first - v[j].first);
            int dy = abs(v[i].second - v[j].second);
            ans = max(ans, dx + dy);
        }
    }
    cout << ans << endl;
    return 0;
}



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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  int N, A, B, C, X;
  while(cin >> N >> A >> B >> C >> X, N||A||B||C||X){
    vector<int> Y(N);
    for(int i = 0; i < N; i++){
      cin >> Y[i];
    }
    int x = X, index = 0, frame = -1;
    for(int i = 0; i <= 10000; i++){
      if(x == Y[index])index++;
      if(index == N){
        frame = i;
        break;
      }
      x = (A * x + B) % C;
    }
    cout << frame << endl;
  }
}

Measured memory_bytes: 3000
# -*- coding: utf-8 -*-

def main(N, M):
    if(N>0 and M>2*N):
        print(N+(M-2*N)//4)
    elif(N>0 and M<2*N):
        print(M//2)
    elif(N==0 and M>3):
        print(M//4)
    else:
        print(0)

if __name__ == '__main__':
    N, M = map(int, input().split())

    main(N, M)

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


Measured memory_bytes: 2044
object Main extends App {
  import scala.io.StdIn._

  val l = readInt
  val ears = Array.tabulate(l){_ ⇒ readLong}
  println(solve(ears))
  def solve(ears: Array[Long]): Long = {
    val memo = Array.tabulate(3){_ ⇒ Array.tabulate(ears.length + 1){_ ⇒ Long.MaxValue}}//0, 0>E, 0>E>O
    memo(0)(0) = 0
    memo(1)(0) = 0
    memo(2)(0) = 0
    def M(i: Int): Long = {
      if (memo(2)(i) == Long.MaxValue){
          memo(2)(i) = List(M(i - 1) + (ears(i - 1) + 1) % 2, E(i - 1) + (if (ears(i - 1) == 0) 1 else 0), Z(i - 1)).min
      }
      memo(2)(i)
    }
    def E(i: Int): Long = {
      if (memo(1)(i) == Long.MaxValue) {
          memo(1)(i) = List(E(i - 1) + (if (ears(i - 1) == 0) 2 else ears(i - 1) % 2), Z(i - 1) + ears(i - 1) % 2).min
      }
      memo(1)(i)
    }
    def Z(i: Int): Long = {
      if (memo(0)(i) == Long.MaxValue) {
        memo(0)(i) = Z(i - 1) + ears(i - 1)
      }
      memo(0)(i)
    }
    val reversed = Array.tabulate(3){_ ⇒ Array.tabulate(ears.length + 1){_ ⇒ Long.MaxValue}}
    reversed(0)(0) = 0
    reversed(1)(0) = 0
    reversed(2)(0) = 0
    def MR(i: Int): Long = {
      if (reversed(2)(i) == Long.MaxValue) {
        reversed(2)(i) = List(MR(i - 1) + (ears(ears.length - i) + 1) % 2, ER(i - 1) + (if (ears(ears.length - i) == 0) 1 else 0), ZR(i - 1)).min
      }
      reversed(2)(i)
    }
    def ER(i: Int): Long = {
      if (reversed(1)(i) == Long.MaxValue) {
        reversed(1)(i) = List(ER(i - 1) + (if (ears(ears.length - i) == 0) 2 else ears(ears.length - i) % 2), ZR(i - 1) + ears(ears.length - i) % 2).min
      }
      reversed(1)(i)
    }
    def ZR(i: Int): Long = {
      if (reversed(0)(i) == Long.MaxValue) {
        reversed(0)(i) = ZR(i - 1) + ears(ears.length - i)
      }
      reversed(0)(i)
    }
    for (i ← 0 to ears.length by 3000) {
      M(i)
      MR(i)
    }
    M(ears.length); MR(ears.length)
    (0 to ears.length).map(i ⇒ M(i) + MR(ears.length - i)).min
  }
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline def let[A](@inline func: T ⇒ A): A = func(value)
  }
}

Measured memory_bytes: 130512
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] c = new int[3];
        c[0] = sc.nextInt();
        c[1] = sc.nextInt();
        c[2] = sc.nextInt();
        Arrays.sort(c);

        if (c[0] + c[1] == c[2]) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }

}


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

int fact(const void *a,const void *b) {
    return *(int*)a - *(int*)b;
}

int main(){
    int n,count=0;
    scanf("%d", &n);
    
    int a[n];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    
    qsort(a,n,sizeof(int),fact);
    for(int i=1;i<n;i++){
        if(a[i-1]==a[i]){
            count++;
            break;
        }
    }

    if(count==0){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
    
    return 0;
}


Measured memory_bytes: 1788
#include<stdio.h>
#include<string.h>
int main()
{
   char s[11],t[11];
   int i,c=0;
   scanf("%s%s",s,t);
   int l=strlen(s);
   int l2=strlen(t);
   for ( i = 0; i < l; i++)
   {
       if(s[i]==t[i])
       {
           c++;
       }
   }
   if(l2==l+1&& c==l)
   {
       printf("Yes\n");
   }
   else
   {
       printf("No\n");
   }
   
    
}

Measured memory_bytes: 1616
#include <stdio.h>
#include<vector>
#include<deque>

using namespace std;
#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
inline void reader(int& x) { int k, m = 0; x = 0; for (;;) { mygc(k); if (k == '-') { m = 1; break; }if ('0' <= k&&k <= '9') { x = k - '0'; break; } }for (;;) { mygc(k); if (k<'0' || k>'9')break; x = x * 10 + k - '0'; }if (m) x = -x; }
inline void writer(int x, char c) { int s = 0, m = 0; char f[7]; if (x<0)m = 1, x = -x; while (x)f[s++] = x % 10, x /= 10; if (!s)f[s++] = 0; if (m)mypc('-'); while (s--)mypc(f[s] + '0'); mypc(c); }
inline void writerLn(int x) { writer(x, '\n'); }
#define rep(i,n)for(int i=0;i<n;i++)
vector<int>E[100000];
int u[200000], v[200000], r[200000], ans[200000], d[100000], cnt = 1;
char b[200000], ok[100000];
deque<int>que;

void bfs(int u, char t) {
	que.emplace_back(u);
	while (!que.empty()) {
		int p = que.front(); que.pop_front();
		for (int v : E[p]) {
			if (t) {
				if (d[v] > d[p] && !ok[v]) {
					ok[v] = 1; cnt++; que.emplace_back(v);
				}
			}
			else if (!d[v]) {
				d[v] = d[p] + 1; que.emplace_back(v);
			}
		}
	}
}
int main() {
	ok[0] = d[0] = 1;
	int n, m, q; reader(n); reader(m); reader(q);
	rep(i, m) {
		reader(u[i]); reader(v[i]);
		u[i]--; v[i]--;
		E[u[i]].emplace_back(v[i]); E[v[i]].emplace_back(u[i]);
	}
	bfs(0, 0);
	rep(i, m) {
		if (d[u[i]] > d[v[i]])swap(u[i], v[i]);
	}
	rep(i, n)E[i].clear();
	rep(i, q) {
		reader(r[i]); r[i]--;
		b[r[i]] = 1;
	}
	rep(i, m) {
		if (!b[i]) {
			if (d[v[i]] > d[u[i]]) {
				E[u[i]].emplace_back(v[i]);
			}
		}
	}
	bfs(0, 1);
	for (int i = q - 1; i >= 0; i--) {
		ans[i] = n - cnt;
		if (d[v[r[i]]] > d[u[r[i]]] && !ok[v[r[i]]]) {
			E[u[r[i]]].emplace_back(v[r[i]]);
			if (ok[u[r[i]]]) {
				cnt++; ok[v[r[i]]] = 1;
				bfs(v[r[i]], 1);
			}
		}
	}
	rep(i, q)writerLn(ans[i]);
}

Measured memory_bytes: 13016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 40;
char str[40000];
int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif // LOCAL
    ios::sync_with_stdio(0);
    scanf("%s", str);
    for(int i = 0; str[i]; i ++) {
        if (str[i] == '1') str[i] = '9';
        else if (str[i] == '9') str[i] = '1';
    }
    printf("%s", str);
    return 0;
}


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

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

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rag(con) std::begin(con), std::end(con)

constexpr int MAX = 1e5 + 5, MAXL = 35;

ll vis[MAXL][MAX];
ll sum[MAXL][MAX];

int main()
{
    ll n, x, m;

    std::cin >> n >> x >> m;

    rep(i, m)
    {
        vis[0][i] = i * i % m;
        sum[0][i] = i;
    }

    for (int i = 1; i < MAXL; ++i)
    {
        rep(j, m)
        {
            vis[i][j] = vis[i - 1][vis[i - 1][j]];
            sum[i][j] = sum[i - 1][j] + sum[i - 1][vis[i - 1][j]];
        }
    }

    ll y = 1, ans = x - x % m, now = x % m;

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

        if (y & (n - 1))
        {
            ans += sum[i][now];
            now = vis[i][now];
        }

        y *= 2;
    }

    std::cout << ans + now << std::endl;

    return 0;
}

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

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

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

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

int main()
{
    int R;
    cin >> R;
    if (R < 1200)
        cout << "ABC" << endl;
    else if (R < 2800)
        cout << "ARC" << endl;
    else
        cout << "AGC" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 60;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

vector<vector<pair<int, long long>>> g(100010);
vector<long long> dists(100010, LLINF);

void bfs(int root) {
  queue<int> que;
  que.push(root);
  while (!que.empty()) {
    int x = que.front(); que.pop();
    for (auto e: g[x]) {
      int nx; long long cost;
      tie(nx, cost) = e;
      if (dists[nx] > dists[x] + cost) {
        dists[nx] = dists[x] + cost;
        que.push(nx);
      }
    }
  }
}

int main() {
  int n; cin>>n;
  rep(i, n-1) {
    int a, b, c; cin>>a>>b>>c;
    --a; --b;
    g[a].emplace_back(b, c);
    g[b].emplace_back(a, c);
  }
  int q, k; cin>>q>>k;
  --k;
  dists[k] = 0;
  bfs(k);
  rep(i, q) {
    int x, y; cin>>x>>y;
    --x; --y;
    print(dists[x]+dists[y]);
  }

  return 0;
}


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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct Edge{int from, to; ll cost;};

const ll MOD = 1000000007;
const long double EPS = 10e-10;

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

    int n;
    cin >> n;
    ll cost[n][n];
    rep(n) repp(j, n) cin >> cost[i][j];

    ll ans = 0LL;
    rep(n) repp(j,i) ans += min(cost[i][j], cost[j][i]);
    cout << ans << endl;
}



Measured memory_bytes: 3268
#include<iostream>
#include<cstdio>
#define int long long
using namespace std;
const int N=2005,mod=1e9+7;
int f[2*N+5][2*N+5];
int n;
int ans;
int fac[4*N+5],inv[4*N+5];
int inv2;
int A[200005],B[200005];

int C(int n,int m){	return (fac[n]*inv[m]%mod)*inv[n-m]%mod; }

void init()
{
	inv[1]=1;
	fac[0]=1;
	for(int i=1;i<=4*N;i++) fac[i]=(fac[i-1]*i)%mod;
	for(int i=2;i<=4*N;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	inv2=inv[2];
	for(int i=2;i<=4*N;i++) inv[i]=inv[i]*inv[i-1]%mod;
}

signed main()
{
#ifndef ONLINE_JUDGE
	freopen("bbq.in","r",stdin);
	freopen("bbq.out","w",stdout);
#endif
	init();
	scanf("%lld",&n);
	int a,b;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&a,&b);
		(f[N-a][N-b]+=1)%=mod;
		ans=(ans-C(a+b+a+b,a+a)+mod)%mod;
		A[i]=a,B[i]=b;
	}
	for(int i=1;i<=2*N;i++)
			for(int j=1;j<=2*N;j++) (f[i][j]+=f[i-1][j]+f[i][j-1])%=mod;
	for(int i=1;i<=n;i++) (ans+=f[N+A[i]][N+B[i]])%=mod;
	printf("%lld",ans*inv2%mod);
	return 0;
}


Measured memory_bytes: 132872
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main(){
  double n;
  cin>>n;
  vector<double> x(n),y(n);
  rep(i,n) cin>>x[i]>>y[i];
  vector<int> t(n);
  rep(i,n) t[i]=i;
  double sum=0;
  int cnt=0;
  auto dis= [&](int i,int j){
    double dx=x[i]-x[j];
    double dy=y[i]-y[j];
    return sqrt(dx*dx+dy*dy);
  };
  do{
    for(int i=1;i<n;i++){
      sum+=dis(t[i],t[i-1]);
    }
    cnt++;
  }while(next_permutation(all(t)));
  printf("%.10f\n",sum/cnt);
}

Measured memory_bytes: 3876
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();
        long ans = 0;

        long mul = x;
        while(mul <= y) {
            mul *= 2;
            ans++;
        }
        System.out.println(ans);
    }
}


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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
#define pii pair< ll , pair<ll,ll> >
const int N = 55;
ll n , m , s , c[N] , d[N] , cost[N][2555];
vector< pair< pair<int,int> , int> > adj[N];

void dijk()
{
    priority_queue< pii , vector< pii > , greater< pii > > q;
    for(int i=1; i<=n; i++)
    {
        for(int j=0; j<=2500; j++)
            cost[i][j] = 1e18;
    }
    s = min(s , (ll)2500);
    cost[1][s] = 0;
    q.push({cost[1][s] , {1,s}});

    while(q.size())
    {
        int node = q.top().s.f , sil = q.top().s.s , cst = q.top().f;

    }
}

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

    ll n;
    cin >> n;
    cout << n/2 + n%2 << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iso646.h>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

const ll N_MAX = 1e10;

int main() {
    string T;
    cin >> T;
    ll i;
    ll ans = 0;
    for(i = 0; i < T.length(); i++) {
        if(T[i] == '?') {
            cout << "D";
        } else {
            cout << T[i];
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3372
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double x = sc.nextDouble();
		sc.close();
		double res = 0.0;

		if(a*a*b/2.0 <= x) {
			BigDecimal atan = new BigDecimal(Math.atan(2*(a*a*b-x)/(a*a*a)));
			res = atan.doubleValue();
		}else {
			BigDecimal atan = new BigDecimal(Math.PI / 2.0 - Math.atan(2 * x / (a*b*b)));
			res = atan.doubleValue();
		}

		System.out.println(res * 180 / Math.PI);
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <stack>
#include <cctype>
#include <cmath>
#include <bitset>

using namespace std;

/* typedef */
typedef long long ll;

/* constant */
const int INF = 1 << 30;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;

/* global variables */

/* function */

/* main */
int main(){
    int n;
    double w, value, weight;
    cin >> n >> w;
    vector< pair< double, double> > items(n);
    for (int i = 0; i < n; i++) {
        cin >> value >> weight;
        items[i] = make_pair(value / weight, weight);
    }
    sort(items.begin(), items.end(), greater<pair<double, double>>());

    double knapsak = 0;
    for (int i = 0; i < n && w; i++) {
        value = items[i].first;
        weight = items[i].second;
        double take = min(w, weight);
        knapsak += take * value;
        w -= take;
    }

    cout << fixed << setprecision(9) << knapsak << '\n';

}



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

using namespace std;

#define ll long long
#define ar array



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

  int x;
  cin >> x;
  if(x>=30){
    cout << "Yes";
  }  else{
    cout << "No";
    
  return 0;
  }
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fr(i,k,n) for(ll i = k;i<n;i++)
#define mo map<ll,ll> 
int main(){
	 ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s;
    cin>>t;
    ll ans = LLONG_MAX;
    fr(i,0,ll(s.size()-t.size()+1)){
    	ll cnt = 0;
    	fr(j,0,ll(t.size())){
    		if(s[i+j] != t[j]){
    			cnt++;
    		}
    	}
    	ans = min(ans,cnt);
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define fio     ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define pi      3.14159265
#define ll      long long
#define repe    ll tc,cas=0;cin>>tc;while(tc--)
#define op      freopen("output.txt", "w", stdout);

#define maxn 10000010
using namespace std;

ll dp[100005][4],n;
ll a[100005],b[100005],c[100005];

ll solve(int ind,int stat){
    if(ind>=n) return 0;
    if(dp[ind][stat]!=-1) return dp[ind][stat];
    ll mx=0;
    if(stat!=0)
        mx = max(mx,a[ind]+solve(ind+1,0));
    if(stat!=1)
        mx = max(mx,b[ind]+solve(ind+1,1));
    if(stat!=2)
        mx = max(mx,c[ind]+solve(ind+1,2));

    dp[ind][stat]=mx;
    return mx;
}

int main()
{
    fio;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
        dp[i][0]=-1;
        dp[i][1]=-1;
        dp[i][2]=-1;
        dp[i][3]=-1;
    }
    ll ans = solve(0,3);

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


Measured memory_bytes: 13752
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << P.first << " " << P.second; }

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

int n, m;
char fi[25][25];
string pat;

int dist[25][25][25][25][11];

pair<int,pint> solve() {
    pint s, t;
    for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) {
        cin >> fi[i][j];
        if (fi[i][j] == 'A') s = pint(i,j);
        if (fi[i][j] == 'B') t = pint(i,j);
    }
    cin >> pat;
    memset(dist, -1, sizeof(dist));
    dist[s.first][s.second][t.first][t.second][0] = 0;
    queue< pair<pair<pint,pint>,int> > que;
    que.push( MP(MP(s,t),0) );
    while (!que.empty()) {
        pint girl = que.front().first.first;
        pint goast = que.front().first.second;
        int p = que.front().second;
        //cout << girl << ", " << goast << " : " << dist[girl.first][girl.second][goast.first][goast.second] << endl;
        que.pop();
        if (girl == goast) { 
            return MP(dist[girl.first][girl.second][goast.first][goast.second][p], girl); 
        }
        
        pint ngoast = goast;
        char c = pat[p];
        if (c == '8') ngoast = pint(goast.first-1, goast.second);
        if (c == '6') ngoast = pint(goast.first, goast.second+1);
        if (c == '4') ngoast = pint(goast.first, goast.second-1);
        if (c == '2') ngoast = pint(goast.first+1, goast.second);
        if (ngoast.first < 0 || ngoast.first >= n || ngoast.second < 0 || ngoast.second >= m) ngoast = goast;
        int np = (p+1)%pat.size();
        
        for (int i = 0; i < 5; ++i) {
            pint ngirl = girl;
            if (i < 4) ngirl = pint( girl.first + dx[i], girl.second + dy[i] );
            if (ngirl.first < 0 || ngirl.first >= n || ngirl.second < 0 || ngirl.second >= m) continue;
            if (fi[ngirl.first][ngirl.second] == '#') continue;
            if ( dist[ngirl.first][ngirl.second][ngoast.first][ngoast.second][np] == -1 ) {
                dist[ngirl.first][ngirl.second][ngoast.first][ngoast.second][np] 
                = dist[girl.first][girl.second][goast.first][goast.second][p] + 1;
                que.push( MP(MP(ngirl, ngoast),np) );
            }
        }
    }
    return MP(-1,pint(-1,-1));
}

int main() {
    while (cin >> n >> m) {
        if (n == 0) break;
        pair<int,pint> res = solve();
        if (res.first == -1) puts("impossible");
        else cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 18020
n = int(input())
strings = [input() for _ in range(n)]

chars = []
for s in strings:
    chars += list(set(s))

used_in_all = []
for c in set(chars):
    if chars.count(c) == n:
        used_in_all.append(c)

if not used_in_all:
    print('')
    exit()

used_in_all.sort()

counts = []

for c in used_in_all:
    for i in range(n):
        count = strings[i].count(c)
        if i == 0:
            m = count
        m = min(m, count)
    counts.append((c, m))

ans = ''
for c in counts:
    ans += c[0] * c[1]

print(ans)

Measured memory_bytes: 3064
while True:
    H,W=map(int,input().split(" "))
    if W==0 and H==0:
        break

    else:
        for i in range(H):
            for j in range(W):
                if i==0 or i==H-1:
                    print("#",end="")
                else:
                    if j==0 or j==W-1:
                        print("#",end="")
                    else:
                        print(".",end="")            
            print("")
        print("")


Measured memory_bytes: 7008
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
int main(){
    int n,p;
    cin >> n >> p;
    int a = 0;
    rep(i,n){
        int x;
        cin >> x;
        if(x%2==0)a++;
    }
    int b = n-a;
    if(b==0){
        if(p==0){
            cout << (1LL<<n) << endl;
        }else{
            cout << 0 << endl;
        }
    }else{
        cout << (1LL<<(n-1)) << endl;
    }
}

Measured memory_bytes: 256