akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#define MAX_N 100001
#define INF 2147483647
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
int main()
{
  long long int N,A,cou=0,sq=0;
  priority_queue<long long int> que;
  cin >> N;
  REP(i,N){cin >> A;
    que.push(A);
  }
  while(!que.empty()){
    A = que.top();que.pop();
    if(!que.empty() && (que.top() == A)){
      que.pop();
      if(cou == 0){
        cou=1;
        sq = A;
      }
      else if(cou == 1){
        sq *= A;
        cout << sq <<endl;
        return 0;
      }
    }
  }
  cout << 0 << endl;
  
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 1400
from collections import Counter

n = int(input())
l = [Counter(input()) for _ in range(n)]

ans = ''
c = sorted(l[0])

for key in c:
    m = l[0][key]
    for i in range(1, n):
        m = min(m, l[i][key])
    ans += key * m

print(ans)


Measured memory_bytes: 3316
from collections import deque
H,W = map(int,input().split())
sy,sx = map(int,input().split())
sy-=1
sx-=1
gy,gx = map(int,input().split())
gy,gx = gy-1,gx-1
grid = [0] * H
done = [[0]*W for _ in range(H)]
cost = [[float('inf')]*W for _ in range(H)]
cost[sy][sx] = 0
done[sy][sx] =1
for i in range(H):
    grid[i] = input()

walk_q = deque()
magic_q = deque()
def walk_bfs(magic_count):
    y,x = walk_q.popleft()
    magic_q.append([y,x])
    for new_y,new_x in [[y+1,x],[y,x+1],[y-1,x],[y,x-1]]:
        if 0<=new_y<H and 0<=new_x<W and grid[new_y][new_x] == '.':
            if not done[new_y][new_x]:
                done[new_y][new_x] = 1
                cost[new_y][new_x] = min(cost[new_y][new_x],magic_count)

                walk_q.append([new_y,new_x])
                magic_q.append([new_y,new_x])

def magic_bfs(magic_count):
    y,x = magic_q.popleft()
    for y_add in range(-2,3):
        for x_add in range(-2,3):
            if y_add == 0 and x_add == 0:
                continue
            new_y = y+y_add
            new_x = x+x_add

            if 0<=new_y<H and 0<=new_x<W and grid[new_y][new_x] == '.':
                if not done[new_y][new_x]:
                    done[new_y][new_x] = 1
                    cost[new_y][new_x] = min(cost[new_y][new_x],magic_count+1)

                    walk_q.append([new_y,new_x])

walk_q.append([sy,sx])
magic_q.append([sy,sx])
magic_count = 0
# 毎回、既にqueueにあるやつ（初回を除く）が、done、costの処理をされない？
# や、初回以外は常にどっかしらで「発見」される
while walk_q or magic_q:
    while walk_q:
        walk_bfs(magic_count)
    while magic_q:
        magic_bfs(magic_count)
    magic_count += 1
if done[gy][gx]:
    print(cost[gy][gx])
else:
    print(-1)

Measured memory_bytes: 172444
def fb(num):
    """num番目のフィボナッチ数を返す
    """
    a, b = 1, 0
    for _ in range(num):
        a, b = a + b, a
    return b

import functools
import operator

import sys
n, m = map(int, input().split())
a = sorted(list(set(map(int, sys.stdin.readlines()))))
m = len(a)

s = 0
e = n
xs = [0] * (m + 1)
for i, j in enumerate(a):
  xs[i] = fb(j - s)
  s = j + 1
xs[m] = fb(n - s + 1)
if 0 in xs:
  print(0)
else:
  result = functools.reduce(operator.mul, xs)
  print(result % 1000000007)


Measured memory_bytes: 18872
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::cmp::{max, min};
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut a = a;
    let mut v = vec![0];
    v.append(&mut a);
    let mut d = vec![0;n+1];
    v.push(0);
    for i in 0..n+1 {
        d[i]=i64::abs(v[i]- v[i+1]);
    }
    for i in 1..n+1 {
        d[i]=i64::abs(v[i]- v[i+1]);
    }
    let sum = d.iter().sum::<i64>();
    for i in 1..n+1 {
        println!("{}", sum - d[i-1] - d[i] + i64::abs(v[i-1] - v[i+1]));
    }
}

Measured memory_bytes: 11388
import sys

def partition(A, p, r):
  x = A[r]
  i = p - 1
  for j in range(p, r):
    if A[j] <= x:
      i  = i + 1
      A[i], A[j] = A[j], A[i]
  A[i + 1], A[r] = A[r], A[i + 1]
  return i + 1
  

n = sys.stdin.readline()
n = int(n)

data = sys.stdin.readline()
data_list = data.split(" ")

data_list = map(int, data_list)

co = partition(data_list, 0, n-1)

data_list = map(str, data_list)

data_list[co] = "[{0}]". format(data_list[co])

print " ".join(data_list)

Measured memory_bytes: 18244
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    string s;
    cin>>s;
    if(s=="SUN")cout<<7<<endl;
    if(s=="MON")cout<<6<<endl;
    if(s=="TUE")cout<<5<<endl;
    if(s=="WED")cout<<4<<endl;
    if(s=="THU")cout<<3<<endl;
    if(s=="FRI")cout<<2<<endl;
    if(s=="SAT")cout<<1<<endl;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

