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

using namespace std;

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.first <<","<<P.second <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif



int main() {
    
    string s;
    cin >> s;
    
    bool good = true;
    if (s.size() % 2) {
        good = false;
    }
    for (int i = 0; i < s.size(); i++) {
        if (i % 2 == 0) good &= s[i] == 'h';
        else good &= s[i] == 'i';
    }
    
    printf(good ? "Yes\n" : "No\n");
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;

int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    if(a%2==0||b%2==0||c%2==0){
        cout<<0<<endl;
    }
    else{
        vector<ll> x(3);
        x[0]=a;
        x[1]=b;
        x[2]=c;
        sort(all(x));
        cout<<x[0]*x[1]<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((int)(x).size())

using namespace std;
typedef long long ll;


ll table_l[200001];
ll table_r[200001];
void solve(long long N, std::vector<long long> A){
  table_l[0] = 0;
  table_r[N] = A[N];

  for (int i = 1; i <= N; i++) {
    table_l[i] = max(table_l[i - 1], A[i]);
    table_r[N - i] = max(table_r[N - i + 1], A[N - i]);
  }

  for (int i = 1; i <= N; i++) {
    printf("%lld\n", max(table_l[i - 1], table_r[i + 1]));
  }
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N+1);
  A[0] = 0;
  for(int i = 1 ; i < N+1 ; i++){
    scanf("%lld",&A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s1s2s3;
  cin >> s1s2s3;
  int a = s1s2s3 % 10;
  int b = s1s2s3 % 100 / 10;
  int c = s1s2s3 / 100;
  cout << a+b+c << endl;
}

Measured memory_bytes: 256
j,a['   '],z=1e6;main(i){for(;++i<998;)for(j=i*i;!a[i]?a[j]=j<z:0;j+=i);for(i=1;++i<z||~scanf(j="%d\n",a)&&printf(j,a[*a]);a[i]=*a+=!a[i]);}

Measured memory_bytes: 0
import java.io.*;
import java.math.*;

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        String s[]=bu.readLine().split(" ");
        BigDecimal a=new BigDecimal(s[0]),b=new BigDecimal(s[1]);
        a=a.multiply(b);
        String st=a.toString(); int i=0;
        while(i<st.length() && st.charAt(i)!='.') sb.append(st.charAt(i++));
        System.out.print(sb);
    }
}


Measured memory_bytes: 33044
#include <iostream>
#include <cmath>

using namespace std;

int main(){
  int n,m,x;
  int a=0, b=0;
  cin >>n>>m>>x;
  int temp;
  for(int i=0;i < m; ++i){
    cin >> temp;
    ++(temp <= x ? a:b);
  }
  cout << min(a,b)<<endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i;
    cin>>n;
    int z;
    int mp[n+1];
    memset(mp,0,sizeof mp);
    for(i=1;i<n;i++)
    {
        cin>>z;
        mp[z]+=1;
    }
    for(i=1;i<=n;i++)
    cout<<mp[i]<<"\n";
    return 0;
}

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

using namespace std;

void err() {
  puts("NO");
  exit(0);
}

const int MAX = 410;
const int K = 200;

vector <int> _g[2 * MAX], _gr[2 * MAX], *g = _g + MAX, *gr = _gr + MAX;
int _x[2 * MAX], _din[2 * MAX], _dout[2 * MAX], *x = _x + MAX, *din = _din + MAX, *dout = _dout + MAX;
bool _was[2 * MAX], *was = _was + MAX;

int main() {
  int n, h;
  scanf("%d %d", &n, &h);
  for (int i = 0; i < n; i++) {
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    int x = (c == 0 ? -a : c);
    int y = (d == 0 ? b : -d);
    g[x].push_back(y);
    gr[y].push_back(x);
  }
  for (int i = -K; i <= K; i++) {
    dout[i] = g[i].size();
    din[i] = gr[i].size();
    if (i < 0 && dout[i] < din[i]) {
      err();
    }
    if (i > 0 && dout[i] > din[i]) {
      err();
    }
    was[i] = (din[i] + dout[i] == 0 ? true : false);
  }
  for (int i = -K; i <= K; i++) {
    if (was[i]) {
      continue;
    }
    int b = 0, e = 1;
    x[0] = i;
    was[i] = true;
    while (b < e) {
      for (int j : g[x[b]]) {
        if (!was[j]) {
          was[j] = true;
          x[e++] = j;
        }
      }
      for (int j : gr[x[b]]) {
        if (!was[j]) {
          was[j] = true;
          x[e++] = j;
        }
      }
      b++;
    }
    int sum_pos = 0, sum_neg = 0;
    for (int j = 0; j < e; j++) {
      if (x[j] > 0) {
        sum_pos += din[x[j]] - dout[x[j]];
      } else {
        sum_neg += dout[x[j]] - din[x[j]];
      }
    }
    if (sum_pos != sum_neg || sum_pos == 0) {
      err();
    }
  }
  puts("YES");
  return 0;
}


Measured memory_bytes: 1792
fun main(args: Array<String>) {
    val abcd = readLine()!!

    for (bit in 0 until (1 shl abcd.length - 1)) {
        var expr = abcd[0].toString()
        var eval = abcd[0] - '0'
        for (i in 0 until abcd.length - 1) {
            if (1 and (bit shr i) == 1) {
                expr += "+" + abcd[i + 1]
                eval += abcd[i + 1] - '0'
            } else {
                expr += "-" + abcd[i + 1]
                eval -= abcd[i + 1] - '0'
            }
        }
        if (eval == 7) {
            println("$expr=7")
            return
        }
    }
}

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

const int C = 2005;

int s[C];
int t[C];
long long dp[C][C];
long long MOD = 1000000007;

int main() {
  int N, M;

  while (cin >> N >> M) {
    for (int i = 0; i < C; i++) {
      s[i] = t[i] = 0;
      for (int j = 0; j < C; j++) {
        dp[i][j] = 0;
      }
      dp[i][0] = dp[0][i] = 1;
    }

    for (int i = 1; i <= N; i++) {
      cin >> s[i];
    }
    for (int i = 1; i <= M; i++) {
      cin >> t[i];
    }
    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= M; j++) {
        dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD;
        if (s[i] != t[j]) {
          dp[i][j] = (dp[i][j] - dp[i-1][j-1] + MOD) % MOD;
        }
      }
    }
    cout << dp[N][M] << endl;
  }
}


