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

class MyClass
{
    public static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        for (int i = 0; i < n; i++)
        {
            var a = BigInteger.Parse(Console.ReadLine());
            var b = BigInteger.Parse(Console.ReadLine());
            var sum = a + b;
            if (sum.ToString().Length > 80)
            {
                Console.WriteLine("overflow");
            }
            else
            {
                Console.WriteLine(sum);
            }
        }
    }
}


Measured memory_bytes: 16040
#include<cstdio>

using namespace std;
const int mod = 1e9 + 7;
int qs[(int)1e5 + 5], inv[(int)1e5 + 5];
int pow(int val, int idx){
    if(idx == 0) return 1;
    if(idx == 1) return val;
    int k = pow(val, idx >> 1);
    k = (1LL * k * k) %  mod;
    if(idx & 1) k = (1LL * k * val) % mod;
    return k;
}
int main(){
    int n, pre, x;
    scanf("%d %d",&n,&pre);
    for(int i = 1; i < n;i++){
        scanf("%d", &x);
        qs[i] = qs[i-1] + x - pre;
        pre = x;
    }
    int fac = 1;
    for(int i = 1;i < n;i++){
        fac = (1LL * fac * i) % mod;
        inv[i] = i == 1 ? 1 : pow(i, mod - 2);
    }
    int ans = 0;
    for(int i = 1; i < n; i++){
        ans += (1LL * (qs[n - 1] - qs[i-1]) * (1LL * fac * inv[i] % mod)) % mod;
        ans = ans >= mod ? ans - mod : ans;
    }
    printf("%d",ans);



}


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

h, w = map(int, input().split())
s_list = [list(input()) for _ in range(h)]
ans_list = [[0] * w for _ in range(h)]

for i in range(h):
    for j in range(w):
        if s_list[i][j] == "#":
            ans_list[i][j] = "#"
        else:
            if (i!=0) and (j!=0):
                if (s_list[i-1][j-1] == "#"):
                    ans_list[i][j] += 1
            if (i!=0):
                if (s_list[i-1][j] == "#"):
                    ans_list[i][j] += 1
            if (i!=0) and (j!=w-1):
                if (s_list[i-1][j+1] == "#"):
                    ans_list[i][j] += 1
            if (j!=0):
                if (s_list[i][j-1] == "#"):
                    ans_list[i][j] += 1
            if (j!=w-1):
                if (s_list[i][j+1] == "#"):
                    ans_list[i][j] += 1
            if (i!=h-1) and (j!=0):
                if (s_list[i+1][j-1] == "#"):
                    ans_list[i][j] += 1
            if (i!=h-1):
                if (s_list[i+1][j] == "#"):
                    ans_list[i][j] += 1
            if (i!=h-1) and (j!=w-1):
                if (s_list[i+1][j+1] == "#"):
                    ans_list[i][j] += 1

for i in ans_list:
    print(''.join(map(str, i)))

Measured memory_bytes: 3188
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
using namespace std;

bool compare(pair<int,int> a, pair<int,int> b) {
	if(a.second == b.second )
		return a.first < b.first;
	else
		return a.second > b.second;
}

int main() {
	vector<pair<int,int> > in;
	int n;

	cin >> n;
	
	for(int i = 0; i < n; i++) {
		pair<int,int> tmp;
		cin >> tmp.first >> tmp.second;
		in.push_back(tmp);
	}

	sort(in.begin(), in.end(), compare);
	cout << in[0].first << " " << in[0].second << endl;

	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using  namespace std;
#define    ll  long long int
int main( )
{
    long int n, i, x, k, mx = 0;
    map<long int, long int> mp;
    vector<int> v;
    cin >> n;
    for (i = 1; i <= n; i++)
    {
        cin>>x;
        if(mp[x]==0)
        {
            mp[x]++;
            mx++;
        }
        else if(mp[x]!=0)
        {
            mp[x]=0;
            mx--;
        }

    }
    cout<<mx<<endl;
    return 0;
}



Measured memory_bytes: 6528
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, int> T;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
ll u[200100], v[200100];

ll solve() {
    ll res = 0;
    for (ll i = 1; i <= n; i++) {
        res += i * (n - i + 1);
    }
    for (int i = 0; i < n-1; i++) {
        if (u[i] > v[i]) swap(u[i], v[i]);
        res -= u[i] * (n - v[i] + 1);
    }
    return res;
}

void input() {
    cin >> n;
    for (int i = 0; i < n-1; i++) cin >> u[i] >> v[i];
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 6748
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		sc.close();

		int count = 0;
		long number = 1;
		while (true) {
			String text = String.valueOf(number);
			int target1 = Integer.parseInt(text.substring(0, 1));
			boolean check = true;
			for (int j = 1; j < text.length(); j++) {
				int target2 = Integer.parseInt(text.substring(j, j + 1));
				if (Math.abs(target2 - target1) > 1) {
					number += (long) Math.pow(10, text.length() - j - 1);
					check = false;
					break;
				}
				target1 = target2;
			}

			if (check) {
				if (++count == k) {
					break;
				}
				number++;
			}
		}

		System.out.println(number);
	}
}