static const ll INF = 1e15;

const ll mod = 1000000007;

struct Edge {
	Edge(int from, int to, ll weight) : src(from), dst(to), weight(weight){}
	int src;
	int dst;
	ll weight;

	bool operator < (const Edge& right) const {
		return weight < right.weight;
	}

	bool operator > (const Edge& right) const {
		return weight > right.weight;
	}

};

typedef ll Weight;
typedef vector<vector<Edge>> Graph;

struct warshall_floyd {
	static void solve(vector<vector<ll>>& d) {
		int n = d.size();
		rep(k, n) {
			rep(i, n) {
				rep(j, n) {
					d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}
	}
};

int main(void)
{
	int v, e;
	cin >> v >> e;
	vector<vector<Edge>> g(v);
	vector<vector<Weight>> w(v, vector<Weight>(v, INF));
	Weight total = 0;
	rep(i, e) {
		ll s, t, d;
		cin >> s >> t >> d;
		g[s].emplace_back(s, t, d);
		g[t].emplace_back(t, s, d);
		total += d;
		w[s][t] = min(w[s][t], d);
		w[t][s] = min(w[t][s], d);
	}
	warshall_floyd::solve(w);
	vector<int> odds;
	vector<int> m(v);
	rep(u, v) {
		if (g[u].size() % 2) {
			m[odds.size()] = u;
			odds.push_back(u);
		}
	}
	ll n = odds.size();
	ll N = 1LL << n;
	vector<Weight> best(N); // DP for general matching 
	rep(S, N) best[S] = INF;
	best[0] = 0;
	for (int S = 0; S < N; ++S)
		for (int i = 0; i < n; ++i) if (!(S & (1LL << i)))
			for (int j = i + 1; j < n; ++j) if (!(S & (1LL << j)))
				best[S | (1LL << i) | (1LL << j)] = min(best[S | (1LL << i) | (1LL << j)], best[S] + w[m[i]][m[j]]);
	cout << best[N - 1] + total << endl;
	return 0;
}



Measured memory_bytes: 3200
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int N = sc.nextInt();
  boolean b = false;
  for (int i = 0; i < N; i++) {
    if(sc.next().equals("Y")) {
      b = true;
      break;
    }
  }
  if (b) {
    System.out.println("Four");
  }
  else {
    System.out.println("Three");
  }
}
}
  


Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define all(v) v.begin(),v.end()
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl

void Suhaib_Sawalha (){

    string s;
    cin >> s;
    cout << s.substr(0,3);

}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<'\n')
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int N;
    vector<int> ans;
    while(true){
        vector<int> train(60*60*24, 0);
        cin >> N;
        if(N == 0) break;
        rep(i, N){
            string S, T; cin >> S >> T;
            int h, m, s;
            h = (S[0]-'0')*10 + (S[1]-'0');
            m = (S[3]-'0')*10 + (S[4]-'0');
            s = (S[6]-'0')*10 + (S[7]-'0');
            train[h*3600 + m*60 + s]++;

            //cout << h << " " << m << " " << s << endl;

            h = (T[0]-'0')*10 + (T[1]-'0');
            m = (T[3]-'0')*10 + (T[4]-'0');
            s = (T[6]-'0')*10 + (T[7]-'0');
            train[h*3600 + m*60 + s]--;
        }
        int res = 0;
        rep(i, 86399){
            train[i+1] += train[i];
            res = max(res, train[i+1]);
        }
        ans.push_back(res);
    }
    rep(i, ans.size()) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 3412
#include <iostream>
#include <map>

using namespace std;
int n, ans = 0;
map<string, int> v;

int main(){
    cin >> n;
    while (n--){
        string s;
        cin >> s;
        v[s]++;
        if (v[s]==1) ans++;
    }
    cout << ans;
}



Measured memory_bytes: 19228
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define REP(i, b, e) for ( int i = b; i < e; i++)
#define rep(i, n) REP(i, 0, n)

static const int MAX_N = 1000000;
static const int MAX_P = 2000000000;

int N, M, Q, S[MAX_N];

map<int, int> PM; // point map
vector<int> ATI, ATV;
vector<int> MS;
set<int> R;
vector<pair<int, int> > seg;

void init(){
  MS.clear();
  for ( set<int>::iterator it = R.begin(); it != R.end(); it++ ){
    MS.push_back(S[*it]);
  }
  sort(MS.begin(), MS.end());
}

int getCount(int r){
  seg.clear();

  if ( MS.size() > 0 ) seg.push_back(make_pair(MS[0]-r, MS[0]));

  for ( int i = 1; i < MS.size(); i++ ){
    int b = MS[i]-r;
    int e = MS[i];
    if ( b <= seg[seg.size()-1].second){
      seg[seg.size()-1].second = max(seg[seg.size()-1].second, e);
    } else {
      seg.push_back(make_pair(b, e));
    }
  }

  int cnt = 0;

  for ( int i = 0; i < seg.size(); i++ ){
    int a = distance(ATI.begin(), lower_bound(ATI.begin(), ATI.end(), max(0, seg[i].first) )) - 1;
    int b = distance(ATI.begin(), lower_bound(ATI.begin(), ATI.end(), max(0, seg[i].second) ));
    cnt += ATV[b] - ATV[a];
  }

  return cnt;
}

