akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	int ans=0;
	int mi=1e9;
	for(int i=0;i<n;i++){
		int a; cin >> a;
		if(mi>a){
			mi=a;
			ans++;
		}
	}
	cout << ans << endl;
}

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

#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;//print
using namespace std;

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int n;
    int ans = 1;
    cin >> n;
    while(n>1){
        n=n/2;
        ans = ans*2;
    }
    P(ans);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = [input() for x in range(n)]
m = int(input())
t = [input() for x in range(m)]
ans = 0
for i in range(n):
	counter = 0
	for u in range(n):
		if s[i] == s[u]:
			counter += 1
	for x in range(m):
		if s[i] == t[x]:
			counter -= 1
	if ans <= counter:
		ans = counter
print(ans)

Measured memory_bytes: 3064
using System;

class Program{
  static void Main(string[] args){
    var array = Console.ReadLine().Split(' ');
    var A = int.Parse(array[0]);
    var B = int.Parse(array[1]);
    var C = int.Parse(array[2]);
    var X = int.Parse(array[3]);
    var Y = int.Parse(array[4]);
    var sum = 0;
    if(X>Y){
      if(A+B > 2*C){
        sum += 2 * C * Y;
      }
      else{
        sum += (A + B) * Y;
      }
      if(A > 2 * C){
        sum += 2*C*(X-Y);
      }
      else{
        sum += A * (X-Y);
      }
    }
    else{
      if(A+B > 2*C){
        sum += 2 * C * X;
      }
      else{
        sum += (A + B) * X;
      }
      if(B > 2 * C){
        sum += 2*C*(Y-X);
      }
      else{
        sum += B * (Y-X);
      }
    }
    Console.WriteLine(sum);
  }
}

Measured memory_bytes: 13140
#include <cstdio>
#include <cstdint>
#include <vector>

constexpr intmax_t mod = 1e9+7;

namespace detail {
template <typename Tp, size_t N>
std::vector<Tp> make_vector(
    std::vector<size_t>& sizes,
    typename std::enable_if<(N == 1), Tp const&>::type x
) {
  return std::vector<Tp>(sizes[0], x);
}
template <typename Tp, size_t N>
auto make_vector(
    std::vector<size_t>& sizes,
    typename std::enable_if<(N > 1), Tp const&>::type x
) {
  size_t size = sizes[N-1];
  sizes.pop_back();
  return std::vector<decltype(make_vector<Tp, N-1>(sizes, x))>(
      size, make_vector<Tp, N-1>(sizes, x)
  );
}
}  // detail::

template <typename Tp, size_t N>
auto make_vector(size_t const(&sizes)[N], Tp const& x) {
  std::vector<size_t> s(N);
  for (size_t i = 0; i < N; ++i) s[i] = sizes[N-i-1];
  return detail::make_vector<Tp, N>(s, x);
}

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
// constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

int main() {
  size_t n, k;
  scanf("%zu %zu", &n, &k);

  auto dp = make_vector<intmax_t>({k+1, n+1}, 0_jd);
  dp[0][0] = 1;
  for (size_t i = 1; i <= k; ++i) {
    for (size_t j = 0; j <= n; ++j) {
      dp[i][j] = dp[i-1][j];
      if (j >= i)
        (dp[i][j] += dp[i][j-i]) %= mod;
    }
  }

  printf("%jd\n", dp[k][n]);
}



Measured memory_bytes: 10376
# ABC 093: B – Small and Large Integers
a, b, k = [int(s) for s in input().split()]

if k >= b - a + 1:
    for c in list(range(a, b + 1)):
        print(c)
else:
    s = set(list(range(a, a + k)) + list(range(b - k + 1, b + 1)))
    list_s = list(s)
    list_s.sort()

    for c in list_s:
        print(c)

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

const int INF = 0x3f3f3f3f;
const int MAXN = 112345;

int n, m;
vector<int> adj[MAXN];
int pd[MAXN];

int rec(int cur)
{
	if(pd[cur]!=-1)
		return pd[cur];

	int rtn = 0;
	for(int i=0; i<adj[cur].size(); i++)
	{
		rtn = max(1 + rec(adj[cur][i]), rtn);
	}

	return pd[cur] = rtn;
}

int main() {
	memset(pd, -1 , sizeof(pd));

	cin >> n >> m;

	for(int i=0; i<m; i++){
		int a,b;
		cin >> a >> b;
		adj[a].push_back(b);
	}

	int resp = 0;
	for(int i=1; i<=n; i++)
		resp = max(resp, rec(i));
	cout << resp << endl;

	return 0;
}

Measured memory_bytes: 8448
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();

    int sum = 0;
    for (int i = 0; i < n; i++) {
      if (i < k) {
        sum = sum + x;
      } else {
        sum = sum + y;
      }
    }

    System.out.println(sum);
  }
}


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

int main() {
  int N;
  cin>>N;
  string s;
  cin>>s;
  for (int i = 0; i < s.size(); i++) {
    int x=s.at(i)-'A';
    x=(x+N)%26;
    char b='A'+x;
    cout<<b;
  }  
}

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

