akhauriyash/Code-Regression huggingface dataset:
H,W = map(int,input().split())
S = [input().strip() for _ in range(H)]
flag = 0
for i in range(H):
    for j in range(W):
        if S[i][j]=="#":
            if j+1<W and S[i][j+1]=="#" or i-1>=0 and S[i-1][j]=="#" or j-1>=0 and S[i][j-1]=="#"\
            or i+1<H and S[i+1][j]=="#":
                continue
            else:
                flag = 1
                break
    if flag==1:break
if flag==0:
    print("Yes")
else:
    print("No")


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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> s[10];
    for(int i=0;i<m;i++){
        int k;
        cin >> k;
        for(int j=0;j<k;j++){
            int ss;
            cin >> ss;
            s[i].push_back(ss-1);
        }
    }
    int p[10];
    for(int i=0;i<m;i++) cin >> p[i];

    int ans = 0;
    for(int stat=0;stat<(1<<n);stat++){
        int cnt = 0;
        for(int i=0;i<m;i++){
            int pa = 0;
            for(int sw : s[i]){
                if((stat>>sw)&1) pa++;
            }
            if(pa%2 == p[i]) cnt++;
        }
        if(cnt == m) ans++;
    }

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

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = 0;
        int count = 0;
        int max = Math.min(a, b);
        for (int i = max; 0 < i; i--) {
            if (a % i == 0 && b % i == 0) {
                count++;
                if (count == k) {
                    result = i;
                }
            }
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 23764
/* template.cpp(shinobu_menkoi) {{{ */
#include <bits/stdc++.h>
using namespace std;

// clang-format off
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (lint i = (a); i < (lint)(n); i += (s))
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, 1)
#define rrep4(i, a, n, s) for (lint i = (a); i >= (lint)(n); i -= (s))
#define each(i, ctn) for (auto &&i : (ctn))

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(v) begin(v), end(v)
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'
#define TEMP_T template <class T>
#define TEMP_TU template <class T, class U>

TEMP_T using vec = vector<T>;
TEMP_T using heap = priority_queue<T>;
TEMP_T using minheap = priority_queue<T, vec<T>, greater<T>>;
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
using vi = vec<int>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<int, int>;
using vs = vec<string>;

TEMP_TU ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << p.fi << " " << p.se; }
TEMP_TU istream &operator>>(istream &is, pair<T, U> &p) { return is >> p.fi >> p.se; }

const int INF{1001001001};
const lint LINF{1001001001001001001ll};
const int MOD{(int)1e9 + 7};
const double EPS{1e-9};
const double PI{acos(-1)};
const int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};

inline bool inside(int y, int x, int h, int w) { return y >= 0 && x >= 0 && y < h && x < w; }
TEMP_T inline bool chmin(T &a, const T &b) { if (a > b) a = b; return a > b; }
TEMP_T inline bool chmax(T &a, const T &b) { if (a < b) a = b; return a < b; }
TEMP_T inline void print(const T &x) { cout << x << '\n'; }
TEMP_T inline void print(const vec<T> &v, string d = "\n") { rep(i, v.size()) cout << v[i] << (i == (lint)v.size() - 1 ? "\n" : d); }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = string> vec<T> split(const string &s, char d = ',') {
  vec<T> v; stringstream ss(s); for (string b; getline(ss, b, d); ) {
    stringstream conv(b); T t; conv >> t; v.eb(t); } return v;
}
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;
// clang-format on
/* }}} */

signed main() {
  int n = in();
  bool dp[101][10101] = {};
  vi s(n); rep(i, n) s[i] = in();
  
  dp[0][0] = true;
  rep(i, n) {
    rep(j, 10101) {
      if (dp[i][j]) {
        dp[i + 1][j] = true;
        dp[i + 1][j + s[i]] = true;
      }
    }
  }
  rrep(i, 10100) {
    if ((dp[n][i] && i % 10 != 0) || i == 0) {
      print(i);
      break;
    }
  }
}


Measured memory_bytes: 1280
from bisect import bisect_left, bisect_right

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

A.sort()
B.sort()
C.sort()

ans = 0

for b in B:
    i = bisect_left(A, b)
    j = bisect_right(C, b)
    if i - 1 >= 0 and N - j:
        ans += i * (N - j)

print(ans)


Measured memory_bytes: 104804
#include<bits/stdc++.h>
#define llu unsigned long long
#define ll long long
#define INF 0x3f3f3f3f
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;