void bsearch(int X){
  init();

  int l = 0;
  int r = MAX_P+2000000;
  int m;
  int diff = r - l;
  int cnt = getCount(r);
  if ( cnt < X ){
    cout << "NA" << endl;
    return;
  }

  //  for (int i = 0; i < 100; i++ ){
  while(1){
    m = (l+r)/2;
    cnt = getCount(m);
    if ( cnt >= X ){
      r = m;
    } else if ( cnt < X ){
      l = m;
    }
    if ( diff == l - r ) break;
    diff = l - r;
  }
  cout << r << endl;
}

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

  MS.clear();
  PM.clear();
  ATI.clear();
  ATV.clear();

  rep(i, N) {
    scanf("%d", &S[i]);
    PM[S[i]]++;
  }

  bool isR[MAX_N];
  rep(i, N) isR[i] = false;

  M = 0;

  ATI.push_back(-1);
  ATV.push_back(0);
  int pre = 0;
  for ( map<int, int>::iterator it = PM.begin(); it != PM.end(); it++ ){
    ATI.push_back((*it).first);
    ATV.push_back((*it).second + ATV[pre++]);
  }

  string com;
  int x;
  rep(i, Q){
    cin >> com >> x;
    if ( com[0] == 'C' ){
      bsearch(N - x);
    } else if ( com[0] == 'R' ){
      x--; // 0 base
      R.erase(R.find(x));
      M--;
    } else if ( com[0] == 'A' ){
      x--; // 0 base
      R.insert(x);
      M++;
    }
  }
}

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

using namespace std;

const int MAXN = 1e5+5;
const int INF = 1e9;

int n, k;
int h[MAXN];
int dp[MAXN];

int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d", h+i);
  }

  dp[n-1] = 0;
  for (int i = n-2; i >= 0; --i) {
    dp[i] = INF;
    for (int j = 1; j <= k; ++j) {
      if (i+j >= n) continue;
      dp[i] = min(dp[i], abs(h[i]-h[i+j])+dp[i+j]);
    }
  }

  printf("%d\n", dp[0]);
  return 0;
}



Measured memory_bytes: 896
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
# define int ll
using namespace std;

int n,a[1 << 17];
map<int,int>M,m;
vector<int>vec;
int ans[1 << 17],anss[1 << 17],mx;
int mm[1 << 17];

int32_t main(){_
    //freopen("input","r",stdin);
    cin >> n;
	for(int i = 1;i <= n;i++)
	{
		cin >> a[i];
		m[a[i]]++;
		if(a[i] > a[mx]) mx = i;
		ans[i] = mx;
	}
	int k = 0;
	for(auto it : m)
	{
		vec.pb(0);
		M[it.first] = k++;
		mm[k - 1] = it.first;
	}
	int i = ans[n];
	for(int j = mx;j <= n;j++) vec[M[a[j]]]++;
	while(1)
	{
		if(i == 1) break;
		int nxt = ans[i - 1];
		for(int j = M[a[nxt]] + 1;j <= M[a[i]];j++) {
			vec[M[a[nxt]]] += vec[j];
			anss[i] += vec[j] * mm[j] - vec[j] * a[nxt];
			vec[j] = 0;
		}
		for(int j = nxt;j <= i - 1;j++) vec[M[a[j]]]++;
		i = nxt;	
	}
	for(int i = 0;i < k;i++) anss[1] += vec[i] * mm[i];
	for(int i = 1;i <= n;i++) cout << anss[i] << '\n';
}

Measured memory_bytes: 17908
#include<iostream>
using namespace std;
int main(){
  int c1,c5,c10,c50,c100,c500;
  cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
  int ans = c1 + 5*c5 + 10*c10 + 50*c50 + 100*c100 + 500*c500;
  if(ans>=1000)
    cout << 1 << endl;
  else 
    cout << 0 << endl;
  return 0;  
}

Measured memory_bytes: 1160
#!/usr/bin/env python3
class Bit:
    # Binary Indexed Tree
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def __iter__(self):
        psum = 0
        for i in range(self.size):
            csum = self.sum(i + 1)
            yield csum - psum
            psum = csum
        raise StopIteration()

    def __str__(self):  # O(nlogn)
        return str(list(self))

    def sum(self, i):
        # [0, i) の要素の総和を返す
        if not (0 <= i <= self.size): raise ValueError("error!")
        s = 0
        while i>0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        if not (0 <= i < self.size): raise ValueError("error!")
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def __getitem__(self, key):
        if not (0 <= key < self.size): raise IndexError("error!")
        return self.sum(key+1) - self.sum(key)

    def __setitem__(self, key, value):
        # 足し算と引き算にはaddを使うべき
        if not (0 <= key < self.size): raise IndexError("error!")
        self.add(key, value - self[key])

(n, q), c, *d = [[*map(int, o.split())] for o in open(0)]

d = sorted(enumerate(d), key = lambda x: x[1][1])

B = Bit(n)
ans = [-1] * q
last = [-1] * (n + 1)
ind = 0  # [-, ind) まで確認終了
for i, (l, r) in d:
    for j in range(ind, r):
        if last[c[j]] != -1:
            B.add(last[c[j]], -1)
        B.add(j, 1)
        last[c[j]] = j
    ind = r
    ans[i] = B.sum(r) - B.sum(l - 1)
for a in ans:
    print(a)


Measured memory_bytes: 231692
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

