akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

const int mod = 1000000007;
int dp[1100][1100];


int main(){
    int h, w; cin >> h >> w;
    vector<string> a(h);
    rep(i,h) cin >> a[i];
    
    dp[0][0]=1;
    //dp[i][j] is already known.

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(i+1 < h && a[i+1][j] == '.'){
                //i+1<hを先に
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= mod;
            }
            if(j+1 < w && a[i][j+1] == '.'){
                dp[i][j+1] += dp[i][j];
                dp[i][j+1] %= mod;
            }
        }
    }
    cout << dp[h-1][w-1] << endl;
}

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

signed main(void)
{
	int i = 0;
	string s, tmp;
	bool ok;

	cin >> s;
	reverse(s.begin(), s.end());
	ok = true;
	while (i < s.size() && ok)
	{
		tmp = s.substr(i, 5);
		if (tmp == "maerd" || tmp == "esare")
			i += 5;
		else
		{
			tmp = s.substr(i, 6);
			if  (tmp == "resare")
				i += 6;
			else
			{
				tmp = s.substr(i, 7);
				if (tmp == "remaerd")
					i += 7;
				else
					ok = false;
			}
		}
	}
	if (ok)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

/**
 * A https://atcoder.jp/contests/abc172/tasks/abc172_a
 * 
 */
public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        
        try {
            int a = Integer.parseInt(reader.readLine());
            System.out.println((int) (a + Math.pow(a, 2) + Math.pow(a, 3)));
        } catch (NumberFormatException | IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
    }
}

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

int main() {
    int n,ans=0; cin >> n;
    vector<int> l(n*2);
    rep(i,n*2) cin >> l[i];
    sort(l.begin(), l.end());
    for (int i=0;i<n*2;i+=2) {
        ans += l[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
use std::str::FromStr;
use std::collections::HashMap;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let n : usize = get_one();
    let v : Vec<i32> = get_vec();
    let mut map = HashMap::new();
    let mut eights = 0;
    for i in 0..n {
        let mut x = v[i] / 400;
        //println!("{}", x);
        if x < 8 {
            *map.entry(x).or_insert(0) = 1;
        }
        else {
            eights += 1;
        }
    }
    let mx = map.values().fold(0, |sm, k| sm+k);
    println!("{} {}", if mx == 0 {1} else {mx}, mx+eights);
}


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

int main(){
    int N,M ;
    cin >> N>>M ;
    vector<int> A(M);
    for (int i = 0; i < M; i++)
    {
        cin >> A[i] ;
    }
    int wa = accumulate(A.begin(),A.end(),0);
    if(N-wa>=0){
        cout<<  N-wa<<endl ;
    }else{
        cout << -1 <<endl;
    }


    
    

    return 0 ;
}

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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A+B > C+D){
    cout << "Left" <<endl;
  }
  if (A+B == C+D){
    cout << "Balanced" <<endl;
  }
  if (A+B < C+D){
    cout << "Right" <<endl;
  }
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
 
int main(){
	
    int n;
    cin>>n;
    
   // vector<int> v;
    unordered_map<ll,ll> mp;
    ll sum=0;
    for(int i=0;i<n;i++){
    	ll x;
    	cin>>x;
    	//v.push_back(x);
    	mp[x]++;
    	 sum+=x;
	}
	int q;
	cin>>q;
	
	for(int i=0;i<q;i++){
		
		ll b,c;
		cin>>b>>c;
		if(mp[b]>0){
			sum=sum-mp[b]*b;
			sum=sum+mp[b]*c;
			cout<<sum<<endl;
			
			mp[c]+=mp[b];
			mp.erase(b);
		}
      else cout<<sum<<endl;
		
	}
	
    
    
    
    return 0;
}

Measured memory_bytes: 6644
#include <iostream>
using namespace std;
int main(){
	int sum, d, tmp;
	while(cin>>d){
		sum = 0;
		tmp = d;
		while(tmp < 600){
			sum += tmp*tmp*d;
			tmp += d;
		}
		cout<<sum<<endl;
	}
	return 0;
}


Measured memory_bytes: 3060
data class AB(val a: Int, val b: Int) {
    constructor(pc: List<Int>): this(pc[0], pc[1])
}
fun main(arg: Array<String>) {
    var (N, H) = listOfInt()
    val AB = Array(N) { AB(listOfInt()) }.sortedBy { -it.b }
    val maxA = AB.maxBy { it.a }!!.a
    var ans = 0
    var n = 0
    while (n < N && 0 < H && maxA < AB[n].b) {
        H -= AB[n].b
        ans += 1
        n += 1
    }
    if (H > 0) ans += (H + (maxA - 1)) / maxA
    println(ans)
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }


Measured memory_bytes: 76048
n = int(input())
l = [int(_) for _ in input().split()]
ans = 0
L = [0 for _ in range(1,2000+2)]
s = [0 for _ in range(0,2000+2)]
for k in range(0, n):
    L[l[k]-1] += 1
for x in range(0,2001):
    s[x+1] = s[x] + L[x]
 
for i in range(0, n-1):
    for j in range(i+1, n):
        exc = 0
        m = abs(l[i] - l[j])
        M = l[i] + l[j]
        if l[i] > m:
            exc += 1
        if l[j] > m:
            exc += 1
        ans += s[M] - s[m] - L[M-1] - exc
print(ans//3)

Measured memory_bytes: 44252
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define x real()
#define y imag()
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	int n;
	cin >> n;
	int h[n];
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);
	if (n > 2) {
		for (int i = 2; i < n; i++) {
			dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]),
					dp[i - 2] + abs(h[i] - h[i - 2]));
		}
	}
	cout << dp[n - 1] << "\n";
}



Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <unordered_map>
#define maxn 100005
#define mod 998244353
using namespace std;
typedef long long LL;
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int a[1005],sum=0;
    for(int i=1;i<=n;i++)
      {scanf("%d",&a[i]);sum+=a[i];}
    sort(a+1,a+n+1);
    double x=sum*1.0/(4.0*m);
    for(int i=n;i>n-m;i--)
        if(a[i]<x) {printf("No");return 0;}
    printf("Yes");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=(n);i++)
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9+7;