int main()	
{
	#ifdef SANS
		freopen("C:\\Users\\ASUS\\Documents\\Sublime\\input_output\\inputf.txt","r",stdin);
		freopen("C:\\Users\\ASUS\\Documents\\Sublime\\input_output\\outputf.txt","w",stdout);
	#endif
	fast
	int t=1;
	// cin>>t;
	while(t--)
	{
		ll A,B,C,K;
		cin>>A>>B>>C>>K;
		if(K<A)
			cout<<K<<endl;
		else if(K<=A+B)
			cout<<A<<endl;
		else
			cout<<(A-(K-(A+B)))<<endl;
	}
	#ifdef SANS
		cout<<"\nTime Elapsed:"<<1.0*clock()/CLOCKS_PER_SEC <<"sec\n";
	#endif
}

Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<cstring>
//#include<vector>
#include<algorithm>


#ifdef L_JUDGE
#pragma warning(disable:4996)
#endif

using namespace std;
const int MAXN=1005;


int main(){
	#ifdef L_JUDGE
		freopen("in.txt","r",stdin);
//		freopen("out.txt","w",stdout);
	#endif
    int a,b;
    char ch;
    cin>>a>>ch>>b;
    if(ch=='+')printf("%d\n",a+b);
    else printf("%d\n",a-b);

	#ifdef L_JUDGE
		fclose(stdin);
		fclose(stdout);
//		system("out.txt");
	#endif

	return 0;
}


Measured memory_bytes: 256
'use strict'

function Main(input){
	let temp = input.trim().split('\n');
	const N = parseInt(temp[0].split(' ')[0]);
	const Q = parseInt(temp[0].split(' ')[1]);
	const S = temp[1];

	const ac = new Array(N);
	let count = 0;
	ac[0]=0;
	for(let i=1;i<N;i++){
		if((S[i-1]+S[i])=='AC') count++;
		ac[i] = count;
	}
	//console.log(ac);
	for(let i=0;i<Q;i++){
		let li = parseInt( temp[i+2].split(' ')[0] )-1;
		let ri = parseInt( temp[i+2].split(' ')[1] )-1;
		//console.log(ri,li,ac[ri],ac[li])
		console.log( ac[ri] - ac[li] );
	}

}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 34712
#include<vector>
#include<algorithm>
#include<iostream>
using namespace std;
int gcd(int a,int b)
{
    if(!b)return a;
    else return gcd(b,a%b);
}
/*int n,q,ara[200001],st[800004],a,b,mx=2000000000;
void build(int si,int ss,int se)
{
    if(ss==se){
        st[si]=ara[ss];
        return;
    }
    int mid=(ss+se)/2;
    build(2*si,ss,mid),build(2*si+1,mid+1,se);
    st[si]=min(st[2*si],st[2*si+1]);
}
int query(int si,int ss,int se,int qs,int qe)
{
    if(qe<ss || se<qs)return mx;
    if(ss>=qs && qe>=se)return st[si];
    int mid=(ss+se)/2;
    return min(query(2*si,ss,mid,qs,qe),query(2*si+1,mid+1,se,qs,qe));
}
int main()
{
    //freopen ("input.txt","r",stdin);
    //freopen ("output1.txt","w",stdout);
    cin>>n>>q;
    for(int i=1;i<=n;i++)cin>>ara[i];
    build(1,1,n);
    while(q--){
        cin>>a>>b;
        cout<<query(1,1,n,a,b)<<"\n";
    }
}*/
int main()
{
    int n;
    cin>>n;
    int ara[n];
    long long int ans=0;
    cin>>ara[0];
    for(int i=1;i<n;i++){
        cin>>ara[i];
        if(ara[i]<ara[i-1])ans+=ara[i-1]-ara[i],ara[i]=ara[i-1];
    }
    cout<<ans;
}


Measured memory_bytes: 4408
//g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g $PROGRAM -o $OUTPUT -DLOCAL -lasan -lubsan
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
	if (!y)
		return x;
	return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

vector<string> split(char d,string s)
{
	stringstream ss(s);
	string t;
	vector<string> words;
	while(getline(ss,t,d))
	{
		words.pb(t);
	}

	return words;
}

int main(int argc, char *argv[])
{
#ifdef LOCAL
	auto start = chrono::high_resolution_clock::now();
#endif
	
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int n, k;
	cin >> n >> k;
	VII hsh(n + 1, 0);
	while(k--)
	{
		int d;
		cin >> d;
		for (int i = 0; i < d;++i)
		{
			int xx;
			cin >> xx;
			hsh[xx] = 1;
		}
	}
	int cnt = 0;
	for (int i = 1; i <= n;++i)
	if(hsh[i]==0)
		cnt++;

	cout << cnt;

#ifdef LOCAL
		   auto end = chrono::high_resolution_clock::now();
	double time_taken =
		chrono::duration_cast<chrono::nanoseconds>(end - start).count();

	time_taken *= 1e-9;

	cerr << "\nTime taken by program is : " << fixed
		 << time_taken << setprecision(9);
	cerr << " sec" << endl;
#endif
	return 0;
}


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