Measured memory_bytes: 93132
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(void){
	int n,i,j;
	string s,s1,s2,alph;
	int c,cmax;
	cin>>n;
	cin>>s;
	cmax=0;
	alph="abcdefghijklmnopqrstuvwxyz";
	for(i=0;i<n-1;i++){
		s1=s.substr(0,i+1);
		s2=s.substr(i+1,n-1-i);
		c=0;
		for(j=0;j<26;j++){
			if(s1.find(alph[j])<100&&s2.find(alph[j])<100){
				c++;
			}
		}
		cmax=max(c,cmax);
	}
	cout<<cmax<<endl;
	return 0;
}


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

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;
const int mod = 1e9 + 7;

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	map<int, int> mp;
	for(int i = 1; i <= n; i++){
			int tmp = i;
			for(int j = 2; j * j <= i; j++){
					while(tmp % j == 0){
							mp[j]++;
							tmp = tmp / j;
					}
			}
			if(tmp != 1)mp[tmp]++;
	}
	int res = 1;
	for(auto itr = mp.begin(); itr != mp.end(); ++itr){
			res = ((ll)res * ((*itr).second + 1)) % mod;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define MAX(x, y) (((x)>(y))?(x):(y))

int dp[100001];

int getMaxProfit(int money, int n, int today[], int next[])
{
	if(dp[money] >= 0) return dp[money];
	
	int profit, max_profit = -1;
	for(int i = 0; i < n; i++){
		if(money < today[i]) continue;
		profit = (next[i] - today[i]) + getMaxProfit(money - today[i], n, today, next);
		if(max_profit < profit) max_profit = profit;
	}
	if(max_profit == -1) max_profit = 0;
	dp[money] = max_profit;
	return max_profit;
}



int main(void)
{
  int n, d, x;
  int p[10][10];

  scanf("%d %d %d", &n, &d, &x);
  for(int i = 0; i < d; i++){
    for(int j = 0; j < n; j++){
      scanf("%d", &(p[i][j]));
    }
  }

  int money = x;
  for(int i = 0; i < d-1; i++){
  	for(int j = 0; j < 100001; j++) dp[j] = -1;
    money += getMaxProfit(money, n, p[i], p[i+1]);
  }

  printf("%d\n", money);
  return 0;
}

Measured memory_bytes: 3124
use std::io::*;
use std::str::FromStr;
use std::collections::VecDeque;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}

fn main(){

    let mut s = VecDeque::new();
    let init:Vec<char> = read::<String>().chars().collect();
    let q: usize = read();
    let mut rev = true; //true:normal , false:reverse

    for c in init.iter() {
        s.push_back(*c);
    }

    for _ in 0..q{
        let o:u8 = read();
        if o == 1 {
            rev = !rev;
        }else{
            let f:u8 = read();
            let c = read::<String>();
            let c = c.chars().next().unwrap();
            if f == 1 {
                if rev {
                    s.push_front(c);
                }else{
                    s.push_back(c);
                }
            }else{
                if rev {
                    s.push_back(c);
                }else{
                    s.push_front(c);
                }
            }
        }
    }

    if rev {
        println!("{}",s.iter().join(""));
    }else{
        println!("{}",s.iter().rev().join(""));
    }



}


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


int main(void){
    int n, d, cnt=0;
    string x, ans;
    cin >> n >> x >> d;
    ans = x;
    
    for(int i=0; i<2*n; i++){
        if(cnt==d)    break;
        if(i>=n){
            if(x[2*n-1-i]=='1'){
                ans[2*n-1-i]='0';
                cnt++;
            }
        }
        else if(i<n){
            if(x[i]=='0'){
                ans[i]='1';
                cnt++;
            }
        }
    }
    
    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <map>
#include <cmath>
#include <algorithm>
#include <stack>
using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    int ans = max(a+b,a-b);
    ans = max(ans,a*b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

	if (N % 2 == 0) 
	{
		cout << N / 2 << endl;
	}
	else
	{
		cout << (N + 1) / 2 << endl;
	}

	return 0;
}

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

public class Main {
    static int h = 0;
    static int w = 0;
    static int k = 0;
    static int[][] c = null; // 各マスの色。0は黒。1は白or赤
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        h = in.nextInt();
        w = in.nextInt();
        k = in.nextInt();
        c = new int[h][w];
        for(int i=0; i<h; i++) {
            String line = in.next();
            for(int j=0; j<w; j++) {
                int color = 0;
                if(line.charAt(j) == '.') {
                    color = 1;
                }
                c[i][j] = color;
            }
        }
        int max = 1<<(h+w);
        int ans = 0;
        for(int i=0; i<max; i++) {
            if(equalsToK(i)) {
                ans++;
            }
        }
        System.out.println(ans);
    }
    private static boolean equalsToK(int pattern) {
        // patternのビットの低い方から順に、列の右側から左側へ、そして行の下から上へと並んでいる。
        // ビットが1なら「操作」をする
        int[][] c2 = copyC();
        for(int i=0; i<(h+w); i++) {
            int doIt = pattern & (1<<i);
            if(doIt > 0) {
                if(i<w) {
                    // 列の塗り潰し
                    int col = i;
                    for(int row=0; row<h; row++) {
                        c2[row][col] = 1;
                    }
                }
                else {
                    // 行の塗り潰し
                    int row = i-w;
                    for(int col=0; col<w; col++) {
                        c2[row][col] = 1;
                    }
                }
            }
        }
        int count = 0;
        for(int row=0; row<h; row++) {
            for(int col=0; col<w; col++) {
                if(c2[row][col]==0) {
                    count++;
                }
            }
        }
        return (count==k);
    }
    private static int[][] copyC() {
        int[][] result = new int[h][w];
        for(int i=0; i<h; i++) {
            for(int j=0; j<w; j++) {
                result[i][j] = c[i][j];
            }
        }
        return result;
    }
}


