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

int main(){
    int h,w;
    cin>>h>>w;
    vector<string> v;
    for(int i=0;i<h;i++){
        string s;
        cin>>s;
        v.push_back(s);
    }
    long long int dp[h+1][w+1];
    int mod=(int)1e9+7;
    dp[0][0] = (int)(v[0][0]!='#');
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++){
            if(i==0 and j==0) continue;
            if(v[i][j]=='#')
                dp[i][j]=0;
            else if(i==0)
                dp[i][j]=dp[i][j-1];
            else if(j==0)
                dp[i][j] = dp[i-1][j];
            else
                dp[i][j] = (dp[i-1][j]+ dp[i][j-1])%mod;
        }
    cout<<dp[h-1][w-1]<<endl;
}

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

int main() {
    int x, n; cin >> x >> n;
    unordered_set<int> s;
    for (int i = 0; i < n; ++i) {
        int p; cin >> p; s.insert(p);
    }
    int m = INT_MAX;
    int ans = INT_MAX;
    for (int i = 101; i >= 0; --i) {
        if (s.find(i) != s.end()) continue;
        if (abs(x - i) <= m) {
            m = abs(x - i);
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <cstdio>
#include <vector>
#include <set>
#include <iostream>
#include <cstring>
using namespace std;
#define MAX 100000

vector<int> G[MAX];
int N;
bool visited[MAX];

int prenum[MAX],parent[MAX],lowest[MAX],timer;

void dfs(int current,int prev){
	prenum[current]=lowest[current]=timer;
	timer++;
	visited[current]=true;

	for(int i=0;i<G[current].size();i++){
		int next=G[current][i];
		if(!visited[next]){
			parent[next]=current;
			dfs(next,current);
			lowest[current]=min(lowest[current],lowest[next]);
		}else{
			lowest[current]=min(lowest[current],prenum[next]);
		}
	}
}

void art_points(){
	memset(visited,false,sizeof(visited));
	timer=1;
	dfs(0,-1);
	set<int> ap;
	int np=0;
	for(int i=1;i<N;i++){
		int p=parent[i];
		if(p==0)np++;
		else if(prenum[p]<=lowest[i])ap.insert(p);
	}
	if(np>1)ap.insert(0);
	for(set<int>::iterator it=ap.begin();it!=ap.end();it++){
		cout << *it << endl;
	}
}

int main(void){
	int m;
	scanf("%d %d",&N,&m);
	for(int i=0;i<m;i++){
		int s,t;
		scanf("%d %d",&s,&t);
		G[s].push_back(t);
		G[t].push_back(s);
	}
	art_points();
	return 0;
}

Measured memory_bytes: 5084
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize,
        c: Chars,
    }

    let mut head = 0;
    let mut tail = n-1;
    let mut ans = 0i64;
    while head < tail {
        if c[head] == 'W' && c[tail]  == 'R' {
            ans += 1;
            head += 1;
            tail -= 1;
        } else if c[head] == 'R' {
            head += 1;
        } else if c[tail] == 'W' {
            tail -= 1;
        }
    }
    println!("{}", ans);
}


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

void main()
{
  auto s = readln.chomp;
  auto a = ["dream", "dreamer", "erase", "eraser"];

 loop: while (!s.empty) {
    foreach (ai; a) {
      if (s.length >= ai.length && s[$-ai.length..$] == ai) {
        s = s[0..$-ai.length];
        continue loop;
      }
    }
    writeln("NO");
    return;
  }

  writeln("YES");
}


Measured memory_bytes: 2556
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1000000007;// 1e9 + 7;

char m[2000][2000];
ll W[2000][2000];
ll H[2000][2000];
ll A[2000][2000];
int main(){
	ll h, w; cin >> h >> w;

	rep(i,0,h) {
		cin >> m[i];
	}

	rep(i, 0, h) rep(j, 0, w) {
		if (m[i][j] != '#') {
			W[i][j] = 1;
			H[i][j] = 1;
		}
		else {
			W[i][j] = 9;// 1 << 20;
			H[i][j] = 9;// 1 << 20;
		}

	}
	rep(i, 0, h) {
		rep(j, 1, w) {
			if (m[i][j] != '#') {
				if (m[i][j - 1] == '#') {
					W[i][j] = 1;
				}
				else {
					W[i][j] += W[i][j-1];
				}
			}
		}
		for (int j = w - 2; j >= 0; j--) {
			if (m[i][j] != '#') {
				if (m[i][j + 1] != '#') {
					W[i][j] = max(W[i][j],W[i][j+1]);
				}
			}
		}
	}

	rep(j, 0, w) {
		rep(i, 1, h) {
			if (m[i][j] != '#') {
				if (m[i-1][j] == '#') {
					H[i][j] = 1;
				}
				else {
					H[i][j] += H[i-1][j];
				}
			}
		}
		for (int i = h - 2; i >= 0; i--) {
			if (m[i][j] != '#') {
				if (m[i+1][j] != '#') {
					H[i][j] = max(H[i][j], H[i+1][j]);
				}
			}
		}
	}
	ll maxV = 0;
	rep(i, 0, h) {
		rep(j, 0, w) {
			if (m[i][j] != '#') {
				A[i][j] = H[i][j] + W[i][j];
				maxV = max(maxV, A[i][j]);
			}
		}
	}
	cout << maxV - 1 << endl;

	return 0;
}

Measured memory_bytes: 97920
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;
int n,r;
int p,c;
vector<int> card;
vector<int> tmp;
int main(){
  while(true){

    cin >> n >> r;
    if(n==0&&r==0)break;
    card.resize(n);
    REP(i,n)card[i]=i+1;
    REP(i,r){
      cin >> p >> c;
      for(int j=n-p+1;j<n-p+1+c;j++)
	tmp.push_back(card[j-c]);
      for(int j=n-p+1;j<n;j++){
    card[j-c] = card[j];
      }
      /*      REP(k,n)cout << card[k] << " ";
	      cout << "\n";*/
    if(p!=1)
      for(int j=n-c;j<n;j++)
        card[j] =tmp[j-n+c];
    /*      REP(k,n)cout << card[k] << " ";
	    cout << "\n";*/
      tmp.clear();
    }
    cout << card[n-1] << endl;
    card.clear();

  }

  return 0;
    
}

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

int main()
{
    int second;
    int h, m, s;

    cin >> second;
    h = second / 3600;
    m = (second % 3600) / 60;
    s = (second % 3600) % 60;

    cout << to_string(h) + ":" + to_string(m) + ":" + to_string(s) << endl;
    return 0;
}


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

#define F first
#define S second
#define prev azaza
#define MP make_pair
#define PB push_back

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

const int max_n = 100111, inf = 1000111222;

ll a[max_n];
ll mn[max_n];
ll mx[max_n];

int main()
{
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    for (int i = 0; i <= n; ++i) {
        cin >> a[i];
    }
    if (n == 0) {
        if (a[0] == 1) {
            cout << 1 << endl;
            return 0;
        }
        cout << -1 << endl;
        return 0;
    }
    if (a[0] > 0) {
        cout << -1 << endl;
        return 0;
    }
    mn[n] = a[n];
    mx[n] = a[n];
    for (int i = n - 1; i >= 0; --i) {
        mn[i] = a[i] + (mn[i + 1] + 1) / 2;
        mx[i] = a[i] + mx[i + 1];
    }
    mx[0] = 1;
    for (int i = 1; i <= n; ++i) {
        mx[i] = min(mx[i], (mx[i - 1] - a[i - 1]) * 2);
    }
    ll ans = 0;
    for (int i = 0; i <= n; ++i) {
        if (mx[i] < mn[i]) {
            cout << -1 << endl;
            return 0;
        }
        ans += mx[i];
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 5928
import java.util.Scanner;
public class Main{
	static long ans;
	public static void main(String[] args){
		Scanner sc= new Scanner(System.in);
		int n = sc.nextInt();
		long m = sc.nextLong();
		ans=1;
		long mod=1000000007;
		for(long i = 2; i<=m; i++){
			long o=0;
			while(m%i==0){
				m/=i;
				o++;
			}
			if(o!=0){
				for(long j = 1; j<=o;j++){
					ans*=((o+n-j)%mod);
					ans%=mod;
				}
				for(long h=2; h<=o; h++){
					pow(h,mod-2,mod);
					ans%=mod;
				}
			}
		}
		System.out.println(ans);
	}
	public static void pow(long h,long e,long mod){
		while(e>0){
			if((e & 1)==1){
				ans*=h;
				ans%=mod;
			}
			h*=h;
			h%=mod;
			e>>=1;
		}
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
/// Macros ---------------------
#define ll long long
#define sz(a) (int)a.size()
#define int long long
#define pb push_back
#define vi vector<int>
#define f first
#define s second
#define ii pair<int,int>
#define lb lower_bound
#define up upper_bound
#define rep(i,x,y) for(int i=(x);i<=(y);i++)
#define ld long double
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
/// Constracts -----------------------------------------------
const int maxn=1e5;
const int INF=(1ll)<<(30ll);
const int inf=1000000000000000000;
const int eps=1e-9;
const int mod=1e9+7;
/// Quick Pow ------------------------------------------------
int qpow(int b,int e)
{
    if( !e ) return 1;
    if( e & 1 ) return qpow(b, e - 1) * b;
    int pwur = qpow(b, e >> 1);
    return pwur * pwur;
}

int lcm(int a,int b){
    return a*b/__gcd(a,b);
}

/// My Code ---------------------------------------------------

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

    int a,b,c;
    map<int,int>mp;
    cin>>a>>b>>c;
    mp[a]++,mp[b]++,mp[c]++;
    if(mp[5]==2 && mp[7]==1)cout<<"YES\n";
    else cout<<"NO\n";
    return 0;
}


Measured memory_bytes: 3600
using System;
using System.Collections;
using System.Collections.Generic;

namespace _0589
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            List<string> catalog = new List<string>();
            List<int> ret = new List<int>();
            for (int i = 0; i < n; i++)
            {
                string[] s = Console.ReadLine().Split();
                if (catalog.Contains(s[0]))
                {
                    ret[catalog.IndexOf(s[0])] += int.Parse(s[1]);
                }
                else
                {
                    catalog.Add(s[0]);
                    ret.Add(int.Parse(s[1]));
                }
            }
            string[] x = catalog.ToArray();
            IComparer strlenComp = new StrLenComparer();
            Array.Sort(x, strlenComp);
            for (int i = 0; i < catalog.Count; i++)
            {
                Console.WriteLine(catalog[catalog.IndexOf(x[i])] + " " + ret[catalog.IndexOf(x[i])]);
            }
        }
    }
    public class StrLenComparer : IComparer
    {
        public int Compare(object x, object y)
        {
            string str1 = (string)x;
            string str2 = (string)y;
            if (str1.Length != str2.Length) return str1.Length - str2.Length;
            else return str1.CompareTo(str2);
        }
    }
}

Measured memory_bytes: 10004
#include <stdio.h>

int main(void) {
  char str1[11], str2[11], str3[11], str4[4];
  scanf("%s %s %s", str1, str2, str3);
  str4[0] = str1[0] - 32;
  str4[1] = str2[0] - 32;
  str4[2] = str3[0] - 32;
  str4[3] = '\0';
  printf("%s\n", str4);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll h[100005], dp[100005];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> h[i];
  dp[1] = 0, dp[2] = abs(h[2] - h[1]);
  for (int i = 3; 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] << endl;
}

Measured memory_bytes: 1920
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		List<Long> list = new ArrayList<Long>(); 
		br.readLine();
		String str;
		while((str = br.readLine()) != null){
			list.add(Long.valueOf(str));
		}
		Long[] arr = new Long[list.size()];
		arr = list.toArray(arr);
		int cursor = arr.length - 2;
		long maxProfit = arr[cursor + 1] - arr[cursor];
		long a, b;
		long max = (a = arr[cursor + 1]) > (b = arr[cursor]) ? a : b;
		cursor--;
		while(cursor >= 0){
			if(max - arr[cursor] > maxProfit){
				maxProfit = max - arr[cursor];
			}
			if(arr[cursor] > max){
				max = arr[cursor];
			}
			cursor--;
		}
		System.out.println(maxProfit);
	}
}