int main() {

  int A; //組数
  int B = 0; //人数

  cin >> A;
  
  for (int i = 0; i < A; i++) {
	int x, y;
    
    cin >> x >> y;
    B = B + y - x + 1;
   
  }
  
  cout << B << endl;
  
  
  
}


Measured memory_bytes: 256
#include <assert.h>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

//const ll MOD = 998244353;
const ll MOD = 1e9+7;

ll flag[3]={false};
 
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  std::string s;
  std::cin>>s;
  rep(i,0,3)flag[s[i]-'a']=true;
  if(flag[0]&&flag[1]&&flag[2])std::cout<<"Yes";
  else std::cout<<"No";
  return 0;
}

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

typedef long long ll;
const int maxn=1e5+10;
int n,m;
int a[maxn];
ll sum;
priority_queue<int,vector<int> > q;

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),q.push(a[i]);
	while(m--)
	{
		int x=q.top();q.pop();
		x/=2;
		q.push(x);
	}
	while(!q.empty())
	{
		sum+=q.top();q.pop();
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 1148
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N), B(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    vector<ll> dif(N);
    rep(i, N) { dif[i] = A[i] - B[i]; }
    ll cnt = 0;
    rep(i, N) {
        if(dif[i] > 0)
            cnt += dif[i];
        else {
            cnt -= (-dif[i]) / 2 + ((-dif[i]) % 2);
            cnt += ((-dif[i]) % 2);
        }
    }
    if(cnt <= 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define INFTY 1<<20
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;

int main(){
   
   int n;
   ll y,sum;
   cin>>n>>y;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
        int k = n-i-j;
        if(k<0)continue;
        sum = 10000*i+5000*j+1000*k;
        if(sum==y){
            printf("%d %d %d",i,j,k);
            return 0;
        } 
    }
    }
    printf("-1 -1 -1");
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define P(x) cout << x << endl
#define D(x) P(#x << ": " << x)
#define F(i,n) for (int i=0; i<(int)(n); i++)
#define DEC(i,n) for (int i=(int)(n); --i>=0;)
#define S(s) (int)((s).size())
#define ALL(v) v.begin(), v.end()
#define MI(a,v) a = min(a,(v))
#define MA(a,v) a = max(a,(v))
#define V vector
#define pb push_back
#define mt make_tuple
using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s; cin>>s;
    int best=S(s);
    for (int l='a'; l<='z'; l++) {
        int here=0, last=S(s);
        DEC(j,S(s)) {
            if (s[j] == l) {
                last = j;
            } else {
                MA(here, last-j);
            }
        }
        MI(best, here);
    }
    cout<<best<<"\n";
}

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

#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

const int INF = INT_MAX;

using PII = pair<int, int>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