Measured memory_bytes: 31744
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;

int main() {
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		if (i % 2 == 1 && x % 2 == 1) {
			ans++;
		}
	}
	cout << ans;
}


Measured memory_bytes: 3584
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def solve(N: int, K: int):
    s = 0
    for i in range(K, N+2):
        p = i*(N-i+1) + 1
        s += p
        s %= MOD
    print(s)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()

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

using namespace std;

#define int 		long long
#define endl		"\n"
#define mod			1000000007
#define inf			1e12
#define IOS			ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int32_t main() {

	IOS;

	int a, b, c, k;
	cin >> a >> b >> c >> k;

	while (b <= a) {
		b *= 2;
		k--;
	}

	if (k < 0) {
		cout << "No\n";
		return 0;
	}

	while (c <= b) {
		c *= 2;
		k--;
	}

	if (k < 0) {
		cout << "No\n";
	}
	else {
		cout << "Yes\n";
	}

	return 0;
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    double a, b;
    cin >> a >> b;

    cout << ceil((a+b) / 2) << endl;

}

Measured memory_bytes: 256
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;

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

    // 貪欲で、(V-C)が正のものを全て選べば良さそう
    let mut ans = 0;
    for i in 0..N {
        let val = Vs[i] - Cs[i];
        if val > 0 {
            ans += val;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2140
program D_solution

implicit none
integer :: Q,l(10**5),r(10**5)
integer :: i,j
logical :: is_prime(10**5)
integer :: like_2017(0:50001)

read(*,*) Q
do i = 1, Q
  read(*,*) l(i),r(i)
enddo

is_prime(1) = .false.

do i = 2, 10**5
  is_prime(i) = .true.
  do j = 2, int((i)**0.5)
    if(mod(i,j) == 0) then
      is_prime(i) = .false.
    endif
  enddo
enddo

like_2017 = 0

do i = 1, 10**5, 2
    if(is_prime(i) .and. is_prime(int((i+1)/2))) then
      like_2017(int((i+1)/2):) = like_2017(int((i+1)/2):) + 1
    endif
enddo

do i=1,Q
    write(*,*) like_2017((r(i)+1)/2) - like_2017((l(i)-1)/2)
enddo
end program

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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll int n;
  cin >> n;
  ll int ans = (n / 11) * 2;
  ll int nokori = n - (n / 11) * 11;
  if(nokori > 0){
	if(nokori <= 6) ans++;
	else ans+=2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
s=input()
ans=0
d=len(s)-1
for i in range(2**d):
  c =bin(i)[2:].zfill(d).replace("0","#").replace("1","+")+"#"
  q="".join(["".join(a) for a in zip(s,c)]).replace("#","")
  ans+=eval(q)
print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int dp[5][200005];
int a[200005];
int cal(int i, int x){
    if(i == 0 or i == 4)return x;
    if(i == 1 or i == 3){
        if(x == 0)return 2;
        else return x % 2;
    }
    return (x + 1) % 2;
    
}
int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i + 1];
    }
    for(int i = 0; i < 5; i++){
        for(int j = 1; j <= n; j++){
            if(i)dp[i][j] = dp[i-1][j];
            else dp[i][j] = INT_MAX / 2;
            dp[i][j] = min(dp[i][j], dp[i][j - 1] + cal(i, a[j]));
        }
    }
    int ans = INT_MAX;
    for(int i = 0; i < 5; i++){
        ans = min(ans, dp[i][n]);
    }
    cout << ans << endl;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) xmax = x; return true;
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) xmin = x; return true;
    return false;
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;
ll mod_pow(ll x, ll n) {
    if (n == 0) return 1;
    if (n % 2 == 0) return mod_pow(x * x % MOD, n / 2) % MOD;
    else return x * mod_pow(x, (n - 1)) % MOD;
}
ll mod_pow_r(ll x, ll n) {
    if (x == 0) return 0;
    if (n == 0) return 1;
    ll ret = 1;
    while (n) if (n & 1) ret = ret * x % MOD; x = x * x % MOD; n /= 2;
    return ret;
}
ll factorial(ll n) {
    ll ret = 1;
    REP(i, n) ret *= (i + 1); ret %= MOD;
    return ret;
}
ll combination(ll n, ll r) {
    if (n < 0 || n < r || r < 0) return 0;
    ll fn = factorial(n);
    ll fr = factorial(r);
    ll fn_r = factorial(n-r);
    ll d = (mod_pow(fr, MOD - 2) * mod_pow(fn_r, MOD - 2)) % MOD;
    ll u = fn % MOD;
    return u * d % MOD;
}