int main(){
    int n,ma,mb;
    cin>>n>>ma>>mb;
    vector<int> a(n+1),b(n+1),c(n+1);
    rep(i,n) cin>>a[i]>>b[i]>>c[i];
    vector<vector<vector<int>>> dat(45,vector<vector<int>>(500,vector<int>(500,INF)));
    dat[1][0][0]=0;
    rep(i,n){
        for(int j=0;j<=400;j++){
            for(int k=0;k<=400;k++){
                if(dat[i][j][k]==INF) continue;
                dat[i+1][j][k]=min(dat[i][j][k],dat[i+1][j][k]);
                dat[i+1][j+a[i]][k+b[i]]=min(dat[i+1][j+a[i]][k+b[i]],dat[i][j][k]+c[i]);
            }
        }
    }
    int ans=INF;
    rep(j,401){
        rep(k,401){
            if(j*mb==k*ma){
                ans=min(ans,dat[n+1][j][k]);
            }
        }
    }
    if(ans==INF) cout<<"-1";
    else cout<<ans;
}

Measured memory_bytes: 49212
#include<bits/stdc++.h>
using namespace std;
int n,d[55],ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>d[i];
	for(int i=1;i<n;i++)
	    for(int j=i+1;j<=n;j++)
	        ans+=d[i]*d[j];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

main(void)

{
int S;

scanf("%d",&S);

int h,m,s;

h=0;
m=0;
s=S;

if(s>=59){
	m +=s/60;
	s%=60;
}

if(m>=59){
	h +=m/60;
	m%=60;
}

printf("%d:%d:%d\n",h,m,s);

return 0;
}

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

int main()
{
	int n,k,i,j;
	cin>>x;
	if(x<=599)
	cout<<8<<endl;
	else if(x<=799)
	cout<<7<<endl;
	else if(x<=999)
	cout<<6<<endl;
	else if(x<=1199)
	cout<<5<<endl;
	else if(x<=1399)
	cout<<4<<endl;
	else if(x<=1599)
	cout<<3<<endl;
	else if(x<=1799)
	cout<<2<<endl;
	else
	cout<<1<<endl;
	return 0;
}

Measured memory_bytes: 3552
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int n ; 
    cin >> n;
    pair<pair<string,int>,int>s[n] ;
    string name ;
    int temp ;
    for(int i = 0; i < n ; i++ ){
        cin >> name >> temp ;
        s[i] = make_pair(make_pair(name, -temp), i);
    }
    sort(s, s + n);
    
    for(int j = 0; j < n ; j ++ ){
        cout << s[j].second  +1<< endl;
    }
    return 0;
}

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

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

using namespace std;
using ll = long long;

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