std::string s;
const char p[] = {'A', 'C', 'G', 'T'};

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

    int ans = 0;
    int ct = 0;
    REP(i, s.size()) {
        if(s[i] == 'A') ct++;
        else if(s[i] == 'T') ct++;
        else if(s[i] == 'C')  ct++;
        else if(s[i] == 'G') ct++;
        else ct = 0;
        ans = (ans < ct) ? ct : ans;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		
		int C = sc.nextInt();
		int D = sc.nextInt();
		
		sc.close();

		while(true) {
			
			C -= B;
			if(C <= 0) {
				out.println("Yes");
				return;
			}
			
			A -= D;
			if(A<=0) {
				out.println("No");
				return;
			}
			
		}
		
	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

	@SuppressWarnings("unused")
	private String join(String delimiter, int[] a) {
		StringBuilder sb = new StringBuilder();

		for (int i = 0; i < a.length; i++) {
			sb.append(a[i]);
			sb.append(delimiter);
		}
		return sb.substring(0, Math.max(sb.length() - delimiter.length(), 0));
	}

	@SuppressWarnings("unused")
	private String join(String delimiter, long[] a) {
		StringBuilder sb = new StringBuilder();

		for (int i = 0; i < a.length; i++) {
			sb.append(a[i]);
			sb.append(delimiter);
		}
		return sb.substring(0, Math.max(sb.length() - delimiter.length(), 0));
	}

	@SuppressWarnings("unused")
	private int max(int[] arr) {
		if(arr == null || arr.length == 0) {
			throw new IllegalArgumentException(Arrays.toString(arr));
		}

		int candidate = arr[0];
		for(int i=1;i<arr.length;i++) {
			candidate = candidate > arr[i] ? candidate : arr[i];
		}
		return candidate;
	}

	@SuppressWarnings("unused")
	private long max(long[] arr) {
		if(arr == null || arr.length == 0) {
			throw new IllegalArgumentException(Arrays.toString(arr));
		}

		long candidate = arr[0];
		for(int i=1;i<arr.length;i++) {
			candidate = candidate > arr[i] ? candidate : arr[i];
		}
		return candidate;
	}

	@SuppressWarnings("unused")
	private int min(int[] arr) {
		if(arr == null || arr.length == 0) {
			throw new IllegalArgumentException(Arrays.toString(arr));
		}

		int candidate = arr[0];
		for(int i=1;i<arr.length;i++) {
			candidate = candidate < arr[i] ? candidate : arr[i];
		}
		return candidate;
	}

	@SuppressWarnings("unused")
	private long min(long[] arr) {
		if(arr == null || arr.length == 0) {
			throw new IllegalArgumentException(Arrays.toString(arr));
		}

		long candidate = arr[0];
		for(int i=1;i<arr.length;i++) {
			candidate = candidate < arr[i] ? candidate : arr[i];
		}
		return candidate;
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}

	@SuppressWarnings("unused")
	private long[] nextLongArray(Scanner sc, int n) {
		long[] result = new long[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextLong();
		}
		return result;
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray1origin(Scanner sc, int n) {
		int[] result = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 27016
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

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

void solve() {
    string str; cin >> str;
    int count = 0;
    int ans = 0;
    for (int i = 0; i < str.size(); ++i) {
        if (str[i] == 'A' || str[i] == 'C' || str[i] == 'G' || str[i] == 'T') {
            count++;
            chmax(ans, count);
        } else {
            count = 0;
        }
    }
    cout << ans << endl;
}

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

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 M = sc.nextInt();
    Map<Integer, ArrayList<Integer>> map = new HashMap<>();
    for(int i = 0; i < M; i++){
      int x = sc.nextInt();
      int y = sc.nextInt();
      if(!map.containsKey(x)){
        map.put(x, new ArrayList<Integer>());
      }
      List<Integer> list = map.get(x);
      list.add(y);
    }
    int[] memo = new int[N+1];
    Arrays.fill(memo, -1);
    System.out.println(solve(map, memo));
  }
  
  public static int solve(Map<Integer, ArrayList<Integer>> map, int[] memo){
    int max = -1;
    for(int i = 1; i <=memo.length; i++){
      max = Math.max(max, saiki(map, i, memo));
    }
    return max;
  }
  
  public static int saiki(Map<Integer, ArrayList<Integer>> map, int n, int[] memo){
    if(!map.containsKey(n)){
      return 0;
    }
    if(memo[n] != -1){
      return memo[n];
    }
    List<Integer> list = map.get(n);
    int max = -1;
    for(int i : list){
      max = Math.max(max, saiki(map, i, memo));
    }
    memo[n] = max+1;
    return max+1;
  }
}

Measured memory_bytes: 109652
#include <iostream>
#include <sstream>
#include <string>

//void Aoj_learning1();
void Aoj_learning2();

int main()
{
	Aoj_learning2();
}

void Aoj_learning2()
{
	std::string sInput[2];
	std::string sOutput;
	std::istringstream ss;	// 汎用文字列ストリーム
	int v1, v2;				// 入力値 max:v1,min;v2

	// 入力から2つの数値を取得する
	int count = 0;
	while (count < 2)
	{
		std::cin >> sInput[count];
		count++;
	}
	ss = std::istringstream(sInput[0]);
	ss >> v1;
	ss = std::istringstream(sInput[1]);
	ss >> v2;

	// v1が大きい値になるように変更
	if (v2 > v1)
	{
		int temp = v1;
		v1 = v2;
		v2 = temp;
	}

	// 最大公約数を取得するアルゴリズム
	int amari;
	while (v2 > 0)
	{
		amari = v1 % v2;
		if (amari == 0)
		{
			break;
		}
		else
		{
			v1 = v2;
			v2 = amari;
		}
	}
	std::cout << v2 << std::endl;
}


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

#define sz(x) (int)x.size()
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define __ ios_base::sync_with_stdio(cin.tie(0) && 0);

typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef double ld;

const ld pi = 3.141592653589793;
const ll inf = 1e18 + 5;
const int MOD = 1e9 + 7;
const int maxn = 1e5 + 5;

int main() {
  __;

  int n;
  cin >> n;

  int a[n];
  for(int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);

  int p = n - 2;
  
  ll ans = a[n - 1];
  for(int i = n - 2; i > -1; i--) {
    if(p > 1) ans += 2ll * a[i], p -= 2;
    else if(p > 0) ans += a[i], p--;
    else break;
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 4444
#include<iostream>

using namespace std;

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

	if (A >= 13) {
		cout << B << endl;
	}
	else if (A >= 6 && A <= 12) {
		cout << B / 2 << endl;
	}
	else cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
numofswitch,numoflump = list(map(int, input().split()))
s = []
for i in range(numoflump):
    tmps = list(map(int, input().split()))
    s.append(tmps)
p = list(map(int, input().split()))
switch_counter = 0
num_of_comnination = 0

#print(s)
#print(p)

for switchcombi in range(2**numofswitch):
    Anal = 0
    for lumpindex in range(numoflump):
        switch_counter = 0
        for switch_checker in range(1,len(s[lumpindex])):
            if (switchcombi >> (s[lumpindex][switch_checker] -1)) % 2 == 1:
                #print("not Anal",switchcombi,lumpindex,switch_checker,s[lumpindex][switch_checker])
                switch_counter += 1
            #print("yaba poji",switchcombi,lumpindex,switch_checker,s[lumpindex][switch_checker])
        if switch_counter % 2 != p[lumpindex]:
            Anal = 1
            #print("Anal",switchcombi,lumpindex,switch_checker,s[lumpindex][switch_checker])
            break
    if Anal == 0:
        num_of_comnination += 1
print(num_of_comnination)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x <= 1) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
ll n;
int main(){
 	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	ll ans = n / 500 * 1000;
	n = n % 500;
	ans += n / 5 * 5;
	cout << ans << endl;
	return 0;
}
//do smt instead of nothing! never give up!
//take care of long long!
//take care of upper or lower case e.g "yes" or "YES"?
//boundary condition! e.g. n = 0?
//brute force is always the first choice!
// print the ans to look for patterns in the data!

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

using P = pair<int, int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(int i = 0; i < n; i++) {
        cin >> b[i];
    }
    int ans = INF;
    for(int bit = 0; bit < (1 << n); bit++) {
        // true:表 false:裏
        vector<bool> ch(n, false);
        for(int i = 0; i < n; i++) {
            if(bit & (1 << i)) {
                ch[i] = true;
            }
        }
        // 奇数番目に置かれるカードの枚数
        int oddCnt = 0;
        // 偶数番目に置かれるカードの枚数
        int evenCnt = 0;
        // 奇数番目、偶数番目に使うカードの集合
        vector<P> po, pe;

        for(int i = 0; i < n; i++) {
            if(i % 2 == 0) {
                if(ch[i]) {
                    // 偶数番目かつ表なら、偶数番目に置く必要がある
                    evenCnt++;
                    pe.emplace_back(P(a[i], i));
                } else {
                    // 偶数番目かつ裏なら、奇数番目に置く必要がある
                    oddCnt++;
                    po.emplace_back(P(b[i], i));
                }
            } else {
                if(ch[i]) {
                    // 奇数番目かつ表なら、奇数番目に置く必要がある
                    oddCnt++;
                    po.emplace_back(P(a[i], i));
                } else {
                    // 奇数番目かつ裏なら、偶数番目に置く必要がある
                    evenCnt++;
                    pe.emplace_back(P(b[i], i));
                }
            }
        }
        // 奇数番目に置かれるカードの数は必ずn/2枚のはず
        if(oddCnt != (n / 2)) {
            continue;
        }
        sort(ALL(po));
        sort(ALL(pe));
        // 偶数、奇数の順番に並べる
        vector<P> sorted;
        int o = 0, e = 0;
        for(int i = 0; i < n; i++) {
            if(i % 2) {
                sorted.emplace_back(po[o]);
                o++;
            } else {
                sorted.emplace_back(pe[e]);
                e++;
            }
        }
        // 広義単調増加になっているか調べる
        bool ok = true;
        for(int i = 0; i < n - 1; i++) {
            if(sorted[i].first > sorted[i + 1].first) {
                ok = false;
            }
        }
        if(!ok) {
            continue;
        }
        // 転倒数==swapに必要な回数なので、
        // 転倒数を求める
        int cnt = 0;
        for(int i = 0; i < n; i++) {
            for(int j = i + 1; j < n; j++) {
                if(sorted[i].second > sorted[j].second) {
                    cnt++;
                }
            }
        }
        chmin(ans, cnt);
    }
    cout << (ans == INF ? -1 : ans) << endl;
}

Measured memory_bytes: 384
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <math.h> // sqrt()


using namespace std;


int main() {
    int n, sum, a;
    sum = 0;
    vector<int> list;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a;
        list.push_back(a);
    }
    for (int i = 1; i < n; i++){
        if ( i == 1)
            a  = min(list.at(0) , list.at(1));
        else
            a = min(a , list.at(i));
        if (a == list.at(i))
            sum ++;
        
            
    }
    cout << sum + 1 << endl;
}