Measured memory_bytes: 38032
#include <iostream>
#include <vector>
#include <string>

using namespace std;


int main(void){
	int h, w;

	cin >> h >> w;

	for (int i = 0; i < w+2; i++)
		cout << "#";

	cout << endl;
	string s;

	for (int i = 0; i < h; i++){
		cin >> s;
		cout << "#" << s << "#" << endl;
	}

	for (int i = 0; i < w+2; i++)
	cout << "#";

}

Measured memory_bytes: 256
n,m = map(int, input().split())

from collections import defaultdict 
V = defaultdict(list)

for _ in range(m):
    a,b = map(int, input().split())
    V[a].append(b)
    V[b].append(a)

from collections import deque

def bfs(u):
    queue = deque([u])
    d = [None] * (n+1) # uからの距離の初期化
    d[u] = 0 # 自分との距離は0
    while queue:
        v = queue.popleft()
        for i in V[v]:
            if d[i] is None:
                d[i] = d[v] + 1
                queue.append(i)
    return d

b1 = bfs(1)
if b1[n] ==2:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

string s;
int k;

int main()
{
	cin>>k>>s;
	if(s.size()<=k) cout<<s<<endl;
	else cout<<s.substr(0,k)<<"...\n";
	return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int[][] C=new int[3][3];
	    int[] A =new int[3];
	    int[] B =new int[3];
	    
	    for (int i=0; i<3; i++) {
	    	for (int j=0; j<3; j++) {
                C[i][j]=gi();
		    }
	    }
	    for (A[0]=0; A[0]<=C[0][0]; A[0]++) {
	    	B[0]=C[0][0]-A[0];
	    	for (A[1]=0; A[1]<=C[1][1]; A[1]++) {
	    		B[1]=C[1][1]-A[1];
	    		for (A[2]=0; A[2]<=C[2][2]; A[2]++) {
	    			B[2]=C[2][2]-A[2];
	    			boolean f=true;
	    			for (int i=0; i<3;i++) {
	    				for (int j=0; j<3;j++) {
		    				if(A[i]+B[j]!=C[i][j]) {
		    					f=false;
		    					break;
		    				}
		    			}
	    			}
	    			if(f) {
	    				System.out.println("Yes");
	    				return;
	    			}
	    	    }
		    }
	    }
	    System.out.println("No");
//        if (f) {
//    	    String a=Sq.substring(0, S.lastIndexOf(T)) + T + Sq.substring(S.lastIndexOf(T)+T.length());
//    	    System.out.print(a.replaceAll("\\?", "a"));
//        }else {
//        	System.out.print("UNRESTORABLE");
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 37196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K;
    cin >> K;
    if(K%2==0){
        cout << -1 << "\n";
        return 0;
    }
    int now = 0;
    for(int i=1;i<=1e8;i++){
        now = (10*now+7)%K;
        if(now==0){
            cout << i << "\n";
            return 0;
        }
    }
    cout << -1 << "\n";
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        bool trues = true;
        int n = Read.Int();
        for (int i = 0; i < n; i++)
        { 
            int[] a = Read.ints();
        if (trues == false) { continue; }
            if (a[1] + a[2] > a[0]) { trues = false;continue; }
            if ((a[0]-(a[1] + a[2] )) % 2 == 1) { trues = false; continue; }
        }
        Console.WriteLine(trues ? "Yes":"No");
        Console.ReadLine();
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    public static bool IsPrime(int num)
    {
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2)
        {
            if (num % i == 0)
            {
                // 素数ではない
                return false;
            }
        }

        // 素数である
        return true;
    }
}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long() { return long.Parse(Console.ReadLine()); }
    public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); }
    public static int Int() { return int.Parse(Console.ReadLine()); }
    public static int[] ints() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 17456