int main() {
  ll n, d, a;
  cin >> n >> d >> a;
  vector<pair<ll, ll>> p(n);
  rep(i, n) cin >> p[i].first >> p[i].second;
  sort(p.begin(), p.end());
  queue<pair<ll, ll>> que;

  ll total = 0;
  ll ans = 0;
  rep(i, n) {
    ll x = p[i].first;
    ll h = p[i].second;
    while (que.size() && x > que.front().first) {
      total -= que.front().second;
      que.pop();
    }
    ll damage, cnt;
    if (h > total) {
      h -= total;
      cnt = (h + a - 1) / a;
      ans += cnt;
      damage = cnt * a;
      total += damage;
      que.emplace(x + d * 2, damage);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;
int main()
{
	int A, B, T = 0, ANS = 0;
	cin >> A >> B;

	T = A;

	if (B == 1)
	{
		cout << 0 << endl;
	}
	else
	{
		for (int i = 1; i < 100; i++)
		{
			if (T >= B)
			{
				ANS = i;
				break;
			}
			else
			{
				T = T + (A - 1);
			}
		}
		cout << ANS << endl;
	}
}

Measured memory_bytes: 384
import heapq
from collections import deque
from copy import deepcopy

n,k = map(int,input().split())
V = list(map(int,input().split()))

dq = deque()
dq.extend(V)
INF = 10**10

ans = -INF
for i in range(k+1):
  for j in range(k+1-i):           
    que = deepcopy(dq)
    a = []    
    
    if i+j <= n:
      for l in range(i):      
        heapq.heappush(a,que.popleft())
      for r in range(j):
        heapq.heappush(a,que.pop())    
      
      ans = max(ans,sum(a))        
      for ki in range(k-i-j):   
        if len(a) > 0:
          heapq.heappop(a)
        ans = max(ans,sum(a))        
        
if ans != -INF:          
  print(ans)
else:
  print(0)  

Measured memory_bytes: 3572
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const arr = lines.shift().split(' ').map(Number);
  buildMaxHeap(arr);
  console.log(arr.reduce((s, e) => s += ' ' + e, ''));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
    let left, right, largest = i;
    left = 2 * i + 1;
    right = 2 * i + 2;
    if (left < n && arr[left] > arr[i]) largest = left;
    if (right < n && arr[right] > arr[largest]) largest = right;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };

  for (let i = Math.floor(arr.length / 2); i >= 0; i--) maxHeapify(i);
}



Measured memory_bytes: 140148
/**
     *    author:  shashank_hire
    **/
#include <bits/stdc++.h>
using namespace std;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define ll long long
#define ld long double
#define MOD 1000000007

// A C++ program for Dijkstra's single source shortest path algorithm. 
// The program is for adjacency matrix representation of the graph 
 
// #include <limits.h> 
// #include <stdio.h>

// Number of vertices in the graph 
ll V;

// A utility function to find the vertex with minimum distance value, from 
// the set of vertices not yet included in shortest path tree 
int minDistance(int dist[], bool sptSet[]) 
{ 
	// Initialize min value 
	int min = INT_MAX, min_index; 

	for (int v = 0; v < V; v++) 
		if (sptSet[v] == false && dist[v] <= min) 
			min = dist[v], min_index = v; 

	return min_index; 
} 

// A utility function to print the constructed distance array 
int printSolution(int dist[]) 
{ 
	// printf("Vertex \t\t Distance from Source\n"); 
	// for (int i = 0; i < V; i++) 
	// 	printf("%d \t\t %d\n", i, dist[i]); 
    if(dist[V-1]==2147483647)
        cout<<"-1\n";
    else
    cout<<dist[V-1]<<"\n";
} 

// Function that implements Dijkstra's single source shortest path algorithm 
// for a graph represented using adjacency matrix representation 
void dijkstra(int graph[1001][1001], int src) 
{ 
	int dist[V]; // The output array. dist[i] will hold the shortest 
	// distance from src to i 

	bool sptSet[V]; // sptSet[i] will be true if vertex i is included in shortest 
	// path tree or shortest distance from src to i is finalized 

	// Initialize all distances as INFINITE and stpSet[] as false 
	for (int i = 0; i < V; i++) 
		dist[i] = INT_MAX, sptSet[i] = false; 

	// Distance of source vertex from itself is always 0 
	dist[src] = 0; 

	// Find shortest path for all vertices 
	for (int count = 0; count < V - 1; count++) { 
		// Pick the minimum distance vertex from the set of vertices not 
		// yet processed. u is always equal to src in the first iteration. 
		int u = minDistance(dist, sptSet); 

		// Mark the picked vertex as processed 
		sptSet[u] = true; 

		// Update dist value of the adjacent vertices of the picked vertex. 
		for (int v = 0; v < V; v++) 

			// Update dist[v] only if is not in sptSet, there is an edge from 
			// u to v, and total weight of path from src to v through u is 
			// smaller than current value of dist[v] 
			if (!sptSet[v] && graph[u][v] && dist[u] != INT_MAX 
				&& dist[u] + graph[u][v] < dist[v]) 
				dist[v] = dist[u] + graph[u][v]; 
	} 

	// print the constructed distance array 
	printSolution(dist); 
}

int main()
{
	ll h, a;
	cin>>h>>a;
	cout<<((h+a-1)/a)<<"\n";
    return 0;
}

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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

//#define _USE_MATH_DEFINES
//#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>
#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 1000000007; // 10000000000000007ll;

const double eps = 1e-8;

const i64 MAXN = 300004;

string n;
i64 k;

string d9[102];

i64 solve(string n, i64 k) {
    if (k == 0) {
        //cerr << n << " " << k << ": " << 1 << endl;
        return 1;
    }

    i64 j = 0;
    while (j < n.size() && n[j] == '0') {
        j += 1;
    }
    n = n.substr(j);

    if (k > n.size()) {
        //cerr << n << " " << k << ": " << 0 << endl;
        return 0;
    }

    i64 R = 0;
    for (i64 i = n.size() - 1; i >= 0; i--) {
        string t = n.substr(i + 1);
        if (i) {
            t = d9[t.size()];
            R += 9 * solve(t, k - 1);
        }
        else {
            if (n[i] == '0') {
                R += solve(t, k);
            }
            else {
                R += solve(t, k - 1);
                t = d9[t.size()];
                R += (n[i] - '1') * solve(t, k - 1);
            }
        }
        //R += (i ? 9 : n[i] - '0') * solve(t, k - 1);
    }
    //cerr << n << " " << k << ": " << R << endl;
    return R;
}

i64 cnt(i64 v) {
    i64 R = 0;
    while (v) {
        if (v % 10) {
            R += 1;
        }
        v /= 10;
    }
    return R;
}

i64 test(i64 n, i64 k) {
    i64 R = 0;
    for (i64 i = 1; i <= n; i++) {
        if (cnt(i) == k) {
            R += 1;
        }
    }
    return R;
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    for (i64 i = 1; i < 102; i++) {
        stringstream ss;
        ss << d9[i - 1] << '9';
        d9[i] = ss.str();
    }

    //cerr << test(1002, 3) << endl;

    cin >> n >> k;

    i64 R = 0;
    R = solve(n, k);
    cout << R << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main  {

    static void swapidx(int[] arr, int lhs, int rhs){
    	int tmp = arr[lhs];
    	arr[lhs] = arr[rhs];
    	arr[rhs] = tmp;
    	return;
    }
    
    public static void main(String [] args){
    	Scanner sc = new Scanner(System.in);
    	int w = sc.nextInt();
    	int n = sc.nextInt();

    	int[] lines = new int[w];
    	for(int i=0; i<lines.length;++i){
    	    lines[i] = i + 1;
    	}
	sc.nextLine();
    	for(int i=0; i<n;++i){
	    String line = sc.nextLine();
	    String[] ints = line.split(",");
	    // System.out.println(line);
	    int a = Integer.parseInt(ints[0]);
	    int b = Integer.parseInt(ints[1]);
	    swapidx(lines, a - 1, b - 1);
    	}
	for(int i=0; i<lines.length;++i){
	    System.out.println(lines[i]);
	}
    }

}

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

int IN_int(){
    int x;
    scanf("%d",&x);
    return x;
}

//library----------------------------------------------

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

const int NMAX = 100;
bool flag;

bool cmp(int x,int y){
    return abs(0-x)<abs(0-y);
}

signed main(){
    CIN(H,W);

    vector<string> field(H);
    rep(i,H) cin>>field[i];

    rep(y,H){
        rep(x,W){
            if(field[y][x]=='#') continue;
            int num=0;
            rep(k,8){
                int nx=x+dx[k];
                int ny=y+dy[k];

                if(nx<0||W<=nx||ny<0||H<=ny) continue;
                if(field[ny][nx]=='#') num++;
            }
            field[y][x]=char(num+'0');
        }
    }
    rep(i,H)output_s(field[i]);

    return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    string w;
    cin >> w;

    int ary[26] = { 0 };
    rep (i, w.length())
    {
        ary[w[i] - 'a']++;
    }

    rep (i, 26)
    {
        if (ary[i] % 2)
        {
            cout << "No" << "\n";
            return 0;
        }
    }

    cout << "Yes" << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m,p,ansa=0,ansb=0;
  string s;
  cin>>n>>m;
  int ac[n];
  int pen[n];
  for(int i=0;i<n;i++) ac[i]=pen[i]=0;
  for(int i=0;i<m;i++){
  	cin>>p>>s;
    p--;
    if(s=="WA"){
    	pen[p]++;
    }if(s=="AC"&&!ac[p]){
    	ac[p]=1;
        ansa++;
        ansb+=pen[p];
    }
  }
  cout<<ansa<<" "<<ansb;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int arr[n][3];
  for(int i=0;i<n;i++){
      for(int j=0;j<3;j++){
          cin>>arr[i][j];
      }
  }
  int dp[n][3];
  dp[0][0]=arr[0][0];
  dp[0][1]=arr[0][1];
  dp[0][2]=arr[0][2];
  for(int i=1;i<n;i++){
      dp[i][0]=max(dp[i-1][1],dp[i-1][2])+arr[i][0];
      dp[i][1]=max(dp[i-1][0],dp[i-1][2])+arr[i][1];
      dp[i][2]=max(dp[i-1][1],dp[i-1][0])+arr[i][2];
  }
  cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

Measured memory_bytes: 5868
#include <cstdio>
#include <list>
#include <algorithm>
using namespace std;

int main() {
    int n, x;
    char com[20];
    //標準ライブラリよりlistを使用
    list<int> v;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%s", com);
        if (com[0] == 'i') { //insert
            scanf("%d", &x);
            v.push_front(x);
        } else if (com[6] == 'L'){ //deleteLast
            v.pop_back();
        } else if (com[6] == 'F'){ //deleteFirst
            v.pop_front();
        } else if (com[0] == 'd'){ //delete
            scanf("%d", &x);
            for (list<int>::iterator it = v.begin(); it != v.end(); it++){
                if (*it == x) {
                    v.erase(it);
                    break;
                }
            }
        }
    }
    int i = 0;
    for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
        if (i>0) printf(" ");
        printf("%d", *it);
        i++;
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 34044
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

using ll = long long;
using p = pair<ll, ll>;

constexpr ll INF = 1LL << 62;
constexpr ll MOD = 1e9 + 7;

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

    ll H, W;
    cin >> H >> W;

    vector<ll> C(26, 0);
    for (ll h = 0; h < H; h++) {
        for (ll w = 0; w < W; w++) {
            char c;
            cin >> c;
            C[c - 'a']++;
        }
    }

    ll count[4] = {0};
    for (auto&& c : C) {
        count[c % 4]++;
    }

    string ans = "Yes";
    if (H % 2 && W % 2) {
        if (count[1] + count[3] != 1 || count[2] > H / 2 + W / 2) {
            ans = "No";
        }
    } else if (W % 2) {
        if (count[1] || count[3] || count[2] > H / 2) {
            ans = "No";
        }
    } else if (H % 2) {
        if (count[1] || count[3] || count[2] > W / 2) {
            ans = "No";
        }
    } else {
        if (count[1] || count[2] || count[3]) {
            ans = "No";
        }
    }

    cout << ans << endl;

    return 0;
}



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

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    int n;
    cin >> n;
    map<int, int> v;
    for (int i = 0; i < n; ++i) {
        int a;
        scanf("%d", &a);
        v[a]++;
    }
    int ans = 0;
    for (auto &&x : v) {
        ans += (x.second >= x.first ? (x.second - x.first): x.second);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

lli depth[110][110];
char data[110][110];
bool vis[110][110][2];

signed main(){

	lli h,w;
	cin>>h>>w;

	REP(i,0,h)REP(j,0,w)cin>>data[i][j];

	queue<pair<lli,lli>> q;
	q.push(mp(0,0));
	REP(i,0,110)REP(j,0,110)depth[i][j]=INF;
	depth[0][0]=0;
	if(data[0][0]=='#')depth[0][0]=1;

	while(q.size()){
		lli topY = q.front().first;
		lli topX = q.front().second;
		q.pop();

		lli dx[4]={1,0};
		lli dy[4]={0,1};
		for(lli k=0;k<2;k++){
			lli nextY = topY+dy[k];
			lli nextX = topX+dx[k];
			if(nextY<0||nextY>=h||nextX<0||nextX>=w)continue;
			if(vis[nextY][nextX][k])continue;
			vis[nextY][nextX][k]=true;

			if(data[topY][topX]==data[nextY][nextX]){
				depth[nextY][nextX]=min(depth[topY][topX],depth[nextY][nextX]);
			}
			else{
				depth[nextY][nextX]=min(depth[topY][topX]+1,depth[nextY][nextX]);
			}
			q.push(mp(nextY,nextX));
		}
	}
	if(DEBUG){
			REP(i,0,h){
				REP(j,0,w){
					cout<<depth[i][j]<<" ";
				}
				cout<<endl;
			}
		}
	cout<<(depth[h-1][w-1]+1)/2<<endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> bool chmax(Type_a &a,const Type_b &b){if(a<b){a=b;return true;}return false;}
template<class Type_a,class Type_b> bool chmin(Type_a &a,const Type_b &b){if(a>b){a=b;return true;}return false;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	vi key={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	
	int k;
	cin>>k;
	
	cout<<key[k-1]<<endl;
}

Measured memory_bytes: 256
alpha = "abcdefghijklmnopqrstuvwxyz"
assert len(alpha) == 26


def solve(N):
    ans = []
    while N:
        N -= 1
        N, i = divmod(N, 26)
        ans.append(alpha[i])
    return "".join(ans[::-1])


(N,) = [int(x) for x in input().split()]
print(solve(N))



Measured memory_bytes: 61868
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;

public class Main{
  Scanner sc = new Scanner(System.in);
  public static void main(String args[]){
    Main wk = new Main();
    wk.doIt();
  }

  ArrayList<timeData> stock = new ArrayList<timeData>();
  ArrayList<timeData> result = new ArrayList<timeData>();
  ArrayList<timeData> under2 = new ArrayList<timeData>();

  void doIt(){
    for(int i=0;i<3;i++) {
      octetRead();
      // b_arrdisp("Data Read");
      toGrandStage();
    }
    toGrandStage(under2);
    // b_arrdisp("Grand Final");
    // System.out.println();

    for(timeData k : result){
      System.out.printf("%d %.2f%n",k.number,k.time);
    }
  }

  private timeData readData(){
    return new timeData(sc.nextInt(),sc.nextDouble());
  }

  private void octetRead(){
    for(int i=0;i<8;i++) stock.add(readData());
  }

  private void cropTimeTop2(){
    Collections.sort(stock);
    // b_arrdisp("Sorted");
    result.add(stock.get(0));
    result.add(stock.get(1));
    stock.remove(0);
    stock.remove(0);
  }

  private void toGrandStage(){
    cropTimeTop2();
    under2.addAll(stock);
    stock.clear();
  }

  private void toGrandStage(ArrayList<timeData> datainpt){
    stock.addAll(datainpt);
    toGrandStage();
  }

  private class timeData implements Comparable<timeData>{
    int number;
    double time;

    public timeData(int number,double time){
      this.number = number;
      this.time = time;
    }

    @Override
    public int compareTo(timeData left){
      if(left.time < this.time) return 1;
      else return -1;
    }

    @Override
    public String toString(){
      return this.number + " " + this.time;
    }
  }

  private void b_arrdisp(String com){
    System.out.println(com);
    System.out.println("stock");
    System.out.println(stock);
    System.out.println("under2");
    System.out.println(under2);
    System.out.println("result");
    System.out.println(result);
  }
}

Measured memory_bytes: 28160
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
#include<string.h>
#include <cmath>
#include <iomanip>
using namespace std;
#define inf 1000000007
#define int long long
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
struct edge{int from,to,cost;};
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
signed main(){
    int a,b,c,d;cin>>a>>b>>c>>d;
    if(a+b==c+d)cout<<"Balanced"<<endl;
    else if(a+b>c+d)cout<<"Left"<<endl;
    else cout<<"Right"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,i,j,ans=1;string S,T;cin>>S>>T;
  vector<char>X(26,'#'),Y(26,'#');
  REP(i,S.size()){
    if(X.at(S.at(i)-'a')=='#')X.at(S.at(i)-'a')=T.at(i);
    else if(X.at(S.at(i)-'a')!=T.at(i))ans=0;
    if(Y.at(T.at(i)-'a')=='#')Y.at(T.at(i)-'a')=S.at(i);
    else if(Y.at(T.at(i)-'a')!=S.at(i))ans=0;
  }
  if(ans)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 776
a,b,c,x,y=map(int, input().split())
ans=0
if a+b>2*c:
    ans+=c*min(x, y)*2
    if x==y:
        print(ans)
        exit()
else:
    print(a*x+b*y)
    exit()
if x>y:
    if 2*c<a:
        ans+=2*c*(x-y)
    else:

        ans+=a*(x-y)
else:
    if 2*c<b:
        ans+=2*c*(y-x)
    else:

        ans+=b*(y-x)

print(ans)


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;



int main()
{
	int sum = 100000;
	int tmp;
	int n;

	scanf("%d",& n);

	for (int i = 0; i < n; i++) {
		sum += sum / 20;
		tmp = sum;
		sum -= sum % 1000;
		if (tmp != sum) sum += 1000;
	}
	printf("%d\n", sum);

	return (0);
	
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  string s; std::cin >> s;
  std::cout << (s == "ABC" ? "ARC" : "ABC") << "\n";
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <bitset>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

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

static const ll MOD = 1000000007;
//static const ll INF = 100000000;
//#define PI 3.14159265359


int main() {
    // input
    ll N;
    cin >> N;
    vector<string> S(N);
    for (ll i = 0; i < N; ++i) {
        cin >> S[i];
    }

    // process
    sort(S.begin(), S.end());

    ll ans = 1;
    for (ll i = 0; i < N - 1; ++i) {
        if (S[i] != S[i + 1]) {
            ans++;
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 7544
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using ull=unsigned long long int;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
while(1){
  int n;
  cin>>n;
  if(n==0)return 0;
  V<ll> a(n);
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    a[i]=(ll)s.size();
  }
  for(int i=0;i<n;i++){
    ll sum=0;int ind=i;
    while(ind<n&&sum<5)sum+=a[ind++];
    if(sum!=5)continue;
    sum=0;
    while(ind<n&&sum<7)sum+=a[ind++];
    if(sum!=7)continue;
    sum=0;
    while(ind<n&&sum<5)sum+=a[ind++];
    if(sum!=5)continue;
    sum=0;
    while(ind<n&&sum<7)sum+=a[ind++];
    if(sum!=7)continue;
    sum=0;
     while(ind<n&&sum<7)sum+=a[ind++];
    if(sum!=7)continue;
    cout<<i+1<<"\n";
    break;
  }
}
}


Measured memory_bytes: 3196
import java.util.*;

public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    int ans = str.lastIndexOf('Z') - str.indexOf('A') + 1;

    System.out.println(ans);
  }
}


Measured memory_bytes: 26788
#include <iostream>
#include <string>
#include <string.h>
using namespace std;

int main()
{
	int N;
	string S;
	bool b = false;

	cin >> N >> S;

	if (N % 2 == 0)
	{
		int half = N / 2;

		if (!strcmp(S.substr(0, half).c_str(), S.substr(half,N).c_str()))
			b = true;
	}

	if (b)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<map>
#include<algorithm>
#include<utility>
using namespace std;

int main(void)
{
	int N;
	cin >> N;
	
	map<int, int> cnt;
	for(int i=0; i<N; i++)
	{
		int a;
		cin >> a;

		cnt[a]++;
		cnt[a+1]++;
		cnt[a-1]++;
	}

	int ret = 0;
	for(auto it=cnt.begin(); it!=cnt.end(); it++)
	{
		if(it->second > ret)
			ret = it->second;
	}

	cout << ret << endl;
	
	return 0;
}


Measured memory_bytes: 4736
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;

import std.math;

void main() {
    auto cnt = new int[](5);
    int n;
    scan(n);
    foreach (i ; 0 .. n) {
        string s;
        scan(s);

        switch (s[0]) {
            case 'M':
            cnt[0]++;
            break;

            case 'A':
            cnt[1]++;
            break;

            case 'R':
            cnt[2]++;
            break;

            case 'C':
            cnt[3]++;
            break;

            case 'H':
            cnt[4]++;
            break;

            default:
            break;
        }
    }

    long ans;

    foreach (i ; 0 .. 5) {
        foreach (j ; i + 1 .. 5) {
            foreach (k ; j + 1 .. 5) {
                ans += 1L * cnt[i] * cnt[j] * cnt[k];
            }
        }
    }

    writeln(ans);
}


void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 1276
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    x = ni()

    ans = [1]

    for b in range(2, int(x**0.5) + 1):
        p = 2
        while b**p <= x:
            ans.append(b**p)
            p += 1
            
    print(max(ans))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3824
a,b =map(int,input().split())
A,B,C =("Alice","Bob","Draw")
if max(a,b) ==13 and min(a,b) ==1:
  print(A) if a < b else print(B)
else:
  if a > b:
    print(A)  
  elif a < b:
    print(B)  
  else:
    print(C)

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

typedef long long LL;
#define lowbit(x) ((x)&(-x))
#define INF 0x3f3f3f3f
#define memset(a,b) memset(a,b,sizeof(a))
#define	GE() printf(">----------\n")
#define	IN() freopen("in.txt","r",stdin)
#define	OUT() freopen("out.txt","w",stdout)
const int mod=1000000007;
const int inf=0x3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-8;
const int maxn=1005;

int main()
{
    int a;
    while(~scanf("%d", &a)){
        int b=a%10;
        int c=(a-b)/10;
        if(b==9||c==9)printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
typedef long long llong;
typedef pair<int, int> pii;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
int K, N;
vector<int> P;
vector<int> Q;
int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		llong p;
		cin >> p;
		p++;
		P.push_back(p);
	}
	int tmp = 0;
	for (int i = 0; i < K; i++) {
		tmp += P[i];
	}
	Q.push_back(tmp);
	for (int i = 0; i < N - K; i++) {
		tmp -= P[i];
		tmp += P[i + K];
		Q.push_back(tmp);
	}
	sort(Q.begin(), Q.end(), greater<int>());
	llong ANS = Q[0];
	cout << ANS / 2;
	if (ANS % 2 == 1) cout << ".5";
	return 0;
}

Measured memory_bytes: 2548
/*input
10
8 5
10 8
6 5
1 5
4 8
2 10
3 6
9 2
1 7
4
1 2
1 3
1 4
3
1 2
2 3
*/
#include<bits/stdc++.h>
using namespace std;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;
const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int fast_ex(int a,int n,int m){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= fast_ex(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int n;
const int N = 1e5+1;
vi adj[N];
int dp[N][2];

void dfs(int u,int p){
     //if(adj[u].size() == 1){
       dp[u][1] = 1;
       dp[u][0] = 1;
     //}
     for(int v:adj[u]){
        if(v == p)continue;
        dfs(v,u);
        dp[u][1] *= dp[v][0];// coloring black so childs are white
        dp[u][0] *= (dp[v][0]+dp[v][1]);//coloring white so children can be anything
        dp[u][1] %=MOD;dp[u][0]%= MOD;
        }
}

void solve(){
    cin >> n;
    RE(i,n-1){
      int a,b;cin >> a >> b;
      adj[a].pb(b);
      adj[b].pb(a);
    }
    dfs(1,1);
    cout << (dp[1][0]+dp[1][1])%MOD;

}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;//cin >> t;
  WL(t)solve();
  return 0;
}

Measured memory_bytes: 14208
n, k = map(int, input().split())
xv, yv = [], []
xy = []
for _ in range(n):
    x, y = map(int, input().split())
    xv.append(x)
    yv.append(y)
    xy.append((x, y))

xv = sorted(xv)
yv = sorted(yv)
ans = (xv[n-1] - xv[0]) * (yv[n-1] - yv[0])
for l in range(n):
    lx = xv[l]
    for r in range(l+1, n):
        rx = xv[r]
        for b in range(n):
            by = yv[b]
            for t in range(b+1, n):
                ty = yv[t]
                cnt = 0
                for x, y in xy:
                    if lx <= x <= rx and by <= y <= ty:
                        cnt += 1
                if cnt >= k:
                    ans = min(ans, (rx - lx)*(ty - by))
print(ans)


Measured memory_bytes: 69020
#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 N;
    cin >> N;
    int ans = 0;
    for(int i=1;i<=N;i++){
        int a;
        cin >> a;
        ans += i%2==1 && a%2==1;
    }
    cout << ans << "\n";
}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

struct Edge{
  int to, cap, cost, rev;
  Edge(int to_=0, int cap_ = 0, int cost_ = 0, int rev_ = 0)
	:to(to_), cap(cap_), cost(cost_), rev(rev_){}
};

const int MAX_V = 200*200*3;
const LL INF = 1e15;
int V;
vector<Edge> G[MAX_V];
LL dist[MAX_V];
int prevv[MAX_V], preve[MAX_V]; //直前の頂点と辺

void add_edge(int from, int to, int cap, int cost){
  G[from].push_back(Edge(to, cap, cost, G[to].size()));
  G[to].push_back(Edge(from, 0, -cost, G[from].size()-1));
}

// 始点s, 終点t, フローf の最小費用流。 存在しなければ-1
int min_cost_flow(int s, int t, int f){
  LL res = 0;
  while(f > 0){
	fill(dist, dist+V, INF);
	dist[s] = 0;
	bool update = true;
	while(update){
	  update = false;
	  for(int v=0;v<V;++v){
		if(dist[v] == INF) continue;
		for(int i=0;i<G[v].size();++i){
		  Edge& e = G[v][i];
		  if(e.cap > 0 && dist[v] + e.cost < dist[e.to]){
			dist[e.to] = dist[v] + e.cost;
			prevv[e.to] = v;
			preve[e.to] = i;
			update = true;
		  }
		}
	  }
	}

	if(dist[t] == INF) return -1;

	int d = f;
	for(int v=t;v!=s;v=prevv[v])
	  d = min(d, G[prevv[v]][preve[v]].cap);

	f -= d;
	res += d * dist[t];
	for(int v=t;v!=s;v=prevv[v]){
	  Edge& e = G[prevv[v]][preve[v]];
	  e.cap -= d;
	  G[v][e.rev].cap += d;
	}
  }
  
  return res;
}


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

  int H, W; cin >> H >> W;
  int WH = W*H;
  REP(y,H) REP(x,W){
	int a; cin >> a;
	int f = y*W+x;
	add_edge(f,f+WH,1,-a);
	add_edge(f,f+WH,100,0);
  }

  REP(y,H-1) REP(x,W){
	add_edge(y*W+x+WH,y*W+x+W,100,0);
  }
  REP(y,H) REP(x,W-1){
	add_edge(y*W+x+WH,y*W+x+1,100,0);
  }

  V = WH+WH;
  cout << -min_cost_flow(0,V-1,2) << endl;
  
  return 0;
}


Measured memory_bytes: 10624
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a,b;
  cin>>a>>b;
  string c=a+b;
  int d=stoi(c.substr(0,c.size()));
  for(int i=0;i<sqrt(d)+1;i++){
  	if(d==i*i) {
      cout<<"Yes";
      return 0;
    }
  }
  cout<<"No";
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc168/tasks/abc168_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    int t = N % 10;
    if (t == 3) {
        cout << "bon\n";
    } else if (t == 0 || t == 1 || t == 6 || t == 8) {
        cout << "pon\n";
    } else {
        cout << "hon\n";
    }

    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
#include<memory.h>
#include<algorithm>
using namespace std;

int main()
{
    int N;
    //freopen("input.txt", "r", stdin);
    scanf("%d", &N);
    int a, b, c;
    int dpa = 0;
    int dpb = 0;
    int dpc = 0;
    for(int i=0; i<N; i++)
    {
        scanf("%d%d%d", &a, &b, &c);
        int tmpa = dpa;
        int tmpb = dpb;
        dpa = max(dpb + a, dpc + a);
        dpb = max(tmpa + b, dpc + b);
        dpc = max(tmpa + c, tmpb + c);
    }
    int ans = 0;
    ans = max(ans, dpa);
    ans = max(ans, dpb);
    ans = max(ans, dpc);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
a, b = gets.strip.split.map(&:to_i)
sum = 0
num = 0
ans = 0
ary = []
(a..b).each do |i|
  sum = 0
  num = i
  ary = []
  while num>0 do
    ary << num%10
    num = num/10
  end
  ans += 1 if ary == ary.reverse
end
puts ans

Measured memory_bytes: 4348