Measured memory_bytes: 1400
// Package main provides
//
// File:  b.go
// Author: ymiyamoto
//
// Created on Sun Jan 20 19:48:03 2019
//
package main

import "fmt"

type pair struct {
	a, b int
}

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	pairs := make([]pair, M)
	for i := range pairs {
		fmt.Scan(&pairs[i].a, &pairs[i].b)
	}

	for i := 1; i <= N; i++ {
		var count int
		for j := range pairs {
			if pairs[j].a == i || pairs[j].b == i {
				count++
			}
		}
		fmt.Println(count)
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  
  if((a==b && a!=c) || (a==c && a!=b) || (b==c && b!=a))
    cout << "Yes";
  else
    cout << "No";
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T&a,T b){if(a>b){a=b;return 1;}return 0;}
typedef long long ll;

int n,m,k;
string s,t;

int main() {
  cin >> n >> s;
  int ans=0;
  rep(i,n-2){
    if(s.substr(i,3)=="ABC") ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.function.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int[][] A = new int[H][W];
    int[][] B = new int[H][W];
    for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) A[i][j] = sc.nextInt();
    for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) B[i][j] = sc.nextInt();
    sc.close();
    
    int m = (H + W) * 80;
    boolean[][][] dp = new boolean[H + 1][W + 1][m * 2 + 1];
    dp[0][1][m] = true;
    for (int i = 1; i < H + 1; i++) {
      for (int j = 1; j < W + 1; j++) {
        int c = Math.abs(A[i - 1][j - 1] - B[i - 1][j - 1]);
        boolean[] d = dp[i][j];
        for (int k = 0; k < d.length; k++) {
          if (dp[i - 1][j][k]) {
            d[k - c] = true;
            d[k + c] = true;
          }
          if (dp[i][j - 1][k]) {
            d[k - c] = true;
            d[k + c] = true;
          }
        }
      }
    }
    boolean[] d = dp[H][W];
    int ans = Integer.MAX_VALUE;
    for (int k = 0; k < d.length; k++)
      if (d[k]) ans = Math.min(ans, Math.abs(m - k));
    System.out.println(ans);
  }
}


