akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <utility>
#include <cctype>
#include <vector>
#include <algorithm>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;for(char c;c=gcu(),c!=' '&&c!='\n'&&c!=EOF;)s+=c;return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

int main() {
	for (int n, m; n = in, m = in, n || m;) {
		vector<int> tl(n), tr(m), tm;
		for (int &i: tl)
			i = in;
		for (int &i: tr)
			i = in;
		merge(begin(tl), end(tl), begin(tr), end(tr), back_inserter(tm));
		int r {}, b {};
		for (int i: tm)
			r = max(r, i - exchange(b, i));
		outl(r);
	}
}


Measured memory_bytes: 2752
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from itertools import combinations # (string,3) 3回
#from collections import deque
#import collections.defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    r = int(input())
    import math
    pi_ = math.pi
    print(2*pi_*r)
if __name__ == '__main__':
  main()


Measured memory_bytes: 9168
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int n;
	cin >> n;
	int max=0;
	int max_num = 1;
	int count = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 2 == 0) {
			int a = i;
			while (a % 2 == 0) {
				count++;
				a=a / 2;
			}
			if (count > max) {
				max = count;
				max_num = i;
			}
		}
		count = 0;
	}
	cout << max_num;
}

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

fn main() {
    let n:i32 = read();
    if n > 999 {
        println!("{}", "ABD");
    } else {
        println!("{}", "ABC");
    }
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;
int main() {
  int n;
  int k;
  cin >> n >> k;

  int itr = 0;
  while(true) {
    itr++;
    if (n <= k) {
      break;
    } else {
      n -= k-1;
    }
  }
  cout << itr << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

double dist(double x1,double y1,double x2,double y2){
    return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}

signed main(){
    int n;
    cin >> n;
    vector<double> x(n), y(n);
    rep(i, 0, n){
        cin >> x[i] >> y[i];
    }
    double ans = 0.0;
    vector<int> p(n);
    rep(i, 0, n) p[i] = i;
    sort(p.begin(), p.end());
    int cnt = 0;
    do{
        double sum = 0.0;
        for(int i = 0; i < p.size() - 1; i++){
            sum += dist(x[p[i]], y[p[i]], x[p[i + 1]], y[p[i + 1]]);
        }
        ans += sum;
        cnt++;
    }while(next_permutation(p.begin(), p.end()));
    printf("%.10f\n", ans / (double)cnt);
}

Measured memory_bytes: 256
N = int(input())
s = [input() for _ in range(N)]
c0, c1, c2, c3 = s.count('AC'), s.count('WA'), s.count('TLE'), s.count('RE')
print('AC x', c0)
print('WA x', c1)
print('TLE x', c2)
print('RE x', c3)

Measured memory_bytes: 79168
#include <stdio.h>

#define INF (int)2e9

int min(int a, int b)
{
    if (a <= b) return a;
    else        return b;
}

void matChainMul(int n, const int*p, int M[][110])
{
    int j;
    for (int i = 1; i <= n; ++i) {
        M[i][i] = 0;
    }

    for (int m = 2; m <= n ; ++m) {
        for (int i = 1; i <= n - m + 1; ++i) {
            j = i + m - 1;
            M[i][j] = INF;
            for (int k = i; k <= j - 1; ++k) {
                M[i][j] = min(M[i][j], M[i][k] + M[k+1][j] + p[i-1] * p[k] * p[j]);
            }
        }
    }

}

int main() {
    int p[110],M[110][110];
    int n;

    scanf("%d", &n);

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

    matChainMul(n, p, M);
    printf("%d\n", M[1][n]);
    return 0;
}


Measured memory_bytes: 1988
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int m = n / 2;

    int b = 1;
    for (int i = 0; i < n; i++) {
        if (s[i] != s[n - 1 - i]) b = 0;
    }
    for (int i = 0; i < m; i++) {
        if (s[i] != s[m - 1 - i]) b = 0;
    }
    for (int i = 0; i < m; i++) {
        if (s[i + m + 1] != s[m - 1 - i + m + 1]) b = 0;
    }

    cout << (b ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import deque
H,W=map(int,input().split())
grid = [input() for i in range(H)]

dist = [[-1]*W for _ in range(H)]
black_cells = deque()
#黒マスの位置をblack_cellsに保持
#distの黒マスの部分に0でフラッグ
for h in range(H):
  for w in range(W):
    if grid[h][w]=="#":
      black_cells.append((h,w))
      dist[h][w] = 0
def bfs(black_cells, dist):
  count=0
  while black_cells:
    h,w = black_cells.popleft()
    count = dist[h][w]
    for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
        new_h = h + dy
        new_w = w + dx
        if new_h < 0 or H <= new_h or new_w < 0 or W <= new_w:
          continue
        if dist[new_h][new_w] == -1:
          dist[new_h][new_w] = count+1
          black_cells.append((new_h,new_w))
  return count
print(bfs(black_cells,dist))

Measured memory_bytes: 115936
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    int c = 0;
    for (int i = 0; i < n - 1; i++) {
        c += v[i];
    }
    if (c > v.back())
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

int INF = 1e9+7;

pair<int, int> find_idx(vector<int>& cnt_vect){
  // (idx, cnt)
  int tmp_max = 0;
  int tmp_idx = -1;
  rep(i, cnt_vect.size()){
    if(tmp_max < cnt_vect[i]){
      tmp_max = cnt_vect[i];
      tmp_idx = i;
    }
  }
  if(tmp_idx != -1){
    cnt_vect[tmp_idx] = 0;
    return make_pair(tmp_idx, tmp_max);
  }else{
    return make_pair(-1, -1);
  }
}

int main(){

  int n;
  cin >> n;

  vector<int> cnt_even(1e5+1, 0);
  vector<int> cnt_odd(1e5+1, 0);

  rep(i, n){
    int v;
    cin >> v;
    v--;
    if(i%2 == 0) cnt_even[v]++;
    if(i%2 != 0) cnt_odd[v]++;
  }

  pair<int, int> even_first = find_idx(cnt_even);
  pair<int, int> even_second = find_idx(cnt_even);
  pair<int, int> odd_first = find_idx(cnt_odd);
  pair<int, int> odd_second = find_idx(cnt_odd);

  if(even_first.first <= odd_first.first){
    swap(even_first, odd_first);
    swap(even_second, odd_second);
  }

  int n_e1 = even_first.first;
  int n_e2 = even_second.first;
  int n_o1 = odd_first.first;
  int n_o2 = odd_second.first;

  int v_e1 = even_first.second;
  int v_e2 = even_second.second;
  int v_o1 = odd_first.second;
  int v_o2 = odd_second.second;

  if(n_e1 == n_o1){
    if(v_e2==-1 && v_o2==-1){
      cout << n/2 << endl; 
    }else{
      cout << n - (v_e1 + max(v_e2, v_o2)) << endl;
    }
  }else{
    cout << n - (v_e1 + v_o1) << endl;
  }

  return 0;
}

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

using namespace std;

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

	vector<int> D;
	for (int i = 0; i < N; i++) {
		int d;
		cin >> d;
		D.push_back(d);
	}

	sort(D.begin(), D.end());

	cout << D[D.size() / 2] - D[D.size() / 2 - 1] << endl;


}




Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0, 0, -1};
const vector<int> dy = {0, 1, -1, 0};

// 約数全列挙
set<ll> enum_div(ll n){
  set<ll> ret;
  for (ll i=1; i*i<=n; i++){
    if (n%i==0){
      ret.insert(i);
      if (i!=1&&i*i!=n) ret.insert(n/i);
    }
  }
  return ret;
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i=0; i<N; i++) cin >> A[i];
  map<int, int> dict; // 登場する数字と登場回数
  for (int i=0; i<N; i++) {
    if (dict.count(A[i])) dict[A[i]]++;
    else dict[A[i]] = 1;
  }
  for (auto p: dict) {
    auto key = p.first;
    auto value = p.second;
    if (value!=1) dict[key] = 0;
  }
  for (auto p: dict) {
    auto key = p.first;
    auto value = p.second;
    if (value==0) continue;
    set<ll> s = enum_div(key);
    for (auto value2: s) {
      if (dict.count(value2)&&key!=1) dict[key] = 0;
    }
  }
  int res = 0;
  for (auto p: dict) {
    auto value = p.second;
    res += value;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 13552
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	long long ans = 0;
	for(int i = 0; i < n; i++){
		ans += a[i] / 2;
		a[i] %= 2;
		if(a[i] && i + 1 < n && a[i + 1]){
			ans++;
			a[i]--;
			a[i + 1]--;
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int N, A, B;

struct TGrader{

  string s;

  TGrader() {}
  void set(string t) {
    s = t;
  }

  bool ask(int x, int y) {
    if(s[x] == '1') return (s[y] == '1');
    return rand() % 2;
  }

  void guess(string t) {
    if(s == t) cout << "Correct!!!";
    else cout << "Wrong answer" << endl;
  }
}Grader;

bool ask(int x, int y) {
    cout << "? " << x << " " << y << endl;
    string w; cin >> w;
    return (w == "Y");
}

void answer(string t) {
    cout << "! " << t << endl;
}

void input() {
    cin >> A >> B; N = A + B;
}

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

  if(B >= A) {
    cout << "Impossible" << endl;
    return 0;
  }

  deque<int> vec;

  for(int i = 0; i < N; ++i) {
    if(vec.empty()) {
      vec.push_back(i);
      continue;
    }

    int x = ask(vec.back(), i);
    if(x == 1) {
      vec.push_back(i);
      continue;
    }
    else {
      vec.pop_back();
    }
  }


  string ans;
  for(int i = 0; i < N; ++i) {
    ans += char('0' + ask(vec.back(), i));
  }

  answer(ans);
  return 0;
}


Measured memory_bytes: 724
S = input()
N = len(S)
m = 10**9 + 7

dp = [[0]*(N+1) for _ in range(13)]
dp[0][0] = 1

for i in range(N):
    p = pow(10,i,13)
    for j in range(13):
        digit = S[N-1-i]
        if digit == '?':
            for k in range(10):
                d = (j+k*p%13)%13
                dp[d][i+1] += dp[j][i]
                dp[d][i+1] %= m

        else:
            k = int(digit)
            d = (j+k*p%13)%13
            dp[d][i+1] += dp[j][i]
            dp[d][i+1] %= m
print(dp[5][N])

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

int main(){
  string s;
  cin >> s;
  map<int,int> m;
  for(int i=0;i<s.size();i++){
    if(m.count(s.at(i))){
      m.at(s.at(i))++;
    }else{
      m[s.at(i)]=1;
    }
  }
  if(m.size()!=2){
    cout << "No" << endl;
  }else{
    for(auto p:m){
      if(p.second!=2){
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long

ll n,m,k;
ll a[212345],b[212345];

int main(){
  scanf("%lld%lld%lld",&n,&m,&k);

  a[0]=0;
  b[0]=0;
  for(ll i=1;i<=n;i++){
    scanf("%lld",&a[i]);
    a[i] = a[i]+a[i-1];}
  for(ll i=1;i<=m;i++){
    scanf("%lld",&b[i]);
    b[i] = b[i]+b[i-1];}
  
  ll ans=0;
  ll indb=m;
  for(ll i=0;i<=n;i++){
    if(a[i]>k) break;
    while(a[i]+b[indb]>k && indb>0){
      indb--;}
    if(i+indb>ans) ans=i+indb;
  }

  printf("%lld\n",ans);
  
  return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

string K;
int D;
int dp[10010][2][110];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> K >> D;
  int n = SZ(K);
  dp[0][0][0] = 1;
  REP(i, n) REP(j, 2) REP(k, D) if (dp[i][j][k]) {
    int lim = j ? 9 : K[i]-'0';
    for (int d = 0; d <= lim; d++) {
      (dp[i+1][j | (d < lim)][(k+d)%D] += dp[i][j][k]) %= MOD;
    }
  }
  cout << (dp[n][0][0] + dp[n][1][0] + MOD - 1) % MOD << endl;

  return 0;
}

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

using ll = long long;

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

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

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

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

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

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

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

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

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

  ll x; std::cin >> x;
  ll ans = x / 11 * 2;
  if (x % 11 > 6) ans += 2;
  else if (x % 11) ans++;
  std::cout << ans << "\n";
}


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

namespace A
{
    public class Node
    {
        public int left;
        public int right;
        public int value;
        public Tree tree;
    }

    public class Tree
    {
        List<Node> nodes;

        public Tree()
        {
            nodes = new List<Node>();
        }

        public void Insert(int x)
        {
            if (nodes.Count == 0) Insert(x, -1);
            else Insert(x, 0);
        }

        private void Insert(int x, int parent)
        {
            if (parent == -1) nodes.Add(NewNode(x));
            else
            {
                if (nodes[parent].value > x)
                {
                    if (nodes[parent].left == -1)
                    {
                        nodes.Add(NewNode(x));
                        nodes[parent].left = nodes.Count - 1;
                    }
                    else Insert(x, nodes[parent].left);
                }
                else
                {
                    if (nodes[parent].right == -1)
                    {
                        nodes.Add(NewNode(x));
                        nodes[parent].right = nodes.Count - 1;
                    }
                    else Insert(x, nodes[parent].right);
                }
            }
        }

        public void Preorder(int node)
        {
            Console.Write(" " + nodes[node].value);
            if (nodes[node].left != -1) Preorder(nodes[node].left);
            if (nodes[node].right != -1) Preorder(nodes[node].right);
        }
        public void Inorder(int node)
        {
            if (nodes[node].left != -1) Inorder(nodes[node].left);
            Console.Write(" " + nodes[node].value);
            if (nodes[node].right != -1) Inorder(nodes[node].right);
        }

        private Node NewNode(int value)
        {
            return new Node() { value = value, left = -1, right = -1, tree = this };
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var tree = new Tree();
            for (int i = 0; i < n; i++)
            {
                var strs = Console.ReadLine().Split(' ');
                if (strs[0][0] == 'i') tree.Insert(int.Parse(strs[1]));
                else
                {
                    tree.Inorder(0); Console.WriteLine();
                    tree.Preorder(0); Console.WriteLine();
                }
            }
        }
    }
}

Measured memory_bytes: 46100
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#include<map>
#include <limits>
# include <iomanip>
#include<queue>
#include<stack>
#define INF 1000000009;
#define inl long long
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
int kaizyo(int a) {
	long long ans = 1;
	for (int i = a; i > 0; i--) {
		ans *= i;
		ans = ans % 1000000007;
		//cout << ans << endl;
	}
	ans = ans % 1000000007;
	return ans;
}

int main() {
	int N = 0;
	vector<double>manji;
	stack<double>manjj;
	cin >> N;
	for (int i = 0; i < N; i++) {
		double a;
		cin >> a;
		manji.push_back(a);
	}
	sort(manji.begin(), manji.end(),greater<int>());
	for (int i = 0; i < N ; i++) {
		manjj.push(manji[i]);
	}
	for (int i = 0; i < N - 1; i++) {
		double b, c;
		b = manjj.top();
		manjj.pop();
		c = manjj.top();
		manjj.pop();
		manjj.push((b + c) / 2);
	}
	cout << manjj.top() << endl;
	return 0;
}





Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main( void ) 
{
	char W[11];//,T[1001];
	char T[1001];
	int count;
	int i;
	
	scanf( "%s", W );
	for( i=0; '\0'!=W[i];  i++ ) {
		W[i]=tolower( W[i]);
	}
	
	count=0;
	while( EOF != scanf( "%s", T ) ) {
		if( 0 == strcmp( "END_OF_TEXT", T ) ) { break; }
	
		for( i=0; '\0'!=T[i]; i++ ) {
			T[i]=tolower( T[i]);
		}
		
		if(  0 == strcmp( W, T ) ) {
			count++;
		}
	}

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

	return 0;
}

Measured memory_bytes: 552
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>
#include <set>
#include <iomanip>

using namespace std;

typedef long long ll;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N, W; cin >> N >> W;
  int v[N+1], w[N+1];
  for(int i=1;i<=N;i++){
    cin >> v[i] >> w[i];
  }
  int dp[N+1][W+1];
  for(int i=0;i<=N;i++) dp[i][0] = 0;
  for(int i=0;i<=W;i++) dp[0][i] = 0;
  for(int i=0;i<N;i++){
    for(int j=0;j<=W;j++){
      if(w[i+1] > W || (j-w[i+1]) < 0) dp[i+1][j] = dp[i][j];
      else dp[i+1][j] = max(dp[i][j], dp[i+1][j-w[i+1]]+v[i+1]);
    }
  }
  cout << dp[N][W] << endl;
}


Measured memory_bytes: 7120
// 物极必反

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e7 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9;
const double PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug(){
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

int main(){
    // freopen(".in", "r", stdin);
    // freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    string s; cin >> s;
    
    for(long long i = 0; i < 3; i++) cout << s[i];

    return 0;
}


Measured memory_bytes: 3648
# coding: utf-8
# Your code here!

n,m=map(int,input().split())

items=[]
for i in range(m):
    p,y=map(int,input().split())
    items.append((p,y,i))
items.sort()

now=0
p1=items[0][0]
ans=[]
for p,y,ind in items:
    
    if p==p1:
        now+=1
        tmp=str(p*10**6+now)
        tmp=(12-len(tmp))*"0"+tmp
        
        ans.append((ind,tmp))
    else:
        now=1
        p1=p
        tmp=str(p*10**6+now)
        tmp=(12-len(tmp))*"0"+tmp
        ans.append((ind,tmp))
ans.sort()
for _ , j in ans:
    print(j)

Measured memory_bytes: 39304
#include<iostream>
#include<string>

using namespace std;

int main(){
  string N;
  
  cin >> N;
  
  if(N[0] >= N[1] && N[0] >= N[2]) cout << N[0] << N[0] << N[0];
  else for(int i = 0;i < 3;i++) cout << (char)(N[0] + 1);
  cout << endl;
  
  return 0;
}

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

ll f(ll n) {
    return n * (n + 1) / 2;
}

int main() {
    ll N, K;
    cin >> N >> K;
    ll mod = pow(10, 9) + 7;
    ll sum = 0;
    for (ll i = K; i <= N + 1; i++) {
        sum += f(N + 1) - f(N + 1 - i) - f(i) + 1;
        sum %= mod;
    }
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define     PI                       acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void GO(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const int N=200000+9,mod=1e9+7;
multiset<ll> S1,S2,S3,S4;
ll a[N],b[N];
int main(){
    GO();

    int T;
  //  cin>>T;
    T=1;
    while(T--){
        int n;
        cin>>n;
        S1.clear();
        S2.clear();
        S3.clear();
        S4.clear();
        for(int i=0;i<n;i++){

            cin>>a[i]>>b[i];
            S1.insert(a[i]+b[i]);
            S2.insert(-a[i]-b[i]);
            S3.insert(-a[i]+b[i]);
            S4.insert(a[i]-b[i]);
        }
        ll ans=0;
        for(int i=0;i<n;i++){
            S1.erase(S1.find(a[i]+b[i]));
            S2.erase(S2.find(-a[i]-b[i]));
            S3.erase(S3.find(-a[i]+b[i]));
            S4.erase(S4.find(a[i]-b[i]));




            ll r1= a[i]+b[i]+(*prev(S2.end()));
            ll r2= -a[i]-b[i]+(*prev(S1.end()));
            ll r3= -a[i]+b[i]+(*prev(S4.end()));
            ll r4= a[i]-b[i]+(*prev(S3.end()));

            ans=max(ans,max(r1,max(r2,max(r3,r4))));

            S1.insert(a[i]+b[i]);
            S2.insert(-a[i]-b[i]);
            S3.insert(-a[i]+b[i]);
            S4.insert(a[i]-b[i]);
        }
        cout<<ans<<"\n";
    }

}





















































































































































































Measured memory_bytes: 44220
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a=0, b = 0,c,d, n, k;
string s, t;


int main()
{
	cin >> n; vector<int> a(n),b(n);
	rep(i, n)
	{
		cin >> a.at(i); b.at(i) = a.at(i);
	}

	sort(all(a)); int cnt = 0;
	rep(i, n)
	{
		if (a.at(i) != b.at(i))
			cnt++;
	}
	if (cnt <= 2)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define REP(i, n) for(int i=0; i<n; i++)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 999999999

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

int aaa(int n) {
	if (n % 2 == 1)return 1;
	if (n % 2 == 0 && n % 4 != 0)return 2;
	if (n % 4 == 0)return 4;
}

int main() {
	int n, k1 = 0, k2 = 0, k4 = 0;
	bool ans;
	cin >> n;
	VI a(n);
	REP(i, n)cin >> a[i];
	
	REP(i, n) {
		if (aaa(a[i]) == 1)k1++;
		if (aaa(a[i]) == 2)k2++;
		if (aaa(a[i]) == 4)k4++;
	}
	if (k2 == 0) {
		if (k1 <= k4 + 1)ans = true;
		else ans = false;
	}
	else {
		if (k1 <= k4)ans = true;
		else ans = false;
	}

	if (ans)puts("Yes");
	else puts("No");
}

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

using namespace std;
typedef long long ll;
const int N=110000;
struct vacation{
	ll a,b,c;
}play[N];
struct dp{
	ll a,b,c;
}dp[N];
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n,i,maxis;
	cin>>n;
	for(i=0;i<n;++i) cin>>play[i].a>>play[i].b>>play[i].c;
	dp[0].a=play[0].a;dp[0].b=play[0].b;dp[0].c=play[0].c;
	for(i=1;i<n;++i){
		dp[i].a=play[i].a+max(dp[i-1].b,dp[i-1].c);
		dp[i].b=play[i].b+max(dp[i-1].a,dp[i-1].c);
		dp[i].c=play[i].c+max(dp[i-1].a,dp[i-1].b);
	}maxis=max(dp[n-1].a,max(dp[i-1].b,dp[i-1].c));
	cout<<maxis;
}

Measured memory_bytes: 5248
def inpl(): return list(map(int, input().split()))

class UnionFind():
    def __init__(self, N):
        self.par = [-1]*(N)
        self.size = [1]*(N)

    def find(self, x):
        if self.par[x] == -1:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        px = self.find(x)
        py = self.find(y)
        if px != py:
            if self.size[px] < self.size[py]:
                px, py = py, px
            self.size[px] += self.size[py]
            self.par[py] = px

H, W = inpl()
S = [[-1]*W for _ in range(H)]
for h in range(H):
    s = input()
    for w in range(W):
        S[h][w] = int(s[w] == "#")

UF = UnionFind(H*W)

for h in range(H):
    for w in range(W-1):
        if S[h][w] != S[h][w+1]:
            UF.unite(h*W+w, h*W+w+1)
for h in range(H-1):
    for w in range(W):
        if S[h][w] != S[h+1][w]:
            UF.unite(h*W+w, h*W+w+W)

ans = 0
for i in range(H*W):
    if UF.par[i] == -1:
        s = UF.size[i]
        ans += s*(s-1)//2

BC = [0]*(H*W)
WC = [0]*(H*W)

for h in range(H):
    for w in range(W):
        if S[h][w] == 1:
            BC[UF.find(h*W+w)] += 1
        else:
            WC[UF.find(h*W+w)] += 1
print(sum([BC[i]*WC[i] for i in range(H*W)]))

Measured memory_bytes: 76012
package main
  
import (
    "fmt"
)

func main() {
    var n, k int
    fmt.Scan(&n, &k)
    var bs []byte
    fmt.Scan(&bs)
    for i := range bs {
        if i == k-1 {
            switch bs[i] {
            case 'A':
                fmt.Print("a")
            case 'B':
                fmt.Print("b")
            case 'C':
                fmt.Print("c")
            }
        } else {
            fmt.Print(string([]byte{bs[i]}))
        }
    }
    fmt.Print("\n")
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
//#include <cassert>
//#include <array>
#include <queue>
//#include <stack>
//#include <vector>
//#include <map>
//#include <set>
//#include <unordered_map>
//#include <unordered_set>

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i, n) for (int i = 1; i <= (int)(n); i++)

using namespace std;

int N, M, X,Y;
int x, y;

void solve() {
	bool ans;
	cin >> N >> M >> X >> Y;
	int INF = 1000;
	int xmax = X;
	REP(i, N) {
		cin >> x;
		xmax = max(xmax, x);
	}
	int ymin = Y;
	REP(i, M) {
		cin >> y;
		ymin = min(ymin, y);
	}

	ans = false;
	if (X < Y && xmax < ymin) {
		ans = true;
	}

	if (!ans) {
		cout << "War" << endl;
	}
	else {
		cout << "No War" << endl;
	}
	return;
}

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



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef int status;
typedef long long LL;
const int INF = int(1e9);
const int MAX = 400002;

int N;
int a[MAX];

int main()
{
    cin>>N;
    for(int i = 1;i<=N;i++)
        cin>>a[i];
    sort(a+1,a+1+N);

    for(int i = 1;i<=N;i++)
    {
        if(i%2==0)
        {
            a[i] = 24 - a[i];
        }
    }
    sort(a+1,a+1+N);

    int maxn = 25;
    for(int i = 1;i<=N;i++)
    {
        maxn = min(maxn,a[i] - a[i-1]);
    }

    cout<<maxn<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int[][] map  = new int[8][8];
			int[] p = new int[8];
			int[] a = new int[8];
			int[] b = new int[8];
			
			for(int i=0;i<8;i++){
				for(int j=0;j<8;j++){
					if((i<4 && j%2==0) || (i>3 && j%2==1)){
						map[i][j] = 1;
					}else{
						map[i][j] = 2;
					}
				}
			}
			
			map[0][5] = 4; map[4][4] = 4;
			map[0][7] = 4; map[4][6] = 4;
			map[1][3] = 4; map[5][2] = 4;
			map[1][5] = 4; map[5][4] = 4;
			map[2][1] = 4; map[6][0] = 4;
			map[2][7] = 4; map[6][6] = 4;
			map[3][1] = 4; map[7][0] = 4;
			map[3][3] = 4; map[7][2] = 4;
			
	
			for(int i=0;i<8;i++){
				p[i] = sc.nextInt();
			}
			
			int sub = 0;
			for(int i=0;i<8;i++){
				for(int j=0;j<8;j++){
					sub = map[i][j] - p[j];
					if(sub<0)a[i]-=sub;
				}
			}
			
			b = Arrays.copyOf(a, 8);
			Arrays.sort(a);
			
			for(int i=0;i<8;i++){
				if(b[i]==a[0]){
					for(int j=0;j<8;j++){
						if(j!=0)System.out.print(" ");
						System.out.print(map[i][j]);
					}
					break;
				}
			}
			System.out.println();
			
		}
	}	
}

Measured memory_bytes: 21088
//
//  CPlibrary
//
//  Created by Tanmay Singh on 3/03/2020.
// INDIAN INSTITUTE OF TECHNOLOGY (BHU) , VARANASI
//  Copyright Â© 2020 Tanmay Singh. All rights reserved.
//#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
 
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <climits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
 
#define FAST(); ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define mod 1000000007
 
typedef std::vector< int > vi;
typedef std::vector< long long int > vll;
typedef std::vector< vi > vvi;
typedef long long int bigint ;
using namespace std;
 

typedef long long ll;

int main(){
    int A , B , C , X ; cin >> A >> B >> C >> X ;
    long long int cnt = 0 ;
    for( int i = 0 ; i <= A ; i++ ){
        for( int j = 0 ; j <= B ; j++ ){
            for( int k = 0 ; k <= C ; k++ ){
                if( i * 500 + j * 100 + 50 * k == X )
                    cnt++ ;
            }
        }
    }
    cout << cnt << endl ;
    return 0 ;
}


Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100005
#define NIL -1
 
typedef struct{
  int parent,left,right;
 }Node;
 
Node T[MAX];
 int n, D[MAX];
 int getDepth(int);
void print(int);

  int child[MAX];
  int main(void){
  int i, j;
  int degree,vertex;
 
  scanf("%d", &n);
 
  for (i = 0;i < n;i++ ) {
    T[i].parent = NIL;
    T[i].left = NIL;
    T[i].right = NIL;
  }
 
  for (i = 0;i < n;i++ ){
    scanf("%d %d", &vertex, &degree);
    for (j = 0;j < degree;j++ ){
      scanf("%d", &child[j]);
      T[child[j]].parent = vertex;
     if(j == 0) T[vertex].left = child[0];
      else
    T[child[j - 1]].right = child[j];
    }
  }
   
  for ( i = 0; i < n; i++ )
    D[i] = getDepth(i);
   
  for ( i = 0; i < n; i++ )
    print(i);
   
  return 0;
}

  int getDepth(int u){
  int d = 0;
 
  while(T[u].parent >= 0){
    u = T[u].parent;
    d++;
  }
   return d;
}
 
void print(int u){
 
  int i, cnt = 0;
 
  printf("node %d: parent = %d, depth = %d, ",u,T[u].parent,D[u]);
 
  if(T[u].parent == NIL)
    printf("root, [");
 
  else if(T[u].left == NIL)
    printf("leaf, [");
 
  else
    printf("internal node, [");
 
  u = T[u].left;
  while(u != NIL){
    if(cnt == 0)
      printf("%d",u); 
 
    else
      printf(", %d",u);
   
    u = T[u].right;
    cnt++;
 }
     printf("]\n");
 
}

Measured memory_bytes: 2564
ls=list(input())
ans=0
for i in range(len(ls)):
    if i==0:
        ans+=1
    elif 1<=i<=len(ls)-2:
        if ls[i]=='':
            pass
        else:
            if ls[i]==ls[i-1]:
                ans+=1
                ls[i+1]=''
            else:
                ans+=1
    else:
        if ls[i]=='':
            pass
        else:
            if ls[i]==ls[i-1]:
                pass
            else:
                ans+=1
print(ans)            
    

Measured memory_bytes: 4840
/*
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
*/
#include <bits/stdc++.h>

#define rep(i,n)  for(int i=0; i<(n); i++)
using ll = long long;
using namespace std;

int main()
{
    string s;
    cin >> s;
    bool a = true;
    int n = s.length();
    rep(i,n/2){
        if(s[i] != s[(n/2)-1-i]){
            a = false;
        }
        if(s[(n/2)+1+i] != s[n-i-1]){
            a = false;
        }
        if(s[i] != s[n-1-i]){
            a = false;
        }
    }
    if(a){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pb push_back
#define N 1000003
#define inf (ll)1e9+11
#define warmup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int mod=1e9+7; 
int spf[N],a[N];
int cnt[N];
unordered_map<int,int> mp;
ll ans;

void getspf()
{
    int i,j;
    for(i=2;i<N;i+=2)
        spf[i]=2;
    for(i=1;i<N;i+=2)
        spf[i]=i;
    
    for(i=3;i*i<N;i+=2)
        if(spf[i]==i)
            for(j=i*i;j<N;j+=i)
                spf[j]=i;
}   

int power(int b,int p)
{
    ll r=1;
    while(p)
    {
        if(p&1)
        {
            r*=b;
            if(r>=mod)
                r%=mod;
        }
        b=(b*b)%mod;
        p>>=1;
    }   
    return r;
}   

void spl(int t,vector<pii> v)
{
    int i,sz=v.size(),j,k;
    ll cntm=1;
    
    while(t>1)
    {
        j=spf[t];
        k=0;
        while(t%j==0)
            t/=j, ++k;
        v[mp[j]].second-=k;
    }   
        
    for(i=0;i<sz;++i)
        if(v[i].second)
        {
            cntm*=power(v[i].first,v[i].second);
            if(cntm>=mod)
                cntm%=mod;
        }

    ans+=cntm;
    if(ans>=mod)
        ans-=mod;
}   

signed main()
{
    warmup
    
    getspf();
    int n;
    cin>>n;
    int i,j,k,t;
    for(i=1;i<=n;++i)
    {
        cin>>a[i];
        t=a[i];
        while(t>1)
        {
            j=spf[t];
            k=0;
            while(t%j==0)
                t/=j, ++k;
            cnt[j]=max(cnt[j],k);
        }   
    }   
    
    
    mp.clear();
    vector<pii> v;
    j=-1;
    if(cnt[2])
        v.pb({2,cnt[2]}),mp[2]=++j;
    for(i=3;i<N;i+=2)
        if(cnt[i])
            v.pb({i,cnt[i]}),mp[i]=++j;
        
    for(i=1;i<=n;++i)
        spl(a[i],v);
    
    cout<<ans;
    
    return 0;
}


Measured memory_bytes: 9984
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();

		pr.println(H * W - (H * w + W * h - h * w));
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define FFOR(i, a, b) for(int (i)=a;(i)>(b);--(i))
#define rrep(i,n) FFOR(i,0,n)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define lb long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 123456789012345
#define int ll
typedef pair<int, int> P;
typedef pair<int, P> PP;

const int maxn =1e5 + 10;

//initialization here
//
char f[55][55];
int nh[4] = {1,0,-1,0},nw[4] = {0,1,0,-1};
int h,w;
//
//initialization finish


// your function is here
//

bool isInField(int xh, int xw)
{
    return xh>=0 && xw>=0 && xh <= h-1 && xw <= w-1;
}
//
// your function finished

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// your code is here
	//

	cin >> h>> w;
    
    rep(i,h)rep(j,w) cin >> f[i][j];

    rep(i,h)rep(j,w)
    {
        if(f[i][j] == '.') continue;
        bool isblack = false;
        rep(k,4)
        {
            int xh = i+nh[k], xw = j+nw[k];
            if(!isInField(xh,xw)) continue;
            if(f[xh][xw] == '#') isblack = true;
        }

        if(!isblack)
        {
            No;
            return 0;
        }

    }

    Yes;

	//
	// your code finished


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,m,a,b,c,d[100010],r,i;
  while(scanf("%d %d %d %d %d",&n,&a,&b,&c,&m),n){
    for(i=0;i<n;i++)scanf("%d",&d[i]);
    for(i=r=0;i<10001;i++){
      if(d[r]==m)r++;
      if(r==n)break;
      m=(a*m+b)%c;
    }
    printf("%d\n",r-n?-1:i);
  }
  return 0;
}

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

int main() {
    int n, d; 
    cin >> n >> d;
    int ans = 0; 
    long long x, y; 
    for(int i = 0; i < n; i++) {
    	cin >> x >> y;
        if(sqrt(x*x + y*y) <= 1.0*d) {
          ans++;
        }
    }
  cout<< ans;
	return 0;
}

Measured memory_bytes: 3676
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var rdx = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var x = rdx[2];
            for (var i = 0; i < 10; i++)
            {
                x = rdx[0] * x - rdx[1];
                Console.WriteLine(x);
            }
        }
    }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int main(){
	int A,B,C,D;
	cin >> A >> B >> C >> D;

	int t = (A-1)/D;
	int a = (C-1)/B;
	if(t>=a)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll INF = 1e18L + 5;
 
int main() {
    ll n, w; cin >> n >> w;
    vector<ll> val(n), wt(n); ll sum = 0;
    
    for(ll i = 0; i < n; i++) {
        cin >> wt[i] >> val[i];
        sum += val[i];
    }
    
    vector<ll> dp(sum + 1, INF); // dp[i] = min weight for val = i
    dp[0] = 0;
    for(ll i = 0; i < n; i++) {
        for(ll j = sum; j >= 0; j--){
            if(j >= val[i])
                dp[j] = min(dp[j], dp[j-val[i]] + wt[i]);
        }
    }
    ll ans = 0;
    for(ll i = 0; i <= sum; i++){
        if(dp[i] <= w)
            ans = max(ans, i);
    }
    cout << ans << endl;
}

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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)

int n, k;
const int N = 2e5;
int h[N];
int dp[N];

int calc(int i) {
    if(i == n - 1) return 0;
    int &r = dp[i];
    if(r != -1) return r;
    int res = 1e9;
    fore(j, i + 1, min(n, i + k + 1)) {
        res = min(res, abs(h[i] - h[j]) + calc(j));
    }
    return r = res;
}
int main() {
    cin >> n >> k;
    fore(i, 0, n) cin >> h[i];
    memset(dp, -1, sizeof dp);
    cout << calc(0) << endl;
    return 0;
}

Measured memory_bytes: 6144
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	int q;
	cin >> q;
	while (q--) {
		int C, A, N;
		cin >> C >> A >> N;
		int sum = 0;
		int a, c, n;
		while (1) {
			if (C >= 1 && A >= 1 && N >= 1) {
				C--;
				A--;
				N--;
				sum++;
				continue;
			}
			if (C >= 2 && A >= 1) {
				C -= 2;
				A--;
				sum++;
				continue;
			}
			if (C >= 3) {
				C -= 3;
				sum++;
				continue;
			}
			break;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3068
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

long long GCD(long long a, long long b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) { cin >> A[i]; }
    vector<ll> left(N), right(N);
    ll lgcd = A[0];
    for (int i = 0; i < N; i++) {
        lgcd = GCD(lgcd, A[i]);
        left[i] = lgcd;
    }

    ll rgcd = A[N - 1];

    for (int i = N - 1; i > -1; i--) {
        rgcd = GCD(rgcd, A[i]);
        right[i] = rgcd;
    }

    int lcur = 0, rcur = 2;
    ll ans = 1;
    ans = max(ans, max(right[1], left[N - 2]));
    while (rcur <= N - 1) {
        ans = max(ans, GCD(left[lcur], right[rcur]));
        lcur++;
        rcur++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 5552
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int H,W;
char S[22][22];

int DFS(int x, int y, int max){

    return 0;
}


int main(void) {

    int A,B; cin>>A>>B;
    if(A<=8 && B<=8) cout<<"Yay!"<<endl;
    else cout<<":("<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
const long long MOD = 1e9 + 7;

template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    int N;
    cin >> N;
    if(N < 100)
        cout << 0 << endl;
    else if(N < 106)
        cout << 1 << endl;
    else {
        vector<bool> c(N + 1, 0);
        rep(i, 100, 106) c[i] = 1;
        rep(i, 107, N + 1) {
            c[i] = c[i - 100] || c[i - 101] || c[i - 102] || c[i - 103] ||
                   c[i - 104] || c[i - 105];
        }
        cout << c[N] << endl;
    }
}


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

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  ll sum = pow(3,n);
  ll cnt = 1;
  rep(i,n){
    cin >> a.at(i);
    ll num = 0;
    if( ( a.at(i) - 1 )%2 != 0 ) num++;
    if( ( a.at(i) + 1 )%2 != 0 ) num++;
    if( a.at(i)%2 != 0 ) num++;
    cnt *= num;
  }
  
  cout << sum - cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256