akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	static class Vertex{
		List<Integer> adj;
		int parent;
		boolean leaf;
		int maxDepth;
		public Vertex() {
			adj = new ArrayList<Integer>();
		}
		void add(int e){
			adj.add(e);
		}
	}
	static void dfs(Vertex vs[] , int start , int[] depth){
		Arrays.fill(depth, -1);
		depth[start] = 0;
		vs[start].parent = start;
		Queue<Integer> q = new LinkedList<Integer>();
		q.add(start);
		while(!q.isEmpty()){
			int c = q.poll();
			int cd = depth[c];
			boolean leaf = true;
			for(int a : vs[c].adj){
				if(depth[a] >= 0){
					continue;
				}
				leaf = false;
				vs[a].parent = c;
				depth[a] = cd + 1;
				q.add(a);
			}
			vs[c].leaf = leaf;
		}
	}
	static int searchDepth(Vertex vs[] , int start , int[] depth){
		int maxDepth = depth[start];
		if(vs[start].leaf){
			vs[start].maxDepth = depth[start];
			return depth[start];
		}
		for(int i : vs[start].adj){
			if(i == vs[start].parent){
				continue;
			}
			int m = searchDepth(vs, i, depth);
			maxDepth = Math.max(m, maxDepth);
		}
		vs[start].maxDepth = maxDepth;
		return maxDepth;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int u = sc.nextInt() - 1;
		int v = sc.nextInt() - 1;
		Vertex vs[] = new Vertex[N];
		for(int i = 0 ; i < N ; ++i){
			vs[i] = new Vertex();
		}
		for(int i = 0 ; i < N - 1; ++i){
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			vs[a].add(b);
			vs[b].add(a);
		}
		int depth[] = new int[N];
		dfs(vs , v , depth);
		searchDepth(vs , v , depth);
		int pu = u;
		int md = vs[u].maxDepth;
		int mi = u;
		while(pu != v){
			int d = depth[pu];
			int ud = depth[u] - depth[pu];
			int vd = depth[pu];
			if(ud >= vd){
				break;
			}
			if(md < vs[pu].maxDepth){
				mi = pu;
				md = vs[pu].maxDepth;
			}
//			System.out.println(ud+" "+vd+" "+pu+" "+vs[pu].maxDepth);
			pu = vs[pu].parent;
		}
		int T = 0;
		int cu = u;
		int vdepth = 0;
		boolean asc = true;
//		System.out.println(mi+" "+md);
		while(depth[cu] != vdepth){
//			System.out.println(cu+" "+vdepth+" "+depth[cu]+" "+vs[cu].leaf+" "+asc);
			if(T % 2 == 0){
				if(cu == mi){
					asc = false;
				}
				if(asc){
					cu = vs[cu].parent;
				}else if(vs[cu].leaf){
					cu = vs[cu].parent;							
				}else{
					for(int a : vs[cu].adj){
						if(a == vs[cu].parent){
							continue;
						}
						if(vs[a].maxDepth != md){
							continue;
						}
						cu = a;
						break;
					}
				}
			}else{
				++vdepth;
			}
//			System.out.println(cu+" "+vdepth+" "+depth[cu]);
			++T;
		}
		System.out.println(T / 2);			
	}
}


Measured memory_bytes: 115680
#include<iostream>
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,a;
    cin>>s>>a;
    reverse(s.begin(),s.end());
    if(s==a)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }


}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll x;
	cin>>x;
	ll ans = (x/500)*1000;
	x = x%500;
	ans+=(x/5)*5;
	cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int A[3010];
ll mod=998244353, dp[3010][3010];

int main(void){
    int N, S;
    cin >> N >> S;
    for(int i=0; i<N; ++i) cin >> A[i];
    dp[0][0]=1;
    for(int i=1; i<=S; ++i) dp[0][i]=0;
    for(int i=0; i<N; ++i){
        for(int j=0; j<=S; ++j){
            dp[i+1][j]=(dp[i][j]*2)%mod;
            if(j>=A[i]) (dp[i+1][j] += dp[i][j-A[i]]) %= mod;
        }
    }
    cout << dp[N][S] << endl;
    return 0;
}


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

int n, h[102020], dp[102020];

int main(void){
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> h[i];
        dp[i] = INT_MAX/2;
    }
    dp[0] = 0;
    
    
    
    for(int i=0;i<n;i++){
        if(dp[i] + abs(h[i] - h[i+1]) < dp[i+1] ) {
            dp[i+1] = dp[i] + abs(h[i] - h[i+1]);
        } 
        if(dp[i] + abs(h[i] - h[i+2]) < dp[i+2] ) {
            dp[i+2] = dp[i] + abs(h[i] - h[i+2]);
        }
    }
    
    cout << dp[n-1] << endl;
    
    return 0;
}