Measured memory_bytes: 245364
#include<bits/stdc++.h>
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define inf 1e18 

using namespace std;
int modp(int a,int m,int n)
{
    n=n%(m-1);
    a=a%m;
    int res=1;
    while(n>0)
    {
        if(n&1) res=(res*a)%m;
        a=(a*a)%m;
        n>>=1;
    }
    return res;
}

int modInverse(int n, int p) 
{ 
    return modp(n, p, p-2); 
}
int nCrModPFermat(int n, int r,int p) 
{ 
    if (r==0) return 1; 
    int fac[n+1]; 
    fac[0] = 1; 
    for (int i=1 ; i<=n; i++) fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]*modInverse(fac[r],p)%p*modInverse(fac[n-r],p)%p)%p; 
}
signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif
    
    IOS;
    int s,i;
    cin>>s;
    int n=s/3;
    int ans=0;
    for(i=1;i<=n;i++)
    {
        int num=s-3*i;
        ans+=nCrModPFermat(num+i-1,i-1,mod);
        ans%=mod;
    }
    cout<<ans;
}

Measured memory_bytes: 3652
#include<cstdio>
#include<algorithm>
using namespace std;
bool comp(int a,int b) {return a<b;}
int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	int a[10]={},s=0;
	for(int i=1;i<=3;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+3+1,comp);
	if((a[3]-a[2])%2) {
		s+=(a[3]-a[2]);
		a[1]+=(a[3]-a[2]);
		a[2]=a[3];
	} else if((a[3]-a[2])%2==0) {
		s+=(a[3]-a[2])/2;
		a[2]=a[3];
	}
	if((a[2]-a[1])%2==1) {
		a[3]++;
		a[2]++;
		a[1]+=2;
		s+=2;
	}
	if((a[2]-a[1])%2==0) {
		s+=(a[3]-a[1])/2;
		a[1]=a[3];
	}
	printf("%d\n",s);
	return 0;
}

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

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


Measured memory_bytes: 256
#include <stdio.h>

long long abs(long long a) {
	if ( a < 0 ) return -a;
	return a;
}

long long min ( long long a, long long b ) {
	if ( a < b ) return a;
	return b;
}