void solve() {
    int n, m, c; cin >> n >> m >> c;
    vector<int> b(m); FOR(i, 0, m) cin >> b[i];
    vector<vector<int>> a(n);
    FOR(i, 0, n) {
        vector<int> tmp(m);
        FOR(j, 0, m) cin >> tmp[j];
        a[i] = move(tmp);
    }

    int ret = 0;
    FOR(i, 0, n) {
        ll ans = 0;
        FOR(j, 0, m) {
            ans += a[i][j] * b[j];
        }
        ans += c;
        if (ans > 0) ret++;
    }
    cout << ret;
}

signed main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        int h = stdin.nextInt();
        int w = stdin.nextInt();
        char[][] s = new char[h][w];
        for (int i = 0; i < h; i++) {
            s[i] = stdin.next().toCharArray();
        }
        
        int[] d = {-1, 0, 1};
        int[][] t = new int[h][w];
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (s[i][j] == '#') {
                    continue;
                }
                
                for (int dx : d) {
                    for (int dy : d) {
                        int x = i + dx;
                        int y = j + dy;
                        if (0 <= x && x < h && 0 <= y && y < w && s[x][y] == '#') {
                            t[i][j]++;
                        }
                    }
                }
            }
        }
        
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (s[i][j] == '#') {
                    System.out.print(s[i][j]);
                } else {
                    System.out.print(t[i][j]);
                }
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 22356
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var n = cin.ReadInt;
            var cityArr = new string[n];
            var pointArr = new int[n];


            int[] intArr = new int[2];
            var cityList = new List<CityPoint>();

            string[] line;
            for (int i = 0; i < n; i++)
            {
                line = cin.ReadLine.Split(' ');
                cityArr[i] = line[0];
                pointArr[i] = int.Parse(line[1]);

                cityList.Add(new CityPoint() { name = line[0], point = int.Parse(line[1]), index = i + 1 });
            }

            var resultList = cityList.OrderByDescending(c => c.name).ThenBy(c => c.point).Reverse();
            //for (var i = 0; i < n; i++){
            //    WriteLine(resultList[i].index);
            //}
            foreach( var city in resultList)
            {
                WriteLine(city.index);
            }
            //WriteLine(result);
        }

        class CityPoint
        {
            public string name = "";
            public int point = 0;
            public int index = 0;
        }

    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

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

