akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
const int N = 1234567;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}


int main(void){
	int n;
	cin>>n;
	ll x;
	vector<ll> X;
	//cout<<"hoge"<<endl;
	rep(i,n){
		cin>>x;
		X.push_back(x);
	}
	ll l,q;
	cin>>l;
	vector<vector<ll>> left,right;
	rep(i,n){
		left.push_back(vector<ll>());
		right.push_back(vector<ll>());
		rep(j,20){
			left[i].push_back(-1);
			right[i].push_back(-1);
		}
	}
	//cout<<"hoge"<<endl;
	int li=0,ri=0;
	while(li < n){
		while(ri < n && X[ri] - X[li] <= l){
			ri++;
		}
		while(li < n && (ri == n || X[ri] - X[li] > l)){
			right[li][0] = ri - 1;
			li++;
		}
	}
	//cout<<"hoge"<<endl;

	li=n-1;ri=n-1;
	while(ri >= 0){
		while(li >= 0 && X[ri] - X[li] <= l){
			li--;
		}
		while(ri >= 0 && (li == -1 || X[ri] - X[li] > l)){
			left[ri][0] = li + 1;
			ri--;
		}
	}
	//cout<<"hoge"<<endl;

	reps(j,19){
		rep(i,n){
			right[i][j] = right[right[i][j-1]][j-1];
		}
		REP(i,n){
			left[i][j] = left[left[i][j-1]][j-1];
			//cout<<left[i][j]<<" ";
		}
		//cout<<endl;
	}


	cin>>q;
	rep(i,q){
		ll a,b;
		cin>>a>>b;
		a--;b--;
		ll ans = 0;
		if(a < b){
			while(true){
				int step = 0;
				while(right[a][step+1] < b){
					step++;
				}
				ans += pow(2,step);
				a = right[a][step];
				if(a >= b){
					cout<<ans<<endl;
					break;
				}
				//cout<<step<<endl;
			}

		}else{
			while(true){
				int step = 0;
				while(left[a][step+1] > b){
					step++;
				}
				ans += pow(2,step);
				a = left[a][step];
				
				if(a <= b){
					cout<<ans<<endl;
					break;
				}
				//cout<<step<<endl;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 59876
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	int a, b;
	cin >> a >> b;

	if (a > 0) cout << "Positive" << endl;
	else { // a <= 0
		if (b >= 0) cout << "Zero" << endl;
		else { // b < 0
			if ((b - a + 1) % 2 == 0) cout << "Positive" << endl;
			else cout << "Negative" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    string O, E;
    cin >> O;
    cin >> E;
    string res = "";
    for(int i = 0; i < O.length() + E.length(); i++) {
        if(i % 2 == 0) {
            res += O[i / 2];
        } else {
            res += E[i / 2];
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
from itertools import combinations as comb

def main():
  while True:
    n = int(input())
    if n ==0:break
    m = int(input())
    result = [[None] * n for _ in range(n)]
    for _ in range(m):
      x, y = map(int, input().split())
      x -= 1
      y -= 1
      result[x][y] = True
      result[y][x] = False

    t_count = [lst.count(True) for lst in result]
    
    empty_index = [[] for _ in range(n)]
    empty_nums = [0] * n
    for i in range(n):
      for j in range(i + 1, n):
        if result[i][j] == None:
          empty_index[i].append(j)
          empty_nums[i] += 1
    
    memo = {}
    limit = n // 2
    def search(x, t_count):
      if (x, tuple(t_count)) in memo:return memo[(x, tuple(t_count))]
      if x == n:return 1
      choice_num = limit - t_count[x]
      if choice_num < 0 or choice_num > empty_nums[x]:return 0
      rest_num = empty_nums[x] - choice_num
      ret = 0
      for inds in comb(empty_index[x], rest_num):
        new_count = t_count[:]
        for ind in inds:
          new_count[ind] += 1
        ret += search(x + 1, new_count)
      memo[(x, tuple(t_count))] = ret
 
      return ret

    print(search(0, t_count))

main()


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

int n, ans = 0;

void check(int v[]) {
  long long p = 1;
  for (int i = 0; i < n; i++) {
    p *= v[i];
  }
  if (p%2 == 0) {
    ans++;
  }
  return;
}

void dfs(int v[], int cnt) {
  if (cnt == n) {
    check(v);
    return;
  }
  int tmp = v[cnt];
  dfs(v, cnt + 1);
  v[cnt] = tmp - 1;
  dfs(v, cnt + 1);
  v[cnt] = tmp + 1;
  dfs(v, cnt + 1);
  v[cnt] = tmp;
  return;
}


int main() {
  cin >> n;
  int v[100] = {0};
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  dfs(v, 0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define double long double
using namespace std;

ll n, sum;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (ll i = 1; i <= n; i ++)
        if (i % 3 != 0 && i % 5 != 0)
            sum += i;
    cout << sum;
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
using namespace std;


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

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

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

	string S;
	cin >> S;

	reverse(S.begin(), S.end());
	
	int N = S.size();

	string T = "";

	int l = 0;
	while(l + 2 < N){
	
		string aux = S.substr(l,3);

		if(aux == "res"){
			T += "resare";
			l += 6;
		}
		else if(aux == "esa"){
			T += "esare";
			l += 5;
		}
		else if(aux == "mae"){
			T += "maerd";
			l += 5;
		} 
		else {
			T += "remaerd";
			l += 7;
		}
	}

	if(T == S){
		cout << "YES\n";
	}
	else cout << "NO\n";

	return 0;
}


Measured memory_bytes: 3780
if __name__ == '__main__':
    n = int(input())
    s = input()
    k = int(input())

    chars = []
    needle = s[k - 1]

    for i in range(len(s)):
        if s[i] != needle:
            chars.append('*')
        else:
            chars.append(s[i])

    print(''.join(chars))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr long long INF = 1e18;

struct UF{
	vector<int>par,sz;
	void init(int n){
		par.resize(n);
		sz.resize(n);
		for(int i=0;i<n;i++){
			par[i]=i;
			sz[i]=1;
		}
	}
	int find(int x){
		return x==par[x]?x:par[x]=find(par[x]);
	}
	void unite(int x,int y){
		x=find(x);y=find(y);
		if(x==y)return;
		sz[x]+=sz[y];
		par[y]=x;
	}
	bool same(int x,int y){
		return find(x)==find(y);
	}
	int size(int x){
		return sz[find(x)];
	}
};

#define P2 pair<int,pair<int,int>>

signed main(){
	int N,M;
	cin>>N>>M;
	vector<int>a(M),b(M),c(M);
	priority_queue<P2,vector<P2>,greater<P2>>que;
	REP(i,M){
		cin>>a[i]>>b[i]>>c[i];
		a[i]--;b[i]--;
		que.push({c[i],{a[i],b[i]}});
	}
	int weight = 0;
	UF uf;
	uf.init(N);
	vector<vector<pair<int,int>>>g(N);
	while(que.size()){
		int cost = que.top().first;
		int from = que.top().second.first;
		int to = que.top().second.second;
		que.pop();
		if(uf.same(from,to))continue;
		uf.unite(from,to);
		g[from].push_back({to,cost});
		g[to].push_back({from,cost});
		weight += cost;
	}

	int root = -1;
	vector<vector<int>>dist(N,vector<int>(N,0));
	auto dfs = [&](auto &&f,int now,int par,int ma)->void{
		CHMAX(dist[root][now],ma);
		for(auto e:g[now]){
			if(e.first == par)continue;
			f(f,e.first,now,max(ma,e.second));
		}
	};
	REP(i,N){
		root = i;
		dfs(dfs,i,-1,0);
	}
	int Q;
	cin>>Q;
	vector<int>ans;
	while(Q--){
		int s,t;
		cin>>s>>t;
		s--;t--;
		ans.push_back(dist[s][t]);
	}
	for(auto e:ans){
		cout<<weight - e<<endl;
	}
}

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

#define ll long long
#define ull unsigned long long int
#define INF 0x3f3f3f3f
#define pb push_back
#define pii pair<int, int>

const int t = 100005;
ll memo[105][t];
ll peso[105];
ll valor[105];
int n, w;

ll solve(int id, int peguei) {
    if (peguei > w)
        return -INF;
    if (id == n)
        return 0;
    ll &ans = memo[id][peguei];
    if (ans != -1)  return ans;
    ll pegar = solve(id + 1, peguei + peso[id]) + valor[id];
    ll passar = solve(id + 1, peguei);
    ans = max(pegar, passar);
    return ans;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n >> w;
    for (int i = 0; i < n; i++) 
        cin >> peso[i] >> valor[i];
    memset(memo, -1, sizeof memo);
    cout << solve(0, 0) << "\n";
    
    //cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}

Measured memory_bytes: 82304
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to;
	ld cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y, h;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll x, ll k) {//最大値、個数
	ll sum = 1;
	for (int i = 0; i < k; i++)
		sum *= (x--);
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}
#define int long long
const long long inf = 4523372036854775807;
const int iinf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	string s;
	cin >> s;
	int sum = 0;
	for (int i = 0; i < 6; i++) {
		if (s[i] == '1') sum++;
	}
	cout << sum << endl;
	getchar(); getchar();
}

Measured memory_bytes: 256
// 1_2_B
#include <stdio.h>

void SelectionSort(int [], int);
void Display(int [], int, int);

int main(){
    int length, i;
    int numbers[100] = {};

    scanf("%d", &length);
    for(i = 0; i < length; i++){
        scanf("%d", &numbers[i]);
    }

    SelectionSort(numbers, length);

    return 0;
}

void SelectionSort(int numbers[], int length){
    int i, minj, j, minimum, cnt = 0;

    for(i = 0; i < length; i++){
        minj = i;
        for(j = i; j < length; j++){
            if(numbers[j] < numbers[minj]){
                minj = j;
            }
        }

        if(minj != i){
            minimum = numbers[minj];
            numbers[minj] = numbers[i];
            numbers[i] = minimum;
            cnt++;
        }

    }

    Display(numbers, length, cnt);

    return;
}

void Display(int numbers[], int length, int cnt){
    int i;
    for(i = 0; i < length - 1; i++){
        printf("%d ", numbers[i]);
    }
    printf("%d\n", numbers[length - 1]);
    printf("%d\n", cnt);
    return;
}

Measured memory_bytes: 600
/*************************************
 * @contest:      AGC041.
 * @user_name:    hkxadpall.
 * @time:         2019-12-28.
 * @language:     C++.
 * @upload_place: AtCoder.
*************************************/ 

#include <bits/stdc++.h>
using namespace std;

typedef signed char          int8;
typedef unsigned char       uint8;
typedef short                int16;
typedef unsigned short      uint16;
typedef int                  int32;
typedef unsigned            uint32;
typedef long long            int64;
typedef unsigned long long  uint64;

template <typename Int>
inline Int read()       
{
    Int flag = 1;
    char c = getchar();
    while ((!isdigit(c)) && c != '-') c = getchar();
    if (c == '-') flag = -1, c = getchar();
    Int init = c & 15;
    while (isdigit(c = getchar())) init = (init << 3) + (init << 1) + (c & 15);
	return init * flag;
}

template <typename Int>
inline Int read(char &c)       
{
    Int flag = 1;
    c = getchar();
    while ((!isdigit(c)) && c != '-') c = getchar();
    if (c == '-') flag = -1, c = getchar();
    Int init = c & 15;
    while (isdigit(c = getchar())) init = (init << 3) + (init << 1) + (c & 15);
	return init * flag;
}

template <typename Int>
inline void write(Int x)
{
    if (x < 0) putchar('-'), x = ~x + 1;
    if (x > 9) write(x / 10);
    putchar((x % 10) | 48);
}  

template <typename Int>
inline void write(Int x, char nextch)
{
    write(x);
    putchar(nextch);
}

long long n, v, p; long long m;
struct Prob {
    long long s;
    long long id;
    bool operator < (const Prob &b) const { return s > b.s; }
} a[100006];

int main()
{
    n = read<long long>();
    m = read<long long>();
    v = read<long long>();
    p = read<long long>();
    for (long long i = 1; i <= n; i++) {
        a[i].id = i;
        a[i].s = read<long long>();
    }
    sort(a + 1, a + n + 1);
    if (v <= p) {
        for (long long ans = p; ans <= n; ans++) {
            if (a[ans + 1].s + m < a[p].s || ans == n) {
                write(ans, 10);
                break;
            }
        }
    } else {
        long long could = (n - v) * m;
        long long sum = 0;
        long long ans = p;
        long long minn = a[p].s - m;
        while (ans <= n) {
            sum += a[ans].s;
            if (a[ans + 1].s < minn) break;
            if (sum - a[ans + 1].s * (ans - p + 1) > could) break;
            ans++;
        }
        write(min(ans, n), 10);
    }
    return 0;
}

Measured memory_bytes: 1792
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_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;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;

ll MOD = 1000000007;

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

  vi C(N);

  for (ll i = 0; i < N; i++) {
    cin >> C[i];
  }

  vi v(N, -1);

  unordered_map<ll, ll> m;
  for (ll i = 0; i < N; i++) {
    if (m.find(C[i]) != m.end()) {
      v[i] = m[C[i]];
    }
    m[C[i]] = i;
  }


  vi dp(N);
  for (ll i = 0; i < N; i++) {
    if (i == 0) {
      dp[i] = 1;
    } else {
      if (v[i] != -1 && i - v[i] > 1) {
        dp[i] = dp[i - 1] + dp[v[i]];
      } else {
        dp[i] = dp[i - 1];
      }
    }
    dp[i] %= MOD;
  }

  cout << dp[N - 1] << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> t(n + 1), x(n + 1), y(n + 1);
  t[0] = x[0] = y[0] = 0;
  int ct = 0, cx = 0, cy = 0;
  repe(i, 1, n) cin >> t[i] >> x[i] >> y[i];

  rep(i, 0, n) {
    ll dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (dist > t[i + 1] - t[i] || (dist - (t[i + 1] - t[i])) % 2 != 0) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 4164
H, W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]
move = []
cnt = 0

for i in range(H):
    for j in range(W):
        if a[i][j] % 2 == 0:
            continue
        else:
            if j != W - 1:
                a[i][j] -= 1
                a[i][j + 1] += 1
                move.append((i + 1, j + 1, i + 1, j + 2))
                cnt += 1
            else:
                if i != H - 1:
                    a[i][j] -= 1
                    a[i + 1][j] += 1
                    move.append((i + 1, j + 1, i + 2, j + 1))
                    cnt += 1

print(cnt)
for i in move:
    print(*i)


Measured memory_bytes: 28664
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut 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)*}
    };
}

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

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,
        r: usize,
    }
    if n >= 10 {
        println!("{}", r);
    }
    else {
        println!("{}", r + 100 * (10 - n));        
    }
}


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

int main() {
    long i,a,b,c,d;
    c = 0;
    d = 0;
    cin >> a;


    for(i=0;i < a;i++){
        cin >> b;
        if(b < c){
            d += c - b;
        }else{
            c = b;
        }
    }
    cout << d;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>

using namespace std;

int main()
{
  int64_t K;
  int64_t N;
  vector<int64_t> A;

  cin >> K >> N;
  A.resize(N);

  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  sort(A.begin(), A.end());
  A.push_back(A.back());

  int64_t max_distance = 0;
  for (int i = 0; i < N; i++) {
    max_distance = max(max_distance, A[i + 1] - A[i]);
  }
  max_distance = max(max_distance, A.front() - A.back() + K);

  cout << K - max_distance << endl;

  return 0;
}


Measured memory_bytes: 4864
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<string.h>
#include<math.h>
#include<stdio.h>
#include<queue>
#include<utility>
#include<cstdio>
#include<cstring>
#include<new>
#include<float.h>
#include<ctype.h>
#include<cfloat>
#include<cmath>
#include<cctype>
#include<sstream>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define sz size()
#define em empty()
#define ct continue
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
int a[101010],b[101010];
int main(){
	int n,t,ans=10101010;
	cin>>n>>t;
	fo(i,0,n){
		cin>>a[i]>>b[i];
		if(b[i]<=t)ans=min(ans,a[i]);
	}
	if(ans<1010101)cout<<ans<<endl;
	else cout<<"TLE"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
	
	int n;
	char s[1000];
	scanf("%d",&n);
	scanf("%s",s);
	if(n>=strlen(s)){
		printf("%s\n",s);
	}else{
		for(int i=0; i<=n; i++){
			if(i==n){
				puts("...");
			}else{
				printf("%c",s[i]);	
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 1664
from sys import stdin

s = stdin.readline().rstrip()

ma = 0
point = 1
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        point += 1
    else:
        ma = max(point,ma)
        point = 1

ma = max(point,ma)
if ma <= 2:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//#include <boost/lexical_cast.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define pb push_back
#define mp make_pair
#define endl '\n'
#define PI acos(-1)
#define P pair<int,int>
typedef tree<int,null_type,less_equal <int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

long mod=1e9+7;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,m;
	cin>>n>>m;
	int a[n+2]={0};
	for(int i=0;i<m;i++)
	{
		int l,r;
		cin>>l>>r;
		++a[l];--a[r+1];

	}
	for(int i=1;i<n+2;i++)
	{
        a[i]=a[i-1]+a[i];
        // cout<<a[i];
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==m)
			++ans;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
  int A,B,K;
  cin >> A >> B;
  if ((A + B) % 2) {
    cout << "IMPOSSIBLE" << endl;
  } else {
    cout << max(A, B) - ((max(A, B) - min(A, B))/2) << endl;
  }
  return 0;
}

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

int main() {
    int N, M, C;
    cin >> N >> M >> C;

    vector<vector<int>> A(N, vector<int>(M));
    vector<int> B(M);
    rep(i, M) cin >> B[i];
    rep(i, N) rep(j, M) cin >> A[i][j];

    int res = 0;
    rep(i, N) {
        int sum = 0;
        rep(j, M) {
            sum += A[i][j] * B[j];
        }
        sum += C;
        if(sum > 0) res++;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;

string s;
int a[26],b[26];
string alpha="abcdefghijklmnopqrstuvwxyz";
int main(){
  cin>>s;
  int n=s.size();
  rep(i,n){
    a[s[i]-'a']++;
  }
  int cnt=0;
  rep(i,n){
    cnt+=a[i];
  }
  if(cnt==26){
    if(s=="zyxwvutsrqponmlkjihgfedcba"){
      cout<<-1<<endl;
      return 0;
    }

    bool cnt[26] = {};
    for (int i = 25; i >= 0; i--) {
      cnt[s[i] - 'a'] = true;
      for (char j = s[i] + 0x1; j <= 'z'; j++) {
        if (!count(begin(s), begin(s) + i, j)) {
          s[i] = j;
          s = s.substr(0, i + 1);
          break;
        }
      }
      if (!cnt[s[i] - 'a']) {
        break;
      }
      cnt[s[i] - 'a'] = false;
    }
      cout << s << "\n";
  }else{
    cout<<s;
    rep(j,26){
      if(a[j]==0){
        cout<<alpha[j]<<endl;
        return 0;
      }
    }
  }


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
ll mod= 1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ll R[21];
ll a[40000],b[40000],c[40000];
main(){
    ll n,m,r,ans=1e10;
    cin>>n>>m>>r;
    rep(i,0,r)cin>>R[i];
    rep(i,0,m)cin>>a[i]>>b[i]>>c[i];
    ll dp[220][220];
  	rep(i,0,220){
		rep(j,0,220){
			if(i==j)dp[i][j]=0;
			else if(i!=j) dp[i][j]=100000000;
		}
	}
  rep(i,0,m) dp[a[i]][b[i]]=c[i];
	rep(i,0,m) dp[b[i]][a[i]]=c[i];
  rep(k,0,n+1){
		rep(i,0,n+1){
		rep(j,0,n+1){
			dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
		}
	}
}
  sort(R,R+r);
  do{
    ll tmp=0;
    rep(i,1,r)tmp+=dp[R[i]][R[i-1]];
    ans=min(ans,tmp);
  }while(next_permutation(R,R+r));
  cout<<ans;
}

Measured memory_bytes: 1152
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N = getN()
A = sorted(getArray(N))
A = deque(A)
ans_list = deque([])

cnt = 0
for i in range(N // 2):

    m = A.popleft()
    if cnt % 2 == 0:
        ans_list.append(m)
    else:
        ans_list.appendleft(m)

    m = A.pop()
    if cnt % 2 == 0:
        ans_list.appendleft(m)
    else:
        ans_list.append(m)
    cnt += 1

if N % 2 == 1:
    m = A.pop()
    opt1 = abs(ans_list[0] - m)
    opt2 = abs(ans_list[-1] - m)

    if opt1 >= opt2:
        ans_list.appendleft(m)
    else:
        ans_list.append(m)

ans_list = list(ans_list)
ans = 0
for i in range(N - 1):
    ans += abs(ans_list[i + 1] - ans_list[i])
print(ans)

Measured memory_bytes: 73048
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int main(void) {
	int Rn,Wn,C,R;
	cin >> Rn;
	cin >> Wn;
	cin >> C;
	cin >> R;

	while (Rn!=0||Wn!=0||C!=0||R!=0) {
		bool F = false;
		int X;
		for (int i = 0; !F; i++) {
			if ((Rn+R*i) >= Wn*C) {
				X = i;
				F = true;
			}
		}
		cout << X << endl;

		cin >> Rn;
		cin >> Wn;
		cin >> C;
		cin >> R;
	}
	return 0;
}

Measured memory_bytes: 3084
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    string S; cin >> S;
    int N = S.size();

    int ans = 1;
    string pre = {S[0]};
    FOR(i,1,N) {
        string cur = {S[i]};
        bool ok = true;
        while(pre==cur) {
            i++;
            if (i>=N) {
                ok = false;
                break;
            }
            cur += S[i];
        }

        if(ok) ans++;
        pre = cur;
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;
	cin >> n;
	int sum = 0;
	vector<int> a(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	int ave = round(float(sum)/float(n));
	int ans = 0;

	for(int i = 0; i < n; i++) {
		ans += (a[i] - ave)*(a[i] - ave);
	}
	cout << ans << endl;
	return 0;
}

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


#define ll long long 
ll dp[3001][3001];
ll solve(ll a[],int i, int j){

    if(i>j){

        return 0;
        
    }

    if(dp[i][j]!=-1){
        return dp[i][j];

    }

    if(i==j){
        return a[i];
    }

    return dp[i][j]=max(a[i]+min(solve(a,i+2,j),solve(a,i+1,j-1)),a[j]+min(solve(a,i+1,j-1),solve(a,i,j-2)));

}

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

   ll a[n];
   ll sum=0;

   for(int i=0;i<n;i++){
       cin>>a[i];
       sum+=a[i];
   }
   
   memset(dp,-1,sizeof(dp));


   


   ll X=solve(a,0,n-1);
   ll Y=sum-X;
   cout<<(X-Y);






}


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

const int INF = 10000000;

int main (){
  
  //入力受け取り
  int n, m;
  cin >> n >> m;
  
  int a[1000], b[1000], c[1000];
  int dist[100][100];
  
  rep(i,m){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--, b[i]--;
  }
  
  //距離の初期化
  rep(i,n)rep(j,n){
    if(i == j) 
      dist[i][j] = 0;
    else 
      dist[i][j] = INF;
  }
  
  //辺の距離を代入
  rep(i,m){
    dist[a[i]][b[i]] = c[i];
    dist[b[i]][a[i]] = c[i];
  }
  
  //最短経路を求める
  rep(k,n)rep(i,n)rep(j,n){
    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  }
  
  //辺が使われているか判定
  int ans = m;
  rep(i,m){
    rep(j,n){
      if(dist[j][a[i]] + c[i] == dist[j][b[i]]){
        ans--;
        break;
      }
    }
  }
  
  //出力
  cout << ans << endl;
  return 0;
}

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

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int ans = a*b;
  if(ans%2==0)cout << "No" << endl;
  else cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
#define F first
#define S second

int a[200009],b[200009],c[200009],n,m,C;
vector<P>v[100009];
int dist[100009];

void dij(){
  r(i,100009)dist[i]=1e16;
  priority_queue<P,vector<P>,greater<P> >q;
  dist[0]=0;
  q.push(P(0,0));
  while(!q.empty()){
    P p=q.top();q.pop();
    int cost=p.F;
    int now=p.S;
    r(i,v[now].size()){
      int ncos=cost+v[now][i].S;
      int nex=v[now][i].F;
      if(dist[nex]>ncos){
        dist[nex]=ncos;
        q.push(P(ncos,nex));
      }
    }
  }
}

signed main(){
  int sum=0;
  cin>>n>>m>>C;
  r(i,m){
    cin>>a[i]>>b[i]>>c[i]; a[i]--; b[i]--;
    sum += c[i];
    v[a[i]].push_back(P(b[i],c[i]));
    v[b[i]].push_back(P(a[i],c[i]));
  }
  dij();
  P A[m+1];
  r(i,m){
    A[i].F = max(dist[a[i]],dist[b[i]]);
    A[i].S = c[i];
  }
  A[m]=P(1e16,1e16);
  sort(A,A+m+1);
  int ans=sum;
  r(i,m){
    while(A[i].F==A[i+1].F)sum-=A[i++].S;
    sum-=A[i].S;
    ans=min(ans,C*A[i].F+sum);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 24112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int H, W; cin >> H >> W;
    vector<string> s(H);
    for(int i=0; i<H; ++i) cin >> s[i];

    for(int i=0; i<H; ++i){
        cout << s[i] << endl << s[i] << endl;
    }
}

Measured memory_bytes: 256
using System;
using static System.Console;

class Program
{

    static void Main(string[] args)
    {
        var input = Array.ConvertAll(ReadLine().Split(),int.Parse);
        var n = input[0];
        var k = input[1];

        long count = 0L;


        //余りがゼロ
        long temp = n / k;
        count += temp * temp * temp;


        if (k % 2 == 0)
        {
            temp = 0;
            //余りがk/2
            for (var i = 1; i <= n; i++)
            {
                if (i % k == k / 2) temp++;
            }
            count += temp * temp * temp;
        }

        WriteLine(count);
    }
}

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

int main(){
	int h,n;
	scanf("%d%d",&h,&n);
	int sum=0,arr;
	for(int i=0;i<n;i++){
		scanf("%d",&arr);
		sum+=arr;
	}
	if(sum>=h)printf("Yes");
	else printf("No");
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	ll n = s.size();
	if(s == "keyence") {
		cout << "YES" << endl;
		return 0;
	}
	REP(i, n) FOR(j, i, n) {
		string t = "";
		REP(k, n) {
			if(k < i || k > j) t += s[k];
		}
		if(t == "keyence") {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

/* --------------------------------------- */


Measured memory_bytes: 256
import java.util.Scanner;

class Main{

    static Scanner scan;

    public static void main(String[] args) {
        scan = new Scanner(System.in);

        int[] n = new int[3];
        for (int i = 0; i < n.length; i++) {
            n[i] = scan.nextInt();
        }

        if (n[0] > n[1]) { n = swap(n, 0, 1); }
        if (n[0] > n[2]) { n = swap(n, 0, 2); }
        if (n[1] > n[2]) { n = swap(n, 1, 2); }

        System.out.printf("%d %d %d\n", n[0], n[1], n[2]);
    }

    static int[] swap(int[] n, int i, int j) {
        int tmp = n[i];
        n[i] = n[j];
        n[j] = tmp;

        return n;
    }
}



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

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

    if (s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}


Measured memory_bytes: 3624
import scala.collection.mutable

object Main extends App {

  import scala.io.StdIn._

  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val edges = Array.tabulate(n){_ ⇒ Nil: List[Int]}
  val inEdge = Array.tabulate(n){_ ⇒ 0}
  for (_ ← 0 until m){
    val Array(x, y) = readLine.trim.split(' ').map(_.toInt)
    edges(x - 1) ::= y - 1
    inEdge(y - 1) += 1
  }
  var count = -1
  var currents: List[Int] = inEdge.indices.filter(p ⇒ inEdge(p) == 0).toList
  while (currents.nonEmpty) {
    count += 1
    var nexts = Nil: List[Int]
    for (c ← currents){
      for (n ← edges(c)){
        inEdge(n) -= 1
        if (inEdge(n) == 0){
          nexts ::= n
        }
      }
    }
    currents = nexts
  }
  println(count)
  implicit class Extend[T](value: T){
    def also(func: T ⇒ Unit): T = {func(value); value}
    def let[A](func: T ⇒ A): A = func(value)
  }
}

Measured memory_bytes: 62272
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int MOD = 1000000007;
ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}
ll kj(ll x){
    ll s = 1;
    for(ll i = 1; i <= x; i++){
        s = s * i % MOD;
    }
    return s;
}
ll combination(ll a, ll b){
    if(a == 0 && b == 0) return 1;
    if(a < b || a < 0) return 0;
    return (kj(a) * mpow(kj(b), MOD-2) % MOD) * mpow(kj(a-b), MOD-2) % MOD;
}


int main(){
    int N,K;
    cin >> N >> K;
    int Sepa;
    for(int i=1; i <= K; i++){
        cout <<  combination(N-K+1,i) % MOD * combination(K-1,i-1) % MOD << endl;
    }
}


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

int main()
{
	int n;
	cin >> n;
	auto a = vector<long long int>(n + 1);
	for(auto i = 1; i <= n; ++i){
		cin >> a[i];
		a[i] += a[i - 1];
	}
	long long int ans = 10000000000;
	for(auto i = 1; i <= n - 1; ++i){
		ans = min(ans, abs(a[n] - a[i] * 2));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
h,w=map(int,input().split())
INF=10**10
a=[[INF for i in range(w)] for j in range(h)]
ans=0
for i in range(h):
    s=input()
    for j in range(w):
        if s[j]=="#":
            a[i][j]=0
            
for i in range(h):
    for j in range(w):
        k=a[i][j]+1

        if i!=h-1:
            if k<a[i+1][j]:
                a[i+1][j]=k
        if j!=w-1:
            if k<a[i][j+1]:
                a[i][j+1]=k

for i in range(h):
    for j in range(w):
        k=a[-1-i][-1-j]+1
        if i!=h-1:
            if k<a[-i-2][-j-1]:
                a[-i-2][-j-1]=k

        if j!=w-1:        
            if k<a[-i-1][-j-2]:
                a[-i-1][-j-2]=k

for i in range(h):
    ans=max(ans,max(a[i]))
print(ans)

Measured memory_bytes: 55512
#include <stdio.h>

int main(){
    int hex[] = {10,11,12,13,14,15};
    char a, b, c;
    scanf("%c %c", &a, &b);
    if(a > b) c = '>';
    else if(a == b) c = '=';
    else c = '<';
    printf("%c\n", c);
//    printf("%d%c%d.\n",hex[a-'A'],c,hex[b-'A']);
    return 0;
}


Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10000)
n = int(input())
*A, = map(int, input().split())
# n = 4
# A = [1, 3, 4, 2]
# n = 6
# A = [5, 5, 6, 1, 1, 1]
# n = 6
# A = [8, 6, 9, 1, 2, 1]
# n = 2000
# A = [10**9]*n
A = [(a, i) for i, a in enumerate(A)]
A.sort(reverse=True)
DP = [[None for r in range(n+1)] for l in range(n+1)]


def dp(l, r):
    if l == r:
        DP[l][r] = 0
    if DP[l][r] != None:
        return DP[l][r]
    a, i = A[n-(r-l)]
    x = dp(l+1, r)+a*abs(i-l)
    y = dp(l, r-1)+a*abs(i-r+1)
    DP[l][r] = max(x, y)
    return DP[l][r]


print(dp(0, n))


Measured memory_bytes: 209816
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

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

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (auto &&i : a) scanf("%d", &i);
    for (auto &&j : b) scanf("%d", &j);
    vector<int> X(n);
    iota(X.begin(),X.end(), 1);
    int cnt = 1, p = 0, q = 0;
    do {
        if(a == X) p = cnt;
        if(b == X) q = cnt;
        cnt++;
    }while(next_permutation(X.begin(),X.end()));
    cout << abs(p-q) << "\n";
    return 0;
}

Measured memory_bytes: 256
import heapq

n, m = map(int, input().split())
memo = [[] for _ in range(m+1)]

for _ in range(n):
    a, b = map(int ,input().split())
    if a <= m:
        memo[a].append(-b)

ans = 0
HQ = []
heapq.heapify(HQ)
for i in range(1, m+1):
    for j in memo[i]:
        heapq.heappush(HQ, j)
    if HQ:
        ans += heapq.heappop(HQ)

print(-ans)

Measured memory_bytes: 88740
#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<deque>
#define ll long long
using namespace std;
#define BUF_SIZE 1048576
char _buf[BUF_SIZE],*_is=_buf,*_it=_buf;
inline char rdc(){
	if (_is==_it) _it=(_is=_buf)+fread(_buf,1,BUF_SIZE,stdin);
	return *_is++;
}
inline int rdi(){
	int x=0,f=0;
	register char ch=rdc();
	while ((ch<'0' or ch>'9') and (ch^'-')) ch=rdc();
	if (ch=='-') f=1,ch=rdc();
	while (ch>='0' and ch<='9') x=(x<<3)+(x<<1)+(ch^'0'),ch=rdc();
	return f?-x:x;
}
inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void _write(int x){
	write(x);
	putchar(' ');
}
inline void print(int x){
	write(x);
	putchar('\n');
}
double dp[333][333][333];
int n,a,b,c;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	n=rdi();
	int i,j,k;
	for(i=1;i<=n;++i){
		int t;
		t=rdi();
		if(t==1) ++a;
		else if(t==2) ++b;
		else ++c;
	}
	for(k=0;k<=n;++k){
		for(j=0;j<=n;++j){
			for(i=0;i<=n;++i){
				if(0<i+j+k and i+j+k<=n){
					if(i) dp[i][j][k]+=dp[i-1][j][k]*i;
					if(j) dp[i][j][k]+=dp[i+1][j-1][k]*j;
					if(k) dp[i][j][k]+=dp[i][j+1][k-1]*k;
					dp[i][j][k]=(n+dp[i][j][k])/(i+j+k);
				}
			}
		}
	}
	cout<<fixed<<setprecision(9)<<dp[a][b][c]<<endl;
	return 0;
}

Measured memory_bytes: 262272
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 200020
 
 
#define PI 3.14159265358979323846264338327950
 
#define ll   long long int
ll mod = 1000000007;
ll a[MAXX], b[MAXX];
char str[MAXX];
 
int main()
{
	FAST;
	ll n, k, ans = 0;
	cin >> n;
	cin >> a[0];
	k = a[0];
	for(ll i = 1; i < n; i++){
		cin >> a[i];
		k ^= a[i];
	}
	for(ll i = 0; i < n; i++){
		ll t = k;
		t ^= a[i];
		cout << t << " ";
	}
	
	
}

Measured memory_bytes: 5188
N,M = (int(x) for x in input().split())
hight = [int(x) for x in input().split()]
tenbou = [input().split() for l in range(M)]
result = [1] * N


for i in range(M):
    x = int(tenbou[i][0]) - 1
    y = int(tenbou[i][1]) - 1
    if hight[x] > hight[y]:
        result[y] = 0
    elif hight[y] == hight[x]:
        result[x] = 0
        result[y] = 0
    elif hight[y] > hight[x]:
        result[x] = 0
#print(result)
print(result.count(1))

Measured memory_bytes: 43200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M = 1e6+3;
inline ll mul(ll a, ll b) {return (a*b)%M;}
ll bp(ll b, ll p) {
	ll ac = 1;
	while(p) {
		if(p&1) {
			ac = mul(ac,b);
		}
		b = mul(b,b);
		p >>= 1;
	}
	return ac;
}
ll fac[M+10];
void pre() {
	ll rs = 1;
	fac[0] = rs;
	for(int i=1;i<M;i++) {
		rs = mul(rs,i);
		fac[i] = rs;
	}
}
inline ll inv(ll v) {
	return bp(v,M-2);
}
ll fa(ll v, ll d) {
	if(v >= M) {return 0;}
	return mul(bp(d,v),fac[v]);
}
ll solve(ll x, ll d, ll n) {
	if(d == 0) {
		return bp(x,n);
	}
	if(x == 0) return 0;
	ll id = mul(x,inv(d));
	id = (id+M-1)%M;
	return mul(inv(fa(id,d)),fa(id+n,d));
}
int main() {
	ios::sync_with_stdio(0);
	ll q;
	cin >> q;
	pre();
	while(q--) {
		ll a,b,c;
		cin >> a >> b >> c;
		cout << solve(a,b,c) << '\n';
	}
}

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

int main() {
  string s;
  cin >> s;
  if (s == "SAT") cout << 1 << endl;
  if (s == "FRI") cout << 2 << endl;
  if (s == "THU") cout << 3 << endl;
  if (s == "WED") cout << 4 << endl;
  if (s == "TUE") cout << 5 << endl;
  if (s == "MON") cout << 6 << endl;
  if (s == "SUN") cout << 7 << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
signed main(){
    int n; cin>>n;
    vector <int> s(n);
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    vector <int> c;
    int ans = 0;
    int cnt = 0;
    for(int i=0;i<n;i++){
        cnt++;
        if(i==n) break;
        if(s[i]!=s[i+1]) {c.push_back(cnt); cnt=0;}
    }
    
    if(cnt) c.push_back(cnt); 
    for(int i=0;i<c.size();i++){
        ans+=c[i]/2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include <functional>
#include <queue>
#include <regex>

using namespace std;

constexpr int MOD = 1000000007;
constexpr int INF = 1050000000;

#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 Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;


/*vectorの要素を全部確認するやつだよ。


for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}


*/


/*for文でx,yを上下左右確認するやつだよ。

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


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}
*/

/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}


*/

/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; i++) {
	for (int j = 0; j < w; j++) {

	}
}

*/

int main(void) {
	int r, g, b, n; cin >> r >> g >> b >> n;


	ll ans = 0;

	for (int i = 0; i <= n; i++) {
		int x = i * r;
		for (int j = 0; j <= n; j++) {
			int y = j * g;


			if (x + y > n) { continue; }

			if ((n - (x + y)) % b == 0) { ans++; }
		}
	}




	cout << ans << endl;









}

Measured memory_bytes: 256