void solve(long long K, long long S) {
  ll cnt = 0;
  for (ll x = 0; x <= K; x++) {
    for (ll y = 0; y <= K; y++) {
      ll z = S - x - y;
      if (z >= 0 && z <= K) {
        cnt++;
      }
    }
  }
  print(cnt);
}

int main() {
  long long K;
  scanf("%lld", &K);
  long long S;
  scanf("%lld", &S);
  solve(K, S);
  return 0;
}


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

const int MAXN = 6e3 + 5;

int N;
string s;
string dp[MAXN];
bool good[MAXN];
vector <int> a, b;
int idx[MAXN];
bool taken[MAXN];

void load() {
	cin >> N >> s;
}

string get(int x) {
	string res = "";
	while (x <= N) {
		if (s[x] == 'a' && b[idx[x]] > x) {
			res += "ab";
			x = b[idx[x]];
		}
		x++;
	}
	return res;
}

string greedy(int pos) {
	memset(taken, false, sizeof taken);
	
	vector <int> v;
	for (; pos <= N; pos++) {
		if (!v.empty() && pos > v.back())
			break;
		if (good[pos]) {
			v.push_back(a[idx[pos]]);
			taken[pos] = taken[v.back()] = true;
		}
	}
	
	string res = "";
	for (int i = 1; i <= N; i++)
		if (taken[i])
			res += s[i];
	
	if (!dp[pos].empty())
		return res + dp[pos];
	
	return res + get(pos);
}

string solve() {
	N *= 2;
	s = ' ' + s;
	for (int i = 1; i <= N; i++)
		if (s[i] == 'a')
			a.push_back(i);
		else
			b.push_back(i);
	
	for (int i = 0; i < b.size(); i++) {
		if (a[i] > b[i]) 
			good[b[i]] = true;
		idx[a[i]] = i;
		idx[b[i]] = i;
	}
	
	for (int i = N; i >= 0; i--) {
		dp[i] = dp[i + 1];
		if (good[i]) {
			string tmp = greedy(i);
			if (tmp > dp[i])
				dp[i] = tmp;
		}
	}
	
	return dp[0].empty() ? get(1) : dp[0];
}

int main() {
	load();
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 10368
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);
	    String az="abcdefghijklmnopqrstuvwxyz";

	    String s=gs();
	    
	    //System.out.print(String.valueOf(s.charAt(0))+ (s.length()-2)+s.charAt(s.length()-1));
	    StringBuilder sb= new StringBuilder();
	    for (int i=0; i<s.length(); i+=2) {
	    	sb.append(s.charAt(i));
	    }

	    System.out.print(sb.toString());


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 39328
<?php
fscanf(STDIN, "%s", $s);
$length = strlen($s);

for($i = 0; $i < $length; $i++){
    for($j = 0; $j <= $length-$i; $j++){
        $judge = false;
        $s_kari = substr($s, $i, $j);
        for($k = 0; $k < strlen($s_kari); $k++){ 
            if(!preg_match('/[ACGT]/',$s_kari[$k])){
                $judge = true;    	
            }
        }
        if(!$judge){
            $sarr[] = $s_kari;
        }
    }
}

$count = count($sarr);
$carr = [];
for($i = 0; $i < $count; $i++){
    $carr[] = strlen($sarr[$i]);
}

echo max($carr);

?>

Measured memory_bytes: 3828
#include<iostream>
#include<vector>
#include<string>
#include<map>

#define REP(i,j,k) for( int i=j; i<k; i++ )
#define rep(i,j) REP(i,0,j)

using namespace std;

typedef long int LI;

int main(){
	
	int n,k;
	string s;
	
	cin >> n >> k;
	cin >> s;
	
	vector<int> v(1,0);
	
	char c[2] = {'1','0'};
	int bo = 0;
	
	rep(i,n)
		if( s[i] == c[bo%2] ) v[bo]++;
		else{
			bo++;
			v.push_back(1);
		}
	
	if(v.size()%2 == 0) v.push_back(0);
	
//	rep(i,v.size()) cout << v[i] << endl;
	
	
	int ans = 0;
	
	rep(i,v.size()){
		
		if(i%2) continue;
		
		int temp = 0;
		
		REP(j,i,i+2*k+1){
			if( j == v.size() ) break;
			temp += v[j];
//			cout << v[j] << " ";
		}
		
//		cout << temp << endl;
		
		ans = max(ans,temp);
		
	}
	
	cout << ans << endl;
	
	return 0;
	
}


Measured memory_bytes: 1020
N = int(input())
XY = []
for _ in range(N):
    x, y = map(int, input().split())
    XY.append((x + y, x - y))
if any(XY[0][0] % 2 != xy[0] % 2 for xy in XY):
    print(-1)
    exit()
odd = XY[0][0] % 2 == 1
if odd:
    d = [2 ** i for i in range(30, -1, -1)]
else:
    d = [2 ** i for i in range(30, -1, -1)] + [1]
print(len(d))
print(*d)
for xpy, xmy in XY:
    s = ""
    p = 0
    m = 0
    for di in d:
        ps = 1 if p <= xpy else -1
        ms = 1 if m <= xmy else -1
        p += ps * di
        m += ms * di
        if ps == 1:
            s += "R" if ms == 1 else "U"
        else:
            s += "D" if ms == 1 else "L"
    print(s)


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