using namespace std;

int main() {
	
  int x;
  int ans;
  int t = 1;
  int max;

	cin >> x;

  for (int i = x; i >= 1; i--) {
    if (x == 1) {
      cout << 1 << endl;
      return 0;
    }

    for (int j = 2; j <= 31; j++) {
      t = j;
      for (int k = 1; k <= 10; k++) {
        t *= j;
        if (t > i) {
          break;
        }
        if (t == i) {
          cout << t << endl;
          return 0;
        }
      }
    }
  }

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dp[505][505];
int main(){
	int n, m, q;
	scanf("%d%d%d", &n, &m, &q);
	for(int i=1;i<=m;i++){
		int l, r;
		scanf("%d%d", &l, &r);
		dp[l][r]++;
	}
	for(int i=2;i<=n;i++){
		for(int j=1;j<=n;j++){
			int l = j, r = j+i-1;
			dp[l][r] += dp[l][r-1] + dp[l+1][r] - dp[l+1][r-1];
		}
	}
	for(int i=1;i<=q;i++){
		int u, v;
		scanf("%d%d", &u, &v);
		printf("%d\n", dp[u][v]);
	}
}

Measured memory_bytes: 1920
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
a = list(map(int,input().split()))

bc =[]
for i in range(m):
    b,c = map(int,input().split())
    bc.append((b,c))

bc.sort(key=lambda x:x[1],reverse=True)
newcard=[]
for b,c in bc:
    newcard.extend([c]*b)
    if(len(newcard)>=n):
        break
a += newcard
a.sort(reverse=True)
print(sum(a[:n]))

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

int main(){
  int N,count,finally,x;
  cin >> N;
  for(int i=0 ; i<N ; i++ ){
    cin >> x;
    while(x%2 == 0){
      count++;
      x /= 2;
    }
    if(i == 0) finally = count;
    else if(count < finally) finally = count;
    count = 0;
  }
  cout << finally;
    
}  

Measured memory_bytes: 256
import           System.IO
import           Text.Printf
import           Data.List
import           Control.Monad

list n =
  [ (a, b, c, d)
  | a <- [0 .. 9]
  , b <- [0 .. 9]
  , c <- [0 .. 9]
  , d <- [0 .. 9]
  , a + b + c + d == n
  ]

main = do
  n <- readLn
  print $ length $ list n
  eof <- isEOF
  unless eof $ main


Measured memory_bytes: 4100
#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<queue>
#include<map>

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef double db;
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mp make_pair
#define case_for(n) for(int i = 1 ; i <= n ; i ++) { cout<<"Case "<<i<<": "<<endl; solve();}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll power(ll a, ll b, ll p) { ll ans = 1; while (b) { if (b & 1) ans = ans * a % p; a = a * a % p, b /= 2; }return ans; }
int hw_check(string a, int l, int r) { int ans = r - l + 1; for (l, r; l < r; l++, r--)if (a[l] != a[r]) return 0; return ans; }
string movesubstr(string a, int l, int r) { string s = "";	for (int i = l; i <= r; i++) s.push_back(a[i]);	return s; }

const int N = 2e5 + 15;
int a[N], b[N], c[N];
map<int, int>bs;

void solve()
{
	int n; cin >> n;
	//vector<int>a(n + 15),b(n + 15),c(n + 15);
	for (int i = 1; i <= n ; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) b[i] = a[i] - i , bs[b[i]]++;
	for (int i = 1; i <= n; i++) c[i] = a[i] + i;
	sort(c + 1, c + n + 1);
	ll res = 0;
	for (int i = 1; i <= n; i++)
	{
		res += bs[-1 * c[i]];
		
	}
	cout << res << endl;
}
	
/*
3 3
3 3 3
4 1 3
4 1 3
*/
int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(nullptr),cout.tie(0);

	/*int t; cin >> t;
	while (t--) 
	{
		solve();
	}*/
	solve();
	return 0;
}
/*

*/

Measured memory_bytes: 22860
S = input()

modList = [0] * 2019 # あまりは0～2018の2019個

ans = 0

modList[0] = 1 # 解答でいうT(n)=0 の場合

# 最大20万回ループ、時間かかるならＤＰする？
# ↓ではTLEになった
# for i in range(len(S)):
#     m = int(S[i:]) % 2019
#     modList[m] += 1

# ↓　これでもTLEになった
# T = 0
# for i in range(1,len(S)+1):
#     # T += int(S[-i]) * 10**i
#     T += int(S[-i]) * ((10**i) % 2019)
#     modList[T % 2019] +=1

T = 0
a = 1
for s in S[::-1]:
    T = T+int(s) * a
    modList[T%2019]+=1
    a*=10
    a%=2019
#print(modList)

for j in modList:
    if j <= 1:
        continue
    else:
        ans += j*(j-1)/2

