akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define REPEACH(i,k) for(auto& i:k)
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;


signed main() {
	int h,w;
	cin >> h >> w;
	vector<string> s(h);
	vector<vector<int>> v(h,vector<int>(w,0));
	REP(i,h){
		cin >> s[i];
		int count=0;
		int now=0;
		REP(j,w){
			if(s[i][j]=='#'){
				v[i][j]=0;
				for(int k=now;k<j;k++){
					v[i][k]=count;
				}
				now=j+1;
				count=0;
			}
			else{
				count++;
			}
		}
		if(now!=w){
			for(int k=now;k<w;k++){
				v[i][k]=count;
			}
		}
	}
	int max=0;
	REP(j,w){
		int count=0;
		int now=0;
		REP(i,h){
			if(s[i][j]=='#'){
				v[i][j]=0;
				for(int k=now;k<i;k++){
					v[k][j]+=count-1;
					if(max<v[k][j]){
						max=v[k][j];
					}
				}
				now=i+1;
				count=0;
			}
			else{
				count++;
			}
		}
		if(now==h){
			continue;
		}
		for(int k=now;k<h;k++){
			v[k][j]+=count-1;
			if(max<v[k][j]){
				max=v[k][j];
			}
		}
	}
	cout << max << endl;
}

Measured memory_bytes: 35712
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>

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

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a+b)/2 + (a+b)%2 << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
int arr[200005], pre[200005][25], nxt[200005][25], dp_l[800005], dp_r[800005];
int main()
{
	// freopen("AGC012-E.in", "r", stdin);
	int n, v, len = 0;
	scanf("%d%d", &n, &v);
	for (int i = 1; i <= n; i++)
		scanf("%d", arr + i);
	while (true)
	{
		pre[0][len] = pre[1][len] = 0;
		for (int i = 2; i <= n; i++)
			pre[i][len] = arr[i] - arr[i - 1] <= v ? pre[i - 1][len] : i - 1;
		nxt[n + 1][len] = nxt[n][len] = n + 1;
		for (int i = n - 1; i; i--)
			nxt[i][len] = arr[i + 1] - arr[i] <= v ? nxt[i + 1][len] : i + 1;
		len++;
		if (!v)
			break;
		v >>= 1;
	}
	for (int i = 0; i < 1 << len; i++)
	{
		dp_l[i] = 1;
		dp_r[i] = n;
	}
	for (int i = 0; i < 1 << len; i++)
	{
		for (int j = 0; j < len; j++)
		{
			if (i & (1 << j))
				continue;
			dp_l[i | (1 << j)] = std::max(dp_l[i | (1 << j)], nxt[dp_l[i]][j]);
			dp_r[i | (1 << j)] = std::min(dp_r[i | (1 << j)], pre[dp_r[i]][j]);
		}
	}
	if (dp_l[(1 << len) - 1] <= n)
	{
		for (int i = 0; i < n; i++)
			puts("Impossible");
		return 0;
	}
	for (int l = 1; l <= n; l = nxt[l][0])
	{
		bool flg = false;
		int r = nxt[l][0];
		for (int i = 0; i < 1 << len && !flg; i++)
		{
			if (i & 1)
				continue;
			flg |= l <= dp_l[i] && dp_r[(1 << len) - 2 ^ i] < r;
		}
		for (int i = l; i < r; i++)
			puts(flg ? "Possible" : "Impossible");
	}
	return 0;
}


Measured memory_bytes: 48384
#include<stdio.h>

int main(void) {
  long long x,y;
  long long ans;
  scanf("%lld %lld",&x,&y);
  if(x<0 && y>0 && y > -x|| y >= -x && y <=0){
    ans = x+y+1;
  }else if(x > 0 && y>0 && y < x){
    ans = x-y+2;
  }else if(y>=x && x>=0 || y>=x && y<=0){
    ans = y-x;
  }else if(x < 0 && y < x){
    ans = x-y+2;
  }else{
    ans = -(x+y)+1;
  }
  printf("%lld\n",ans);
  return 0;
}

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

#define print cout <<
#define printl(s) cout << s << endl;
#define rep(i,n) for (int i = 0; i < (n); ++i)

template <typename T>
vector<T> getValues(int num){
    vector<T> values(num);
    for(int i=0;i<num;i++){
        cin >> values.at(i);
    }
    return values;
}

int main(){
    auto inputs = getValues<int>(5);
    int ans = 0;
    rep(i,inputs.size()){
      if(inputs.at(i)==0){
        ans = i+1;
        break;
      }
    }
    printl(ans);
}


Measured memory_bytes: 3504
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
#define INF 1e9+7
#define PI 3.141592653
using namespace std;


int main(){
    int n;
    cin>>n;
    ll a=0,b=0,mx=0;
    multimap<ll,ll> m;
    pan(i,n){
        cin>>b>>a;
        mx=max(mx,a);
        m.insert(pair<ll,ll>(a,b));
    }
    bool flag=false;
    ll sum=0;
    auto i=m.begin();
    for(i=m.begin();i!=m.end();i++){
        sum+=i->second;
        // cout<<sum<<endl;
        if(i->first < sum) {
            flag=true;
            break;
        }
    }
    ll t=sum;
    if(flag==false && t<=mx) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 12800
import numpy as np
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)

N = int(input())
A_str = input()

A_lst = A_str.split(" ")
A_lst = [int(A_lst[i]) for i in range(N)]

dai_lst = []