const ll inf = 1e18;
using C = ll;

class Dijkstra {
	struct edge {
		int to;
		C cost;
		edge(int to_, C cost_) : to(to_), cost(cost_) {}
	};
	bool isdir;
	vector<vector<edge>> G;
	int V;
public:
	Dijkstra(int V_, bool isdir_ = true) : isdir(isdir_), V(V_), G(V_) {}
	void add(int a, int b, C c) {
		G[a].emplace_back(b, c);
		if (!isdir) G[b].emplace_back(a, c);
	}
	vector<C> calc(int s) {
		vector<C> d(V, inf);
		using pci = pair<C, int>;
		priority_queue<pci, vector<pci>, greater<pci>> q;
		q.emplace(0, s);
		while (!q.empty()) {
			auto p = q.top(); q.pop();
			int v = p.second;
			if (d[v] < p.first) continue;
			d[v] = p.first;
			for (auto& e : G[v]) {
				if (d[e.to] > d[v] + e.cost) {
					d[e.to] = d[v] + e.cost;
					q.emplace(d[e.to], e.to);
				}
			}
		}
		return d;
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int V, E, r;
	cin >> V >> E >> r;
	Dijkstra dk(V);
	for (int i = 0; i < E; i++) {
		int s, t;
		ll d;
		cin >> s >> t >> d;
		dk.add(s, t, d);
	}
	auto d = dk.calc(r);
	for (int i = 0; i < V; i++) {
		if (d[i] == inf) {
			puts("INF");
		}
		else {
			printf("%lld\n", d[i]);
		}
	}
	return 0;
}

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

public class Main {

		public static void main(String[] args){
			 int sam ;
			 int check ;
			
			Scanner sc = new Scanner(System.in);
			// 整数の入力
			// スペース区切りの整数の入力
			int a = sc.nextInt();

			ArrayList<Integer> stateList = new ArrayList<Integer>();
					
			for (int i = 0; i < a;i ++ ){
				stateList.add(sc.nextInt());
			}
			 
			 Collections.sort(stateList);
			 
			 sam = 0;
			 for(int i=0;i<stateList.size();i++){
				 sam = sam + stateList.get(i);
			 }

			 check = sam  % 10 ;
    		 if(check != 0 ){
	    		// 出力
	    		System.out.println(sam);
	    		return ;
    		 }else{
    			 for(int j=0;j<stateList.size();j++){
    				 int sum2 = sam - stateList.get(j); 
	    			 check = sum2 % 10 ;
	    			 if(check != 0 ){
		        		// 出力
		    	    	System.out.println(sum2);
		    	    	return ;
	    		     }
	    		 }
			 }
			// 出力
			System.out.println(0);
		}
}


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

using namespace std;

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

  int n, m, q;
  cin >> n >> m >> q;
  vector<vector<int>> trains(n, vector<int>(n + 1, 0));

  int l, r;
  for (int i = 0; i < m; ++i) {
    cin >> l >> r;
    trains[--l][--r]++;
  }

  for (int i = 0; i < n; ++i) {
    for (int j = n - 1; 0 < j; --j) {
      trains[j - 1][i] += trains[j][i];
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 1; j <= n; ++j) {
      trains[i][j] += trains[i][j - 1];
    }
  }

  int p, t;
  for (int i = 0; i < q; ++i) {
    cin >> p >> t;
    cout << trains[--p][--t] << "\n";
  }
}