Measured memory_bytes: 1024
/// referenced: https://beta.atcoder.jp/contests/abc060/submissions/2402625
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
main(){
  int N,W;
  cin>>N>>W;
  vector<int> w(N), v(N);
  for(int i=0;i<N;++i)cin>>w[i]>>v[i];
  for(int i=1;i<N;++i)w[i]-=w[0];
  
  vector<vector<int>> xss(4, vector<int>());
  xss[0].push_back(v[0]);
  for(int i=1;i<N;++i)xss[w[i]].push_back(v[i]);
  for(int i=0;i<4;++i)sort(xss[i].rbegin(), xss[i].rend());
  for(int i=0;i<4;++i)xss[i].insert(xss[i].begin(), 0);
  for(int i=0;i<4;++i)
    for(int j=0;j<xss[i].size()-1;++j)
      xss[i][j+1]+=xss[i][j];
  
  int max_=0;
  for(int i=0;i<xss[0].size();++i)
    for(int j=0;j<xss[1].size();++j)
      for(int k=0;k<xss[2].size();++k)
        for(int l=0;l<xss[3].size();++l) {
          int weight=i*(w[0]+0)+j*(w[0]+1)+k*(w[0]+2)+l*(w[0]+3);
          if(weight>W)continue;
          int value=xss[0][i]+xss[1][j]+xss[2][k]+xss[3][l];
          max_=max(max_,value);
        }
  cout<<max_<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int a[4], b[4];
	while (1) {
		for (int i=0; i<4; ++i) cin >> a[i];
		for (int i=0; i<4; ++i) cin >> b[i];

		if (cin.eof()) break;

		int hit = 0, blow = 0;
		for (int i=0; i<4; ++i) {
			for (int j=0; j<4; ++j) {
				if (a[i] == b[j] && i == j) {
					hit ++;
				} else if (a[i] == b[j]) {
					blow ++;
				}
			}
		}

		cout << hit << " " << blow << endl;
	}
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
using NX = System.Int64;


public class Prog
{
    public static void Solve()
    {
        int N = NextInt();
        if (N % 2 == 0) { Console.WriteLine(N / 2 - 1); }
        else { Console.WriteLine(N/2); }

    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
        return;
    }
}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}

Measured memory_bytes: 11220
import java.util.*;

class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String S = sc.next();
      String T = sc.next();
      String result = "Yes";
      
      if(S.length()+1 != T.length()){
        result = "No";
      }
      if(!T.substring(0,S.length()).equals(S)){
        result = "No";
      }
      
      System.out.println(result);
    }
}

Measured memory_bytes: 35724
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,a,b,c;
    
    cin>>n;
    
    a=n/100;
    b=(n-a*100)/10;
    c=n-a*100-b*10;
    //cout<<a<<b<<c<<endl;
    
    if(a==9) a=1;
    else if(a==1) a=9;
    if(b==9) b=1;
    else if(b==1) b=9;
    if(c==9) c=1;
    else if(c==1) c=9;
    
    cout<<a*100+b*10+c<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b;
  
  c = a * b;
  
  if(c % 2 == 1){ 
  	cout << "Odd" << endl;
  }
  else{
    cout << "Even" << endl;
  }
}

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

int main (){
	int a,b;cin>>a>>b;
	for(int i=b-a+1;i<=b+a-1;i++)if(i>=-1000000&&i<=1000000)cout<<i<<" ";
	cout<<endl;
	return 0;
}

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

/// Create sieve table for 0,...,n-1, O(n log n)
fn eratosthenes_sieve(n: usize) -> Vec<i32> {
    let mut sieve = vec![0; n];
    sieve[0] = 1;
    sieve[1] = 1;
    for i in 2..n {
        if i * i >= n {
            break;
        }
        for j in 2..=n / i {
            if i * j >= n {
                continue;
            }
            if sieve[i * j] != 0 {
                continue;
            }
            sieve[i * j] = i as i32;
        }
    }
    sieve
}

fn main() {
    input! {
        q: usize,
        lr: [(usize, usize); q],
    }
    let n = 1000000;
    let sieve = eratosthenes_sieve(n + 1);

    let mut cum = vec![0; n + 1];
    for i in 0..=n {
        if i % 2 == 1 && sieve[i] == 0 && sieve[(i + 1) / 2] == 0{
            cum[i] = 1;
        }
    }
    for i in 0..n {
        cum[i + 1] += cum[i];
    }

    for i in 0..q {
        println!("{}", cum[lr[i].1] - cum[lr[i].0 - 1]);
    }
}


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

typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999

int data[20][20];


int main(){
    int n;
    while(cin>>n){
        if(n==0)break;
        
        rep(i,20)rep(j,20)data[i][j]=0;
        int x,y;
        x=(n-1)/2;
        y=(n-1)/2+1;
        
        int c=1;
        while(1){
//            cout<<x<<" "<<y<<endl;
            if( x<0 ){
                x=n-1;
            }else if(y<0){
                y=n-1;
            }else if(y>=n){
                y=0;
            }else if(x>=n){
                x=0;
            }
            else if( data[x][y]!=0 ){
                x--,y++;
            }
            else{
                data[x][y]=c;
                c++;
                x++,y++;
            }
//            cout<<c<<endl;
            if(c==n*n+1)break;
        }
        rep(i,n){
            rep(j,n){
                printf("%4d",data[j][i]);
            }
            cout<<endl;
        }
   }
}