#include<stdio.h>
int main()
{
    int r,g,b,sum=0;
    scanf("%d%d%d",&r,&g,&b);
    sum=sum*10+r;
    sum=sum*10+g;
    sum=sum*10+b;
    if(sum%4==0)
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
int main()
{
std::string input{};
std::getline(std::cin,input,'\n');
if (input.size()==3)
 for (auto iter{rbegin(input)};iter!=rend(input);++iter)
  std::cout<<*iter;
else
 std::cout<<input;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define pf push_front

using namespace std;	
typedef long long int lli;
lli n,k,m,t,a,b,l,r,temp1,temp2,s,x,y,temp,q,d,mod=1e9+7,w,p,c;

lli gcd (lli a, lli b) {
    if (b == 0)
        return a;
    else
        return gcd (b, a % b);
}
lli hashm[1000005];
lli spf[1000005];

void precalc()
{
	spf[1]=1;
	
	for(int i=2;i<=1000000;i++)
	{
		if(spf[i]==0)
		{
			for(int j=i;j<=1000000;j+=i)
			{
				spf[j]=i;	
			}
		}
	}
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 	precalc();
	cin>>n;
	vector<lli>v(n);
	
	for(int i=0;i<n;i++)
	{	
		cin>>v[i];
		
		lli temp=v[i];
	
		set<lli>dis;
		
		while(spf[temp]>1)
		{
			dis.insert(spf[temp]);
			temp=temp/spf[temp];
		}
		
		for(auto x:dis)hashm[x]++;
	}
	
	bool pairw=true,setwise=false;
	
	for(int i=0;i<n;i++)
	{
		lli temp=v[i];
		
		set<lli>dis;
		
		while(spf[temp]>1)
		{
			dis.insert(spf[temp]);
			temp=temp/spf[temp];
		}
		
		for(auto x:dis)
		{
			hashm[x]--;
		}
		
		for(auto x:dis)
		{
			if(hashm[x]>=1)pairw=false;
		}
		
		if(!pairw)break;
	}
	
	lli temp=v[0];
	
	for(int i=1;i<n;i++)
	{
		temp=gcd(temp,v[i]);
	}
	
	if(temp==1)setwise=true;
	
	if(pairw)
	{
		cout<<"pairwise coprime"<<endl;
	}
	else if(setwise)
	{
		cout<<"setwise coprime"<<endl;
	}
	else
	{
		cout<<"not coprime"<<endl;
	}
	
	
	
}


Measured memory_bytes: 26492
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll n, ll m) { cout << (n - 1) * (m - 1) << endl; }

int main() {
  ll n;
  cin >> n;
  ll m;
  cin >> m;
  solve(n, m);
  return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
# pragma GCC target("avx2")
# pragma GCC optimize("O3")
# pragma GCC optimize("unroll-loops")
# define int long long

using namespace std;

const int N = 3e3 + 7;
const int mod = 1e9 + 7;

double dp[N][N];

int32_t main() {
    speed;
    int n;
    cin >> n;
    vector < double > a(n + 1), b(n + 1);
    for ( int i = 1; i <= n; i++ ) {
        cin >> a[i];
        b[i] = 1.0 - a[i];
        //cout << a[i] << ' ' << b[i] << '\n';
    }
    dp[0][0] = 1;
    for ( int i = 1; i <= n; i++ ) {
        for ( int j = 0; j <= i; j++ ) {
            dp[i][j] += dp[i - 1][j] * b[i];
            if ( j )
                dp[i][j] += dp[i - 1][j - 1] * a[i];
            //cout << i << ' ' << j << ' ' << dp[i][j] << '\n';
        }
    }
    double ans = 0;
    for ( int i = n / 2 + 1; i <= n; i++ ) {
        //cout << i << ' ' << dp[n][i] << '\n';
        ans += dp[n][i];
    }
    cout << setprecision(10) << ans;
}


Measured memory_bytes: 50372
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(x=from;x<to;x++)

using namespace std;


int main(void){

int N, tm[10];
	cin >> N;
	rep(qq,N){
		bool chk = true;
		int bh=0,ch=0;
		rep(i,10) cin >> tm[i];
		rep(i,10){
			if(bh > tm[i] && ch > tm[i]){
				chk = false;
//				printf("i=%i (%d,%d)\n",i,bh,ch);
				break;
			}
			if(bh > tm[i] && ch < tm[i]) ch =tm[i];
			else if(ch > tm[i] && bh < tm[i]) bh =tm[i];
			else if(tm[i] -bh < tm[i] -ch) bh = tm[i];
			else                    ch = tm[i];
		}
		cout << (chk ? "YES": "NO") << endl;
	}
	return 0;
	
	
}

Measured memory_bytes: 1152
#include <stdio.h>

int main(){
  int n, i, j;
  scanf("%d", &n);
  int A[n], B[n], k=0;
  for(i=0;i<n;i++){
    scanf("%d", &A[i]);
    if(A[i]>k) k=A[i];
  }
  int C[k+1];

  for(i=0;i<=k;i++)C[i]=0;
  for(j=0;j<n;j++) C[A[j]]++;
  for(i=1;i<=k;i++) C[i] = C[i] + C[i - 1];
  for(j=n-1;j>=0;j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i=1;i<n;i++) printf("%d ", B[i]);
    printf("%d\n", B[n]);
  return 0;
}


Measured memory_bytes: 17424
#include<stdio.h>

int n,A[2000];

int main(){
  int i,Mi,q;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&Mi);
    if(solve(0,Mi))printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int solve(int i, int Mi){
  int Ans=0;
  if(Mi==0)return 1;
  if(i>=n)return 0;
  Ans = solve(i+1,Mi)||solve(i+1,Mi-A[i]);
  return Ans;
}



Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
int main()
{
    ll n ,ma ; cin >>n>>ma;
    map <ll,ll> m;
    for(ll i = 0 ; i <ma ;i++){
        ll x,y ; cin>>x >>y;
        m[x]++;m[y]++;

    }

    for(ll i = 0 ; i<n ;i++)
    {
        if(m[i] % 2) {
            cout<<"NO"<<endl;
            return 0;
        }


    }
    cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 6528
import sys
n = int(input())

lst = []
for i in range(n):
    a, b = (int(i) for i in input().split())
    lst.append([a, b])

sortedLst = sorted(lst, key=lambda x: x[1])

job = 0
for sl in sortedLst:
    job += sl[0]
    if job > sl[1]:
        print('No')
        sys.exit()

print('Yes')



Measured memory_bytes: 39608
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
#include<set>

using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)

#define shosu setprecision(10)
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
typedef pair<Q,ll> R;
ll longinf=1ll<<60;
int inf=1<<29;
//mleしなければぜんぶllでかく。
//↑はあんまり気にしなくていい。

int main(){
    int n,m;
    cin>>n>>m;
    int N=1<<n;
    int k[m];
    vector<int> s[n];
    rep0(l,m){
        cin>>k[l];
        rep0(j,k[l]){
            int a;
            cin>>a;
            a--;
            s[a].push_back(l);
        }
    }
    int p[m];
    rep0(l,m) cin>>p[l];
    int ans=0;
    rep0(st,N){
        int pos[m];
        fill(pos,pos+m,0);
        rep0(i,n){
            if((st>>i)&1){
                for(auto t:s[i]){
                    pos[t]++;
                }
            }
        }
        bool ok=true;
        rep0(l,m){
            if(pos[l]%2!=p[l]) ok=false; 
        }
        if(ok)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
sunuke_dict = {}
for i in range(K):
    d = int(input())
    sunuke_dict[i] = list(map(int,input().split()))
ans = [1]*(N+1)
ans[0]  =0
for v in sunuke_dict.values():
    for v_ in v:
        if ans[v_] == 1:
            ans[v_] =0
print(sum(ans))

Measured memory_bytes: 9224
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ll gcd(ll a, ll b) {
	if(a < b)swap(a, b);
	while (b) {
		ll r = a % b; a = b; b = r;
	}
	return a;
}
//x,yがax+by=gcd(a,b)の解になる
ll extgcd(ll a, ll b, ll& x, ll& y) {
	ll d = a;
	if (b != 0) {
		d = extgcd(b, a%b, y, x);
		y -= (a / b)*x;
	}
	else {
		x = 1; y = 0;
	}
	return d;
}
int main(){
	int n; cin >> n;
	ll key = (ll)25000 * 25000 * 2;
	rep(aa, n) {
		ll a, b; cin >> a >> b;
		ll x, y;
		bool tra = false;
		if (a < b) {
			tra = true; swap(a, b);
		}
		ll d = gcd(a, b);
		if (d == 1) {
			extgcd(b, -a, x, y);
			if (tra) {
				swap(a, b); swap(x, y);
			}
			cout << 3 << endl;
			cout << "0 0" << endl;
			cout << a << " " << b << endl;
			cout << x << " " << y << endl;
		}
		else {
			ll a1 = a / d; ll b1 = b / d;
			if (a1*a1 + b1 * b1 <= key) {
				if (tra) {
					swap(a1, b1); swap(a, b);
				}
				cout << 4 << endl;
				cout << "0 0" << endl;
				cout << a - 1 << " " << b << endl;
				cout << a1 << " " << b1 << endl;
				cout << a << " " << b - 1 << endl;
			}
			else {
				extgcd(b1, -a1, x, y);
				if (tra) {
					swap(x, y); swap(a, b);
				}
				cout << 3 << endl;
				cout << "0 0" << endl;
				cout << a << " " << b << endl;
				cout << x << " " << y << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#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 mp make_pair
#define fi first
#define sc second
int n;
int t[1000],v[1000];

int f(int i,int x) {
	if(i == 0) {
		return x;
	}
	if(i == n + 1) {
		return t[n] - x;
	}

	i--;
	if(0 <= x && x <= t[i]) {
		return v[i] + (t[i] - x);
	}else if(x <= t[i + 1]) {
		return v[i];
	}else 
		return v[i] + (x - t[i + 1]);
}

int main(){
	cin >> n;
	t[0] = 0;
	REP(i,n) {
		cin >> t[i + 1];
		t[i + 1] *= 2;
	}
	REP(i,n){
		cin >> v[i];
		v[i] *= 2;
	}
	REP(i,n) {
		t[i + 1] += t[i];
	}

	int pre = 0;
	ll ans = 0;
	REP(i,t[n] + 1) {
		int mini = 1000000000;
		REP(j,n + 2) {
			mini = min(mini,f(j,i));
		}
		if(pre < mini) {
			ans += pre * 2 + 1;
		}else if(pre == mini) {
			ans += pre * 2;
		}else 
			ans += pre * 2 - 1;
		pre = mini;
	}

	printf("%10.10lf\n",ans / 8.0);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n, k; cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; i++) cin >> h[i];
  sort(h.rbegin(), h.rend());
  ll ans = 0;
  for (int i = k; i < n; i++) ans += h[i];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
import fractions

N,X = map(int,input().split())
x_ = list(map(int,input().split()))
x_.append(X)
x_.sort()

d_ = list(set([x_[i+1]-x_[i] for i in range(N)]))

gcd = d_[0]
for i in d_[1:]:
  gcd = fractions.gcd(gcd,i)
print(gcd)
  

Measured memory_bytes: 16284
import java.util.*

fun main(args: Array<String>) {
    val N = nextInt()
    val A = Array<Double>(N) { nextDouble() }
    val D = mutableListOf<Double>()
    for (n in 0 until N) {
        if (D.count() == 0) {
            D.add(A[n])
        } else {
            val a = D.binarySearch(A[n] - 0.1 , Comparator<Double> { a, b -> a.compareTo(b) })
            val b = a.inv()
            if (a >= 0) {
                D.add(a, A[n])
            } else if (b == 0){
                D.add(0, A[n])
            } else {
                D[b - 1] = A[n]
            }
        }
    }
    val ans = D.count()
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun nextDouble() = next().toDouble()


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

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
	return x * f;
}

int main()
{
	int n = read();
	if (n >= 30) puts("Yes");
		else puts("No");
	return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

void hoge(vector<int> &v) {
  sort(ALL(v));
  v.erase(unique(ALL(v)), v.end());
}

int x[5000], y[5000], num[5000];
int a[5001][5001];
int sum[5001][5001];

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> xs, ys;
  REP(i,n) {
    cin >> x[i] >> y[i];
    xs.push_back(x[i]);
    ys.push_back(y[i]);
  }
  hoge(xs);
  hoge(ys);
  REP(i,n) {
    int yy = lower_bound(ALL(ys),y[i]) - ys.begin();
    int xx = lower_bound(ALL(xs),x[i]) - xs.begin();
    a[yy][xx]++;
    //cout << yy << " " << xx << endl;
  }
  REP(i,ys.size()) {
    REP(j,xs.size()) {
      sum[i+1][j+1] = sum[i][j+1] + sum[i+1][j] - sum[i][j] + a[i][j];
    }
  }
  REP(i,m) {
    int xx1, yy1,xx2, yy2;
    cin >> xx1 >> yy1 >> xx2 >> yy2;

    int x2 = lower_bound(ALL(xs),xx1) - xs.begin();
    int y2 = lower_bound(ALL(ys),yy1) - ys.begin();
    int x1 = upper_bound(ALL(xs),xx2) - xs.begin();
    int y1 = upper_bound(ALL(ys),yy2) - ys.begin();
    //cout << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
    int res = sum[y1][x1]+sum[y2][x2]-sum[y1][x2]-sum[y2][x1];
    cout << res << endl;
    
  }
}

Measured memory_bytes: 196040
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;


//const int mod=1000000007;
const int mod=998244353;
//



int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d;
    cin >> a >> b;
    if(b>=a)
        cout << "unsafe\n";
    else
        cout << "safe\n";
    
    return 0;
    
}



Measured memory_bytes: 3652
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
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()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int N;
    cin >> N;

    vll H(N);
    rep(i, N) in(H[i]);

    ll count = 0;
    rep(i, N)
    {
        bool flg = true;
        rep(j, i)
        {
            if (H[i] < H[j])
            {
                flg = false;
                break;
            }
        }

        if (flg) count++;
    }

    outl(count);

    return 0;
}

Measured memory_bytes: 3624
n,m=map(int,input().split())
if n%2==1:
    #x=["{} {}".format(i+1,n-i) for i in range(m)]
    x=[f"{i+1} {n-i}" for i in range(m)]
    print(" ".join(x))
else:
    #x=["{} {}".format(i+1,n-i) if i<m/2 else "{} {}".format(i+1,n-i-1) for i in range(m)]
    x=[f"{i+1} {n-i}" if i<m/2 else f"{i+1} {n-i-1}" for i in range(m)]
    print(" ".join(x))

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

int main(){
  int64_t N,K;
  cin >>N>>K;
  vector<int> H(N);
  
  for(int i=0;i<N;i++){
    cin >>H.at(i);
  }
  sort(H.begin(),H.end());
  reverse(H.begin(),H.end());
  int64_t sum =0;
  for(int i = K;i<N;i++){
    sum += H.at(i);
  }
  cout <<sum<<endl;
}


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

int main(){
	int x,n;
	cin >> x >> n;
	set<int> all;
	for(int i=0;i<n;i++){
		int a;
		cin >> a;
		all.insert(a);
	}
	for(int i=0;i<n+3;i++){
		if(!all.count(x-i)){
			cout << x-i << '\n';
			return 0;
		}
		if(!all.count(x+i)){
			cout << x+i << '\n';
			return 0;
		}
	}
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#include<vector>
#include<string>
using namespace std;
#define l long long
#define pb push_back
#define mem(a,n) memset(a,n,sizeof(a))
#define find(v,n) find(v.begin(),v.end(),n)
#define sort1(v) sort(v.begin(),v.end())
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mod 998244353
#define reverse(s) reverse(s.begin(),s.end())
//#define pi pair<l,l> 
const double pi=3.141592653589793;
bool isprime(l n)
{
	for(l i=2;i<=n;i++)
	{
		if(n%i==0)
			return false;
	}
	return true;
}
/*bool fact(l n)
{
	vector<l> v;
	for(l i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			if(i%2==1||(n/i)%2==1)
			{
				return true;
			}
		}
	}
	return false;
}*/
l power(l a,l b)
{
	l ans=1;
	while(b>0)
	{
		if(b&1)
		{
			ans=(ans*a)%mod;
		}
		b>>=1;
		a=(a%mod*a%mod)%mod;
	}
	return ans;
}//prefixsums
void frooty()
{
	l n,k;
	cin>>n>>k;
	vector<l> v;
	for(l i=0;i<n;i++)
	{
		l a;
		cin>>a;
		v.pb(a);
	}
	l sum=0;
	sort1(v);
	for(l i=0;i<k;i++)
	{
		sum+=v[i];
	}
	cout<<sum<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int q=1;
//	cin>>q;
	while(q--)
	{
		frooty();
	}
}

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

int main() {
  
   int A,B;
  cin>>A>>B;
  
  int c=A*B;
    
  if(c%2==0){
    	cout<<"Even";
    }
  	
  else{
    cout<<"Odd";
    }
  
}


       


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
//ビーカーにちょうどx[g]の水を入れられる必要十分条件は非負整数i,jが存在してx=100*A*i+100*B*jとなること。
//同様にビーカーにy[g]の砂糖を入れられる必要十分条件は非負整数i,jが存在してy=C*i+D*jとなること
//x,yとしてはF以下の値だけを考えればよいのでx,yとしてあり得る値は全てのi,jを試すことで全列挙できる
//最後にすべての(x,y)の組についてビーカーに水をx[g]と砂糖をy[g]入れた時に砂糖が水に全て溶けているかどうか調べ、
//溶けているものについて濃度が最大のものをとって出力すればよい
int main() {
	double A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	double water;
	double sugar;
	double ans = 0;
	for (double i = 0; i*100*A<=F; ++i) {
		for (double j = 0; i * 100 * A + j * 100 * B <= F; ++j) {
			for (double k = 0; i * 100 * A + j * 100 * B+k*C <= F; ++k) {
				for (double l = 0; i * 100 * A + j * 100 * B + k * C+l*D <= F; ++l) {
					if ((k*C + l * D) * 100 / E > i * 100 * A + j * 100 * B)continue;
					else {
						double New = 100 * (k*C + l * D) / (i * 100 * A + j * 100 * B);
						if (ans <= New) {
							ans = New;
							water = i * 100 * A + j * 100 * B;
							sugar = k * C + l * D;
						}
					}
				}
			}
		}
	}
	cout << water+sugar << " " << sugar << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#pragma warning(disable : 4996)
int N, Q, v[1048588], vx[1048588], vy[1048588], pc[75]; char s[1048588], qs[29];
int main() {
	scanf("%d%d%s", &N, &Q, s);
	for (int i = 0; i < 1 << N; ++i) {
		v[i] = s[i] - '0';
		vx[i] = v[i];
		vy[i] = v[i];
	}
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 1 << N; ++j) {
			if ((j >> i) & 1) {
				vx[j] += vx[j - (1 << i)];
				vy[j - (1 << i)] += vy[j];
			}
		}
	}
	pc[0] = 1;
	for (int i = 1; i < 1 << (N / 3); i++) {
		pc[i] = pc[i >> 1] ^ (i & 1);
	}
	for (int i = 0; i < Q; ++i) {
		scanf("%s", qs);
		int cx = 0, cy = 0, cz = 0, sx = 0, sy = 0, sz = 0;
		for (int j = 0; j < N; ++j) {
			if (qs[N - j - 1] == '0') ++cx, sx |= 1 << j;
			if (qs[N - j - 1] == '1') ++cy, sy |= 1 << j;
			if (qs[N - j - 1] == '?') ++cz, sz |= 1 << j;
		}
		int ret = 0;
		if (3 * cz <= N) {
			for (int j = sz; j >= 0; --j) {
				j &= sz;
				ret += v[j + sy];
			}
		}
		else if (3 * cy <= N) {
			for (int j = sy, k = 0; j >= 0; --j, ++k) {
				j &= sy;
				if(pc[k]) ret += vx[j + sz];
				else ret -= vx[j + sz];
			}
		}
		else {
			for (int j = sx, k = 0; j >= 0; --j, ++k) {
				j &= sx;
				if (pc[k]) ret += vy[sx + sy - j];
				else ret -= vy[sx + sy - j];
			}
		}
		printf("%d\n", ret);
	}
	return 0;
}


Measured memory_bytes: 16052
#include <iostream>
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ull unsigned long long 
#define ll long long 
#define pre(a,b) cout<<fixed<<setprecision(a)<<b<<"\n";//a for precision b for answer
#define mp make_pair
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define pb push_back 
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b) 
#define forn(n) for(ll i=0;i<n;i++) 
#define ff first
#define ss second
#define MAX 1e18;
#define all(x) (x).begin(),(x).end()
#define lb lower_bound
#define ub upper_bound
#define vmin *min_element
#define vmax *max_element
const int MOD = 1e9 + 7;
const int v1=1e5+5;
#define pi 3.141592653589793238
const int N=2e5+5;
 
 
//cout<<"Case #"<<p<<": "<<;
//f ile input  freopen("input.txt","r",stdin); 
//file output freopen("output.txt","w",stdout);
 
using namespace std;
 
vector < vector < ll > > adj(N);
vector <bool> visited(N);
ll ans=0;
vector <ll> dp;
 
void dfs(ll v)
{
  visited[v]=true;
  //ans=max(ans,count1);
  for(auto i:adj[v])
  {
    if(!visited[i])
      dfs(i);
    dp[v]=max(dp[v],1+dp[i]);
  }
}
 
int32_t main()
{
  IOS;
  ll n=0;
  ll m=0;ll x,y;
  cin>>n>>m;
  ll w=0;
  map <ll,ll> q;
  vector <ll> p;
  forn(m)
  {
    cin>>x>>y;
    adj[x].pb(y);
    q[x]++;
    if(q[x]==1)
    {
      p.pb(x);w++;
    }
    //adj[y].pb(x);
  }
  dp.resize(n+1);
  p.resize(w);
  forn(w)
  {
    if(!visited[p[i]])
    {
      dfs(p[i]);
    }
  }
  cout<<vmax(all(dp))<<"\n";
}

Measured memory_bytes: 18420
suuji = int(input())
srclist = [1, 2, 4, 8, 16, 32, 64, 128]
dst = 0
for i in range(len(srclist)):
    if srclist[i] > suuji:
        break
print(srclist[i-1])
cntmax = 0
dst = 1
for i in range(suuji):
    for cnt in range(1, 1000):
        bit = 2**cnt-1
        if i & bit != 0:
            break
    if cntmax < cnt - 1:
        cntmax = cnt - 1
        dst = i


Measured memory_bytes: 3060
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
#define N 100005
int num[N];
bool peak[N];
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;++i)  scanf("%d",&num[i]),peak[i]=true;
	for(int i=1;i<=m;++i)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		if(num[x]>=num[y]) peak[y]=false;
		if(num[y]>=num[x]) peak[x]=false;
	}
	int ans=0;
	for(int i=1;i<=n;++i) if(peak[i]) ++ans;
	cout<<ans;
	return 0;
}

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

using ll = long long;
const ll INF = (1LL << 31) - 1;

// Segment-Tree
struct SegmentTree {
  int n;
  vector<ll> dat;
  
  SegmentTree(int _n) {
    init(_n);
  }
  
  void init(int _n) {
    n = 1;
    while (n < _n) n *= 2;
    dat.resize(2 * n - 1, INF);
  }
  
  // i番目の値をxに変更
  void update(ll i, ll x) {
    i += n - 1; // 葉のノード
    dat[i] = x;
    while (i > 0) { // 更新
      i = (i - 1) / 2;
      dat[i] = min(dat[2 * i + 1], dat[2 * i + 2]);
    }
  }
  
  // [a, b)の最小値
  // k:ノードの番号 [l, r)がkに対応づいている
  // query(a, b, 0, 0, n)と呼ぶ
  ll query(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r == -1) r = n;
    if (r <= a || b <= l) return INF;
    if (a <= l && r <= b) return dat[k];
    else {
      ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
      ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
      return min(vl, vr);
    }
  }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, q;
  cin >> n >> q;
  
  SegmentTree st(n);
  
  while (q--) {
    ll com, x, y;
    cin >> com >> x >> y;
    if (com == 0) {
      st.update(x, y);
    }
    else {
      cout << st.query(x, y + 1) << '\n';
    }
  }
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

int64 GCD(int64 a, int64 b) {
  if (a < b) return GCD(b, a);
  int64 r = a % b;
  if (r == 0) return b;
  else return GCD(b, r);
}

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

  int64 a, b;
  cin >> a >> b;
  int64 d = GCD(a, b);
  // cout << d << endl;

  set<int64> ps;
  ps.insert(1);
  while (true) {
    bool found = false;
    for (int64 x = 2; x * x <= d; x++) {
      if (d % x == 0) {
        ps.insert(x);
        d /= x;
        found = true;
        break;
      }
    }
    if (!found) {
      ps.insert(d);
      break;
    }
  }
  cout << ps.size() << endl;
}

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

using namespace std;

typedef long long ll;

#include <iostream>
#include <vector>

using namespace std;

struct potential_union_find {
    vector<int> par, sz, diff_weight;

    potential_union_find(int n) {
        par.resize(n);
        sz.resize(n);
        diff_weight.resize(n);
        for (int i = 0; i < n; i++) {
            par[i] = i;
            sz[i] = 0;
            diff_weight[i] = 0;
        }
    }

    int find(int x) {
        if (x == par[x])
            return x;
        else {
            int r = find(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    int weight(int x) {
        find(x);
        return diff_weight[x];
    }

    int diff(int x, int y) {
        return diff_weight[y] - diff_weight[x];
    }

    bool unite(int x, int y, int w) {
        w += weight(x);
        w -= weight(y);
        
        x = find(x), y = find(y);

        if (x == y)
            return false;
        
        if (sz[x] < sz[y]) {
            swap(x, y);
            w = -w;
        }

        if (sz[x] == sz[y])
            sz[x]++;
        par[y] = x;

        diff_weight[y] = w;
        return true;
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

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

    potential_union_find uf(n);

    for (int i = 0; i < m; i++) {
        int l, r, d;    cin >> l >> r >> d;

        if (uf.same(r, l) && uf.diff(r, l) != d) {
            cout << "No" << endl;
            return 0;
        }

        else if (!uf.same(r, l)) {
            uf.unite(r, l, d);
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>

int main(void) {
	int N;
	int i;
	int current = 0, max = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		int A;
		if (scanf("%d", &A) != 1) return 1;
		if (A == 0) current = 0; else current++;
		if (max < current) max = current;
	}
	printf("%d\n", max + 1);
	return 0;
}



Measured memory_bytes: 2140