int main(){
 string s;
  cin >>s;
  int x=0;
  if(s[0] == '1')x++;
  if(s[1] == '1')x++;
  if(s[2] == '1')x++;
  
  cout << x <<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

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

int bfs(int y, int x,
         int h, int w, vector<string> arr) {
    vector<vector<int>> dist(h, vector<int>(w, -1));
    queue<pair<int, int>> que;

    int res = 0;
    dist[y][x] = 0;
    que.push({y, x});
    while (!que.empty()) {
        auto cur = que.front();
        que.pop();
        res = max(res, dist[cur.first][cur.second]);

        rep(i, 4) {
            int ny = cur.first + dy[i];
            int nx = cur.second + dx[i];
            if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
            if (arr[ny][nx] == '#') continue;
            if (dist[ny][nx] != -1) continue;
            dist[ny][nx] = dist[cur.first][cur.second] + 1;
            que.push({ny, nx});
        }
    }
    return res;
}
int main() {
    int h, w; cin >> h >> w;
    vector<string> arr(h);
    rep(i, h) cin >> arr[i];


    int ans = 0;

    for (int y = 0; y < h; ++y) {
            for (int x = 0; x < w; ++x) {
            if (arr[y][x] == '#') continue;
            ans = max(ans, bfs(y, x, h, w, arr));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
int main() {
  int H, n;
  cin >> H >> n;
  vector<int> dp(H+1,INF);
  dp[0] = 0;
  while(n--){
    int value, cost;
    cin >> value >> cost;
    for(int i = 0; i <= H; ++i){
      int j = min(H,i + value);
      dp[j] = min(dp[j],dp[i] + cost);
    }
  }
   cout << dp[H] << endl;
}


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;
using P = pair<int, int>;

int main() {
  string s, t;
  cin >> s >> t;
  if (s.size() + 1 != t.size()) {
    cout << "No" << endl;
    return 0;
  }
  rep(i, s.size()) {
    if (s[i] != t[i]) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}

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

# define x first
# define y second
# define mp make_pair
// everything goes according to my plan
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") {
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}
int n;

int a[Sz];

int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  int n;
  cin >> n;
  for (int k = 1; k <= 2*n; k++) {
    if (k * (k - 1) / 2 == n) {
      cout << "Yes" << endl;
      vec < vec<int> > a(k + 1);
      int clr = 0;
      for (int i = 1; i <= k; i++)
        for (int j = i + 1; j <= k; j++)
          clr++, a[i].pb (clr), a[j].pb (clr);
      cout << k << endl;
      for (int i = 1; i <= k; i++) {
        cout << sz(a[i]) << ' ';
        for (auto x : a[i]) cout << x << ' ';
        cout << endl;
      }
      cout << endl;
      return 0;
    }
  }
  cout << "No";
  return 0;
}






// Coded by Z..


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
int a[4][4],f[4][4];
int main()
{
	for(int i=1;i<=3;i++)for(int j=1;j<=3;j++)cin>>a[i][j];
	int t;
	cin>>t;
	for(int i=1;i<=t;i++)
	{
		int x;
		cin>>x;
		for(int g=1;g<=3;g++)for(int j=1;j<=3;j++)if(a[g][j]==x)f[g][j]=1;
	}
	//for(int i=1;i<=3;i++)for(int j=1;j<=3;j++)cout<<f[i][j];
	if(f[1][1]==1&&f[1][2]==1&&f[1][3]==1)
	{
		cout<<"Yes";
		return 0;
	}
	if(f[1][1]==1&&f[2][2]==1&&f[3][3]==1)
	{
		cout<<"Yes";
		return 0;
	}
	if(f[3][1]==1&&f[2][2]==1&&f[1][3]==1)
	{
		cout<<"Yes";
		return 0;
	}
	if(f[2][1]==1&&f[2][2]==1&&f[2][3]==1)
	{
		cout<<"Yes";
		return 0;
	}
	if(f[3][1]==1&&f[3][2]==1&&f[3][3]==1)
	{
		cout<<"Yes";
		return 0;
	}
	if(f[1][1]==1&&f[2][1]==1&&f[3][1]==1)
	{
		cout<<"Yes";
		return 0;
	}
	if(f[1][2]==1&&f[2][2]==1&&f[3][2]==1)
	{
		cout<<"Yes";
		return 0;
	}
	if(f[1][3]==1&&f[2][3]==1&&f[3][3]==1)
	{
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

struct Task {
    size_t a;
    size_t b;
};

int main() {
    size_t n;
    std::cin >> n;

    std::vector<Task> task(n);
    for (auto&& ti : task) std::cin >> ti.a >> ti.b;

    std::sort(task.begin(), task.end(), [](const auto& ti, const auto& tj){
        return ti.b < tj.b;
    });

    
    const auto is_feasible = [&task]() {
        auto cum = task[0].a;
        if (cum > task[0].b) return false;
        for (size_t i = 1; i < task.size(); ++i) {
            cum += task[i].a;
            if (cum > task[i].b) return false;
        }
        return true;
    }();
    
    std::cout << (is_feasible ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;

int main()
{
	bool a[1000001];
	for(int i=1;i<=1000000;i++)a[i]=true;
	for(int i=2;i*i<=1000000;i++){
		for(int j=2;i*j<=1000000;j++){
			a[i*j]=false;
		}
	}
    int n;
	while(cin >> n){
		int ans=-1;
		for(int i=1;i<=n;i++){
			if(a[i])ans++;
		}
		printf("%d\n",ans);
	}
    return 0;
}

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

int main(){
    int a, b; cin >> a >> b;
    string sa, sb;
    for(int i=0; i<b; i++){
        sa += to_string(a);
    }
    for(int i=0; i<a; i++){
        sb += to_string(b);
    }
    if(sa<sb) cout << sa << endl;
    else cout << sb << endl;
}

Measured memory_bytes: 256
n,t=map(int,input().split())
c=[0]*n
T=[0]*n
count=1000000
ans=0
for i in range(n):
    c[i],T[i]=map(int,input().split())
if min(T)>t:
    print('TLE')
else:
    for j in range(n):
        if T[j]<=t:
            if c[j]<count:
                count=c[j]
                ans=c[j]
    print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){	if(c=='-') f=-1;c=getchar();}
	while(isdigit(c)) {x=(x<<1)+(x<<3)+(c^48);c=getchar();}
	return x*f;
}
inline void print(int x){
	if(x<0) x=-x,putchar('-');
	if(x>=10) print(x/10);
	putchar(x%10+48);
}
int n,m;
int fa[200010],siz[200010];
int find(int x){
	if(fa[x]==x) return x;
	return fa[x]=find(fa[x]);
}
void add(int x,int y){
	int fx=find(x);int fy=find(y);
	if(fx!=fy) fa[fx]=fy,siz[fy]+=siz[fx];
}
int main(){
	n=read(),m=read();
	for(int i=1;i<=n;++i) fa[i]=i,siz[i]=1;
	for(int i=1;i<=m;++i){
		int u=read(),v=read();
		add(u,v);
	}
	int ans=0;
	for(int i=1;i<=n;++i) ans=max(ans,siz[i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;

int main() {
  ll n,ans=0,a,b,tmp,ind=0;
  cin >> n;
  vector<ll>l(n);
  rep(i,n) cin >> l.at(i);
  sort(l.begin(),l.end());
  rep(i,n){
  	a=l.at(i);
  	for(int j=i+1;j<n;j++){
  		b=l.at(j);
  		tmp=a+b;
  		for(int k=j+1;k<n;k++){
  			if(tmp<=l.at(k)) break;
  			else if(a+l.at(k)>b) ans++;
  		}
  	}
  }
  cout << ans << endl; 
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>

using namespace std;

//static const int maxint = 2**32 -1;

int main(){
  int H, N;
  scanf("%d %d", &H, &N);

  int A[N], B[N];
  int maxA = -1;
  for(int i =0; i<N; i++){
    scanf("%d %d",&A[i], &B[i]);
    if(A[i]>maxA) maxA = A[i];
  }

  int DP[H+maxA];
  for(int i=0; i<H+maxA; i++)DP[i]=INT32_MAX;
  DP[0]=0;

  for(int i=0; i<N; i++){
    for(int j=0; j<A[i]; j++){
      DP[j] = min(DP[j],B[i]);
    }
    for(int j=A[i]; j<H+maxA; j++){
      DP[j] = min(DP[j], DP[j-A[i]]+B[i]);
    }
  }
  int minB = INT32_MAX;
  for(int i=H; i<H+maxA; i++){
    if(minB>DP[i])minB = DP[i];
    
  }
  cout << minB << endl;
  return 0;
}


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

int main() {
  string S,T;
  cin>>S>>T;
  int a=S.size(), b=T.size();
  vector<string> ans;
  for(int i=0;i<=a-b;i++){
    bool hantei=true;
    string SS=S;
    for(int j=0;j<b;j++){
      if(S.at(i+j)=='?'||S.at(i+j)==T.at(j));
      else hantei=false;
    }
    if(hantei==true){
      for(int k=i;k<i+b;k++){
        SS.at(k)=T.at(k-i);
      }
      for(int k=0;k<SS.size();k++){
        if(SS.at(k)=='?')SS.at(k)='a';
      }
      ans.push_back(SS);
    }
  }
  if(ans.size()==0)cout<<"UNRESTORABLE";
  else{
    sort(ans.begin(), ans.end());
    cout<<ans.at(0);
  } 
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N, K = map(int, input().split())
H = []
for _ in range(N):
    H.append(int(input()))
H.sort()

ans = INF
for i in range(N-K+1):
    ans = min(ans, H[i+K-1] - H[i])

print(ans)

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

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// Type / Class / Struct Definitions:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;

// Global Variables:

// Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    int n;
    cin >> n;

    switch(n % 10) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        case 3:
            cout << "bon" << endl;
            break;
    }
    return 0;
}
// ===========================================

// Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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;
}


Measured memory_bytes: 3636
s = gets.chomp.split("").map(&:to_s)
q = gets.to_i
queries = []
q.times do
  tmp = gets.chomp.split
  if tmp.first == 1
    queries << tmp.first
  else
    queries << [tmp[0].to_i, tmp[1].to_i, tmp[2]]
  end
end
reversed = false
queries.each do |a, b, c|
  if a == 1
    reversed = !reversed
  else
    if b == 1
      if reversed
        s.push(c)
      else
        s.unshift(c)
      end
    else
      if reversed
        s.unshift(c)
      else
        s.push(c)
      end
    end
  end
end
s.reverse! if reversed
puts s.join


Measured memory_bytes: 40940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace AtCoder.ABC056
{
    static class GoHome
    {
        static public void Main()
        {
            var x = int.Parse(ReadLine().Trim());
            var i = 0;
            for (var sum = 0; sum < x; sum += ++i) ;
            WriteLine(i);

        }
    }
}


Measured memory_bytes: 13140
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

using namespace std;
vector <int> memo;

int f(int n){
	memo[0]=1;
	memo[1]=2;
	memo[2]=4;
	
	for(int i = 3;i < 30 ; i++){
		memo[i] = memo[i-1]+memo[i-2]+memo[i-3];
	}
	if(n < 0){
		return 0;
	}
	if(n == 0){
		return 1;
	}
	return memo[n]/10/365+1;
}
int main(){
	int n;
	memo.resize(31,-1);
	while(cin >> n,n){
		n -= 1;
		int num = f(n);
		cout << num << endl;
	}
	return 0;
}

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

int main(){
 int a, b, c, m;
 cin >> a >> b >> c;
 if(a > b){
  m = b;
  b = a;
  a = m;
  }
 if(b > c){
  m = c;
  c = b;
  b = m;
  }
 if(a > b){
  m = b;
  b = a;
  a = m;
  }
 cout << a << " " << b << " " << c << endl;
 return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
const int ss=3e5+5;

// ll ar[84],dp[82][5005][51],n;

// ll f(int idx,int cur,int st)
// {
//     if(idx==n)
//         return cur;
//     ll &res = dp[idx][cur][st];
//     if(res!=-1)
//         return res;
//     res = f(idx+1,cur,st);
//     if(st)
//     {
//         for(int i=0;i<=st;i++)
//         {
//             res = max(res,f(idx+1,cur+i*ar[idx],st-i));
//         }
//     }
//     else
//     {
//         for(int i=0;i*ar[idx]<=cur;i++)
//         {
//             res = max(res,f(idx+1,cur-i*ar[idx],st+i));
//         }
//     }

//     return res;
// }


 
int main()
{

    int t=1;
    // cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll ar[n];
        for(int i=0;i<n;i++)
        {
            cin>>ar[i];
        }
        int i=0;
        ll cur=1000;
        while(i<n-1)
        {
            while(i<(n-1) and ar[i+1]<=ar[i])
            {
                i++;
            }
            if(i==n-1)
                break;
            ll buy=i;
            ll st=(cur/ar[buy]);
            cur-=(st*ar[buy]);
            i++;
            while(i<n and ar[i]>=ar[i-1])
            {
                i++;
            }
            ll sell=i-1;
            cur+=(st*ar[sell]);

        }

        cout<<max(cur,1000ll)<<endl;
        

    }

    return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(long long i=(l);i<(r);i++)
#define dec(i, l, r)   for(long long i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int c[3][3];
    inc(i, 0, 3){
        inc(j, 0, 3){
            cin >> c[i][j];
        }
    }
    string ans = "Yes";
    inc(i, 1, 3){
        if(c[i][0]-c[i-1][0] != c[i][1]-c[i-1][1]) ans = "No";
        if(c[i][1]-c[i-1][1] != c[i][2]-c[i-1][2]) ans = "No";
    }
    inc(j, 1, 3){
        if(c[0][j]-c[0][j-1] != c[1][j]-c[1][j-1]) ans = "No";
        if(c[1][j]-c[1][j-1] != c[2][j]-c[2][j-1]) ans = "No";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
using P = std::pair<int, int>;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int n,d[555][555],p[555*555],e[555][555];
std::queue<int> que;

bool check(int i, int j){
	return (0<=i && i<n && 0<=j && j<n);
}

int main(void){
	int m,i,j,k,v,x,y,ans=0,dx[4]={-1,0,0,1},dy[4]={0,-1,1,0};
	std::cin >> n;
	m = n*n;
	for(i=0; i<n; ++i){
		for(j=0; j<n; ++j){
			e[i][j] = 1;
			d[i][j] = std::min({i,n-i-1,j,n-j-1});
		}
	}
	for(i=0; i<m; ++i){
		std::cin >> p[i]; --p[i];
		x = p[i]/n; y = p[i]%n;
		ans += d[x][y];
		e[x][y] = 0;
		que.push(p[i]);
		while(!que.empty()){
			v = que.front();
			que.pop();
			x = v/n; y = v%n;
			for(k=0; k<4; ++k){
				if(!check(x+dx[k],y+dy[k])){
					continue;
				}
				if(d[x][y]+e[x][y]<d[x+dx[k]][y+dy[k]]){
					d[x+dx[k]][y+dy[k]] = d[x][y]+e[x][y];
					que.push((x+dx[k])*n+y+dy[k]);
				}
			}
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


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

int main(){
  int n;
  cin>>n;
  vector<int> price(n);
  for(int i=0;i<n;i++){
    cin>>price.at(i);
  }
  sort(price.begin(),price.end());
  int x=0;
  for(int i=0;i<n;i++){
    if(i==n-1){
      x+=price.at(i)/2;
    }
    else{
      x+=price.at(i);
    }
  }
  cout<<x<<endl;
}

Measured memory_bytes: 256
#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 INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

lli dp[500][500];

void func(long long N, long long M_a, long long M_b, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c){
    REP(i,0,500)REP(j,0,500)dp[i][j]=INF;

    dp[0][0]=0;
    REP(i,0,N){
        lli aa = a[i];
        lli bb = b[i];

        for(lli j=400;j>=0;j--){
            for(lli k=400;k>=0;k--){
                dp[j+aa][k+bb] = min(dp[j+aa][k+bb],dp[j][k]+c[i]);
            }            
        }
    }

    lli ans = INF;
    REP(i,1,500){
        lli aa = i*M_a;
        lli bb = i*M_b;
        if(aa>480 || bb>480)break;
        ans = min(ans,dp[aa][bb]);
    }
    if(ans == INF)cout<<-1<<endl;
    else cout<<ans<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long M_a;
    scanf("%lld",&M_a);
    long long M_b;
    scanf("%lld",&M_b);
    std::vector<long long> a(N);
    std::vector<long long> b(N);
    std::vector<long long> c(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        scanf("%lld",&c[i]);
    }
    func(N, M_a, M_b, std::move(a), std::move(b), std::move(c));
    return 0;
}


Measured memory_bytes: 2176
#include <stdio.h>
#include <string.h>

int a,sum,len;
char line[26],line1[26];

void b(int o,int sign){
    if(o > len-1 ||  line1[o] != line[sign])
        return;
    if(!line[sign+1]){
        sum++;
        return;
    }
    b(o+a,sign+1);
}
int main(void){
    int num,i,o,t,sum1,sign;
    scanf("%d\n%s",&num,line);
    for(i=0;sign=0,i<num;i++){
        scanf("%s",line1);
        len=strlen(line1);
        for(o=0;line1[o];o++){
            if(line[0] == line1[o]){
                for(t=o+1;line1[t];t++){
                    if(line[1] == line1[t]){
                        a=t-o;
                        sum1=sum;
                        b(t+a,2);
                        if(sum1 != sum){
                            sign=1;
                            break;
                        }
                    }
                }
            }
            if(sign)
                break;
        }
    }
    printf("%d\n",sum);
    return 0;
}

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

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,w;
    cin>>n>>w;
    
    vector<pair<int,int>> v(n+1);
    for(int i=1;i<=n;i++)
    {
        int a,b;
        cin>>a>>b;
        pair<int,int> temp=make_pair(a,b);
        v[i]=temp;
    }
    
    long long int dp[n+1][w+1];
    memset(dp,0,sizeof(dp));
    
    for(int i=1;i<=n;i++)
    {
        int wt=v[i].first;
        int val=v[i].second;
        
        for(int j=1;j<=w;j++)
        {
            if(wt<=j)
            {
                dp[i][j]=max(dp[i-1][j],val+dp[i-1][j-wt]);
            }
            else
            {
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    
    cout<<dp[n][w]<<endl;
    
    return 0;
}

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

const bool DEBUG = false;

int main(int argc, char const *argv[]) {
  int a;
  cin >> a;
  string s;
  cin >> s;
  if (a >= 3200)
    cout << s << endl;
  else
    cout << "red" << 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;

typedef long long ll;

int main() {
    string S;
    cin >> S;
    int ans = 0;
    rep(i, S.size() - 1) {
        if (S[i] != S[i + 1]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
 
constexpr int INF = 1e9;
constexpr int MOD = 1e9+7;

int main() {
    int x;
    cin >> x;
    cout << (x >= 30 ? "Yes" : "No") << endl;
 
	return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B, C;
  cin >> A >> B >> C;
  if((A+B)>=(C-1)) cout << B+C << endl;
  else cout << B*2+A+1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define INF 200001 
using namespace std;
  
int main(){
 int u,k,C,V,A[1000][1000],D[1000][1000],n;
  scanf("%d",&n);
   for(int i=0;i<n;i++)for(int j=0;j<n;j++)D[i][j] = INF;
  for(int i=0;i<n;i++){
      scanf("%d %d",&u,&k);    
      for(int j=0;j<k;j++){
    scanf("%d %d",&V,&C);
    D[u][V] = C;
      }    
  }
  for(int i=0;i<n;i++)D[i][i] = 0;
  for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++)D[i][j]= min(D[i][j],D[i][k] + D[k][j]);
  for(int i=0;i<n;i++)printf("%d %d\n",i,D[0][i]);
  return 0;
}

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

#define ll long long int
#define INFTY (1<<21)

using namespace std;

int main(void){
    cin.sync_with_stdio(false);
    int n,a,b;
    cin>>n>>a>>b;
    int ans = a+b-n;
    cout<<min(a,b)<<" "<<(ans<0?0:ans)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;

int main()
{
	FAST;

	int n;
	cin >> n;

	cout << (n / 500 * 1000) + ((n % 500) / 5) * 5;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    cin >> N ;

    int count=100000000;
    
    for (int i=0; i<N; i++) {
        int A;
        cin >> A;
        int sisuu=0;
        while (A%2==0) {
            A/=2;
            sisuu++;
        }
        if (count>sisuu) count=sisuu;
    }
    if (count==100000000)cout <<0<<endl;
    else cout <<count <<endl;
}

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;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

const int mod = 1000000007;
struct mint
{
    ll x;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }
    mint inv() const
    {
        return pow(mod - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const
    {
        mint res(*this);
        return res /= a;
    }
};
int n,k;
int solve(){
    mint ans=0;
    for(int i=k;i<=n+1;i++){
        mint l= mint(i)*(i-1)/2;
        mint r=mint(i)*(2*n+1-i)/2;
        ans+=r-l+1;
    }
   return ans.x;
}
int main()
{
    cin>>n>>k;
    cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 3636
X,Y,Z,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
C=C[:K]

from itertools import product
D=sorted([a+b for a,b in product(A,B)],reverse=True)
D=D[:K]
E=sorted([d+c for d,c in product(D,C)],reverse=True)
E=E[:K]
for i in range(K):
    print(E[i])


Measured memory_bytes: 186080
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(a) cout << (a) << endl;
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

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


Measured memory_bytes: 256