Measured memory_bytes: 1920
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_043A
{
    class Program
    {
        static void Main(string[] args)
        {
            int N;
            int s;
            int i;

            N = int.Parse(Console.ReadLine());

            s = 0;

            for (i = 1; i <= N; i++)
            {
                s = s + i;
            }

            Console.WriteLine(s);

            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 int N;
  cin>>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
     cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  int sum=0;
  for(int j=1;j<N+1;j++){
     if(j%2==1){
       sum +=vec.at(j-1);
     }
    else{
       sum -=vec.at(j-1);
    }
  }
cout<<sum;
}

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

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

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

class UnionFind {
private:
	vector<int> data;
public:
	int root(int x) { return (x == INF || data[x] < 0) ? x : data[x] = root(data[x]); }
	
	UnionFind(int size) : data(size, -1) { }
	bool is_same(int x, int y) { return root(x) == root(y); }
	lint size(int x) { return -data[root(x)]; }

	void unify(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
};


int main() {

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

	int N;
	cin >> N;

	UnionFind UF(2 * N);
	int u, v, len;

	for (int i = 0; i < N - 1; i++){
		cin >> u >> v >> len;
		if (len % 2 == 0) {
			UF.unify(u - 1, v - 1);
			UF.unify(u + N - 1, v + N - 1);
		}
		else {
			UF.unify(u - 1, v + N - 1);
			UF.unify(u + N - 1, v - 1);
		}
	}

	for (int i = 0; i < N; i++) {
		if(UF.is_same(0, i)) cout << '0' << "\n";
		else cout << '1' << "\n";
	}

	return 0;
}

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

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

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const double INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

const double EPS = 1e-8;

using R = double;
using P = complex<R>;

inline istream& operator>>(istream& is, P& p) {
  R x, y;
  is >> x >> y;
  p = P(x, y);
  return is;
}

// 線分abから見たcの位置
inline int sgn(const R& r) { return (r>EPS) - (r<-EPS); }
enum CCW{LEFT=1, RIGHT=2, BACK=4, FRONT=8, ON_SEG=16};
int ccw(P a, P b, P c) {
	P p = (c-a)/(b-a);
	if(sgn(imag(p)) > 0) return LEFT;
	if(sgn(imag(p)) < 0) return RIGHT;
	if(sgn(real(p)) < 0) return BACK;
	if(sgn(real(p)-1) > 0) return FRONT;
	return ON_SEG;
}

double dp[10010][25][25], d[25][25];
VI g[25][25];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  double PI = acos(-1);
  // cout << PI << endl;

  int n;
  double r, t;
  cin >> n >> r >> t;
  t *= PI/180.0;
  vector<P> ps(n);
  REP(i, n) cin >> ps[i];

  if(n == 1) {
    cout << 0 << endl;
    return 0;
  }

  REP(i, n) REP(j, n) {
    if(i == j) continue;
    g[i][j].clear();
    REP(k, n) {
      if(j == k) continue;
      double ang = abs(arg((ps[k] - ps[j]) / (ps[j] - ps[i])));
      if(ang <= t + EPS) {
        g[i][j].PB(k);
        // cout << i << " " << j << " " << k << endl;
      }
    }
    d[i][j] = abs(ps[i] - ps[j]);
  }

  REP(i, 10010) REP(j, n) REP(k, n) dp[i][j][k] = INF;
  FOR(i, 1, n) {
    if(d[0][i] <= r + EPS) {
      dp[1][0][i] = d[0][i];
    }
  }

  FOR(i, 1, 10001) REP(j, n) REP(k, n) {
    if(dp[i][j][k] == INF) continue;
    for(auto &l: g[j][k]) {
      chmin(dp[i+1][k][l], dp[i][j][k] + d[k][l]);
    }
  }

  double ans = 0;
  for(int i=10001; i>=0; --i) REP(j, n) REP(k, n) {
    if(dp[i][j][k] <= r + EPS) {
      ans = i;
      goto end;
    }
  }
  end:;
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 52480
#include <bits/stdc++.h>
using namespace std;
//B - Addition and Multiplication
int main() {
  int n, k;
  cin >> n >> k;
  int number = 1;
  for(int i = 0;i < n; i++){
    if(number*2 < number + k)
      number = number*2;
    else
      number += k;
  }
  cout << number << endl;
}


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

using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;

	if (A + B < 24) {
		cout << A + B << endl;
	}
	else {
		cout << A + B - 24 << endl;
	}



}





Measured memory_bytes: 3540
N = int(input())

ret = []
for i in range(1, N + 1) :
    for j in range(i + 1, N + 1) :
        if N % 2 == 0 and i + j == N + 1 :
            continue
        if N % 2 == 1 and i + j == N :
            continue
        ret.append((i, j))

print(len(ret))
for r in ret :
    print(*r)


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

using namespace std;

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> a(m);
    int left = 0;
    int right = 0;
    for (int i = 0; i < m; i++) {
        cin >> a.at(i);
        if (a.at(i) < x) {
            left++;
        } else {
            right++;
        }
    }
    cout << min(left, right) << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
double ans;
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    cin>>a>>b>>x;
    if(a*a*b>=2*x){
    double x1=(double)x*2.0/((double)a*(double)b);
    ans=atan((double)b/x1);
    ans*=180.0;
    ans/=M_PI;
    doublecout(ans);
    }
    else{
        double x1=2.0*(double)x/((double)a*(double)a)-(double)b;
        ans=(double)a*x1/((double)b-x1);
        //doublecout(x1);
        ans=atan(x1/ans);
        ans*=180.0;
        ans/=M_PI;
        doublecout(ans);
    }
    return 0;
}

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

int main() {
    int k;cin>>k;
    string s; cin>>s;
    if(k>=s.size()) cout<<s<<endl;
    else cout<<s.substr(0,k)<<"..."<<endl;
}

Measured memory_bytes: 3628
n = int(input())
l = list(map(int,input().split()))
# l.sort()
# l = set(l)
# n = len(l)
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i] != l[j] and l[j] != l[k] and l[i] != l[k] and l[i]+l[j]+l[k]-max(max(l[i],l[j]),l[k]) > max(max(l[i],l[j]),l[k]) :
                ans += 1
                # print(i,j,k)
print(ans)

Measured memory_bytes: 9208
#include <iostream>
using namespace std;
int main(){
  int N,M,C,B[20],A[20][20];
  cin >>N >> M >> C;
  for(int i=0;i<M;i++)cin >> B[i];
  for(int i=0;i<M;i++){
    for(int j=0;j<M;j++)cin >> A[i][j];
  }
  int Chara=0,answers=0;
  for(int code=0;code<N;code++){
    for(int i=0;i<M;i++)Chara+=B[i]*A[code][i];
    if (Chara+C > 0)answers++;Chara=0;
  }
   cout << answers <<endl;
}


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