tmp = A_lst[0]

for a in A_lst:
  if a<tmp:
    dai_lst.append(tmp-a)
  elif a>tmp:
    tmp = a

out = sum(dai_lst)
print(out)

Measured memory_bytes: 51972
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main(){
    int n, mx = 0;
    string s;
    map<string, int> mp;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> s;
        mp[s]++;
        mx = max(mx, mp[s]);
    }
    for(auto i = mp.begin(); i!=mp.end(); i++){
        if(i->second == mx){
            cout << i->first << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 25216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef multiset<int> MS;
typedef queue<int> Q;

int main(){
    int x,a; cin>>x>>a;
    if(x<a) OUT(0);
    else OUT(10);
}

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

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

	int cnt = 0;
	rep(i, n-2){
		if(s.at(i) == 'A' && s.at(i+1) == 'B' && s.at(i+2) == 'C'){
			cnt++;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, c, d, n, count;
	
	while (1) {
		count = 0;
		if (scanf("%d", &n) == EOF)
			break;
		
		for (a = 0; a < 10; a++) {
			for (b = 0; b < 10; b++) {
				for (c = 0; c < 10; c++) {
					for (d = 0; d < 10; d++) {
						if (a + b + c + d == n)
							count++;
					}
				}
			}
		}
		
		printf("%d\n", count);
	}

	return 0;
}

Measured memory_bytes: 0
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string s;
  cin >> s;
  int a;
  int b;

  rep(i,s.size()){
    if(s.at(i) =='A'){
      a = i;
      break;
    }
  }
  for(int i= s.size()-1;i >= 0;i--){
    if(s.at(i) =='Z'){
      b = i;
    break;
    }
  }

  cout << b - a + 1 << endl;
}

Measured memory_bytes: 640
n_t = int(input())
t_lis = list(map(int,input().split()))
n_d = int(input())
d_lis = []
for _ in range(n_d):
  d_lis.append(list(map(int,input().split())))
d_dif = [0]*n_d
for i,item in enumerate(d_lis):
  d_dif[i] = item[1] - t_lis[item[0]-1]
sum_t = sum(t_lis)
for num in d_dif:
  print(sum_t + num)

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline


def main():
    N, D = map(int, input().split())
    D = D ** 2
    ans = 0
    for _ in range(N):
        X, Y = map(int, input().split())
        if X ** 2 + Y ** 2 <= D:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

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

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

  vector<int> c(n-1);
  vector<int> s(n-1);
  vector<int> f(n-1);
  for(int i = 0; i < n-1; i++){
    cin >> c.at(i) >> s.at(i) >> f.at(i);
  }


  for(int x = 0; x < n - 1; x++){
    int tmp = 0, start;
    for(int i = x; i < n - 1; i++){
      start = s.at(i);
      while(tmp > start){
        start += f.at(i);
      }
      tmp = start + c.at(i);
    }
    cout << tmp << endl;
  }
  cout << 0 << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int n = sc.nextInt();
        int[] x = new int[n];
        int sum = 0;
        for(int i = 0; i < n; i++){
            x[i] = sc.nextInt();
        }
        if(m < n){
            Arrays.sort(x);
        sum = x[n-1] - x[0];
        int[] dif = new int[n-1];
        for(int i = 0; i < n-1; i++){
            dif[i] = x[i+1] - x[i];
        }
        Arrays.sort(dif);
        int i = 1;
        int j = n-2;
        while(i < m){
            sum -= dif[j];
            i++;
            j--;
        }
        }
        
        System.out.println(sum);
    }
}


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

#define int long long
#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define reps(i, n) for (int (i) = 1; (i) <= (n); (i)++)
typedef vector<int> vint;
typedef pair<int, int> pint;
constexpr double PI = 3.141592653589793238462643383279;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
        cerr << fixed << setprecision(20);
    };
} init;

int N;
int a[110];
int cnt[110];
signed main() {
    cin >> N;
    rep(i, N) { cin >> a[i]; }
    rep(i, N) { cnt[a[i]]++; }
    int ax = *max_element(a, a + N);
    int in = *min_element(a, a + N);
    bool ans = in >= (ax + 1) / 2;
    for (int i = (ax + 1) / 2 + 1; i <= ax; i++) { ans &= cnt[i] >= 2; }
    if (ax & 1) { ans &= cnt[(ax + 1) / 2] == 2; }
    else { ans &= cnt[(ax + 1) / 2] == 1; }
    if (ans) { cout << "Possible" << endl; }
    else { cout << "Impossible" << endl; }

}

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

using ll = long long; using ld = long double; using ull = unsigned long long; using uint = unsigned int;
using vi  = vector<int>; using vb  = vector<bool>; using vd  = vector<double>; using vl  = vector<ll>;
using vvi = vector<vi>;  using vvb = vector<vb>;   using vvd = vector<vd>;     using vvl = vector<vl>;

#define REP(i,n) for(ll i=0; i<(n); ++i)
#define FOR(i,b,n) for(ll i=(b); i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define TEN(x) ((ll)1e##x)

template<typename T> inline string join(const vector<T>& vec, string sep = " ") { stringstream ss; REP(i, vec.size()) ss << vec[i] << ( i+1 == vec.size() ? "" : sep ); return ss.str(); }


///////////////

#define EPS (1e-10)
#define NEXT(x, i) (x[(i + 1) % x.size()])

template<class T> using CR = const T &;
using P = complex<ld>;
using G = vector<P>;