Measured memory_bytes: 45848
//
//  main.cpp
//  Colorful_Slimes_2
//
//  Created by Uttam Datta on 02/06/19.
//  Copyright © 2019 Uttam Datta. All rights reserved.
//

#include <iostream>
#include <vector>
using namespace std;

vector <int> A;
int N;

int ans(){
    int res = 0;
    for(int i = 1; i < N;){
        if(A[i] == A[i-1]){
            res++;
            i+=2;
        }
        else{
            i++;
        }
    }
    return res;
}


int main(){
    cin >> N;
    A.clear();
    A.resize(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    cout << ans() << endl;
    return 0;
}


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

using namespace std;

//input
int a[3];

void solve(){
	sort(a, a + 3);
	if(a[0] * a[0] + a[1] * a[1] == a[2] * a[2])
		printf("YES\n");
	else
		printf("NO\n");
}

int main(int argc, char const *argv[]){
//	freopen("in.txt", "r", stdin);

	int t;
	scanf("%d", &t);
	while(t --){
		for(int i = 0; i < 3; i ++)
			scanf("%d", &a[i]);
		solve();
	}

	return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.stream.Collectors;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;

public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    List<Character> list1 = new ArrayList<>();

    int k = sc.nextInt();
    int x = sc.nextInt();
    int coin = 500 * k;
    if(coin >= x){
        System.out.println("Yes");
    }else{
        System.out.println("No");
    }
    }


}