print(int(ans))


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

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

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

  int ans = 800 * n - 200 * (n / 15);

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
	int n, f = 0, m;
	cin >> n;
	m = n;
	while (n > 0) {
		f += n % 10;
		n /= 10;
	}
	if (m % f == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
while True:
	try:
		a, b, c, d, e, f = map(int, input().split())
	except EOFError:
		break
	print(format(round((c*e-b*f)/(a*e-b*d)+0.,3), ".3f"), format(round((a*f-c*d)/(a*e-b*d)+0.,3), ".3f"), sep=" ")


Measured memory_bytes: 5620
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    string S, A, B;
    cin >> S;
    int Q, T = 0, F = 0, cnt = 0;
    char C;
    cin >> Q;
    for(int i = 0; i < Q; ++i){
        cin >> T;
        if(T == 1) cnt++;
        else if (T == 2){
            cin >> F >> C;
            if(F == 1 && cnt % 2 == 0) A = C + A;
            else if(F == 2 && cnt % 2 == 0) B = B + C;
            else if(F == 1 && cnt % 2 == 1) B = B + C;
            else if(F == 2 && cnt % 2 == 1) A = C + A;
        }
    }
    S = A + S + B;
    if(cnt % 2 == 1) reverse(S.begin(), S.end());
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 1512
# coding:utf-8

import sys
import math
INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n, m = LI()
    A = LI()
    A.sort()
    A.reverse()

    match = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
    # dp[i]: ちょうどマッチをi本使ったときに作れる整数の最大の桁数（-1: 作れない）
    dp = [-1] * (n + 1)
    dp[0] = 0
    res = [0] * (n + 1)
    for i in range(1, n + 1):
        for j in A:
            # 最上位桁の数字を決める
            # k: 最上位桁をjにしたときの残りのマッチの数
            k = i - match[j]
            if k < 0 or dp[k] == -1:
                continue

            if dp[i] < dp[k] + 1:
                dp[i] = dp[k] + 1
                res[i] = j * 10 ** dp[k] + res[k]

    return res[n]


print(main())


Measured memory_bytes: 15092
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
int h,w;
vector<string> f;
const int INF = 1001001001;
int dp[110][110];
int rec(int x,int y){
    //x,yから始めたときの場合の数
    if(x == h-1 && y == w-1)return 0;
    if(dp[x][y] != -1)return dp[x][y];
    int ret = INF;
    if(f[x][y] == '.'){
        if(x + 1 < h)ret = min(ret,rec(x+1,y) + (int)(f[x+1][y] != f[x][y]));
        if(y + 1 < w)ret = min(ret,rec(x,y+1) + (int)(f[x][y+1] != f[x][y]));

    }
    else {
        if(x+1 < h)ret = min(ret,rec(x+1,y));
        if(y+1 < w)ret = min(ret,rec(x,y+1));
    }
    
    return dp[x][y] = ret;
}
signed main(){
    cin >> h >> w;
    f.resize(h);
    rep(i,h)cin >> f[i];
    rep(i,110)rep(j,110)dp[i][j] = -1;
    cout<< rec(0,0)+(int)(f[0][0] == '#') << endl;
    
    return 0;
}

Measured memory_bytes: 3748
a, b, c, d = map(int, input().split())
if c <= a <= d <= b:
    print(d - a)
elif a <= c <= d <= b:
    print(d - c)
elif c <= a <= b <= d:
    print(b - a)
elif a <= c <= b <= d:
    print(b - c)
else:
    print(0)


Measured memory_bytes: 2940
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

template <class T>
vector<T> sumup(const vector<T>& a) {
  int N = a.size();
  vector<T> res(N + 1);
  for (int i = 0; i < N; i++) res[i + 1] = res[i] + a[i];
  return res;
}

bool check(const vector<ll>& A, ll g, ll K) {
  vector<ll> r = A;
  for (ll& x : r) x %= g;
  sort(r.begin(), r.end());
  auto sum = sumup(r);
  if (sum.back() == 0) return true;
  for (int i = 1; i < A.size(); i++) {
    ll a = sum[i];
    ll b = (A.size() - i) * g - (sum.back() - a);
    if (max(a, b) <= K) return true;
  }
  return false;
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  ll K;
  while (cin >> N >> K) {
    vector<ll> A(N);
    for (ll& x : A) cin >> x;
    ll S = accumulate(A.begin(), A.end(), 0ll);
    ll res = 1;
    for (ll g = 1; g * g <= S; g++) {
      if (S % g != 0) continue;
      if (check(A, g, K)) chmax(res, g);
      if (check(A, S / g, K)) chmax(res, S / g);
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
	ll N;
	cin >> N;
	vector<vector<pair<ll, ll>>> connect(N);
	for (ll i = 0; i < N - 1; i++) {
		ll u, v, w;
		cin >> u >> v >> w;
		u--; v--;
		connect[u].push_back({ v, w });
		connect[v].push_back({ u, w });
	}

	for (ll init = 0; init < 1; init++) {
		vector<ll> color(N, -1);
		color[0] = init;
		stack<ll> st;
		st.push(0);

		bool ok = true;
		while (!st.empty() && ok) {
			ll curr = st.top();
			st.pop();

			for (auto next : connect[curr]) {
				ll c = (next.second % 2 == 0 ? color[curr] : 1 - color[curr]);
				if (color[next.first] != -1 && color[next.first] != c) {
					ok = false;
					break;
				}
				else if (color[next.first] != c) {
					color[next.first] = c;
					st.push(next.first);
				}
			}
		}
		if (ok) {
			for (ll i = 0; i < N; i++) {
				cout << color[i] << endl;
			}
			return 0;
		}
	}
}

Measured memory_bytes: 8704
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int n,x[555],ord[555],a[555*555];
bool cmp(int a,int b){return x[a]<x[b];}
int main()
{
	get1(n);
	for(int i=1;i<=n;i++)
	{
		get1(x[i]);
		ord[i]=i;
	}
	sort(ord+1,ord+n+1,cmp);
	int cur=1;
	for(int _=1,i;_<=n;_++)
	{
		i=ord[_];
		for(int j=1;j<i;j++)
		{
			while(cur<x[i]&&a[cur])cur++;
			if(cur==x[i])
			{
				puts("No");
				return 0;
			}
			a[cur]=i;
		}
		a[x[i]]=i;
	}
	for(int i=1;i<=n;i++)
	{
		int cur=x[i]+1;
		for(int j=0;j<n-i;j++)
		{
			while(cur<=n*n&&a[cur])cur++;
			if(cur==n*n+1)
			{
				puts("No");
				return 0;
			}
			a[cur]=i;
		}
	}
	puts("Yes");
	for(int i=1;i<=n*n;i++)printf("%d ",a[i]);
	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
char a[50][50];
int c,d,b[55][55];
int main(){
    cin>>c>>d;
    for(int i=0;i<c;i++)
    cin>>a[i];
    for(int i=0;i<c;i++)
    for(int j=0;j<d;j++)
    if(a[i][j]=='#')
    b[i][j]++,b[i][j+1]++,b[i][j+2]++,
    b[i+1][j]++,b[i+1][j+1]++,b[i+1][j+2]++,
    b[i+2][j]++,b[i+2][j+1]++,b[i+2][j+2]++;
	for(int i=0;i<c;i++){
		for(int j=0;j<d;j++)
    	if(a[i][j]=='#') cout<<'#';
    	else cout<<b[i+1][j+1];
    	cout<<endl;
	}
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  int N;
  int a[100000];
  cin >> N;
  rep(i, N) {
    cin >> a[i];
  }
  for(int i = N - 1; i >= 1; i--) {
    if(a[i-1] == a[i] + 1) a[i-1]--;
    else if(a[i-1] <= a[i]) continue;
    else {
      cout << "No" << endl;
      return 0;
    }
    // cout << a[i-1] << endl;
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 4024
#include<iostream>
#include<algorithm>
#include<cstdint>
using namespace std;

const int MAX = 2000; // N
const int64_t INF = 4611686018427387903; // 10^62-1、使わない辺とかに用いる
int main() {
	int64_t N, x, a[MAX], b[MAX];
	cin >> N >> x;
	for (int i = 0;i < N;++ i) {
		cin >> a[i];
		b[i] = a[i];
	}
	int64_t ans = INF, sum;
	for (int i = 0;i < N;++ i) { // 魔法詠唱回数
		sum = i * x;
		for (int j = 0;j < N;++ j) b[j] = min(b[j], a[(j - i + N) % N]);
		for (int j = 0;j < N;++ j) sum += b[j];
		ans = min(ans, sum);
	}
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

まず、魔法の詠唱回数を決め打つ
この時、O(N)でコストが分かるので、計算するだけになるよね
*/

Measured memory_bytes: 256
#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;
};
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 p) {//最大値、個数
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	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;
}//x^n%p
#define int long long
const long long inf = 4523372036854775807;
const int iinf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int t, p, r;
int a[51];//スコアは？
int c[51];//問題の正解数
int w[51][51];//何回間違えたか
bool b[51][51];//問題を正解したか
struct A {
	int id, prob, pen;
};
bool operator<(A a, A b) {
	if (a.prob != b.prob) return a.prob < b.prob;
	if (a.pen != b.pen) return a.pen > b.pen;
	return a.id > b.id;
}
A d[51];
signed main() {
	while (cin >> t >> p >> r&&t + p + r > 0) {
		for (int i = 0; i < 51; i++) {
			for (int j = 0; j < 51; j++)
				w[i][j] = 0, b[i][j] = 0;
			a[i] = 0, c[i] = 0;
		}
		for (int i = 0; i < r; i++) {
			int tid, pid, time;
			string mes;
			cin >> tid >> pid >> time >> mes;
			if (!b[tid][pid]) {
				if (mes == "CORRECT") {
					a[tid] += w[tid][pid] * 1200 + time;
					c[tid]++;
					b[tid][pid] = 1;
				}
				else {
					w[tid][pid]++;
				}
			}
		}
		for (int i = 1; i <= t; i++) {
			d[i].id = i;
			d[i].pen = a[i];
			d[i].prob = c[i];
		}
		sort(d + 1, d + t + 1);
		reverse(d + 1, d + t + 1);
		for (int i = 1; i <= t; i++) {
			cout << d[i].id << " " << d[i].prob << " " << d[i].pen << endl;
		}
	}
	getchar(); getchar();
}


Measured memory_bytes: 3236
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

int main() {
	char a;
	cin >> a;
	if (a == 'a' || a == 'i' || a == 'u' || a == 'e' || a == 'o') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	int N, K; cin >> N >> K;
	priority_queue<int> que;

	REP(i, N){
		int tmp;
		cin >> tmp;
		que.push(tmp);
	}

	int sum = 0;
	REP(i, K){
		int tmp = que.top(); 
		que.pop();
		sum += tmp;
	} 

	cout << sum << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		while (true)
		{
			int n = sc.nextInt(), count = 0;
			if (n == 0) break;
			while (n != 1)
			{
				if (n % 2 == 0) n /= 2;
				else n = 3 * n + 1;
				count++;
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define maxn 2010
int n,i,j,x,y,ans=0;
bitset <maxn> f[maxn],g[maxn],a[maxn];
int getnum()
{
	char c=getchar();
	for (;!isdigit(c);c=getchar());
	return c-'0';
}
int main()
{
	scanf("%d",&n);
	for (i=2;i<=n;i++)
		for (j=1;j<i;j++)
		{
			x=getnum();
			if (x) a[i][j]=1;
				else a[j][i]=1;
		}
	for (i=1;i<=n;i++)
		f[i][i]=g[i][i]=1;
	for (i=1;i<n;i++)
		for (j=1;j+i<=n;j++)
		{
			x=j;
			y=j+i;
			f[x][y]=((f[x]&g[y-1]&a[y]).count()>0);
			g[y][x]=((f[x+1]&g[y]&a[x]).count()>0);
		}
	for (i=1;i<=n;i++)
		ans+=(f[1][i]&g[n][i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n,m;
  cin >> n >> m;
  int k;
  cin >> k;
  rep(a,n+1)rep(b,m+1){
    int cnt = a*b + (n-a)*(m-b);
    if(cnt==k){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
    

}


Measured memory_bytes: 3540
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
const int maxn=1e6;
int main(){
	int a[111],m,n,x,l=0,r=0;
	cin>>n>>m>>x;
	for(int i=0;i<m;i++){
		cin>>a[i];
	if(a[i]>x)r++;
	if(a[i]<x)l++;
	}
	int minn=min(l,r);
	printf("%d",minn);
	printf("\n");

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
ll lcm(ll a,ll b){
    ll tmp = a*b;
    ll g = gcd(a,b);
    return tmp/g;
}
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    ll N,X; cin >> N >> X;
    vector<ll> x(N); rep(i,N) cin>>x[i];


    for(int i=0;i<N;i++){
        x[i] = abs(x[i]-X);
    }

    if(N==1){
        cout << x[0] << endl;
        return 0;
    }


    ll ans = gcd(x[0],x[1]);
    for(int i=0;i<N;i++) ans = gcd(ans,x[i]);
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,c,x,q,w,e,r=0;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&x);
    for(q=0;q<=a;q++)
        for(w=0;w<=b;w++)
        for(e=0;e<=c;e++)
        if(500*q+100*w+50*e==x)
        r++;
    printf("%d",r);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool check(string s,ll l,ll r)
{
    while(l<=r&&s[l]==s[r]) ++l,--r;
    return l>r;
}
int main ()
{
    ios::sync_with_stdio(false);
    string s;cin>>s;
    ll n=s.size();
    s="0"+s;
    ll bj=1;
    if(!check(s,1,s.size()-1)) bj=0;
    if(!check(s,1,(n-1)/2)) bj=0;
    if(!check(s,(n+3)/2,n)) bj=0;
    cout<<(bj?"Yes":"No");
    return 0;
}



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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define _sort(a) sort(a.begin(), a.end())
#define _sortd(a) sort(a.rbegin(), a.rend())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

int main() {
  string s;
  cin >> s;
  if (s == "Sunny") {
    p("Cloudy");
  } else if (s == "Cloudy") {
    p("Rainy");
  } else {
    p("Sunny");
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[26];
		Arrays.fill(arr, Integer.MAX_VALUE);
		for (int i = 0; i < n; i++) {
			String s = sc.next();
			int[] tmp = new int[26];
			for (int j = 0; j < s.length(); j++) {
				tmp[s.charAt(j) - 'a']++;
			}
			for (int j = 0; j < 26; j++) {
				arr[j] = Math.min(arr[j], tmp[j]);
			}
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < 26; i++) {
			for (int j = 0; j < arr[i]; j++) {
				sb.append((char)(i + 'a'));
			}
		}
		System.out.println(sb);
	}
}


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

set<ll> an;

void dfs(string s){
    ll num=stoll(s);
    if(num>=3234566668)return;
    an.insert(num);
    char foot=s[s.size()-1];
    if(foot=='0'){
        dfs(s+'0');
        dfs(s+'1');
    }
    else if(foot=='9'){
        dfs(s+'8');
        dfs(s+'9');
    }
    else{
        char nx1=foot+1,nx2=foot-1;
        dfs(s+nx1);
        dfs(s+foot);
        dfs(s+nx2);
    }
        
    
}

int main(){
    ll k;cin>>k;
    dfs("1");
    dfs("2");
    dfs("3");
    dfs("4");
    dfs("5");
    dfs("6");
    dfs("7");
    dfs("8");
    dfs("9");
    ll cn=0,ans;
    for(auto i:an){
        cn++;
        if(cn==k){ans=i;break;}
    }
    cout<<ans<<endl;

}
    









Measured memory_bytes: 4992
#include<stdio.h>
int main()
{
	int n,i,j,k;
	char a[2][106];
	scanf("%d",&n);
	getchar();
	for(i=0;i<n;i++)
	scanf("%c",&a[0][i]);
	getchar();
	for(i=0;i<n;i++)
	scanf("%c",&a[1][i]);
	//puts(a[0]);
	//puts(a[1]);
	for(i=0;i<n;i++)
	{
		if(a[0][i]==a[1][0])
		{
			for(j=i,k=0;j<n;j++,k++)
			{
				if(a[0][j]!=a[1][k])
				{
					break;
					j--;
				}
			}
			if(j==n)
			{
				printf("%d\n",n+(n-k));
				return 0;
		    }
	    } 
    }
	if(i==n)
	printf("%d\n",n*2); 
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int num[3] = {3, 5, 7};
int ans;
ll n;
set<int> st;
void dfs(ll now, int a){
	if(a == 7){
		if(st.find(now) == st.end()){
			st.insert(now);
			ans++;
		}
	}
	if(now > n) return;
	for(int i = 0; i < 3; i++){
		ll t = now * 10 + num[i];
		int e = int(pow(2, i));
		if(t <= n){
			dfs(t, (a|e));
		}
	}
}
int main(){
	cin >> n;
	ans = 0;
	dfs(3,1);
	dfs(5,2);
	dfs(7,4);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1536
def c_successive_subtraction(N, A):
    A.sort()
    maximum = A.pop()
    minimum = A.pop(0)

    # Aの要素のうち、最大のものと最小のものを分けて置いておく。
    # それら以外の要素 a_k について、
    # a_k が非負なら、最小のものから a_k を引くことで負の方向に大きくできる。
    # a_k が負なら、最大のものから a_k を引くことで正の方向に大きくできる。
    # 最後に 最大のもの - 最小のもの とすると、最後に残る整数を最大にできる。
    operation = []
    for a in A:
        if a >= 0:
            operation.append('{} {}'.format(minimum, a))
            minimum -= a
        else:
            operation.append('{} {}'.format(maximum, a))
            maximum -= a
    operation.append('{} {}'.format(maximum, minimum))
    return str(maximum - minimum) + '\n' + '\n'.join(operation)

N = int(input())
A = [int(i) for i in input().split()]
print(c_successive_subtraction(N, A))

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

#define sf scanf
#define pf printf
#define pfn printf("\n");
#define pfk printf(" ");
#define pf0 printf("0");
#define pf1 printf("1");
#define ll long long
#define sfd(n) scanf("%d",&n);
#define sfdd(n,m) scanf("%d%d",&n,&m);
#define sfld(n) scanf("%lld",&n);
#define sfldd(n,m) scanf("%lld%lld",&n,&m);
#define sflf(n) scanf("%lf",&n);
#define sflff(n,m) scanf("%lf%lf",&n,&m);
#define sfc(n) scanf("%c",n);
#define sfcc(n,m) scanf("%c%c",n,m);
#define sfs(n) scanf("%s",n);
#define sfss(n,m) scanf("%s%s",n,m);
#define pfd(n) printf("%d",n);
#define pfld(n) printf("%lld",n);
#define pflf(n) printf("%lf",n);
#define pfc(n) printf("%c",n);
#define pfs(n) printf("%s",n);

#define csh(a,n) memset(a,n,sizeof(a));

int main(){
	int n;
	cin>>n;
	map<int,int>mp;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		if(mp[a]==1){
			cout<<"NO"<<endl;
			return 0;
		}
		else{
			mp[a]=1;
		}
	}
	cout<<"YES"<<endl;
}

Measured memory_bytes: 9600
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;
constexpr LL kInf = 1e18;

template<typename T>
auto makeNdVector(int n, const T& v) {
  return vector<T>(n, v);
}

template<typename T, typename N, typename... Tail>
auto makeNdVector(const N& n, const Tail&... tail) {
  auto vec = makeNdVector<T>(tail...);
  vector<decltype(vec)> vecs(n, vec);
  return vecs;
}

int L;
vector<vector<LL>> d;

void warshal_floyd() {
  int V = d.size();
  for (int k = 0; k < V; ++k) {
    for (int i = 0; i < V; ++i) {
      for (int j = 0; j < V; ++j) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main() {
  int N, M; cin >> N >> M >> L;
  d = makeNdVector<LL>(N, N, kInf);
  for (int i = 0; i < M; ++i) {
    int A, B, C; cin >> A >> B >> C; --A, --B;
    d[A][B] = C;
    d[B][A] = C;
  }

  warshal_floyd();

  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      if (i == j) d[i][j] = 0;
      else        d[i][j] = (d[i][j] <= L) ? 1 : kInf;
    }
  }

  warshal_floyd();

  int Q; cin >> Q;
  for (int i = 0; i < Q; ++i) {
    int s, t; cin >> s >> t; --s, --t;
    if (d[s][t] < kInf) cout << d[s][t] - 1 << endl;
    else                cout << -1 << endl;
  }
}


Measured memory_bytes: 4288
package main

import (
	"bufio"
	"fmt"
	"os"
)

var stdInScanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	stdInScanner.Scan()
	return stdInScanner.Text()
}

func main() {
	stdInScanner.Split(bufio.ScanWords)

	S := nextString()

	if S[2] == S[3] && S[4] == S[5] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
import sys

s = int(input())
a = [0, s]
i = 2

while a[-2] != 2 and a[-1] != 1:
  if (a[i-1])%2 == 0:
    a.append(int(a[i-1]/2))
  elif (a[i-1])%2 == 1:
    a.append(int(1+3*a[i-1]))
  i += 1
a.append(4)
a.append(2)
a.append(1)

stuck = []
for i in range(1, len(a)):
  if (a[i]) in stuck:
    print(i)
    sys.exit()
  else:
    stuck.append(a[i])  

Measured memory_bytes: 9216
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("trapv")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
const ll mod = 1e9 + 7;
int n, m, col[500200], t = 0;
string s;
vvi g;
void dfs(int v) {
	sort(all(g[v]));
	g[v].erase(unique(all(g[v])), g[v].end());
	col[v] = 1;
	for(auto i : g[v]) {
		if(col[i]==1)
			cout << "Yes", exit(0);
		if(col[i]) continue;
		dfs(i);
	}
	col[v] = 2;
}
int main() { //DINIC ORZ
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m >> s;
	g.resize(2*n);
	for(int f, t, i = 0; i < m; i++) {
		cin >> f >> t, f--, t--;
		f*=2, t*=2;
		if(s[f>>1] == s[t>>1]) {
			g[f].pb(t+1);
			if(f!=t)
			g[t].pb(f+1);
		} else {
			g[f+1].pb(t);
			g[t+1].pb(f);
		}
	}
	for(int i = 0; i < 2*n; i++) {
		if(col[i]) continue;
		dfs(i);
	}
	cout << "No";
}


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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#ifdef MPS
#define D(x...) printf(x)
#else
#define D(x...)
#endif
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;

void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}

const int maxn = 200050;

int n, A[maxn], Ans;
unordered_map<int,int> appear;

int main()
{
	#ifdef MPS
		fp("1.in","r",stdin);
		fp("1.out","w",stdout);
	#endif
	sf("%d",&n);
	fo(i,1,n) sf("%d",&A[i]);

	sort(A+1,A+n+1);
	fd(i,n,1)
	{
		fd(j,30,0) if((1<<j) > A[i] && appear.count((1<<j)-A[i]))
		{
			if(!appear[(1<<j)-A[i]]) continue;
			appear[(1<<j)-A[i]] --;
			++ Ans;
			goto gg;
		}
		appear[A[i]] ++;
		gg:;
	}
	pf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 9288
#include <iostream>
using namespace std;
int main(void){
    int a=0,b=0,n;
    string A,B;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>A>>B;
        if(A==B){
            a++;
            b++;
        }
        else if(A>B) a+=3;
        else b+=3;
    }
    cout<<a<<" "<<b<<endl;
    return 0;
    }


Measured memory_bytes: 3152
//PCK2019予選問題2
#include "bits/stdc++.h"
using namespace std;

int main(){
  int n;
  cin >> n;
  if(n>=65 && n<=90){
      cout << 1 << endl;
  }else if(n>=97 && n<=122){
      cout << 2 << endl;
  }else{
      cout << 0 << endl;
  }


  return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long int n;
    cin >> n;
    cout << (n*(n+1))/2-((n/3)*(n/3+1)/2)*3-((n/5)*(n/5+1)/2)*5+((n/15)*(n/15+1)/2)*15;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#include <cstring>
#define FOR(i,a,n) for (int i = a; i < n; i++)
#define IFOR(i,n,a) for (int i = n; i >= a; i--)
#define mp make_pair
#define full(a) a.begin(), a.end()
#define sz(x) ((int)(x).size())
#define pii pair<int, int>
#define trav(a,x) for (auto& a : x)
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
using namespace std;
const ll mod = 998244353;

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll x; cin >> x;
    ull k, d; cin >> k >> d;
    x = abs(x);
    ull num = x / k;
    if (x % k != 0) num++;
    if (num >= d)
    {
        cout << x - (k * d);
        return 0;
    }
    ll mn = x % d;
    ll steps = x - mn;
    steps /= d;
    if ((k - steps) % 2 == 1) mn -= d;
    cout << abs(mn);

    return 0;
}





Measured memory_bytes: 3192
a,b,c,d = map(int, input().split())
d_ab = abs(a-b)
d_bc = abs(b-c)
d_ac = abs(a-c)

if d_ac <= d:
    print("Yes")
elif d_ab <= d and d_bc <= d:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    int a,b;
    cin >> a >> b;
    cout << max(a - 2 * b ,0) << endl;
    return 0;
}


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

int main() {
    string s1, s2;
    cin >> s1;
    cin >> s2;

    vector<vector<int>> dp(s1.size()+1, vector<int>(s2.size()+1, 0));

    for (int i = 0; i <= s1.size(); ++i) {
        dp[i][0] = i;
    }
    for (int j = 0; j <= s2.size(); ++j) {
        dp[0][j] = j;
    }

    for (int i = 0; i < s1.size(); ++i) {
        for (int j = 0; j < s2.size(); ++j) {
            if (s1[i] == s2[j]) {
                dp[i+1][j+1] = min({dp[i+1][j]+1, dp[i][j], dp[i][j+1]+1});
            } else {
                dp[i+1][j+1] = min({dp[i+1][j]+1, dp[i][j]+1, dp[i][j+1]+1});
            }
        }
    }

    cout << dp[s1.size()][s2.size()] << endl;
}



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

int main() {
  int A,B,cou=0,i,j;
  cin >> A >> B;
  for(i=A;i<=B;i++){
    j=i%10*10000+i%100/10*1000+i%1000/100*100+i%10000/1000*10+i/10000;
    if(j==i)cou++;
  }
  cout << cou <<endl;
}

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

#define rep(i, a, b) for(int i=a; i<=b; i++)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MOD = 1e9+7;

ll n, a;
ll ans=0;
vector<ll> ps;
vector<ll> vec;

int main(){
  // freopen("input.txt", "r", stdin); 
  // freopen("output.txt", "w", stdout);
  cin.sync_with_stdio(0); cin.tie();
  cin.exceptions(cin.failbit);

  cin >> n;
  rep(i, 1, n){
  	cin >> a;
  	vec.pb(a);
  	ps.pb(a+(i==1?0:ps[i-2]));
  }

  rep(i, 0, n-2){
  	ans+=((ll)vec[i]%MOD*(((ll)ps[n-1]-(ll)ps[i])%MOD))%MOD;
  }
  cout << ans%MOD;
}

Measured memory_bytes: 6728
import static java.lang.Math.*;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] sum = new long[n];
        sum[0] = sc.nextLong();
        for (int i = 1; i < n; i++) {
            sum[i] = sc.nextLong() + sum[i-1];
        }
        long ans = Long.MAX_VALUE;
        for (int i = 0; i < n - 1; i++) {
            ans = min(ans, abs(sum[n-1] - sum[i] *2));
        }


        System.out.println(ans);
        sc.close();
    }
}


Measured memory_bytes: 87204
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > P;
int main()
{
  ll n,k;
  cin>>n>>k;
  vector<int> a(n),exi(n+1,0);
  for(int i=0;i<n;i++)
  {
    cin>>a.at(i);
    exi.at(a.at(i))++;
  }
  sort(exi.begin(),exi.end());

  int ans=n;
  for(int i=1;i<=k;i++)
  {
    ans-=exi.at(n+1-i);
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <math.h> 
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>
#include <numeric>

using namespace std;



int main() {

	int n = 0;
	cin >> n;

	for (int i = n; i >= 0; --i) {
		//cout << sqrt(i) << endl;
		if (sqrt(i) == int(sqrt(i))) {
			cout << i << endl;
			break;
		}
	}


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int compare_int(const void* a, const void* b)
{
	return *(int*)a - *(int*)b;
}

int main(void) {
	int N;
	int i;
	scanf("%d", &N);
	int d[N];
	for (i = 0;i < N;i++) {
		scanf("%d", &d[i]);
	}

	qsort(d, N, sizeof(int), compare_int);

	int answer;
	answer = d[N / 2] - d[N / 2 - 1];

	printf("%d", answer);

	return 0;

}

Measured memory_bytes: 1020
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    // get value from StandardIn
    int n = Integer.parseInt(sc.next());
    int m = Integer.parseInt(sc.next());
    if(n==m){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
    // System.out.println(n);
  }
}


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int res = 0;
  for (int i = 0; i <= n / r; i++) {
    for (int j = 0; j <= n / g; j++) {
      int sum = i * r + j * g;
      if (sum > n) {
        continue;
      }
      if ((n - sum) % b == 0) {
        res++;
      }
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    k,t = map(int,input().split())
    A = list(map(int,input().split()))

    a = max(A)

    limit = (k+1) //2

    if k % 2 == 0:
        ans = max(0,1 + 2*(a - limit -1))
    else:
        ans = max(0,2*(a-limit))

    print(ans)

main()

Measured memory_bytes: 9140