int sgn(ld a, ld b = 0) {
	if (a > b + EPS) return 1;
	if (a < b - EPS) return -1;
	return 0;
}

ld dot(P a, P b) { return real(conj(a)*b); }
ld cross(P a, P b) { return imag(conj(a)*b); }

int ccw(P a, P b, P c) {
	b -= a;
	c -= a;
	if (sgn(cross(b, c))) return sgn(cross(b, c)); // clockwise(-1) or counter clockwise(1)
	if (sgn(dot(b, c)) == -1) return 2;            // c--a--b
	if (sgn(norm(b), norm(c)) == -1) return -2;    // a--b--c
	return 0;                                      // a--c--b
}

namespace std {
	bool operator < (P a, P b) {
		return sgn(real(a), real(b)) ? real(a) < real(b) : imag(a) < imag(b);
	}
}

pair<ll, ll> convex_diameter(CR<G> g) {
	ll n = g.size();

	ll is = 0, js = 0;
	FOR(i, 1, n) {
		if (imag(g[i]) > imag(g[is])) is = i;
		if (imag(g[i]) < imag(g[js])) js = i;
	}
	ld maxd = norm(g[is] - g[js]);

	ll i, maxi, j, maxj;
	i = maxi = is;
	j = maxj = js;
	do {
		if (cross(g[(i + 1) % g.size()] - g[i], g[(j + 1) % g.size()] - g[j]) >= 0) {
			j = (j + 1) % n;
		} else {
			i = (i + 1) % n;
		}
		if (norm(g[i] - g[j]) > maxd) {
			maxd = norm(g[i] - g[j]);
			maxi = i; maxj = j;
		}
	} while (i != is || j != js);
	return {maxi, maxj};
}

//////////////

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	ll n; cin >> n;

	G g(n);
	REP(i,n){
		ld x, y;
		cin >> x >> y;
		g[i] = { x, y };
	}
	auto p = convex_diameter(g);

	cout << abs(g[p.first] - g[p.second]) << endl;
	return 0;
}