Measured memory_bytes: 22608
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll INF = 1e18+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; ll k; cin >> n >> k;
    vector<ll> a(n);
    rep(i,0,n) cin >> a[i];
    vector<ll> s(n+1,0ll);
    rep(i,0,n){
        s[i+1] = s[i] + a[i];
    }
    map<ll,ll> m;
    ll ans = 0ll;
    rep(i,0,n+1){
        ll x = s[i]-i;
        x %=k;
        if(i-k>=0){
            m[s[i-k]]--;
        }
        ans += m[x];
        m[x]++;
        s[i] = x;
    }
    cout << ans << endl;
}

Measured memory_bytes: 15872
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		var S = GetStrings(N);
		Array.Sort(S, StringComparer.Ordinal);
		
		var ans = new List<string>();
		int cnt = 1;
		int max = 0;
		ans.Add(S[0]);
		for(int i = 1; i < N; i++)
		{
			if(S[i].Equals(S[i - 1]))
			{
				cnt++;
			}
			else
			{
				if(cnt > max)
				{
					ans = new List<string>(){ S[i - 1] };
					max = cnt;
				}
				else if(cnt == max)
				{
					ans.Add(S[i - 1]);
				}
				cnt = 1;
			}
		}
		if(cnt > max)
		{
			ans = new List<string>(){ S[N - 1] };
			max = cnt;
		}
		else if(cnt == max)
		{
			ans.Add(S[N - 1]);
		}

		WriteLine(string.Join("\n", ans));
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 42572
# https://atcoder.jp/contests/abc063/tasks/arc075_b
# 問題文あなたが散歩していると、突然 N 体の魔物が出現しました。
# それぞれの魔物は 体力 という値を持ち、i 体目の魔物の出現時の体力は hi です。
# 体力が 0以下となった魔物は直ちに消滅します。
# 幸い、あなたは熟練の魔法使いであり、爆発を引き起こして魔物を攻撃できます。
# 一回の爆発では、以下のように魔物の体力を減らすことができます。
# 生存している魔物を一体選び、その魔物を中心に爆発を引き起こす。
# 爆発の中心となる魔物の体力は A 減り、
# その他の魔物の体力はそれぞれ B 減る。
# ここで、A と B はあらかじめ定まった値であり、A>B である。
# すべての魔物を消し去るためには、最小で何回の爆発を引き起こす必要があるでしょうか？
# 制約入力値はすべて整数である。
# 1≤N≤10^5
# 1≤B<A≤10^9
# 1≤hi≤10^9