int main(void) {
	int n,a[200000];
	long long s[200001] = {0};
	scanf("%d",&n);
	for(int i = 0;i < n;i++) {
		scanf("%d",&(a[i]));
		s[i+1] = s[i] + a[i];
	}
	long long res = 200000000000;
	for(int i = 1;i < n;i++) {
		res = min(res,abs((s[n]-s[i])-s[i]));
	}
	printf("%d",res);
}


Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    private static int[] d = new int[3];
    static {
        d[0] = 3;
        d[1] = 5;
        d[2] = 7;
    }
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        String s = Integer.toString(N);
        System.out.println(dfs(N, s.length(), new StringBuilder()));
    }
    private int dfs(int N, int len, StringBuilder sb) {
        if (len < sb.length()) {
            return 0;
        }
        if (sb.length() != 0 && N < Integer.parseInt(sb.toString())) {
            return 0;
        }
        int ans = 0;
        if (3 <= sb.length()) {
            boolean found3 = false;
            boolean found5 = false;
            boolean found7 = false;
            for (int i = 0; i < sb.length(); i++) {
                if (sb.charAt(i) == '3') {
                    found3 = true;
                }
                if (sb.charAt(i) == '5') {
                    found5 = true;
                }
                if (sb.charAt(i) == '7') {
                    found7 = true;
                }
            }
            if (found3 && found5 && found7) {
                ans += 1;
            }
        }
        for (int i : d) {
            sb.append(i);
            ans += dfs(N, len, sb);
            sb.delete(sb.length()-1, sb.length());
        }
        return ans;
    }

}


Measured memory_bytes: 28092
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;
// const int INF = 1000000;


ll pa(ll n){
  if(n > 0) return 2*pa(n-1)+1;
  else return 1;
}

ll search(ll n,ll x,ll sum){
  if(n == 0){
    return 1;
  }
  if(x == sum){
    return 2*pa(n-1) + 1;
  }else if(x > (sum+1)/2){
    return pa(n-1) + 1 + search(n-1,x-(sum+1)/2,(sum-3)/2);
  }else if(x == (sum+1)/2){
    return pa(n-1) + 1;
  }else if(x > 1){
    return search(n-1,x-1,(sum-3)/2);
  }else{
    return 0;
  }
}