Measured memory_bytes: 5268
n = int(input())
ans = 0
for i in range((n//4)+1):
    for j in range((n//7)+1):
        sum_price = 4 * i + 7 * j
        if sum_price == n:
            ans = 1
            
if ans == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(void){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    bool xcondition = x >= r && x <= W - r;
    bool ycondition = y >= r && y <= H - r;
    if (xcondition && ycondition) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3044
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;
 
string S; int c1 = 0, c2 = 0;
 
int main() {
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		char B = '0'; if (i % 2 == 1) B = '1';
		if (S[i] == B) c2++;
		else c1++;
	}
	cout << min(c1, c2) << endl;
	return 0;
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;

public class Main {
	public void solve() {
		int N = nextInt();
		int A = nextInt();
		int B = nextInt();
		int a = 0;
		int b = 0;
		String s = next();
		for(int i = 0; i < s.length(); i++){
			if(s.charAt(i) == 'a'){
				if(a + b < A + B){
					a++;
					out.println("Yes");
				}else{
					out.println("No");
				}
				
			}else if(s.charAt(i) == 'b'){
				if(a + b < A + B && b < B){
					b++;
					out.println("Yes");
				}else{
					out.println("No");
				}
				
			}else{
				out.println("No");
			}
		}
	}

	private static PrintWriter out;

	public static void main(String[] args) {
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}

	public static int nextInt() {
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(; i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}

	public static long nextLong() {
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(; i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}

	public static String next() {
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}

	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;

	private static int read() {
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return(bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}

	private static boolean isAlNum(int c) {
		return '!' <= c && c <= '~';
	}
}


Measured memory_bytes: 12200
t = gets.to_i
t.times do
  str = gets.split()
  n = str[0].to_i
  k = str[1].to_i
  d = gets.split()
  data = Array.new(n, 0)
  n.times do |i|
    data[i] = d[i].to_i
  end
  prev = 0
  now = 0
  min = 0
  hoge = Array.new(n-1, 0)
  n.times do |i|
    prev = now
    now = data[i]
    tmp = now - prev
    next if i == 0
    hoge[i-1] = tmp
  end
  hoge.sort!
  hoge.reverse!
  a = data[n-1] - data[0]
  if n > k
    (k-1).times do |i|
      a -= hoge[i]
    end
  else
   a = 0
  end
  a = 0 if a < 0
  p a
end

Measured memory_bytes: 21088
#include<stdio.h>
#define N 200000
int main(){
  int ary[N],i,n,min,t,max;
  scanf("%d",&n);
  scanf("%d",&ary[0]);
  min=ary[0];
  for(i=1;i<n;i++){
    scanf("%d",&ary[i]);
    }
  max=ary[1]-min;
  for(i=1;i<n;i++){
    if(ary[i]-min>max){
      max=ary[i]-min;
    }
    if(ary[i]<min){min=ary[i];}
  }
  printf("%d\n",max);
  return 0;
}



Measured memory_bytes: 2564
n,m=map(int,input().split())
if n%2==1:  
  for i in range(m):
    print(i+1,n-i)
else:
  l=[]
  for i in range(n//4):
    l.append([i+1,n//2-i])
  for i in range((n-(n//2)-1)//2):
    l.append([(n//2)+1+i,n-1-i])
  for i in range(m):
    print(*l[i])

Measured memory_bytes: 19616
/**
 * C - Boxes and Candies
 * https://atcoder.jp/contests/abc048/tasks/arc064_a
 **/
#include<iostream>
#include<vector>

#define ll long long

using namespace std;

int main() {
    int n, x;
    cin >> n >> x;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    ll ans = 0;
    for(int i=0; i<n-1; i++) {
        if(a[i+1]+a[i]>x) {
            ll sa = a[i+1]+a[i]-x;
            if(a[i+1]>=sa) {
                a[i+1] = a[i+1] - sa;
            } else {
                a[i+1] = 0;
                a[i] = a[i] - (sa-a[i+1]);
            }
            ans += sa;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int N, L;
    cin >> N >> L;
    string A[N];
    for (int i=0; i<N; i++) cin >> A[i];
    sort(A, A+N);
    string ans;
    for (int i=0; i<N; i++) ans+=A[i];
    cout << ans << endl;
}

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

#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()

typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

ll h,w;

int main(){
    cin >> h >> w;
    ll res = INT_MAX;
    if(h%3==0){
        chmin(res,0);
    }else{
        chmin(res,h);
    }
    if(w%3==0){
        chmin(res,0);
    }else{
        chmin(res,w);
    }
    FOR(i,1,w+1){
        ll s1 = h*i;
        ll s2 = (h/2)*(w-i);
        ll s3 = (h-h/2)*(w-i);
        ll d = max({s1,s2,s3}) - min({s1,s2,s3});
        chmin(res,d);
    }
    FOR(i,1,h+1){
        ll s1 = w*i;
        ll s2 = (w/2)*(h-i);
        ll s3 = (w-w/2)*(h-i);
        ll d = max({s1,s2,s3}) - min({s1,s2,s3});
        chmin(res,d);
    }
    put(res);
    return 0;
}


Measured memory_bytes: 256
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

from collections import deque
sys.setrecursionlimit(10**6)

N, M = mi()
x = li2(M)

adj = [[] for i in range(N)]
for i in range(M):
    x[i][0] -= 1
    x[i][1] -= 1
    adj[x[i][0]].append(x[i][1])

flag = [0]*N
ans = deque([])

def dfs(x):
    if flag[x]:
        return None
    else:
        flag[x] = 1
        for a in adj[x]:
            dfs(a)
        global ans
        ans.appendleft(x)

for i in range(N):
    dfs(i)

dp = [0]*N
for a in ans:
    for b in adj[a]:
        dp[b] = max(dp[b], dp[a] + 1)

print(max(dp))

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

namespace ConsoleApp15 {
    class Program {
        static void Main(string[] args) {
            //入力
            string s = Console.ReadLine();
            int N = int.Parse(s.Split(' ')[0]);
            int K = int.Parse(s.Split(' ')[1]);

            //回答となる数値
            double ans = 0;
            double value;
            double a;

            //実行
            for (int i = 0; i < N; i++) {
                if (K > i) {
                    a = Math.Floor(Math.Log((K - 0.000001f) / (i + 1), 2)) + 1;
                } else {
                    a = 0;
                }
                value = Math.Pow(0.5f, a) / (double)N;
                ans += value;
            }

            //出力
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
#define ll long long

int main() {
    int w, h, n;
    cin >> w >> h >> n;//w = x, h = y, n = count
    vector<int> x(n);
    vector<int> y(n);
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> x[i] >> y[i] >> a[i];
    } 

    int xs = 0, ys = 0;
    int xl = w, yl = h;
    int ans = xl*yl;
    for(int i = 0; i < n; i++) {
        if(a[i] == 1) {
            xs = max(x[i], xs);
        }
        else if(a[i] == 2) {
            xl = min(x[i], xl);
        }
        else if(a[i] == 3) {
            ys = max(y[i], ys);
        }
        else if(a[i] == 4) {
            yl = min(y[i], yl);
        }
        if(yl <= ys) {
            ans = 0;
            break;
        }
        else if(xl <= xs) {
            ans = 0;
            break;
        }
    }

    ans = (xl-xs)*(yl-ys);
    if(ans < 0) {
        cout << 0 << endl;
        return 0;
    } 
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include <cstdio>
#include<cmath>
#define endl '\n'
#define sz 1000001
using namespace std;
typedef long long ll;
ll siv[sz],cnt;
std::vector<ll>prime;

int main()
{
	ll limit = sqrt(sz+1);
	for(ll i = 3; i<=limit; i++)
		if(!siv[i])
			for(ll j = i*i; j<sz; j+=i+i)
				if(!siv[j])siv[j]=1;
	prime.push_back(2);
	for(ll i = 3; i<sz; i+=2)
		if(!siv[i])prime.push_back(i);
	ll x;
	cin >> x;
	vector<ll>::iterator it;
	it = lower_bound(prime.begin(),prime.end(),x);
	cout<<*it;
	return 0;
}

Measured memory_bytes: 9208
X,Y=map(int,input().split())
prize = [0,3*10**5,2*10**5,10**5]
ans = 0
if X < 4:
    ans += prize[X]
if Y < 4:
    ans += prize[Y]
if X == 1 and Y == 1:
    ans += 4*10**5
print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	int N, K;

	cin >> N >> K;

	cout << N - K + 1<< endl;

	return 0;
}


Measured memory_bytes: 256
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

A,B,C,D=map(int,input().split())

lcm_cd = lcm(C,D)

tmp_all_c=B//C
tmp_all_d=B//D
tmp_all_cd=B//lcm_cd
tmp_all=tmp_all_c+tmp_all_d-tmp_all_cd

tmp_untilA_c=(A-1)//C
tmp_untilA_d=(A-1)//D
tmp_untilA_cd=(A-1)//lcm_cd
tmp_untilA=tmp_untilA_c+tmp_untilA_d-tmp_untilA_cd

print((B-A+1)-(tmp_all-tmp_untilA))

Measured memory_bytes: 3064
# D - RGB Triplets
from collections import defaultdict


def main():
    _, S = open(0).read().split()
    indices, doubled_indices = defaultdict(list), defaultdict(set)
    for i, c in enumerate(S):
        indices[c].append(i)
        doubled_indices[c].add(2 * i)

    cnt = len(indices["R"]) * len(indices["G"]) * len(indices["B"])
    for x, y, z in ("RGB", "RBG", "BGR"):
        cnt -= sum(i + j in doubled_indices[z] for i in indices[x] for j in indices[y])
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9752
n, m = gets.chomp.split.map(&:to_i)
hash = {}
m.times do |i|
	hash[gets.chomp.to_i] = true 
end
mod = 10 **9 + 7

ngo = Array.new(n+1,0)
ngo[0] = 1

(n-1).times do |i|
	ngo[i] %= mod
	next if hash.has_key?(i)
	ngo[i+1] += ngo[i] if hash.has_key?(i+1) == false 
	ngo[i+2] += ngo[i] if hash.has_key?(i+2) == false 
end
ngo[n] += ngo[n-1] if hash.has_key?(n-1) == false

puts ngo[n] % (10 ** 9 + 7)



Measured memory_bytes: 19048
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) throws IOException {
	Main mainObj = new Main();
	mainObj.solve();
}

public void solve() throws IOException {
	FastScanner fs = new FastScanner();
	int n = fs.nextInt();
	int i = fs.nextInt();
	
	System.out.println(n - i +1);
}



public class FastScanner {

	BufferedReader reader;
	private StringTokenizer st;

	public FastScanner() {
		st = null;
		reader = new BufferedReader(new InputStreamReader(System.in));
	}

	public String next() throws IOException {
		if (st == null || !st.hasMoreElements()) {
			st = new StringTokenizer(reader.readLine());
		}
		return st.nextToken();
	}

	public String nextLine() throws IOException {
		st = null;
		String readLine = null;
		readLine = reader.readLine();
		return readLine;
	}

	public int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(next());
	}

	public long nextLong() throws NumberFormatException, IOException {
		return Long.parseLong(next());
	}

	public int[] nextIntArr(int n) throws NumberFormatException, IOException {
		int[] retArr = new int[n];
		for (int i = 0; i < n; i++) {
			retArr[i] = nextInt();
		}
		return retArr;
	}

	public long[] nextLongArr(int n) throws NumberFormatException, IOException {
		long[] retArr = new long[n];
		for (int i = 0; i < n; i++) {
			retArr[i] = nextLong();
		}
		return retArr;
	}

	public void close() throws IOException {
		reader.close();
	}
}

}


Measured memory_bytes: 21076
import java.util.*;

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int A=sc.nextInt();
		int P=sc.nextInt();
		P += 3*A;
		int ans = P/2;
		System.out.println(ans);
		sc.close();
	}


}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

vector<vector<ll>> g;
vector<ll> dp;

ll dfs(ll v = 0) {
    if (dp[v] != -1) return dp[v];
    vector<ll> s;
    for(auto &x : g[v]) {
        s.push_back(dfs(x));
    }
    sort(rall(s));
    dp[v] = sz(s);
    rep(i, sz(s)) {
        dp[v] = max(dp[v], s[i] + i);
    }
    return dp[v] + 1;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    g.resize(n);
    rep(i, n - 1) {
        ll a;
        cin >> a;
        g[a - 1].push_back(i + 1);
    }
    dp.resize(n, -1);
    cout << (dfs(0) - 1) << endl;
    return 0;
}


Measured memory_bytes: 21792
#include<bits/stdc++.h>
using namespace std;
int sum;
int main(){
	int a,b,c,x;
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int n=0;n<=c;n++){
				if(500*i+100*j+n*50==x){
					sum++;
				}
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}

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

int main(void) {

    int n;
    cin >> n;
    int n2 = n % 10;
    switch (n2)
    {
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl;
        break;
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon" << endl;
        break;
    case 3:
        cout << "bon" << endl;
        break;
    default:
        break;
    }

    return 0;

}

Measured memory_bytes: 3636
s = input()

n = 4

for i in range(2 ** (n-1)):
    formula = s[0]
    for j in range(n-1):
        if i >> j & 1 == 1:
            formula += '+{}'.format(s[j+1])
        else:
            formula += '-{}'.format(s[j+1])

    if eval(formula) == 7:
        print(formula+'=7')
        exit()


Measured memory_bytes: 3060
#include<stdio.h>

int main(void)
{
   int n,d,x,i,o,s,j,a[100];

   scanf("%d",&n);
   scanf("%d%d",&d,&x);
   for(i=0;i<n;i++)
      scanf("%d",&a[i]);
   s=0;
   for(i=0;i<n;i++){
     for(j=1;j<=d;j=j+a[i])
        s++;
   }

   printf("%d\n" ,s+x);
   return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define N 1000005
#define fori(i,j,n) for(int i=j;i<n;i++)
#define ford(i,j,n) for(int i=j-1;i>=n;i--)
ll a[N];
ll b[N];
ll c[N];
ll fq[N]={0};
string str[N];
bool mycmp(ll x,ll y){
    return (x>y);
}
ll fun(ll x, ll y, ll p) 
{ 
    ll res=1;
    x = x % p;
    while (y > 0){ 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p;   
    } 
    return res; 
} 
int main(){
	ll T,TT=1;
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	//cin>>TT;
	for(T=1;T<=TT;T++){
	    ll n,i,j=0,l,r,k=1,m=0,ans=0,max_ele=INT_MIN,q,min_ele=INT_MAX,dig,sum=0,x=0,y=0,z=0,p=int(1e9+7);
	    ld a1,a2=INT_MAX;
	    string s,s1,s2,s3;
	    vector<ll>v;
	    vector<pair<ll,ll>>vec1;
	    vector<pair<ll,pair<ll,ll>>>vec2;
        cin>>s;
        fori(i,0,s.size()){
            s1.pb(s[i]);
            if(s1.size()==1 &&(k==1||(k==0 && s[i]!=s[i-1]))){
                j++;
                s1.clear();
                k=0;
            }
            if(s1.size()==2){
                j++;
                s1.clear();
                k=1;
            }
        }
        cout<<j;
	}
	return 0;
}

Measured memory_bytes: 8912
n = int(input())
ab = 0
bx = 0
xa = 0
bxa = 0

for ln in range(n):
    line = input().rstrip()
    ab += line.count("AB")
    first , last = line[0], line[-1]
    if (first, last) == ('B', 'A'):
        bxa += 1
    elif first == 'B':
        bx += 1
    elif last == 'A':
        xa += 1

if bx + xa == 0:
    bxa = max(0, bxa - 1)

print(ab + bxa + min(bx, xa))

Measured memory_bytes: 3188
n = int(input())
mod = 10**9+7
def power(a,n):
  ans = 1
  while n:
    if n%2:
      ans = (ans*a)%mod
    a = (a*a)%mod
    n >>= 1
  return ans%mod  
s = power(10,n)
s -= 2*power(9,n)
s += power(8,n)
print(s%mod)

Measured memory_bytes: 61776
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <numeric>
#include <iomanip>
#define FI first
#define SE second
#define EB emplace_back
#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 1100000000
#define LLINF 1100000000000000000LL
#define Decimal fixed << setprecision(20)
#define ALL(c) c.begin(),c.end()
#define SHOWVEC(v, sz) for(int i = 0; i < sz; i++) cerr << v[i] << ' '; cerr << endl;
#define SHOWX(x) cerr << #x << ": " << x << endl;
#define SHOWP(p) cerr << "[" << p.first << ',' << p.second << "]";

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

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

  vector<string> T = { "RUD", "LUD" };
  REP(i, S.size()) {
    int t = i % 2;
    if (find(ALL(T[t]), S[i]) == T[t].end()) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
h_s = list(map(int, input().split()))+[0]*K
# print(h_s)
dp = [float("inf")]*(N+K)
dp[0] = 0
 
for i in range(N):
    for j in range(1, K+1):
        dp[i+j] = min(dp[i+j], dp[i]+abs(h_s[i]-h_s[i+j]))
 
print(dp[N-1])

Measured memory_bytes: 56288
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

unordered_set<long> st;

bool isok(long i) {
  while (true) {
    if (i == 0) return true;
    long tmp = i % 10;
    if (st.count(tmp)) return false;
    i /= 10;
  }
}

void solve() {
  long N, K;
  cin >> N >> K;
  rep (i, K) {
    long d;
    cin >> d;
    st.insert(d);
  }
  for (long i = N;; i++) {
    if (isok(i)) {
      cout << i << endl;
      return;
    }
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
num = int(input())
build = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for i in range(num):
    b,f,r,v = map(int,input().split())
    build[b-1][f-1][r-1] += v
#    print(build)

for k in range(4):
    for j in range(3):
        for i in range(10):
            print("",build[k][j][i],end='')
        print()
    if k <= 2:
        print("#"*20)


Measured memory_bytes: 5632
#include<stdio.h>
int main(void){
int A, B, sum=0, ch=0;
scanf("%d%d", &A , &B);
sum+=A;
if(A>B && B==1){
    printf("0\n");
}else{
while(1){
    if(sum>=B){
        break;
    }
    sum+=A-1;
    ch++;
}
printf("%d\n", ch+1); 
}
return 0;
}

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

int main (void){
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  k--;
  cout << a[k] << '\n';
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    
    int r,d,ans[11];cin>>r>>d>>ans[0];
    
    for(int i=1;i<11;++i){
        ans[i]=r*ans[i-1]-d;
        cout<<ans[i]<<endl;
    }
	return 0;
}

Measured memory_bytes: 256
N = gets.to_i
a = gets.split.map(&:to_i)

ans = 0

(2**30).times do |i|
  
  f = true
  
  a.each do |j|
    
    if j % 2 == 1
      f = false
      break
    end
  end
  
  if f
    ans += 1
    a = a.map{ |j| j / 2 }
  end
  
  break if !f

end

puts ans

Measured memory_bytes: 1788
M, D = map(int, input().split())

ans = 0
for m in range(1, M + 1):
  for d in range(1, D + 1):
    d1 = d % 10
    d10 = d // 10
    if d1 * d10 == m and d1 >= 2 and d10 >= 2:
      ans += 1
print(ans)

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

int main(){
double x,h,c,a;
while(1){
scanf("%lf%lf",&x,&h);
if(x==0&&h==0)break;
c=4*h*h+x*x;
c=sqrt(c);
a=x*c+x*x;
printf("%f\n",a);
}
return 0;
}

Measured memory_bytes: 1068
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
int n,m,c;
int b[25];
int a[25][25];
int sum=0;
int yes=0;
scanf("%d %d %d",&n,&m,&c);
for(int count=0;count<m;count++){
scanf("%d",&b[count]);
}

for(int count2=0;count2<n;count2++){
    for(int count=0;count<m;count++){
        scanf("%d",&a[count2][count]);
    }
}

for(int i=0;i<n;i++){
    for(int ii=0;ii<m;ii++){
        sum=sum+a[i][ii]*b[ii];
    }
    sum=sum+c;
    if(sum>0){yes++;}
    sum=0;
}
printf("%d",yes);
}


Measured memory_bytes: 128
num,renzoku=map(int,input().split())
dices=list(map(int,input().split()))
expects=[0]*num
for i in range(num):
  pi=dices[i]
  expects[i]=(1+pi)/2
Si=[0]*(num+1)
for i in range(1,num+1):
  Si[i]=Si[i-1]+expects[i-1]
max_Si=0
for i in range(0,num-renzoku+1):
  if max_Si<Si[i+renzoku]-Si[i]:
    max_Si=Si[i+renzoku]-Si[i]
print(max_Si)

Measured memory_bytes: 25060
def inpl(): return [int(i) for i in input().split()]

N =int(input())
p = inpl()
H = ''
for i in range(1,N+1):
    if i != p[i-1]:
        H += '1'
    else:
        H += '0'
H = H.replace('00','1')
ans = N - len(H)

ans += H.count('0')
print(ans)

Measured memory_bytes: 13880
// https://atcoder.jp/contests/abc108/tasks/arc102_a

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 2*1e5;
const int K_MAX = 2*1e5;

int N, K;

void solve() {
  ll m = N / K;
  ll ans = m * m * m;
  if (K % 2 == 0) {
    ll m2 = N / (K / 2) - m;
    ans += m2 * m2 * m2;
  }
  printf("%lld\n", ans);
}

void input() {
  scanf("%d%d", &N, &K);
}

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(void)
{
	int R[MAX], n;
	
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> R[i];

	int maxv = -2000000000;
	int minv = R[0];
	for (int i = 1; i < n; i++)
	{
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}

	cout << maxv << endl;
	return 0;
}


Measured memory_bytes: 3868
import java.util.Scanner;
class Main {
	int n,i,y;
	String x;
	private int[] S = new int[14];
	private int[] H = new int[14];
	private int[] C = new int[14];
	private int[] D = new int[14];
	public void suzuki(){
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		for(i = 0;i != n;i++){
			x = sc.next();
			if(x.equals("S")){
				y = sc.nextInt();
				S[y] = y;
			}else if(x.equals("H")){
				y = sc.nextInt();
				H[y] = y;
			}else if(x.equals("C")){
				y = sc.nextInt();
				C[y] = y;
			}else if(x.equals("D")){
				y = sc.nextInt();
				D[y] = y;
			}
		}
		for(i = 1;i <= 13;i++){
			if(S[i]  == 0){
				System.out.println("S" + " " + (i));
			}
		}
		for(i = 1;i <= 13;i++){
			if(H[i] == 0){
				System.out.println("H" + " " + (i));
			}
		}
		for(i = 1;i <= 13;i++){
			if(C[i] == 0){
				System.out.println("C" + " " + (i));
			}
		}
		for(i = 1;i <= 13;i++){
			if(D[i] == 0){
				System.out.println("D" + " " + (i));
			}
		}
	}
	public static void main(String[] args){
		new Main().suzuki();
	}
}

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

int main(){
  int H, W;
  while(true){
    cin >> H >> W;
    if(H == 0 && W == 0){
      break;
    }
    for(int i = 0; i < H; i++){
      if(i % 2 == 0){
        for(int j = 0; j < W; j++){
          if(j % 2 == 0){
            cout << "#";
          }
          else{
            cout << ".";
          }
        }
      }
      else{
        for(int j = 0; j < W; j++){
          if(j % 2 == 0){
            cout << ".";
          }
          else{
            cout << "#";
          }
        }
      }
      cout << endl;
    }
    cout << endl;
  }
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;

// int prime[1000001];
// vector<ll> primes;

// void soe() {
//     int i,j;
//     for(i=2;i<1000001;i++) prime[i] = 1;
//     for(i=2;i<=sqrt(1000001);i++) {
//         if(prime[i] == 1) {
//             for(j=i*i;j<1000001;j+=i) {
//                 prime[j] = 0;
//             }
//         }
//     }
//     for(i=2;i<1000001;i++) {
//         if(prime[i]) primes.pb(i);
//     }
// }

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

    string s;
    cin >> s;
    int l=0, r=s.length()-1, cnt=0;
    while(l<=r) {
        if(s[l]!=s[r]) {
            cnt++;
        }
        l++; r--;
    }
    cout << cnt << "\n";
    return 0;
}




Measured memory_bytes: 256
// In The Name Of God
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define sqr(A) ((A) * (A))
#define X first
#define Y second
#define MP make_pair
#define bsz  __builtin_popcount
#define all(A) A.begin(), A.end()
using namespace std;
using namespace __gnu_pbds;
template < typename T >
using ordered_set = tree < T , null_type , less < T > , rb_tree_tag , tree_order_statistics_node_update >;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
const int MOD2 = 1e9 + 9;
const int PR = 727;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;

const int N = 3e2 + 20;
int dp[N][N][N], n, k;
string s;

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> s >> k; n = s.size();
	for (int i = 0; i < n; i++)
		for (int j = 0; j <= k; j++)
			dp[i][i][j] = 1;
	for (int i = 0; i < n - 1; i++) {
		dp[i][i + 1][0] = (s[i] == s[i + 1] ? 2 : 1);
		for (int j = 1; j <= k; j++)
			dp[i][i + 1][j] = 2;
	}
	for (int gap = 3; gap <= n; gap++)
		for (int i = 0; i < n - gap + 1; i++) {
			int j = i + gap - 1;
			if (s[i] == s[j])
				dp[i][j][0] = dp[i + 1][j - 1][0] + 2;
			dp[i][j][0] = max({dp[i][j][0], dp[i + 1][j][0], dp[i][j - 1][0]});
			for (int x = 1; x <= k; x++) {
				if (s[i] == s[j])
					dp[i][j][x] = dp[i + 1][j - 1][x] + 2;
				dp[i][j][x] = max({dp[i][j][x], dp[i + 1][j - 1][x - 1] + 2, dp[i + 1][j][x], dp[i][j - 1][x]});
			}
		}
	cout << dp[0][n - 1][k] << endl;
}



Measured memory_bytes: 120960
n = int(input())
pl = list(map(int, input().split()))

ans = 0
for i in range(1, n-1):
    if (pl[i-1] < pl[i] <= pl[i+1]) | (pl[i+1] < pl[i] <= pl[i-1]):
        ans += 1
        
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
    int a, b;
    int ans;
    
    scanf("%d %d", &a, &b);
    
    if(a - b < 0){
        ans = (a-b) * (-1);
    }else{
        ans = a - b;
    }
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 2760
#include <cstdio>
#include <math.h>

using namespace std;

int main(){
  int a, b;
  while(true) {
    scanf("%d %d", &a, &b);
    if(a==0 && b==0) {
      return 0;
    }
    for(int i=0; i<a; i++) {
      for(int j=0; j<b; j++) {
        if((i+j) % 2 == 0) {
          printf("#");
        } else {
          printf(".");
        }
      }
      printf("\n");
    }
    printf("\n");
  }
}



Measured memory_bytes: 2616
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e9;
int main(){
	string s;
	cin>>s;
	int co=0;
	rep(i,s.size()-1)if(s[i]!=s[i+1])co++;
	cout<<co<<endl;
}









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

int main()
{
    const int MAX_VALUE = 10000;

    int n;
    cin >> n;

    int A[n + 1], B[n + 1], C[MAX_VALUE + 1];
    for (int i = 0; i <= MAX_VALUE; i++) {
        C[i] = 0;
    }
    for (int i = 1; i <= n; i++) {
        cin >> A[i];
        C[A[i]]++;
    }
    for (int i = 1; i <= MAX_VALUE; i++) {
        C[i] += C[i - 1];
    }
    for (int i = 1; i <= n; i++) {
        B[C[A[i]]--] = A[i];
    }
    for (int i = 1; i <= n; i++) {
        cout << B[i] << (i < n ? " " : "\n");
    }
    return 0;
}

Measured memory_bytes: 18712
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
	char a,b;
	cin>>a>>b;
	if(a==b)cout<<"H"<<endl;
	else cout<<"D"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll inf = numeric_limits<ll>::max()/3;

int main(void){
  int n,k;
  cin >> n >> k;
  for(int i = 0;i < n;++i){
    int tmp;
    cin >> tmp;
  }
  cout << (int)ceil((double)(n-1)/(k-1)) << endl;
  return 0;
}



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

int main()
{
  int n;
  cin>>n;
  vector<double> ip(n);
  vector<vector<double>> dp(n+1,vector<double>(n+1,0.0));
  //dp[i]->i heads
  for(double &x: ip)
  cin>>x;

  dp[0][0]=1;
  for(int i=1;i<=n;i++)
  {
    for(int j=0;j<=i;j++)
    {
      dp[i][j]=dp[i-1][j]*(1-ip[i-1])+(j==0?0:dp[i-1][j-1]*ip[i-1]);
    }
  }
  double sum=0;
  for(int i=(n+2)/2;i<=n;i++)
  {
    sum+=dp[n][i];
  }
  printf("%.10lf\n",sum);

  return 0;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main()
{
	ll n,h,a,b,maxa=0,cnt=0,i=0;
	vll bb;
	cin >> n >> h;
	rep(i,n){
		cin >> a >> b;
		maxa=max(maxa,a);
		bb.pb(b);
	}
	sort(rall(bb));
	while(h>0){
		if(bb[i]>maxa) h-=bb[i];
		else break;
		cnt++;
		i++;
	}
	if(h>0)cnt+=(h%maxa==0?h/maxa:h/maxa+1);
	cout << cnt << endl;
	return 0;
}

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

int main() {
    int N, K, X, Y;
    cin >> N >> K >> X >> Y;
    int t=0;
    for (int i=0; i<N; i++) {
        if (i<K) t+=X;
        else t+=Y;
    }
    cout << t << "\n";
}

Measured memory_bytes: 256