# N A B
# h1
# h2
# :
# hN

# 4 5 3
# 8
# 7
# 4
# 2

# 2

# 2 10 4
# 20
# 20

# 4

# 5 2 1
# 900000000
# 900000000
# 1000000000
# 1000000000
# 1000000000

# 800000000

N, A, B = gets.split.map(&:to_i)
H = []
N.times {
  H << gets.to_i
}
H.sort!.reverse!

A_B = A - B

class Integer
  def able?
    counter = self
    bself = B * self
    b2 = - bself + A_B - 1
    H.each do |value|
      break if value <= bself
      counter -= ((value + b2)/(A_B))
      break if counter < 0
    end
    counter >= 0
  end
end

# T回で倒しきれるか？ を二分探索
# ng = 0, ok = h.max
ng = 0
ok = 1 << 30
mid = 0
while (ok - ng) > 1
  mid = (ng + ok)/2
  if mid.able?
    ok = mid
  else
    ng = mid
  end
end
puts ok

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    if (n & 1) cout << "No" << endl;
    else {
        for (int i = 0; i < n / 2; ++i) {
            if (s[i] != s[n/2 + i]) {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3528
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

ll a, b;

bool check(vll h, int k) {
    ll attack = 0;
    rep(i,h.size()) {
        ll rem = h[i] - k*b;
        if (rem > 0) attack += (rem+(a-b)-1)/(a-b); 
    }
    if (attack <= k) return true;
    else return false;
}

int main() {
    int n; cin >> n >> a >> b;
    vll h(n);
    rep(i,n) cin >> h[i];
    int lb = -1, ub = inf;
    while (ub - lb > 1) {
        int mid = (lb+ub)/2;
        if (check(h,mid)) ub = mid;
        else lb = mid;
    }
    cout << ub << endl;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
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;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

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

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

const int maxA = 1e5 + 1;
int arr[maxA];

signed main() {
  int n = read();
  REP(i, n) {
    int a = read();
    arr[a]++;
    arr[a + 1]++;
    if (a - 1 >= 0)
      arr[a - 1]++;
  }
  print(*(max_element(arr, arr + maxA)));
}


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

ll gcd(ll a, ll b)
{
	if (a % b == 0) return b;
	return gcd(b,a%b);
}

int main()
{
	ll k,ans=0,res; cin >> k;
	for (ll a=1; a<=k; a++)
		for (ll b=1; b<=k; b++)
			for (ll c=1; c<=k; c++)
				res = gcd(a,b), res = gcd(res,c), ans += res;

	cout<<ans<<"\n";

	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B, C, remain;
    cin >> A >> B >> C;
    remain = C - (A - B);
    cout << (remain >= 0 ? remain : 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int a[N];
long long ans;
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	if (a[0] != 0) {
		cout << -1;
		return 0;
	}
	for (int i = 1; i < n; i++) {
		if (a[i] - a[i - 1] > 1 && a[i] != 0) {
			cout << -1;
			return 0;
		}
	}
	int mx = 0;
	for (int i = n - 1; i > 0; i--) {
		mx--;
		if (a[i] > mx) {
			ans += a[i];
			mx = a[i];
		}
	}
	cout << ans;
	return 0;
}


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

int n, k;

int main()
{
	scanf("%d %d", &n, &k);
	int cur = 1;
	for (int i = 0; i < n; i++)
		if (cur <= k) cur *= 2;
		else cur += k;
	printf("%d\n", cur);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

int main() {
  int r;
  cin >> r;
  cout << r * r << endl;

  
  return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>
#include<map>
#include<iterator>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);
const int MAX = 100'000;

//変数
int N, H, W;
vector<pair<int, int>> xy;
vector<bool> use;
map<int, vector<int>> x2i, y2i;

vector<int> udlr = vector<int>(4, 0);



//サブ関数
//入力
void input()
{
	cin >> N >> W >> H;
	use.resize(N, false);
	REP(i, N) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		xy.push_back({ a,b });
	}
}


void make_xy_join()
{
	//x,y軸で、座標毎の含有点作成
	REP(i,N){
		int x = xy[i].first;
		int y = xy[i].second;


		if (x2i.find(x) == x2i.end()) x2i[x] = vector<int>();
		x2i[x].push_back(i);


		if (y2i.find(y) == y2i.end()) y2i[y] = vector<int>();
		y2i[y].push_back(i);
	}
}


void make_connected_graph(int route)
{
	queue<int> q;
	vector<bool> mudlr = vector<bool>(4, false);
	q.push(route);
	use[route] = true;

	while (!q.empty()) {
		int node = q.front(); q.pop();
		int x = xy[node].first;
		int y = xy[node].second;

		if (y == 0)mudlr[0] = true;
		if (y == H - 1)mudlr[1] = true;
		if (x == 0)mudlr[2] = true;
		if (x == W - 1)mudlr[3] = true;


		for (int next : x2i[x]) if (!use[next]) {
			use[next] = true;
			q.push(next);
		}
		for (int next : y2i[y]) if (!use[next]) {
			use[next] = true;
			q.push(next);
		}
	}
	for (int i = 0; i < 4; i++) if (mudlr[i]) {
		udlr[i]++;
	}
}


//計算
void calc()
{
	int tree = 0;

	make_xy_join();
	REP(i, N) if (!use[i]) {
		tree++;
		make_connected_graph(i);
	}


	if (tree == 1) {
		cout << N - 1 << endl;
	}
	else {
		cout << N + tree - 1 - *max_element(udlr.begin(), udlr.end()) << endl;
	}
}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	debug();
	
	return 0;
}



Measured memory_bytes: 10448
#include<bits/stdc++.h>
using namespace std;
int main(){
	long N,sum=0,tmp,dig=0;
	cin>>N;
	tmp=N;
	while(N){
		dig=N%10;
		sum+=dig;
		N/=10;
	}
	//cout<<sum<<endl;
	if(tmp%sum==0){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}


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

 typedef long long ll;

 int main()
 {
     int n, k, q;
     cin >> n >> k >> q;

     ll a[100000+10];
     for(int i = 0;i < n; i++) a[i] = k;

     for(int i = 0; i < q; i++)
     {
         int y;
         cin >> y;
         a[y - 1]++;
     }

    for(int i = 0; i < n; i++)
    {   a[i] -= q;
        if(a[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    
     
     return 0;
 }

Measured memory_bytes: 1408
<?php

$card = [
    explode(' ', trim(fgets(STDIN))),
    explode(' ', trim(fgets(STDIN))),
    explode(' ', trim(fgets(STDIN))),
];

fscanf(STDIN, '%d', $N);
for ($i=0; $i < $N; $i++) {
    fscanf(STDIN, '%d', $num);
    for ($j=0; $j < 3; $j++) {
        for ($k=0; $k < 3; $k++) {
            if ($card[$j][$k] == $num) {
                $card[$j][$k] = '○';
            }
        }
    }
}

if ($card[0][0] === '○' && $card[0][1] === '○' && $card[0][2] === '○') {
    echo 'Yes';
} elseif ($card[1][0] === '○' && $card[1][1] === '○' && $card[1][2] === '○') {
    echo 'Yes';
} elseif ($card[2][0] === '○' && $card[2][1] === '○' && $card[2][2] === '○') {
    echo 'Yes';
} elseif ($card[0][0] === '○' && $card[1][0] === '○' && $card[2][0] === '○') {
    echo 'Yes';
} elseif ($card[0][1] === '○' && $card[1][1] === '○' && $card[2][1] === '○') {
    echo 'Yes';
} elseif ($card[0][2] === '○' && $card[1][2] === '○' && $card[2][2] === '○') {
    echo 'Yes';
} elseif ($card[0][0] === '○' && $card[1][1] === '○' && $card[2][2] === '○') {
    echo 'Yes';
} elseif ($card[0][2] === '○' && $card[1][1] === '○' && $card[2][0] === '○') {
    echo 'Yes';
} else {
    echo 'No';
}
echo PHP_EOL;


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

void show(int *A, int size) {
  for(int i = 1; i <= size; ++i) {
    if(i>1) cout << " ";
    cout << A[i];
  }
  cout << endl;
}

void insertion_sort(int *A, int size) {
  show(A, size);
  for(int j = 2; j <= size; ++j) {
    int key = A[j];
    int i = j - 1;
    while(i > 0 && A[i] > key) {
      A[i+1] = A[i];
      i = i - 1;
    }
    A[i+1] = key;
    show(A, size);
  }
}

int main() {
  int N;
  cin >> N;
  int A[N+1];
  for(int i = 1; i <= N; ++i) {
    cin >> A[i];
  }
  insertion_sort(A, N);
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int n;
int m;

vector<int> edges[200010];
vector<bool> vis(200010,false);
int main()
{
    cin >> n >> m;
    rep(i,1,n)
    {
        int k;
        cin >> k;
        rep(j,0,k - 1)
        {
            int l;
            cin >> l;
            l += n;
            edges[i].push_back(l);
            edges[l].push_back(i);
        }
    }

   

    queue<int> que;
    que.push(1);
    vis[1] = true;
    while(!que.empty())
    {
        int v = que.front();
        que.pop();

        for(int to : edges[v])
        {
            if(!vis[to])
            {
                vis[to] = true;
                que.push(to);
            }
        }
    }

    rep(i,1,n)
    {
        if(!vis[i])
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;

}

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

int main() {
  int a, b;
  cin >> a >> b;
  int c;
  if (b == 100) c = a * 1000 + b;
  else if (b >= 10) c = a * 100 + b;
  else c = a * 10 + b;
  int d = (int)sqrt((double)c);
  if (d * d == c || (d+1) * (d+1) == c) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int FF = 255, F  = 16;

string name[] = {"black", "blue", "lime", "aqua", "red", "fuchsia", "yellow", "white"};
int R[] = { 0, 0, 0, 0, FF, FF, FF, FF};
int G[] = { 0, 0, FF, FF, 0, 0, FF, FF};
int B[] = { 0, FF, 0, FF, 0, FF, 0, FF};

int num(char t)
{
    if(t >='0' && t <= '9') return t - '0';
    else return t - 'a' + 10;
}
int f(int n) { return n * n;}

int main()
{
    string s;
    while(cin >> s)
    {
        if(s == "0") break;

        int mind = FF * FF * F, d = 0, ans = 0;
        REP(8)
        {
            d = f(R[i] -( num(s[1]) * F + num(s[2]) )) + f(G[i]-(num(s[3])*F + num(s[4]))) + f(B[i] - (num(s[5])*F + num(s[6])));
            if(mind > d) { ans = i; mind = d;}
        }
        cout << name[ans] << endl;
    }
    return 0;
}

Measured memory_bytes: 1188
import java.util.*;
class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int a;
                int n = sc.nextInt();
                int basePrice = sc.nextInt();
                int topPrice = sc.nextInt();
                int baseCal = sc.nextInt();
                int[] topCal = new int[n];
                for(int i=0;i<n;i++){
                        topCal[i]=sc.nextInt();
                }
                Arrays.sort(topCal);
                for(int i=n;i>0;i--){
                        if((baseCal+topCal[i-1])/(basePrice+topPrice)>=(baseCal/basePrice)){
                                baseCal += topCal[i-1];
                                basePrice += topPrice;
                        }
                }
                System.out.println(baseCal/basePrice);
        }
}

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

const int N = 100010;

std::vector <int> e[N];
int n;
int dep[N], sz[N], fa[N];

void addedge(int u, int v){
	e[u].push_back(v);
	e[v].push_back(u);
}

void dfs(int u, int fa){
	sz[u] = 1;
	for (auto v : e[u]){
		if (v == fa){
			continue;
		}
		::fa[v] = u;
		dep[v] = dep[u] + 1;
		dfs(v, u);
		sz[u] += sz[v];
	}
}

int main(){
	scanf("%d", &n);
	for (int i = 0, u, v; i < n - 1; ++ i){
		scanf("%d%d", &u, &v);
		addedge(u, v);
	}
	dfs(1, 0);
	int v = n;
	for (int i = 0, sz = dep[n] - 1 >> 1; i < sz; ++ i){
		v = fa[v];
	}
	return printf(n - sz[v] > sz[v] ? "Fennec\n" : "Snuke\n"), 0;
}

Measured memory_bytes: 13184
# 値の入力
N=int(input())
S=str(input())

i=N-1
result=0

# 処理
while True:
    if i-2<0:
        break
    if S[i]=='C' and S[i-1]=='B' and S[i-2]=='A' :
        result+=1
    i-=1

print(result) 

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int n,m,a,i;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++)	scanf("%d",&a);
	printf("%d\n",n-m-1);
	return 0;
}


Measured memory_bytes: 2744
#include<iostream>
#include<sstream>

using namespace std;

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

template<class A, class B> B convert(A a) {
  stringstream ss;
  ss << a;
  B b;
  ss >> b;
  return b;
}

int main() {
  string a;
  cin >> a;
  int x, y;
  int ans = 0;
  rep (i, a.size() + 1) {
    if (i == 0) {
      x = 0;
    } else {
      if (a[0] == '0') continue;
      x = convert<string, int>(a.substr(0, i));
    }
    if (i == (int)a.size()) {
      y = 0;
    } else {
      if (a[i] == '0') continue;
      y = convert<string, int>(a.substr(i));
    }
    if (x % 2 != y % 2) continue;
    if (x + y < 0) continue;
    if (y - x < 0) continue;
    ++ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template <typename T>
struct SegTree{
    vector<T> dat;
    int n;
    const T Default;
    SegTree(int n_, const T& def) : Default(def){init(n_);}
    void init(int n_){
        n = 1;
        while(n < n_) n *= 2;
        dat = vector<T>(2*n-1, Default);
    }
    T f(const T& a, const T& b) {
    	return a + b;
    }
    void update(int k, const T& a){
        k += n-1;
        dat[k] = a;
        while(k > 0){
            k = (k - 1) / 2;
            dat[k] = f(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
    T query(int a, int b, int k, int l, int r ){
        if(r <= a || b <= l) return Default;
        if(a <= l && r <= b) return dat[k];
        T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return f(vl, vr);
    }
    T query(int a, int b) {
    	return query(a, b, 0, 0, n);
    }
};

int main(){
	int n, k;
	cin >> n >> k;
	vl a(n);
	rep(i, n) cin >> a[i];
	SegTree<ll> st(n+1, 0LL);
	rep(i, n) if(a[i] > 0) st.update(i, a[i]);
	ll sum = 0LL, ans = 0;
	rep(i, k) sum += a[i];
	ans = max(ans, sum + st.query(k, n));
	REP(i, k, n) {
		sum += a[i] - a[i-k];
		ans = max(ans, sum + st.query(0, i-k+1) + st.query(i+1, n));
		ans = max(ans, st.query(0, i-k+1) + st.query(i+1, n));
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
#define ll long long int

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

    int t = 0;

    for (int i = 0; i < S.length(); i++)
    {
        if (S[i] == '+')
            t++;
        else if (S[i] == '-')
            t--;
    }

    cout << t;

    return 0;
}


Measured memory_bytes: 3600
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
#define debug(args...)                                                                             \
    {                                                                                              \
        dbg, args;                                                                                 \
        cerr << endl;                                                                              \
    }
#define massert(x) assert(x)
#else
#define debug(args...) // Just strip off all debug tokens
#define massert(x)
#endif
struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;
int a[30],b[30],mi[30];
struct Edge
{
	int a,b,v;
};
vector<Edge> e;
void solve(long long l){
	LL t=l;
	int n=0;
	int m=0;
	while(l>0) {
		a[++n]=l%2;
		l/=2;
		if (a[n]==1) {
			b[++m]=n;
		}
	}
	//reverse(a+1,a+1+n);
	for(int i=1; i<=n-1; ++i) {
		e.push_back({i,i+1,1<<(n-i-1)});
		e.push_back({i,i+1,0});
	}
	int sum=(1<<(n-1))-1;
	debug(n,m);
	for(int i=m-1; i>0; --i) {
		sum++;
		e.push_back({1,n-b[i]+1,sum});
		sum+=(1<<(b[i]-1))-1;
	}
	cout<<n<<' '<<e.size()<<endl;
	for(auto i:e) {
		cout<<i.a<<' '<<i.b<<' '<<i.v<<endl;
	}
}

int main(){	
#ifdef WAAUTOMATON
	//freopen("./in_D_1.txt","r",stdin);
#endif
	long long L;
	scanf("%lld",&L);
	solve(L);
	return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    

    class Program
    {
        
        
        
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');

            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);

            double K = (double)(A + B) / 2;

            if(K - (int)K != 0)
            {
                Console.WriteLine("IMPOSSIBLE");
            }
            else
            {
                Console.WriteLine((int)K);
            }


        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
vvi a;

int main(){
	cin>>n;
	a=vvi(n,vi(n,1));
	for(int i=0;i<n/2;i++) a[i][n/2*2-1-i]=0;
	cout<<n*(n-1)/2-n/2<<endl;
	for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) if(a[i][j]) cout<<i+1<<' '<<j+1<<endl;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> P;


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


int main(void)
{
	ll n, q;
	cin >> n >> q;
	vector<tuple<double, ll, ll>> events;
	rep(i, n) {
		ll s, t, x;
		cin >> s >> t >> x;
		events.emplace_back(s - x - 0.5, 1, x);
		events.emplace_back(t - x - 0.5, -1, x);
	}
	const ll LARGE = (ll)1e15;
	events.emplace_back(LARGE, 0, LARGE);
	sort(events.begin(), events.end());
	vector<ll> ds(q);
	rep(i, q) cin >> ds[i];

	set<ll> positions;
	int di = 0;
	vector<ll> results(q,-1);
	for(int i = 0;i < events.size();i++){
		double next; 
		ll t, x;
		tie(next, t, x) = events[i];
		if (t == 0) break;
		while (di < q) {
			auto d = ds[di];
			if (d > next) break;
			if (positions.size() != 0) {
				auto m = *positions.begin();
				results[di] = m;
			}
			di++;
		}
		if (di >= q) {
			break;
		}
		if (t == 1) {
			positions.insert(x);
		}
		else if (t == -1) {
			positions.erase(x);
		}
	}
	rep(i, q) {
		cout << results[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 23400
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b;
  cin >> n >> a >> b;
  int p[n];
  int first=0,second=0,third=0;
  rep(i,n) {
    cin >> p[i];
    if(p[i]<=a){
      first++;
    }else if(p[i]>a && p[i]<=b){
      second++;
    }else{
      third++;
    }
  }
  int ans = min(first,min(second,third));
  cout << ans << endl;
  return 0;
}

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

int main(void){

    int N,x; cin>>N>>x;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) {
        cin>>a[i];
    }
    sort(a.begin(),a.end());


    int cnt=0,tmp=0;
    for (int i = 0; i < N; ++i) {
        x -= a[i];
        if(x<0) break;
        cnt++;
    }
    if(x>0) cnt--;
    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 256
while True:

    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for k in range(W):
            if (i+k)%2 == 0:
                print("#",end = "")
            else:
                print(".",end = "")
        print()

    print()
    


Measured memory_bytes: 7000
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}

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

signed main(void)
{
  string s;
  cin >> s;

  int ret = s.size();
  REP(i, s.size()) {
    if(s[i] == '1') {
      chmin(ret, max(i, (ll)s.size()-i-1));
    }
  }

  int res = s.size();
  REP(i, s.size()) {
    if(s[i] == '0') {
      chmin(res, max(i, (ll)s.size()-i-1));
    }
  }

  cout << max(ret, res) << endl;

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
	int sum=0;
	string s;
	while(cin >> s){
		s.resize(s.size()+1);
		for(int i=0;i<s.size()-1;++i){
			if(s[i]=='I'){
				if(s[i+1]=='V') sum+=4 , s[i+1]='@';
				else if(s[i+1]=='X') sum+=9 ,s[i+1]='@';
				else if(s[i+1]=='L') sum+=49 , s[i+1]='@';
				else if(s[i+1]=='C') sum+=99 , s[i+1]='@';
				else if(s[i+1]=='D') sum+=499 , s[i+1]='@';
				else if(s[i+1]=='M') sum+=999 , s[i+1]='@';
				else sum+=1;
			} else if (s[i]=='V'){
				if(s[i+1]=='X') sum+=5 , s[i+1]='@';
				else if(s[i+1]=='L') sum+=45 , s[i+1]='@';
				else if(s[i+1]=='C') sum+=95 , s[i+1]='@';
				else if(s[i+1]=='D') sum+=450 , s[i+1]='@';
				else if(s[i+1]=='M') sum+=950 , s[i+1]='@';
				else sum+=5;
			} else if (s[i]=='X'){
				if(s[i+1]=='L') sum+=40 , s[i+1]='@';
				else if(s[i+1]=='C') sum+=90 , s[i+1]='@';
				else if(s[i+1]=='D') sum+=490 , s[i+1]='@';
				else if(s[i+1]=='M') sum+=990 , s[i+1]='@';
				else sum+=10;
			} else if (s[i]=='L'){
				if(s[i+1]=='C') sum+=50 , s[i+1]='@';
				else if(s[i+1]=='D') sum+=450 , s[i+1]='@';
				else if(s[i+1]=='M') sum+=950 , s[i+1]='@';
				else sum+=50;
			} else if (s[i]=='C'){
				if(s[i+1]=='D') sum+=400 , s[i+1]='@';
				else if(s[i+1]=='M') sum+=900 , s[i+1]='@';
				else sum+=100;
			} else if (s[i]=='D'){
				if(s[i+1]=='M') sum+=500 , s[i+1]='@';
				else sum+=500;
			} else if (s[i]=='M'){
				sum+=1000;
			}
		}
		cout << sum << endl;
		sum=0;
	}
	return 0; 
}

Measured memory_bytes: 1184
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] lArr = new int[n];

        int max = 0;
        int maxIndex = 0;
        for (int i = 0; i < n; i++) {
            lArr[i] = sc.nextInt();
            if (max < lArr[i]) {
                max = lArr[i];
                maxIndex = i;
            }
        }

        int sum = 0;
        for (int i = 0; i < n; i++) {
            if (i != maxIndex) sum += lArr[i];
        }

        System.out.println(sum > max ? "Yes" : "No");
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <map>
#include <cstring>
using namespace std;
typedef long long ll;
const ll maxn = 1e6+10;
const ll inf = 1e16;
const ll mod = 998244353;

int N,M;
int arr[maxn];
priority_queue<int> heap;
int main(){
//    freopen("in.txt", "r", stdin);
    
    cin>>N>>M;
    for(int i = 0;i<N;i++) scanf("%d",&arr[i]);
    for(int i = 0;i<N;i++) heap.push(arr[i]);
    while(M--){
        int t = heap.top(); heap.pop();
        heap.push(t/2);
    }
    ll res = 0;
    while(heap.size()){
        res += heap.top();heap.pop();
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 1276