int main(){
  ll n,x;
  cin >> n >> x;
  ll w;
  w = 4*pow(2,n) - 3;
  ll ans;
  ans = search(n,x,w);
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 256
n=int(input())
s=input()
s2=''
flag=0
cnt=0
for i in range(n):
  if flag==0:
    if s[i]=='(':
      flag=1
      cnt+=1
    elif s[i]==')':
      s2+=')'
  elif flag==1:
    if s[i]=='(':
      cnt+=1
    elif s[i]==')':
      cnt-=1
    if cnt==0:
      flag=0
if flag==1:
  s2+='('*cnt
cntl=0
cntr=0
for i in range(len(s2)):
  if s2[i]=='(':
    cntr+=1
  elif s2[i]==')':
    cntl+=1
ans='('*cntl+s+')'*cntr
print(ans)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int A = sc.nextInt(), B = sc.nextInt();
        if (A>9 || B>9) {
            System.out.println(-1);
        } else {
            System.out.println(A*B);
        }
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll n, k;
    cin >> n >> k;
    if (2 * k - 1 <= n) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
    return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;

const int N = 1e6;
const int LOG = 21;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLMOD = 998244353;
const ll LLINF = 1e18;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int k, x;
    cin >> k >> x;
    int mn = max(x - k + 1, -N);
    int mx = min(x + k - 1, N);
    forab(i, mn, mx + 1) cout << i << " ";
    cout << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF long long int(1e18+1)
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

long long int dp[3][100010];

int main()
{
	int n, k;
	cin >> n >> k;
	int r, s, p;
	cin >> r >> s >> p;
	string t;
	cin >> t;

	rep(i, 0, 3)dp[i][0] = 0;
	rep(j, 1, n + 1) {
		long long int m;
		if (t[j - 1] == 'r') {
			dp[0][j] = dp[0][j - 1];
			dp[1][j] = dp[1][j - 1];
			if (j - k > 0)
				if (dp[2][j - k] != dp[2][j - k - 1]) {
					dp[2][j] = dp[2][j - 1];
					continue;
				}
			m = max(dp[0][j - 1], dp[1][j - 1]);
			m = max(m, dp[2][j - 1]);
			dp[2][j] += m + p;
		}
		else if (t[j - 1] == 's') {
			dp[1][j] = dp[1][j - 1];
			dp[2][j] = dp[2][j - 1];
			if (j - k > 0)
				if (dp[0][j - k] != dp[0][j - k - 1]) {
					dp[0][j] = dp[0][j - 1];
					continue;
				}
			m = max(dp[1][j - 1], dp[2][j - 1]);
			m = max(m, dp[0][j - 1]);
			dp[0][j] += m + r;
		}
		else if (t[j - 1] == 'p') {
			dp[0][j] = dp[0][j - 1];
			dp[2][j] = dp[2][j - 1];
			if (j - k > 0)
				if (dp[1][j - k] != dp[1][j - k - 1]) {
					dp[1][j] = dp[1][j - 1];
					continue;
				}
			m = max(dp[0][j - 1], dp[2][j - 1]);
			m = max(m, dp[1][j - 1]);
			dp[1][j] += m + s;
		}
	}
		long long int ans = 0;
		rep(i, 0, 3)ans = max(ans, dp[i][n]);
		cout << ans << endl;
}



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

using namespace std;

long int N;


int main(){
    vector<int> H;

    cin >> N;
    int tmp = 0;
    for(int i = 0;i < N;i++) {
        cin >> tmp;
        H.push_back(tmp);
    }

    for(int i = 0;i < N-1;i++){
        if(i == 0) H[i]--;//最初はとにかく引いた方が得
        if(H[i] > H[i-1]){
            H[i]--;
        }
    }
  
    for(int i = 0;i < N-1;i++){
        if(H[i] - H[i+1] > 0){
            cout << "No" << endl;
            exit(0);
        }
    }

    cout << "Yes" << endl;



    return 0;
}


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

const int mod = 998244353;

map <string, int> all;

int dfs(string s) {
	if (!s.size()) return 1;
	if (s.size() == 1) return s[0] - '0' + 1;
	if (all.count(s)) return all[s];
	long long res = (s[0] - '0' + 1) * dfs(s.substr(1));
	for (int i = 0; i < s.size(); i++) {
		long long sum = 0;
		for (int j = 1; j < i + 1; j++) {
			if ((i + 1) % j) continue;
			string tmp;
			for (int k = 0; k < j; k++) {
				int x = 1;
				for (int l = k; l < i + 1; l += j) {
					x &= s[l] - '0';
				}
				tmp.push_back(x + '0');
			}
			sum = (sum + dfs(tmp)) % mod;
		}
		res = (res + sum * dfs(s.substr(i + 1))) % mod;
	}
	return all[s] = res;
}

int main () {
	string s; cin >> s;
	cout << dfs(s) << endl;
	return 0;
}


Measured memory_bytes: 6528
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
#include<iostream>
#include<bits/stdc++.h>
#include<cstdio>
#include<string.h>
#include<map>
#include<cmath>
#include<stack>
#include<algorithm>
#include<assert.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define mem0(s) memset(s,0,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))
double pi=acos(-1);
typedef long long ll;
typedef unsigned long long ull;
inline ll lowbit(ll x){return x&(-x);}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll max(ll a,ll b){return a>b?a:b;}
const double Rad_to_deg=45.0/atan(1.0);
inline ll floor(const ll&a,const ll&b){return a/b;}
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
const ll INF=4223372036854775807,max_n=400005,mod=1000000007;
inline ll ceil(const ll&a,const ll&b){if(a%b==0)return a/b;return a/b+1;};
inline ll pow(ll a,ll b,ll mod){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int n;
string s;
int ans;
int main()
{
	cin>>n;
	cin>>s;
	for(int i=1;i<n;i++)
	{
		if(s[i]!=s[i-1])
		{
			ans++;
		}
	}
	cout<<ans+1;
}

Measured memory_bytes: 3752
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

const int MAXN=709;

bool G[MAXN][MAXN];
int N, M;

bool isbipartite=true;
int dir[MAXN]={-1};
int tmpnums[2];

void dfs(int v, int tdir){
    dir[v]=tdir;
    tmpnums[tdir]++;
    rep(e,N){
        if(e==v||!G[v][e]) continue;
        if(dir[e]==-1) dfs(e,tdir^1);
        else if(dir[e]!=(tdir^1)) isbipartite=false;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>M;
    rep(i,N)rep(j,N) G[i][j]=1;
    rep(i,M){
        int a,b; cin>>a>>b;
        a--; b--;
        G[a][b]=G[b][a]=0;
    }
    
    mem(dir,-1);
    vector<pii> nums;
    rep(v,N){
        if(dir[v]!=-1) continue;
        tmpnums[0]=tmpnums[1]=0;
        dfs(v,0);
        nums.push_back({tmpnums[0],tmpnums[1]});
    }
    
    if(!isbipartite){
        cout1(-1);
        return 0;
    }
    
    bool dp[MAXN]={0};
    dp[0]=1;
    rep(i,nums.size()){
        rrep(j,N){
            if(!dp[j]) continue;
            dp[j]=false;
            dp[j+nums[i].first]=true;;
            dp[j+nums[i].second]=true;
        }
    }
    
    ll a=-1;
    ll mindif=N;
    rep(i,N+1){
        if(!dp[i]) continue;
        if(mindif>abs(i-N/2)) mindif=abs(i-N/2),a=i;
    }
    ll b=N-a;
    cout1(a*(a-1)/2+b*(b-1)/2);
}

Measured memory_bytes: 768