int main() {
    int n, k, ans = 1;
    cin >> n >> k;

    for (int i = 1; i <= n; i++) {
        if (i == 1) ans *= k;
        else ans *= k - 1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll A , B , H , M; cin >> A >> B >> H >> M;
  double zi = 0.0 ,  byo = 0.0;
  double pi = acos(-1.0);

  byo = 2 * pi * M / 60 * 1.0;
  zi = (2 * pi * H / 12 * 1.0) + byo / 12 * 1.0;

  double ans = A * A + B * B - 2 * A * B * cos(byo - zi);
  ans = sqrt(ans);
  cout << fixed << setprecision(15) <<  ans << endl;
}


Measured memory_bytes: 4292
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BS
import           Data.List             (subsequences, transpose)
import           Data.Maybe            (fromJust)
import           Data.Vector.Unboxed   (Vector, (!))
import qualified Data.Vector.Unboxed   as V

main :: IO ()
main = do
  [d, g] <- readInts <$> BS.getLine
  pcs <- map readInts . BS.lines <$> BS.getContents
  print $ solve d g pcs

solve :: Int -> Int -> [[Int]] -> Int
solve d g pcs = minimum . map (count d g ps' cs') $ subsequences [0 .. d-1] where
  [ps, cs] = transpose pcs
  ps' = V.fromList ps
  cs' = V.fromList cs

count :: Int -> Int -> Vector Int -> Vector Int -> [Int] -> Int
count d g ps cs is = count' d g' ps is + sum qs where
  g' = g - sum ds - sum (map (\i -> (i + 1) * 100 * ps!i) is)
  qs = map (ps !) is
  ds = map (cs !) is

count' :: Int -> Int -> Vector Int -> [Int] -> Int
count' d g ps is
  | i < 0         = 0
  | g <= 0        = 0
  | g - p * s > 0 = inf
  | otherwise     = (g + s - 1) `div` s where
      i = findProblemIndex d is
      p = ps ! i
      s = 100 * (i + 1)

findProblemIndex :: Int -> [Int] -> Int
findProblemIndex d is = go (d - 1) (reverse is) where
  go x [] = x
  go x (j:js)
    | x > j  = x
    | x == j = go (x - 1) js
    | x < j  = go x js

inf :: Int
inf = maxBound `div` 3

readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt

readInts :: BS.ByteString -> [Int]
readInts = map readInt . BS.words


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	ll n; cin>>n;
	string s=to_string(n);
	int x=s.size();
	int c=0;
	rep(i,0,x){
		c+=int(s[i]-'0');
	}
	if(n%c==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 3688
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();//マス目の設定
        int W = sc.nextInt();
      	int[][] result;
      	result=new int[H+2][W+2];//上下左右に1列分の余裕を
       	
      
      	for(int i=0;i<H;i++) {//データの打ち込み
          	result[i][0]=100;
          	result[i][W+1]=100;
			String input=sc.next();
            for(int j=0;j<W;j++){
              	result[0][j]=100;
              	result[H+1][j]=100;
                if (input.charAt(j)=='#'){
                    result[i+1][j+1]=-1;
                }else{
                    result[i+1][j+1]=0;
                }
            }
        }
      
      
      
      
      	for(int i=1;i<H+1;i++) {//変換
          for(int j=1;j<W+1;j++){
           	if(result[i][j]!=-1){
              
              if(result[i][j+1]==-1){
				result[i][j]+=1;
              }
              if(result[i][j-1]==-1){
				result[i][j]+=1;
              }
              if(result[i+1][j]==-1){
				result[i][j]+=1;
              }
              if(result[i-1][j]==-1){
				result[i][j]+=1;
              }
              if(result[i+1][j+1]==-1){
				result[i][j]+=1;
              }
              if(result[i-1][j+1]==-1){
				result[i][j]+=1;
              }
              if(result[i+1][j-1]==-1){
				result[i][j]+=1;
              }
              if(result[i-1][j-1]==-1){
				result[i][j]+=1;
              }
              
           	}
          }
		}
      
      
      for(int i=1;i<H+1;i++) {//データの書き出し
        for(int j=1;j<W;j++){
          if(result[i][j]==-1){
			System.out.print('#');
          }else{
          	System.out.print(result[i][j]);
          }
        }
        
		if(result[i][W]==-1){
		  System.out.println('#');
        }else{
          System.out.println(result[i][W]);
        } 
      }
      
    }
}




Measured memory_bytes: 36464
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 1000000;
const ll INF = (1LL << 31) - 1;
const double pi=acos(-1);

int h,w;
char f[55][55];

int main(){
  cin >> h >> w;
  rep(i,55){
    rep(j,55){
      f[i][j]='.';
    }
  }
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin >> f[i][j];
    }
  }
  rep(i,h){
    rep(j,w){
      if(f[i][j]=='.')continue;
      if(f[i+1][j]=='#')continue;
      if(f[i][j+1]=='#')continue;
      if(f[i-1][j]=='#')continue;
      if(f[i][j-1]=='#')continue;
      cout <<"No"<<endl; return 0;
    }
  }
  cout <<"Yes"<<endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
	ll a , b ,q;
	scanf("%lld%lld%lld",&a,&b,&q);
	
	vector <ll > s,t;

	for(ll temp, i = 0 ; i < a ; i++)
		scanf("%lld",&temp),s.push_back(temp);
	for(ll temp, i = 0 ; i < b ; i++)
		scanf("%lld",&temp),t.push_back(temp);

	while(q--){
			ll x ;
			scanf("%lld",&x);
			ll fl = lower_bound(s.begin(),s.end(),x)-s.begin();
			
			ll tl = lower_bound(t.begin(),t.end(),x)-t.begin();
			
			ll ans = 0;
		
			ans = 1e18+90 ;
			if(tl >= b)
				tl--;
			if(fl >= a)
				fl--;
			ll fa= fl , ta = tl;
			
			if(fa)
				fa--;
			if(ta)
				ta--;
				
			
			for(auto j : {fa,fl}){
				for(auto y : {ta,tl}){
					ans= min( ans, abs(x-s[j])+abs(s[j]-t[y]));
					ans= min( ans, abs(x-t[y])+abs(t[y]-s[j]));
					
				}
			}
			printf("%lld\n",ans);
			
		
	}

	return 0;
}