Measured memory_bytes: 1192
#include <iostream>

int main()
{
    int x, a, b;
    std::cin >> x >> a >> b;

    if (b - a <= 0) {
        std::cout << "delicious" << std::endl;
    } else if (b - a <= x) {
        std::cout << "safe" << std::endl;
    } else {
        std::cout << "dangerous" << std::endl;
    }
}


Measured memory_bytes: 256
N, M = map(int, input().split())
id = [0 for i in range(N)]

max_l = 0
min_r = 100000
for _ in range(M):
  l, r = map(int, input().split())
  if max_l < l:
    max_l = l
  if min_r > r:
    min_r = r

id = min_r-max_l+1
print(0 if id <0 else id)

Measured memory_bytes: 79276
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    
    const MAX = 110000;
    let dp = [...Array(N)];
    
    for(let i=0; i<MAX; i++) {
        dp[i] = Infinity;
    }
    
    dp[0] = 0;
    
    for(let i=1; i<=N; i++) {
        for(let pow6=1; pow6<=i; pow6 *= 6) {
            dp[i] = Math.min(dp[i], dp[i - pow6] + 1);
        }
        
        for(let pow9=1; pow9<=i; pow9 *= 9) {
            dp[i] = Math.min(dp[i], dp[i - pow9] + 1);
        }
    }

    console.log(dp[N]);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 25620
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>21){
		cout<<"bust";
	}else{
		cout<<"win";
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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


int main(){
	int a,b;
	cin >> a >> b;
	if(a>=13){
		cout << b << endl;
	}else if(a>=6){
		cout << b/2 << endl;
	}else{
		cout << "0" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
N = int(input())
H_list = list(map(int, input().split()))



for i in range(len(H_list)):
    if i ==0:
        H_max = H_list[0]
        count = 1

    elif H_max <= H_list[i]:

        count += 1
        H_max = H_list[i]

print(count)


Measured memory_bytes: 2940
[a, b, c] = [int(input()) for _ in range(3)]
x = int(input()) / 50

count = 0
for num_x in range(int(x/10) + 1):
    if num_x > a:
        break
    x1 = x - 10*num_x
    for num_ii in range(int(x1/2) + 1):
        if num_ii > b:
            break
        num_i = x1 - 2*num_ii
        if num_i <= c:
            count += 1

print(count)

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

using namespace std;

#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(0)
typedef long long ll;
//#define int ll
#define swap(x, y)((x)^=(y)^=(x)^=(y))
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define f first
#define tcase int _; cin>> _; for( ; _; --_)
#define s second
#define endl '\n'
const int MAX = 1e6+1;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const double DEG = 180/PI;
const int MOD = 1e9+7;
int mod(int x, int m){ if(x >= 0) return x % m; if(-x < m) return m-(-x); return mod(x%m, m);}
int gcd (int a, int b) {while(b){a = mod(a, b); swap(a, b);} return a;}
int lcm (int a, int b) {return a / gcd(a, b) * b;}
int fexp(int base, int exp, int m){
	int total = 1;
	while(exp > 0){
		if(exp % 2 == 1){
			total = mod(((mod(total, m)) * (mod(base, m))), m);
			exp--;
		}
		base= mod((mod(base, m) * mod(base, m)), m);
		exp /= 2;
	}
	return mod(total, m);
}

int n;

void solve(){
	string s;

	cin>> s;
	n = s.size();
	int ans = 0;
	for(int i = 0; i< n/2; ++i)
		if(s[i] != s[n-i-1]) ans++;

	cout<< ans<< endl;
}

int32_t main(){
	fastio;
	solve();
	return 0;
}

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

using namespace std;

int main()
{
   long double a,b,c;
   cin>>a>>b>>c;
   long double ans=a+b+2*sqrt(a)*sqrt(b);
   //cout<<sqrt(a)<<" "<<sqrt(b)<<" "<<sqrt(c)<<endl;
   if(ans<c) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   
   return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            ans = i*500+j*100+k*50
            if ans == x:
                count +=1

print(count)



Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ll long long
using namespace std;
string s[1005],t[1005];
ll pre[1005][1005];
ll pre2[1005][1005];
ll mp[1005];
ll mq[1005];
int n1,m1,n2,m2;
ll p=131,q=233;
ll Q=1e9+7;
void solve(){
	mp[0]=mq[0]=1;
	for(int i=1;i<=1000;i++){
		mp[i]=mp[i-1]*p%Q;
		mq[i]=mq[i-1]*q%Q;
	}
	for(int i=1;i<=n1;i++){
		for(int j=1;j<=m1;j++){
			pre[i][j]=(-pre[i-1][j-1]*p*q+pre[i-1][j]*p+pre[i][j-1]*q+s[i-1][j-1])%Q;
			pre[i][j]=(pre[i][j]+Q)%Q;
		}
	}
	for(int i=1;i<=n2;i++){
		for(int j=1;j<=m2;j++){
			pre2[i][j]=(-pre2[i-1][j-1]*p*q+pre2[i-1][j]*p+pre2[i][j-1]*q+t[i-1][j-1])%Q;
			pre2[i][j]=(pre2[i][j]+Q)%Q;
		}
	}
	ll hs=pre2[n2][m2];
	for(int i=1;i<=n1-n2+1;i++){
		for(int j=1;j<=m1-m2+1;j++){
			ll v=(pre[i+n2-1][j+m2-1]+pre[i-1][j-1]*mp[n2]%Q*mq[m2]%Q-pre[i+n2-1][j-1]*mq[m2]%Q-pre[i-1][j+m2-1]*mp[n2]%Q)%Q;
			v=(v+Q)%Q;
			if(v==hs){
				cout<<i-1<<' '<<j-1<<"\n";
			}
		}
	}	
}
int main(){
//	freopen("a.txt","r",stdin);
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin>>n1>>m1;
	for(int i=0;i<n1;i++)cin>>s[i];
	cin>>n2>>m2;
	for(int i=0;i<n2;i++)cin>>t[i];
	solve();	
	return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define ac(x, i) get<i>(x)
#define trace(x) cerr << #x : << x << "\n"
#define in insert
#define nl '\n'
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll ,ll>
#define ff first
#define ss second
#define MOD 1000000007

const int infi = 1e9;
const ll infl = 1e18;

int main() {
  #ifndef ONLINE_JUDGE
  //freopen("input.txt", "r", stdin);
  #endif
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int N, W; cin >> N >> W;
  ll w[N+1], v[N+1];
  for (int i = 1; i <= N; i++) {
    cin >> w[i] >> v[i];
  }
  ll dp[N+1][W+1];
  memset(dp, -1LL, sizeof(dp));
  for (int i = 0; i <= W; i++) dp[0][i] = 0;
  for (int i = 0; i <= N; i++) dp[i][0] = 0;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= W; j++) {
      if (w[i] > j) {
        dp[i][j] = dp[i-1][j];
      } else {
        dp[i][j] = max(dp[i-1][j], v[i] + dp[i-1][j-w[i]]);
      }
    }
  }
  cout << dp[N][W] << "\n";
  return 0;
}

Measured memory_bytes: 79232
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main(){
    ll a,b;
    cin >> a >> b;
    cout << 2*b-a << endl;
}


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

int main(){
	char tmp[13];
	scanf("%s", tmp);
	string str = tmp;
	for(int i=11; i>3; i--){
		str[i+1] = str[i];
	}
	str[4] = ' ';
	printf("%s\n", str.c_str());
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int D = sc.nextInt();
        int G = sc.nextInt();
        int[] p = new int[D];
        int[] c = new int[D];
        int total = 0;
        for (int i = 0; i < D; i++) {
            p[i] = sc.nextInt();
            c[i] = sc.nextInt();
            total += p[i];
        }
        int[] dp = new int[total + 1];
        for (int i = 0; i < D; i++)
            for (int k = dp.length - 1; k >= 0; k--)
                if (k == 0 || dp[k] > 0 && dp[k] < G)
                    for (int j = 1; j <= p[i]; j++) {
                        int point = j * 100 * (i + 1);
                        if (j == p[i]) point += c[i];
                        if (dp[k] + point > dp[k + j])
                            dp[k + j] = dp[k] + point;
                    }
        for (int i = 1; i < dp.length; i++)
            if (dp[i] >= G) {
                System.out.println(i);
                break;
            }

        sc.close();
    }
}


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

int main(){
  long long N, A, B;
  cin >> N >> A >> B;
  long long maxx=B*(N-1) + A;
  long long minn=B + A*(N-1);
  long long ans=maxx-minn+1;
  if(ans<=0) ans=0;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  char s[n][200];
  for(int i=0;i<n;i++){
    cin >> s[i];
  }
  for(int i=1;i<n;i++){
    if(s[i][0]!=s[i-1][strlen(s[i-1])-1]){
      cout << "No";
      return 0;
    }
    for(int j=0;j<i;j++){
      if(strcmp(s[i],s[j])==0){
        cout << "No";
        return 0;
      }
    }
  }
  cout << "Yes";
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Text;
 
public class Program
{
    public void Proc() {
        Reader.IsDebug = false;
        long[] inpt = Reader.ReadLine().Split(' ').Select(a=>long.Parse(a)).ToArray();
        long x = Math.Abs(inpt[0]-inpt[2]);
        long y = Math.Abs(inpt[1]-inpt[3]);
        long kouyaku = GetKouyaku(x, y);
        long ans = (x/kouyaku + y/kouyaku - 1)*kouyaku;
        Console.WriteLine(ans);
    }


    private long GetKouyaku(long num1, long num2) {
        if(num1 % num2 == 0) {
            return num2;
        }
        return GetKouyaku(num2, num1%num2);
    }

    public class Reader {
        public static bool IsDebug = true;
        private static System.IO.StringReader SReader;
        private static string InitText = @"


1 1 3 4



";
        public static string ReadLine() {
            if(IsDebug) {
                if(SReader == null) {
                    SReader = new System.IO.StringReader(InitText.Trim());
                }
                return SReader.ReadLine();
            } else {
                return Console.ReadLine();
            }
        }
    }
    public static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 2904
x, k, d = map(int, input().split())
x = abs(x)
if k*d <= x:
    ans = x-k*d
else:
    # 残り移動回数
    modCount = k - x//d
    # 残り距離
    modDis = x%d

    if modCount%2 == 0:
        ans = min(abs(x%d - d*modCount), abs(x%d))
    else:
        ans = min(abs(x%d - d), abs(x%d + d))
print(ans)


Measured memory_bytes: 9160
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
int main(){
    int n,k;
    cin >> n >> k;
    int a[110]={0};
    rep1(i,k){
        int d;
        cin >> d;
        rep1(j,d){
            int x;
            cin >> x;
            a[x]++;
        }
    }
    int res = 0;
    rep1(i,n){
        if(a[i] == 0) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ll long long 
#define mod 1000000007
using namespace std;

int  dizi[50][50],dp[30][2100000],n,k;

int dpf(int crr,int mask){
	// printf("%d %d\n",crr,mask );
	if( crr==(n) ){
		return 1;
	}
	if(dp[crr][mask]!=-1){
		return dp[crr][mask];
	}
	dp[crr][mask]=0;
	for(int i=0;i<n;i++){
		if( ( ( mask&(1<<i) ) == 0) &&  dizi[crr][i]==1 ){
			dp[crr][mask]+=dpf(crr+1,mask^(1<<i));
			dp[crr][mask]%=mod;
		}
	}
	return	dp[crr][mask];
}
int main(){
	// freopen("a.gir","r",stdin);
	// freopen("a.cik","w",stdout);
	for(int i=0;i<30;i++){
		for(int j=0;j<2100000;j++){
			dp[i][j]=-1;
		}
	}
	int a;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			scanf("%d",&a);
			dizi[i][j]=a;
		}
	}
	printf("%d\n",dpf(0,0) );
}

Measured memory_bytes: 246400
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;

int N, A[20], x[20][20], y[20][20], ans;

int main() {
    cin >> N;
    rep(i, N) {
        cin >> A[i];
        rep(j, A[i]) {
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }
    for (int bit = 0; bit < (1 << N); bit++) {
        bool ok = true;
        int cnt = 0;
        rep(i, N) {
            if (bit & (1 << i)) {
                cnt++;
                rep(j, A[i]) {
                    if (((bit >> x[i][j]) & 1) ^ y[i][j]) ok = false;
                }
            }
        }
        if (ok) ans = max(ans, cnt);
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 384
/*
AUTHOR : Chandan Agrawal
College : Poornima College of Engg. jaipur, Raj
Mail : chandanagrawal23@gmail.com
*/

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX 100050

#define ll long long
#define ld long double
#define lli long long int

#define pb emplace_back
#define INF 1000000000
#define mod 1000000007

// trignometric function always give value in Radians only
#define PI acos(-1) //3.1415926535897932384626433832795028
#define dsin(degree) sin(degree*(PI/180.0))
#define dcos(degree) cos(degree*(PI/180.0))
#define dtan(degree) tan(degree*(PI/180.0))

#define rsin(radian) sin(radian)
#define rcos(radian) cos(radian)
#define rtan(radian) tan(radian)

#define loop(i,n) for (lli i = 0; i < n; i++)
#define loopitr(xt,vec) for (auto xt : vec)
#define FOR(i,a,b) for (lli i = a; i < b; i+=1)
#define loop_rev(i,n) for (lli i = n-1; i >= 0; i--)
#define FOR_REV(i,a,b) for (lli i = a; i >= b; i--)
#define itr :: iterator it
#define WL(t) while(t --)

#define all(v) v.begin(),v.end()
#define sz(x) int(x.size())
#define F first
#define S second

#define mii map<lli,lli>
#define vi vector<lli>
#define seti set<lli>
#define pii pair<lli,lli>

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a/gcd(a,b))*b
#define abs(x) ((x < 0)?-(x):x)

template <typename T>
void print(T x){cout<<x<<endl;}
template <typename T1, typename T2>
void print2(T1 x,T2 y){cout<<x<<" "<<y<<endl;}
template <typename T1, typename T2,typename T3>
void print3(T1 x, T2 y,T3 z){cout<<x<<" "<<y<<" "<<z<<endl;}

#define scanarr(a,n) for(lli i=0;i<n;i++)    cin>>a[i];
#define scanvector(a,n) for(lli i=0;i<n;i++){ lli x ; cin>>x; a.push_back(x);}

#define printarr(a,n) for(lli i=0;i<n;i++)   cout<<a[i]<<" "; cout<<endl;
#define printvector(vec) for(auto xt : vec) cout<<xt<<" ";    cout<<"\n";
#define printset(st) for(auto xt : st) cout<<xt<<" ";    cout<<"\n";

#define FD(N) fixed<<setprecision(N)

#define endl '\n'

#define deb(x) cout<<#x<<" "<<x<<endl;

// chandan1,2
void chandan1(){int y=1;return;}
void chandan2(){
        loop(i,10){
        lli x=1;
    }
    return(chandan1());
}

bool isPrime(lli n){
if(n<=1) return false;
if(n<=3) return true;
if(n==5) return true;
if((n%2==0)||(n%3==0) || (n%5==0)) return false;
for(lli i=5;i*i<=n;i+=6)
    if((n%i==0)||(n%(i+2)==0))
        return false;
return true;
}

bool ispower2(lli n){
    return(n and (n&(n-1))==0 );
}

int main(){
fastio
lli t=1;
//cin>>t;
chandan2();
while(t--) {
    lli n,k;
    string s;
    cin>>n>>k;
    lli a[n];
    scanarr(a,n);
    sort(a,a+n);
    lli tt=0;
    loop(i,min(n,k))
        tt+=a[i];
    print(tt);
  }
return 0;
}

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

long long d = 1e9+7;
long long fac(long long a){
  if(a==0) return 1;
  else{
    long long c=1;
    for(int i=1;i<=a;i++){
      c =  (c*i)%d;
    }
    return c;
  }
}
int main(){
  long long n,m;
  cin >> n >> m;
  if(m<n-1||n+1<m) {
    cout << 0 << endl;
  }
  else{
    if(n!=m) cout << (fac(n)*fac(m))%d << endl;
    else cout <<( (  (2*fac(n)) %d )*fac(m) )%d << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <algorithm>

int main()
{
	int A, B;
	std::cin >> A >> B;
	int C, D;
	std::cin >> C >> D;
	while (true) {
		C -= B;
		if (C <= 0) {
			std::cout << "Yes" << std::endl;
			break;
		}
		A -= D;
		if (A <= 0) {
			std::cout << "No" << std::endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3624
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author vdewansa
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EKnapsack2 solver = new EKnapsack2();
        solver.solve(1, in, out);
        out.close();
    }

    static class EKnapsack2 {
        final long INF = (long) 1e18 + 5;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int W = in.nextInt();
            int[] weight = new int[N + 1];
            int[] value = new int[N + 1];
            int maxValue = 0;
            for (int i = 1; i <= N; i++) {
                weight[i] = in.nextInt();
                value[i] = in.nextInt();
                maxValue += value[i];
            }
            long[][] minWeight = new long[2][maxValue + 1];
            int prev = 0;

            Arrays.fill(minWeight[0], INF);
            minWeight[0][0] = 0;
            for (int i = 1; i <= N; i++, prev = 1 - prev) {
                int next = 1 - prev;
                for (int v = 0; v <= maxValue; v++) {
                    minWeight[next][v] = minWeight[prev][v];
                    if (value[i] <= v) {
                        long weightWithItem = weight[i] + minWeight[prev][v - value[i]];
                        minWeight[next][v] = Math.min(minWeight[next][v], weightWithItem);
                    }
                }
            }
            int res = -1;
            for (int v = 0; v <= maxValue; v++) {
                if (minWeight[prev][v] <= W) {
                    res = v;
                }
            }
            out.println(res);
        }

    }
}



Measured memory_bytes: 25940
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INI(n) scanf("%d",&n)
#define INL(n) scanf("%lld",&n)
#define INS(n) scanf("%s",s)
#define INF 10000000000
#define mod 1000000007
#define X 100000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
void nCrReady(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (ll i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll nCr(ll n,ll k){return fac[n]*(finv[k]*finv[n-k]%mod)%mod;}

int main(void){
  int a,b;
  INI(a);
  INI(b);
  FOR(100000){
    if(!i)continue;
    if((int)(i*0.08)==a&&(int)(i*0.1)==b){
      PRN(i);
      return 0;
    }
  }
  PRN(-1);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h> 
 
#define INF (1<<31) - 1 //INT_MAX/2
#define MOD 1000000007
#define PI  acos(-1)

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

int main(int argc, char *argv[])
{
    ll N, K;
    std::cin >> N >> K;

    std::vector<P> p(N);
    for (int i = 0; i < N; i++) {
        std::cin >> p[i].first >> p[i].second;
    }

    std::sort(p.begin(), p.end());

    ll sum = 0;
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        sum += p[i].second;
        if (sum >= K) {
            ans = p[i].first;
            break;
        }
    }

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

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

int N;
vector<int> G[100010];

int DFS(int v,int p)
{
    int res = 0,line = 0;
    for(int i = 0; i < G[v].size(); i++)
    {
        int ne = G[v][i];
        if(ne == p)continue;
        int mem = DFS(ne,v);
        if(mem == 0)line++;
        res += mem;
    }
    res += max(line - 1,0);
    return res;
}

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N - 1; i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int MAX = 0;
    for(int i = 0; i < N; i++)MAX = max(MAX,(int)G[i].size());
    if(MAX <= 2)
    {
        printf("1\n");
        return 0;
    }

    for(int i = 0; i < N; i++)
    {
        if(G[i].size() >= 3)
        {
            printf("%d\n",DFS(i,-1));
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 9984
import java.util.*;

public class Main{
	public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
      int n= sc.nextInt();
      int x =sc.nextInt();
      int t =sc.nextInt();
      
      int c;
      int a;
      c = (n+x-1)/x;
      a = c*t;
      System.out.println(a);
      
    }
}

Measured memory_bytes: 35700
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
int main(){
int N;cin>>N;
int n=N%10;
if(n==2||n==4||n==5||n==7||n==9)cout<<"hon"<<endl;
if(n==0||n==1||n==6||n==8)cout<<"pon"<<endl;
if(n==3)cout<<"bon"<<endl;
}

Measured memory_bytes: 3624
# -*- coding: utf-8 -*-
s = input()
if s == 'RRR':
  print(3)
elif s == 'RRS' or s == 'SRR':
  print(2)
elif s == 'RSR' or s == 'RSS' or s == 'SSR' or s == 'SRS':
  print(1)
else:
  print(0)


Measured memory_bytes: 8820
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int a, b;
	cin >> a >> b;

	auto f = [](int a, int b) {while (b) { b /= 10; a *= 10; } return a; };

	int x = f(a, b) + b;
	DMP(x);
	bool flag = false;
	for (int i = 0; i*i <= 100100; i++) {
		if (i*i == x) flag = true;
	}
	
	if (flag) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>

#define REP(i, n) for(int i=0;i<n;i++)
#define ll long long
#define INF 999999999
#define pb(a) push_back(a)

using namespace std;

bool dp[100001];
int n;
vector<int> v;

int main(){

  scanf("%d", &n);
  REP(i, n){
    int t;
    scanf("%d", &t);
    v.pb(t);
  }

  REP(i, 100001) dp[i] = false;

  dp[0] = true;
  REP(i, n){
    for(int j = 100000; j >= 0; --j){
      if(dp[j]){
        dp[j + v[i]] = true;
      }
    }
  }

  int res = 0;
  REP(i, 100001){
    if(dp[i] && i % 10 != 0 && res < i){
      res = i;
    }
  }

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

  return 0;
}



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

int main(){
  int N,c=1,p=0,q=0,pc,qc,ans,count=1;
  cin>>N;
  vector<int> P(N);
  vector<int> Q(N);
  vector<int> v(N);
  for(int i=0;i<N;i++){
    cin>>P.at(i);
    P.at(i)--;
  }
  for(int i=0;i<N;i++){
    cin>>Q.at(i);
    Q.at(i)--;
    v.at(i)=i;
  }
  
  sort(v.begin(), v.end());
  do {
    p=0;
    q=0;
    // 1行で今の並び方を出力
    for (int i=0;i<N;i++) {
      if(v.at(i)!=P.at(i)){
        p=1;
      }
      if(v.at(i)!=Q.at(i)){
        q=1;
      }
    }
    if(p==0)
      pc=count;
    if(q==0)
      qc=count;
    count++;
  } while (next_permutation(v.begin(), v.end()));
  ans=pc-qc;
  if(ans<0)
    ans*=-1;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define MOD 1000000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n=0ll,a=0ll,b=0ll,x=0ll,res;
    cin>>n>>a>>b;
    res=0ll;
    for(int i=0;i<n;++i)
    {
        cin>>x;
        if(x>=a&&x<b)
            continue;
        else
            ++res;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws FileNotFoundException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new File("c:\\0515-input.txt"));
		while (true) {
			int n = scan.nextInt();
			int k = scan.nextInt();
			if (n == 0 & k == 0)
				break;

			int[] e = new int[k];
			int max = 0;
			for (int i = 0; i < k; i++) {
				max += (e[i] = scan.nextInt());
			}
			int cur = max;
			for (int i = 0, j = k; j < n; i++, j++) {
				if (i >= k)
					i = 0;
				cur -= e[i];
				e[i] = scan.nextInt();
				cur += e[i];
				if (cur > max)
					max = cur;
			}
			System.out.println(max);
		}

		scan.close();
		System.exit(0);
	}

}

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

// semi-open   Range maximum query

struct RLQ{
  int n=(1<<17),data[(1<<18)];
  RLQ(){
    fill(data,data+(1<<18),INT_MAX);
  }
  void update(int k,int x){
    k+=n-1;
    data[k]=x;
    while(k>0){
      k=(k-1)/2;
      data[k]=min(data[k*2+1],data[k*2+2]);
    }
  }
  int find(int a,int b,int k=0,int l=0,int r=(1<<17)){
    if(r<=a || b<=l)return INT_MAX;
    if(a<=l && r<=b)return data[k];
    int v1=find(a,b,k*2+1,l,(l+r)/2);
    int v2=find(a,b,k*2+2,(l+r)/2,r);
    return min(v1,v2);
  }
};


int main(){
  RLQ a;
  int c,x,y,n,q;
  cin>>n>>q;
  for(int i=0;i<q;i++){
    scanf("%d%d%d",&c,&x,&y);
    if(c)cout<<a.find(x,y+1)<<endl;
    else a.update(x,y);
  }
}


Measured memory_bytes: 4240
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       N: usize,
       K:usize,
       p:[(i64,i64);N],
    }

    let mut ans: usize = 2000000000 * 2000000000 + 5;
    for (x1, _) in &p {
        for (x2, _) in &p {
            for (_, y1) in &p {
                for (_, y2) in &p {
                    if x1 <= x2 && y1 <= y2 {
                        let mut c = 0;
                        for (x, y) in &p {
                            if x1 <= x && x2 >= x && y1 <= y && y2 >= y {
                                c += 1;
                            }
                        }
                        if c >= K {
                            ans = min(ans, ((x2 - x1) * (y2 - y1)) as usize);
                        }
                    }
                }
            }
        }
    }

    echo!(ans);
}


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

int main()
{
  int N;
  double v[1100];
  double res=0;
  cin >> N;
  rep(i,N) cin >> v[i];

  sort(v, v+N);

  res = v[0];
  for(int i=1;i<N;i++){
    res = (res + v[i])/2;
  }
  
  printf("%.16f\n",res);
}



Measured memory_bytes: 256
#pragma GCC optimize("2,Ofast,inline")
#include <bits/stdc++.h>
#define LL long long
#define P pair<int, int>
const LL N = 6e4 + 10;
const LL inf = 0x3f3f3f3f;
const LL mod = 998244353;
using namespace std;
template <typename tp>
inline void read(tp &x)
{
    x = 0; char c = getchar(); bool f = 0;
    for (; c < '0' || c > '9'; f |= (c == '-'), c = getchar()) ;
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar()) ;
    if (f) x = -x;
}
LL n,cost[510][510];
// sum_along i j -> SUM(1->i) cost[i][j];
// along i j -> i到j之间所有顺序cost
LL along[510][510],sum_along[510][510];
LL inverse[510][510],sum_inverse[510][510];
LL dp[510][510];
signed main()
{
    read(n);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
        {
            if(i==j) continue;
            read(cost[i][j]);
        }
    for(int i=1;i<=n;i++)
        for(int j=1;j<i;j++)
            sum_along[j][i]=sum_along[j-1][i]+cost[j][i];
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n+1;j++)
            along[i][j]=along[i][j-1]+sum_along[j-1][j]-sum_along[i-1][j];
    for(int i=1;i<=n;i++)
        for(int j=1;j<i;j++)
            sum_inverse[j][i]=sum_inverse[j-1][i]+cost[i][j];
    for(int i=1;i<=n+1;i++)
        for(int j=n+1;j>i;j--)
            inverse[i][j]=inverse[i][j+1]+sum_inverse[i][j];
    // for(int i=0;i<=n;i++)
    //     for(int j=0;j<=n;j++)
    //         printf("along[%d][%d]=%d\n",i,j,along[i][j]);
    // for(int i=0;i<=n;i++)
    //     for(int j=0;j<=n;j++)
    //         printf("inverse[%d][%d]=%d\n",i,j,inverse[i][j]);
    memset(dp,0x3f,sizeof(dp));
    dp[0][0]=0;
    for(int i=0;i<=n;i++)
        for(int j=i;j<=n;j++)
            if(dp[i][j]<1e18)
                for(int k=j+1;k<=n+1;k++)
                {
                    dp[j][k]=min(dp[j][k],dp[i][j]+along[j+1][k]+inverse[j][k+1]-inverse[i][k+1]);
                    // cout<<i<<" "<<j<<" "<<k<<" "<<dp[j][k]<<" "<<
                    // along[j+1][k]<<" "<<inverse[j][k+1]-inverse[i][k+1]<<endl;
                }
    LL ans=1e18;
    for(int i=0;i<=n;i++)
        ans=min(ans,dp[i][n+1]);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 12416
#include <bits/stdc++.h>
#define REP(i, n) for (decltype(n) i = 0; i < n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define readvec(vec)    \
  for (auto& e : vec) { \
    cin >> e;           \
  }
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<string> vecstr;
typedef vector<char> vecchar;
typedef vector<bool> vecbool;
typedef vector<vector<bool>> vec2bool;
typedef vector<vector<int>> vec2int;
typedef vector<vector<double>> vec2d;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  int n;
  cin >> n;
  vecint a(n);
  int cmax = 0;
  for (auto& e : a) {
    cin >> e;
    cmax = max(cmax, e);
  }
  vecint dp(n, 0);
  vecint dp2(cmax + 1, 0);
  dp[0] = 1;
  dp2[a[0]] = 1;
  for (int i = 1; i < n; i++) {
    dp[i] = dp[i - 1];
    if (a[i] != a[i - 1]) {
      dp[i] += dp2[a[i]];
      dp[i] %= MOD;
      dp2[a[i]] += dp[i - 1];
      dp2[a[i]] %= MOD;
    }
  }
  cout << dp[n - 1] << endl;
}

Measured memory_bytes: 2560