Measured memory_bytes: 3060
/**
 * author:    Ziel(Maksat Sakenuly)
 * created:   28.03.2020 17:51:51
 * judge:     Atcoder
 
 * Solution for problem A
**/

// ~succesfully skatal~

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin, x.rend()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T>
inline void cmin(T &a, T b) { a = min(a, b); }
template <class T>
inline void cmax(T &a, T b) { a = max(a, b); }

const int oo = 0x3f3f3f3f;
const ll N = 1e5 + 123;
const ll MOD = 1e9 + 7;
const ll INF = 1e15 + 9;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

main() {
#ifdef ZVER
	cerr << "Ready\n";
#endif
	fre("");
	ACCELERATE;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
	string s;
  cin >> s;
  if (s[3] == s[2] && s[5] == s[4]) cout << "Yes";
  else cout << "No";
	
	return 0;
}

// uniform_int_distribution<int>(l, r)(rng) -> random in range [l, r]
// assert(condition) -> if (condition == false) Runtime Error
// order_of_key(x) -> number of elements smaller than x
// *find_by_order(k) -> k-th element in 0-based indexation

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define fo(i,a,n) for (i = a; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;

void solve(){
    int a, b, c, k;
    cin>>a>>b>>c>>k;
    if(k <= a){cout<<k;return ;}
    if(k <= (a+b)){cout<<a;return ;}
    k -= (a+b);
    cout<<(a - k);return ;
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


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

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

  vector<int> V(N);
  vector<int> C(N);
  rep(i, N) cin >> V[i];
  rep(i, N) cin >> C[i];

  int ans = 0;
  rep(i, N) {
    if (V[i] - C[i] > 0) ans += V[i] - C[i];
  }
  cout << ans << endl;
  return 0;
}

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

int main(void){
  int n;
  cin >> n;
  int t,a;
  cin >> t >> a;
  
  int x;
  cin >> x;
  double min = abs(t-x*0.006-a);
  int min_i = 1;
  for(int i = 1; i < n; i++){
    cin >> x;
    double y = abs(t-x*0.006-a);    
    if(min > y){
      min = y;      
      min_i = i+1;
    }
  }
  cout << min_i << endl;
  
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n, i, x;
	int check_num = 1, include3 = 1 , end_check_num = 1;

	scanf("%d", &n);

	i = 1;
	while(1)
	{
		if (check_num)
		{
			x = i;
			if(x % 3 == 0)
			{
				printf(" %d", i);
				include3 = 0;
				end_check_num = 1;
				check_num = 0;
			}
			else
			{
				include3 = 1;
				check_num = 0;
				end_check_num = 1;
			}
		}

		if (include3)
		{
			if(x % 10 == 3)
			{
				printf(" %d", i);
				include3 = 0;
				end_check_num = 1;
				check_num = 0;
			}
			else
			{
				x /= 10;
				if(x)
				{
					check_num = 0;
					end_check_num = 0;
					include3 = 1;
				}
				else
				{
					check_num = 0;
					end_check_num = 1;
					include3 = 0;
				}
			}
		}

		if(end_check_num)
		{
			if (++i <= n)
			{	
				check_num = 1;
				end_check_num = 1;
				include3 = 1;
			}
			else
			{
				check_num = 0;
				end_check_num = 0;
				include3 = 0;
			}
		}

		if(check_num || include3 || end_check_num)
			;
		else
		{
			printf("\n");
			break;
		}
	}
}


Measured memory_bytes: 2048
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
#define mod 1000000007
//#define mod 998244353
#define inf 1000000000
#define pr1(a) cout << a << "\n"
#define pr2(a,b)cout << a <<  " " <<b<< "\n"
#define pr3(a,b,c) cout << a <<" " << b << " " << c << "\n"

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

int gcd(int a, int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
const int maxn = 2*1e5 + 10;

void solve(){

    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1;i<=n;i++){
        for(int j  =1;j<=n;j++){
            for(int k = 1;k<=n;k++){
                ans+=gcd(i,gcd(j,k));
            }
        }
    }
    cout << ans << endl;

} 

signed main() 
{   
    IOS;
    int t = 1;
    // cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n),b(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  for(Int i=0;i<n;i++) cin>>b[i];
  Int sum=0;
  for(Int i=0;i<n;i++) sum+=a[i]-b[i];
  if(sum<0){
    cout<<-1<<endl;
    return 0;
  }
  Int ans=0,res=0;
  priority_queue<Int> pq;
  for(Int i=0;i<n;i++){
    if(a[i]<b[i]) ans++,res+=b[i]-a[i];
    else pq.emplace(a[i]-b[i]);
  }
  while(res>0){
    res-=pq.top();pq.pop();
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2936