akhauriyash/Code-Regression huggingface dataset:
//#include<bits/stdc++.h>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
/*#define fast ios_base::sync_with_stdio(0); cin.tie(0)*/
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
const double pi = acos(-1);
typedef long long ll;
int main()
{
	//fast;
	
	ll a,b;
	cin>>a;
	cout<<48-a;
}

Measured memory_bytes: 3544
x, y = gets.split.map(&:to_i) 

cond = true
z = (x - y).abs

ans = 'Alice'
case z%3
when 0 
    ans = 'Brown' if z == 0
when 1
    ans = 'Brown' if z == 1
when 2
    ans = 'Brown' if z == 0
else
    raise
end

puts ans




Measured memory_bytes: 14296
#include<iostream>
#define rep(i,a) for(int i=0;i<a;i++)
using namespace std;

int main(){
	int t[4];
	rep(i,4)cin>>t[i];
	int sum=0;
	rep(i,4)sum+=t[i];
	cout<<sum/60<<"\n"<<sum%60<<endl;
	return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
#include <chrono>
#include <math.h>
using namespace std;
using ll = long long;
using ld = long double;
using namespace std::chrono; 
#define fo(i,z,n) for(int i = z;i<n;i++)
#define Fo(i,z,n) for(ll i = z;i<n;i++)
#define INT_BITS 32
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> > 
#define pb push_back
#define f first
// #define s second
#define int long long
#define all(c) (c).begin(), (c).end()
#define endl '\n'


int32_t main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     cout.tie(0);
   	
//      int t;
//      cin >> t;
//      while(t--){


// }

int n,m,k;
cin >> n >> m >> k;
vi a(n+1);
vi b(m+1);
fo(i,1,n+1)cin >> a[i];
fo(i,1,m+1)cin >> b[i];
fo(i,1,n+1){
	a[i] += a[i-1];
}
fo(j,1,m+1){
	b[j] += b[j-1];
}
int ans = 0;
int j = m;
fo(i,0,n+1){
	if(a[i] > k)break;
	while(b[j] > k-a[i])j--;
	ans = max(ans,i+j);
}
cout << ans << endl;
return 0;
}



Measured memory_bytes: 6372
#include<iostream>
#include<algorithm>
typedef long long lint;
using namespace std;

int main()
{
	lint x;
	lint ans;
	
	cin >> x;
	
	ans=2*(x/11);
	if(x%11!=0)
	{
		if(x%11<=6)ans+=1;
		else ans+=2;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef pair<ll, ll> P;
const int MAXN = 1e5 + 7;
const int LOG = 20;
const int INF = 0x3f3f3f3f;

int jc(int n){
    if(n <= 0)
        return 1;
    int ret = 1;
    for(int i = 1;i <= n;i++)
        ret *= i;
    return ret;
}

void solve() {
    int n, m;
    cin >> n >> m;
    int ans = 0;
    if(n >= 2){
        ans = n*(n-1)/2;
    }
    if(m >= 2){
       ans +=  m*(m-1)/2;
    }
    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int T;
    T = 1;
    while(T--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <numeric>
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define int long long
#define inf 1000000007
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
int comb[55][55];
void init(){
    comb[0][0]=1;
    rep(i,1,55){
        rep(j,0,i+1){
            if(!j)comb[i][j]=comb[i-1][j];
            else if(j==i)comb[i][j]=comb[i-1][j-1];
            else comb[i][j]=comb[i-1][j]+comb[i-1][j-1];
        }
    }
}

signed main(){
    int a,b,n;cin>>n>>a>>b;
    vector<int>v;rep(i,0,n){int s;cin>>s;v.push_back(s);}
        sort(v.begin(),v.end());
        reverse(v.begin(),v.end());
        long double ans=0;
        rep(i,0,a){
            ans+=v[i];
        }
        cout<<setprecision(8)<<ans/a<<endl;
    int h=v[a-1];
    reverse(v.begin(),v.end());
    int num=upper_bound(v.begin(),v.end(),h)-lower_bound(v.begin(),v.end(),h);
    int f=v.end()-upper_bound(v.begin(),v.end(),h);
    int count=0;
    init();
    rep(i,a,b+1){
        if(num<i-f||(i!=a&&f!=0))break;
        count+=comb[num][i-f];
    }
    cout<<count<<endl;
        return 0;
}


Measured memory_bytes: 256
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result = result * int(numerator[k]) % 1000000007
    return result


X, Y = map(int, input().split())

if (X+Y)%3 != 0 or X < Y / 2 or Y < X / 2:
    print(0)
    exit()

num = (X + Y) // 3
ans = cmb(num, X-num)
print(ans)


Measured memory_bytes: 44148
#include<iostream>

using namespace std;

#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  for (int i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }
  for (int i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }
  L[n1].value = R[n2].value = SENTINEL;
  int i = 0;
  int j = 0;
  for (int k = left; k < right; k++) {
    if (L[i].value <= R[j].value) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}
   
void mergeSort(struct Card A[], int left, int right){
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int partition(struct Card A[], int p, int r) {
  struct Card x = A[r];
  int i = p - 1;
  for (int j = p; j < r; j++) {
    if (A[j].value <= x.value) {
      i++;
      swap(A[i], A[j]);
    }
  }
  swap(A[i+1], A[r]);
  return i + 1;
}

void quickSort(struct Card A[], int p, int r) {
  int q;
  if (p < r) {
    q = partition(A, p, r);
    quickSort(A, p, q - 1);
    quickSort(A, q + 1, r);
  }
}

int main() {
  struct Card A[MAX], B[MAX];

  int N;
  cin >> N;

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

  mergeSort(A, 0, N);
  quickSort(B, 0, N - 1);

  bool stable = true;

  for (int i = 0; i < N; i++) {
    if (A[i].suit != B[i].suit) {
      stable = false;
    }
  }

  if (stable) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }
  for (int i = 0; i < N; i++) {
    cout << B[i].suit << " " << B[i].value << endl;
  }

  return 0;
}


Measured memory_bytes: 5428
import java.util.*;
public class Main{
	static long mod=1000000007;
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		long ans=1;
		long xx=0;
		long yy=0;
		if(x>y){
			xx+=x-y;
			x-=xx*2;
			y-=xx;
		}else if(x<y){
			yy+=y-x;
			y-=yy*2;
			x-=yy;
		}
		if(x<0 || y<0){
			System.out.println(0);
			return;
		}
		if(x%3!=0 || y%3!=0){
			System.out.println(0);
			return;
		}
		
		xx+=x/3;
		yy+=x/3;
		long xk=1;
		long yk=1;
		for(long i=2; i<=xx+yy; i++){
			ans*=i;
			ans%=mod;
			if(i<=xx){
				xk*=i;
				xk%=mod;
			}
			if(i<=yy){
				yk*=i;
				yk%=mod;
			}
		}
		ans*=pow(xk,mod-2);
		ans%=mod;
		ans*=pow(yk,mod-2);
		ans%=mod;
		System.out.println(ans);
	}
	static long pow(long p,long q){
		long res=1;
		while(q>0){
			if((q & 1)==1){
				res*=p;
				res%=mod;
			}
			q>>=1;
			p*=p;
			p%=mod;
		}
		return res;
	}
}


Measured memory_bytes: 23124
import java.io.*;

import java.util.*;
import java.math.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.math.BigInteger.*;
import static java.lang.Character.*;

class AOJ1021 {
	public void run() {
		Scanner sc = new Scanner(System.in);
		// while (sc.hasNext()) {
		List<StringBuilder> lb = new ArrayList<StringBuilder>();
		while (true) {
			String s = sc.nextLine();
			if (s.equals("END_OF_TEXT"))
				break;
			lb.add(new StringBuilder(s));
		}
		int cur = 0, line = 0;
		StringBuilder buf = new StringBuilder();
		loop: while (true) {
			char c = sc.nextLine().charAt(0);
			switch (c) {
			case '-':
				break loop;
			case 'a':
				cur = 0;
				break;
			case 'e':
				cur = lb.get(line).length();
				break;
			case 'p':
				cur = 0;
				line = max(line - 1, 0);
				break;
			case 'n':
				cur = 0;
				line = min(line + 1, lb.size() - 1);
				break;
			case 'f':
				if (cur < lb.get(line).length())
					cur++;
				else if (line < lb.size() - 1) {
					cur = 0;
					line++;
				}
				break;
			case 'b':
				if (cur > 0)
					cur--;
				else if (line > 0) {
					line--;
					cur = lb.get(line).length();
				}
				break;
			case 'd':
				if (cur < lb.get(line).length())
					lb.get(line).deleteCharAt(cur);
				else if (line < lb.size() - 1) {
					lb.get(line).append(lb.get(line + 1));
					lb.remove(line + 1);
				}
				break;
			case 'k':
				if (cur < lb.get(line).length()) {
					buf = new StringBuilder(lb.get(line).substring(cur));
					lb.get(line).delete(cur, lb.get(line).length());
				} else if (line < lb.size() - 1) {
					lb.get(line).append(lb.get(line + 1));
					lb.remove(line + 1);
					buf = null;
				}
				break;
			case 'y':
				if (buf == null) {
					if (cur < lb.get(line).length()) {
						lb.add(line + 1, new StringBuilder(lb.get(line).substring(cur)));
						lb.get(line).delete(cur, lb.get(line).length());
					} else {
						lb.add(line + 1, new StringBuilder());
					}
					line++;
					cur = 0;
				} else {
					lb.get(line).insert(cur, buf);
					cur += buf.length();
				}
				break;
			}
		}
		for (StringBuilder sb : lb)
			System.out.println(sb);
		// }
	}
}

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

	public static void debug(Object... os) {
		System.err.println(java.util.Arrays.deepToString(os));
	}
}

class Scanner {
	final java.util.Scanner sc;

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

	public Scanner(java.io.InputStream is) {
		this.sc = new java.util.Scanner(is);
	}

	public boolean hasNext() {
		return sc.hasNext();
	}

	public String next() {
		return sc.next();
	}

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

	public String nextLine() {
		return sc.nextLine();
	}

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

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

ll A, B, v, w, t;

int main() {
    cin >> A >> v;
    cin >> B >> w;
    cin >> t;
    if(w >= v) {
        cout << "NO" << endl;
    }else {
        ll sa = abs(v-w);
        ll len = abs(A-B);
        if(sa*t >= len) {
            cout << "YES" << endl;
        }else {
            cout << "NO" << endl;
        }
    }
}

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

int main(){
    string S;
    cin >> S;
    bool alp[26] = {false};
    for (int i = 0; i < S.size(); ++i) alp[S[i] - 'a'] = true;
    for(int i = 0; i < 26; ++i){
        if(!alp[i]){
            char c=('a'+i);
            cout << c << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    S = list(input())
    N = len(S)

    for i in range(N//2):
        if S[i] != S[-i-1]:
            print("No")
            return
    N1 = (N-1)//2
    for i in range(N1//2):
        if S[i] != S[N1-i-1]:
            print("No")
            return
    N2 = (N+3)//2-1
    for i in range(N2, N):
        if S[i] != S[N2-1-i]:
            print("No")
            return
    print("Yes")

if __name__ == "__main__":
    resolve()


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

int main()
{
	int i, a, b, N, s[100], f[100], F = 0;
	cin >> a >> b;
	cin >> N;
	for (i = 0; i<N; i++) { cin >> s[i]; cin >> f[i]; }
	for (i = 0; i<N; i++) {
		if (s[i]<a && a<f[i]) {
			F = 1;
		}
		else if (s[i]<b && b<f[i]) {
			F = 1;
		}
		else if (a <= s[i] && f[i] <= b) {
			F = 1;
		}
	}
	cout << F << endl;
	return 0;
}





Measured memory_bytes: 3100
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <complex>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

struct Blk {
  int w, s, v, n;
};

Blk A[1000];
long long F[1001][10001];

long long dfs(int n, int w) {
  if (n < 0)
    return 0;
  if (w > 10000)
    return 0;
  if (F[n][w] != -1)
    return F[n][w];
  F[n][w] = dfs(n - 1, w);
  if (w <= A[n].s)
    F[n][w] = max(F[n][w], dfs(n - 1, w + A[n].w) + A[n].v);
  return F[n][w];
}

int main() {
  int N;
  scanf("%d", &N);
  for (auto i = 0; i < N; ++i) {
    scanf("%d%d%d", &A[i].w, &A[i].s, &A[i].v);
    A[i].n = i;
  }
  sort(A, A + N, [](const Blk& a, const Blk& b) {
    return a.w + a.s != b.w + b.s ? a.w + a.s > b.w + b.s : a.n < b.n;
  });
  //static long long F[10001];
  //for (auto i = 0; i < N; ++i)
  //  for (auto j = A[i].w; j <= 10000; ++j)
  //    F[min(j - A[i].w, A[i].s)] = max(F[min(j - A[i].w, A[i].s)], F[j] + A[i].v);
  //static long long F[1001][10001];
  //for (auto i = 0; i < N; ++i)
  //  for (auto j = 0; j <= 10000; ++j) {
  //    F[i + 1][j] = max(F[i + 1][j], F[i][j]);
  //    if (j >= A[i].w)
  //      F[i + 1][min(j - A[i].w, A[i].s)] = max(F[i + 1][min(j - A[i].w, A[i].s)], F[i][j] + A[i].v);
  //  }
  memset(F, -1, sizeof(F));
  printf("%lld\n", dfs(N - 1, 0));
  return 0;
}


Measured memory_bytes: 78464
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
using namespace std;
using ll = long long;
void self_max(int &a,int b){
	a = max(a,b);
}
void self_min(ll &a,ll b){
	a = min(a,b);
}

int main(){
	int a,b; cin >> a >>b;
	if(a>=10 or b >= 10){
		cout << -1 << endl;
	}else {
		cout << a*b << endl;
	}

	return 0;
}




Measured memory_bytes: 256
#include <iostream>

using namespace std;
int n, year, month, day;

main(){
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> year >> month >> day;
		if (year % 3 != 0){
			cout << 196471-(((year - 1) / 3) * (390 + 200) + ((year - 1) % 3) * (195) + ((month - 1) / 2) * (19) + ((month - 1) % 2 + (month - 1) / 2) * (20) + day) << endl;
		}else{
			cout << 196471-(((year - 1) / 3) * (390 + 200) + ((year - 1) % 3) * (195) + (month - 1) * (20) +  day) << endl;
		}
		
	}
}


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

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

    int ans = 0;

    if (s[0] == '1')
        ++ans;
    if (s[1] == '1')
        ++ans;
    if (s[2] == '1')
        ++ans;

    cout << ans << endl;
}

Measured memory_bytes: 256
program b162
        integer*8 i
        integer*8 N,M
        read(*,*)N
        M = 0.D0

        do i = 1,N

        if (.not.((mod(i,3)== 0 ).or.(mod(i,5) == 0)))then
            M = M +i
        endif
        enddo
        write(*,*)M

        end program





Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;
typedef vector<int> ivec;

const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  int a,b,c;cin>>a>>b>>c;
  cout<<(c/a)*b<<endl;
  return 0;
}


Measured memory_bytes: 3604
import itertools
N = int(input())
# N=10^5
count={}
for i in range(N):
    c = input()[0]
    count[c] = count.get(c, 0)+1
s = 0
for a,b,c in itertools.combinations("MARCH", 3):
    s += count.get(a,0)*count.get(b,0)*count.get(c,0)
print(s)
    



Measured memory_bytes: 3060
def main():
    s = input()
    cubes = []
    for c in s:
        if c == "0":
            cubes.append("red")
        else:
            cubes.append("blue")

    buffer = [] #キューブの一時保存場所。同じ色が続くとここにたまっていく
    buffer.append(cubes.pop()) #cubesの最後の要素をbufferの最後に移し替える。
    counter = 0
    while cubes:
        if len(buffer) <= 0 or buffer[-1] == cubes[-1]: #bufferが空じゃないことを確認してからbufferとcubesの最後の要素を比較
            buffer.append(cubes.pop()) #同じ色はbufferに格納
        else: #もし違う色だったら
            buffer.pop() #bufferの最後のキューブをひとつ消す
            cubes.pop() #cubesの最後のキューブをひとつ消す
            counter += 2 #2個消去
    print(counter)




if __name__ == '__main__':
    main()


Measured memory_bytes: 4340
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
int main()
{
    int n,m;
    cin>>n>>m;
    vector<vector<char> > graph(n,vector<char> (m));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        cin>>graph[i][j];
    }
    vector<vector<ll> > ans(n,vector<ll> (m));
    bool found=false;
    for(int i=0;i<m;i++)
    {
        if(found)
        ans[0][i]=0;
        else if(graph[0][i]=='#')
        {
            ans[0][i]=0;
            found=true;
        }
        else if(graph[0][i]=='.')
        ans[0][i]=1;
    }
    found=false;
    for(int i=0;i<n;i++)
    {
        if(found)
        ans[i][0]=0;
        else if(graph[i][0]=='#')
        {
            ans[i][0]=0;
            found=true;
        }
        else if(graph[i][0]=='.')
        ans[i][0]=1;
    }
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<m;j++)
        {
            if(graph[i][j]=='#')
            ans[i][j]=0;
            else
                ans[i][j]=(ans[i-1][j]+ans[i][j-1])%mod;
        }
    }
    cout<<ans[n-1][m-1];
    return 0;
}

Measured memory_bytes: 9088
// luogu-judger-enable-o2
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
using namespace std;
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if((a*b)&1)printf("Odd\n");
	else printf("Even\n");
	return 0;
}



Measured memory_bytes: 256
=begin
def rec_route (hw_map,r,c,target_h,target_w)

    if r > target_h || c > target_h then
        return target_h*target_h
    end

    if r==target_h && c==target_w && hw_map[r-1][c-1]=="#" then
        return 1
    end
    if r==target_h && c==target_w && hw_map[r-1][c-1]=="." then
        return 0
    end

    flip = 0
    if hw_map[r-1][c-1]=="#" then
        flip = 1
    end

    return [rec_route(hw_map,r,c+1,target_h,target_w), rec_route(hw_map,r+1,c,target_h,target_w)].min + flip

end
=end

hw = gets.split(' ').map(&:to_i)
h = hw[0]
w = hw[1]

src = readlines.map(&:chomp)

hw_map = Array.new(h)
cost_map = Array.new(h)
for i in 0..h-1 do
    hw_map[i] = Array.new(w)
    cost_map[i] = Array.new(w)
end

for r in 0..h-1 do
    for c in 0..w-1 do
        hw_map[r][c] = src[r][c]
        cost_map[r][c] = h*w
    end
end

(0..h-1).reverse_each do |r|
    (0..w-1).reverse_each do |c|
        if r == h-1 && c == w-1 then
            cost_map[r][c] = 0
        else

            if r+1 > h-1 then
                row_cost = h*w
            else
                row_cost = cost_map[r+1][c]
                if hw_map[r][c] == "." && hw_map[r+1][c] == "#" then
                    row_cost += 1
                else
                    row_cost += 0
                end
            end
            
            if c+1 > w-1 then
                column_cost = h*w
            else
                column_cost = cost_map[r][c+1]
                if hw_map[r][c] == "." && hw_map[r][c+1] == "#" then
                    column_cost += 1
                else
                    column_cost += 0
                end
            end
            min_cost = [row_cost, column_cost].min
            ##低かった方の、前が#ならコストにならない
            cost_map[r][c] = min_cost
        end
    end
end

if hw_map[0][0] == "#" then
    cost_map[0][0] += 1
end

puts cost_map[0][0]

#ルートを全てだし、黒い色の数が一番少ないのを選ぶ
###puts rec_route(hw_map,1,1,h,w)



Measured memory_bytes: 4860
#include <bits/stdc++.h>
#define ll int
#define N 100000
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define fi first
#define se second
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.14159265
#define cot cout.tie(0)
using namespace std;
/**
        * @author :: Sawlani
        *
        */

int main()
{
  //freopen("input.txt", "r", stdin);

   ll a,b;
   cin >> a >> b;

   if(a%b==0)
   cout <<   a/b;
   else
   {
     cout << a/b+1 ;
   }
    


   
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
ll mod = 1000000007;

int main(){
    int n,l;
	cin>>n>>l;
	int ans = INF;
	int num = INF;
	int m = 0;
	rep(i,1,n+1){
		if (num>abs(i+l-1)){
			ans = i+l-1;
			num = abs(i+l-1);
		}
		m+=i+l-1;
	}
	cout<<m-ans<<endl;
}

Measured memory_bytes: 256
#define LENGTH 4

#include<iostream>
#include<math.h>
using namespace std;

int main()
{
  // 入力                                                                                                              
  char S[LENGTH+1];
  cin >> S;

  //連続回数                                                                                           
  int cont = 0;

  int i;

  //文字の重複をカウント                                                                                               
  for(i=0; i<LENGTH-1; i++){
    if(S[i] == S[i+1])
      cont++;
  }

  if(cont>0)
    cout << "Bad" << endl;
  else
    cout << "Good" << endl;

  return 0;
}

Measured memory_bytes: 256
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  ns <- inpi toInt
  mapM_ (putStrLn . unwords . map show) $ solve ns

solve :: [Int] -> [[Int]]
solve = map pnnn
    
pnnn :: Int -> [Int]
pnnn n = [lpn, upn]
  where
    lpn = last $ takeWhile (< n) pns
    upn = head $ dropWhile (<= n) pns
    
pns :: [Int]
pns = 2 : sieve [3,5..]

sieve :: [Int] -> [Int]
sieve (p:ps) = p : sieve [x | x <- ps, x `mod` p /= 0]

toInt :: String -> Int
toInt s = read s

inpi :: (String -> a) -> IO [a]
inpi f = map f . lines <$> getContents

Measured memory_bytes: 6536
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>

using namespace std;

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

    vector<vector<vector<int>>> b;
    vector<vector<int>> bw;
    for (int w = 0; w<W; w++) {
        bw.push_back({0, 0, 0, 0});
    }
    for (int h = 0; h<H; h++) {
        b.push_back(bw);
    }

    for (int h = 0; h<H; h++) {
        for (int w = 0; w<W; w++) {
            if (S[h][w] == '#') {
                continue;
            }
            // up
            if (h-1 < 0 or S[h-1][w] == '#') {
                b[h][w][0] = 0;
            } else {
                b[h][w][0] = b[h-1][w][0] + 1;
            }
            // left
            if (w-1 < 0 or S[h][w-1] == '#') {
                b[h][w][1] = 0;
            } else {
                b[h][w][1] = b[h][w-1][1] + 1;
            }
        }
    }

     for (int h = H-1; h>=0; h--) {
        for (int w = W-1; w>=0; w--) {
            if (S[h][w] == '#') {
                continue;
            }
            // down
            if (h+1 >= H or S[h+1][w] == '#') {
                b[h][w][2] = 0;
            } else {
                b[h][w][2] = b[h+1][w][2] + 1;
            }
            // right
            if (w+1 >= W or S[h][w+1] == '#') {
                b[h][w][3] = 0;
            } else {
                b[h][w][3] = b[h][w+1][3] + 1;
            }
        }
    }

    long ans = 0;
    for (int h = 0; h<H; h++) {
        for (int w = 0; w<W; w++) {
            if (S[h][w] == '#') {
                continue;
            }
            int tmp = accumulate(b[h][w].begin(), b[h][w].end(), 0) + 1;
            if (tmp > ans) {
                ans = tmp;
            }
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 223360
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<iomanip>
#include<cstring>
#include<string>
#include<set>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll = long long int;

const ll INF = 1LL<<60;
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; }

int main(void) {
    int n; cin >> n;
    vector<vector<int>> a(n, vector<int>(2));
    REP(i, n) {
        a[i][1] = i + 1;
        cin >> a[i][0];
    }
    sort(ALL(a));
    cout << a[0][1];
    for (int i = 1; i < n; i++) cout << " " << a[i][1];
    cout << endl;
}

Measured memory_bytes: 6272
io = STDIN
$n,$y=io.gets.split.map(&:to_i)
def calc
  (0..$n).each do |i|
    yy=$y-10000*i
    break if yy<0
    (0..$n).each do |j|
      yyy=yy-5000*j
      break if yyy<0
      break if i+j>$n
      k=yyy/1000
      return [i,j,k] if i+j+k==$n
    end
  end
  return [-1,-1,-1]
end
puts calc.join(" ")


Measured memory_bytes: 1788
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

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

int a;

void read_input()
{
    cin >> a;
}

void solve()
{
    cout << a + a * a + a * a * a << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}



Measured memory_bytes: 3660
#include <stdio.h>
#include <string.h>

#define MAX 100000 // キュー配列の最大サイズ

int qu[MAX]; // キューを表す配列
int tail = 0, head = 0; // キューの要素区間を表す変数

// キューを初期化する
void init() {
    head = tail = 0;
}

// キューが空かどうかを判定する
int isEmpty() {
    return (head == tail);
}

// スタックが満杯かどうかを判定する
int isFull() {
    return (head == (tail + 1) % MAX);
}

// enqueue (tail に要素を格納してインクリメント)
void enqueue(int v) {
    if (isFull()) {
        puts("error: queue is full.");
        return;
    }
    qu[tail++] = v;
    if (tail == MAX) tail = 0; // リングバッファの終端に来たら 0 に
}

// dequeue (head にある要素を返して head をインクリメント)
int dequeue() {
    if (isEmpty()) {
        puts("error: stack is empty.");
        return -1;
    }
    int res = qu[head];
    ++head;
    if (head == MAX) head = 0;
    return res;
}

int is_substr(char s[], char t[], int i){
    int flag = 1;

    if(s[i] == '\0') flag = 0;

    for(int j = 0; j < strlen(t); ++j, ++i){
        if(s[i] != t[j]){
            flag = 0;
            break;
        }
    }

    return flag;
}

int main(){
    char s[100010];
    char t[4][8]={"dream","dreamer","erase","eraser"};

    scanf("%s", s);

    enqueue(0);
    int flag = 0;
    while(!isEmpty()){
        int i = dequeue();
        if(i == strlen(s)){
            flag = 1;
            break;
        }
        for(int j = 0; j < 4; ++j){
            if(is_substr(s, t[j], i) == 1){
                enqueue(i + strlen(t[j]));
            }
        }
    }

    puts(flag ? "YES" : "NO");

    return 0;
}


Measured memory_bytes: 1816
#include<stdio.h>
using namespace std;

int a[100001];

bool binary(int a[],int n,int key){
    int left=0;
    int right=n;
    int mid;
    while(left<right){
        mid=(left+right)/2;
        if(a[mid]==key)
            return 1;
        if(a[mid]<key){
            left=mid+1;
        }
        else{
            right=mid;
        }
    }
        return 0;

}

int main(){
    int n,m,x=0,k;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    scanf("%d",&m);
    for(int i=0;i<m;i++){
        scanf("%d",&k);
        if(binary(a,n,k)) x++;
    }
    printf("%d\n",x);
    return 0;
}

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

/*** Template Begins ***/

typedef long long    ll;
typedef pair<ll,ll>  PII;
typedef pair<ll, pair<int, int> > PIII;
typedef long double  ld;
typedef vector<int>  vi;

#define endl         '\n'
#define pb           push_back
#define F            first
#define S            second
#define mp           make_pair
#define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007
#define all(a)       (a).begin(),(a).end()
ll power(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; } 

// Constants //

const int N = 1e5+7;

/*** Template Ends ***/



void solve(){
	
	int x;
	cin >> x;
	if ( x == 7 || x == 5 || x == 3 )	cout << "YES" << endl;
	else cout << "NO" << endl;


}

int main(){
	
	ios;
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int t;
	//cin >> t;
	t = 1;
	while(t--)
		solve();

	return 0;
}

Measured memory_bytes: 256
t = [int(input()) for i in range(5)]
T = [(-(-i//10))*10 for i in t]
t_min = [i%10 for i in t]
t_min = min([i for i in t_min if i != 0]) if t_min != [0 for i in range(5)] else 10
print(sum(T) - 10 + t_min)

Measured memory_bytes: 3060
#include <stdio.h>
/* Maximam Profit */
int main(void)
{
	int n, i, max_dif, min;
	int z[200000];

	scanf("%d", &n); /*整数の個数を入力*/
	for (i=0; i<n; i++){
		scanf("%d", &z[i]); /*整数を入力*/
	}

	min = z[0]; /*最小値の初期設定*/
	max_dif = -1000000000; /*最大値の初期設定*/
	for (i=1; i<n; i++){
		if (z[i] - min > max_dif)
			max_dif = z[i] - min;
		if (z[i] < min)
			min = z[i];
	}
	printf("%d\n", max_dif);

	return 0;
}



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

#define oo 1e9
#define fi first
#define se second
#define sp(iiii) setprecision(iiii)
#define IO ios_base::sync_with_stdio(false); cin.tie(0)
#define ms(aaaa,xxxx) memset(aaaa,xxxx,sizeof(aaaa))

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int> piii;
typedef pair<long long,long long> pll;
typedef pair<pair<long long,long long>,long long> plll;

int n,k,sl;

int main(){
    IO;
    cin>>n;
    cin>>k;
    sl=0;
    while (n>0) {
        sl++;
        n/=k;
    } 
    cout<<sl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(15000)
n = int(input())
A = [0]+list(map(int,input().split()))

def maxHeapify(A, i):
  l = i*2
  r = i*2+1
  if l <= n and A[l] > A[i]:
    largest = l
  else:
    largest = i
  if r <= n and A[r] > A[largest]:
    largest = r
  if largest != i:
    A[i],A[largest]=A[largest],A[i]
    maxHeapify(A,largest)

def buildMaxHeap(A):
  for i in range(n//2,0,-1):
    maxHeapify(A,i)

buildMaxHeap(A)
print(" ",end="")
print(" ".join(map(str,A[1:])))


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

int main(){

  int n;
  int a,b,c,x;
  int y[100];
  int sum;


  while(cin >> n >> a >> b >> c >> x){
    if(n==0 && a==0 && b==0 && c==0 && x==0){ break; }

    sum = 0;

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

    int i;
    for(i=0; i<=10000; i++){
      
      if(x==y[sum]){
	sum++;
	if(sum == n)break;
      }

      x = (a*x+b)%c;
    }

    if(i==10001){ cout << -1 << endl; }
    else{         cout << i << endl;  }

  }

  return 0;
}

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

using namespace std;

#define F first
#define S second
#define MP make_pair

constexpr int mod = 1000000007;
int T[100000], A[100000];
pair<int, int> seg[100000];

int main() {
    int N; scanf("%d", &N);
    for(int i = 0; i<N; ++i) scanf("%d", T+i);
    for(int i = 0; i<N; ++i) scanf("%d", A+i);
    int cur = 0;
    for(int i = 0; i<N; ++i) {
        if( T[i] > cur ) {
            seg[i] = MP(T[i], T[i]);
            cur = T[i];
        } else seg[i] = MP(1, cur);
    }
    cur = 0;
    for(int i = N-1; i>=0; --i) {
        if( A[i] > cur ) {
            if( seg[i].F > A[i] || seg[i].S < A[i] ) {
                puts("0");
                return 0;
            }
            seg[i].F = max(A[i], seg[i].F);
            seg[i].S = min(A[i], seg[i].S);
            cur = A[i];
        } else {
            if( seg[i].F > cur ) {
                puts("0");
                return 0;
            }
            seg[i].S = min(cur, seg[i].S);
        }
    }
    long long ans = 1;
    for(int i = 0; i<N; ++i) {
        ans = (ans*(seg[i].S-seg[i].F+1))%mod;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 1792
#-*- coding: utf-8 -*-
n = int(input())
a = list(map(int,input().split()))
ans = 100**3
for i in range(-1000,1001):
    sum = 0
    for j in range(n):
        sum += (a[j]-i)**2
    if ans > sum:
        ans = sum

print(ans)


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

int main(void){
  int a,b; cin >> a >> b;
  if(a - 1 >= b) cout << 2*a - 1 << endl;
  else if(a == b) cout << a + b << endl;
  else cout << 2 * b - 1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
int main(void){
  int n,ans=100000,t;
  std::cin>>n;
  for(int i=0;i<n;i++){
    ans*=1.05;
    t=ans%1000;
    if(t)ans=ans-t+1000;
  }
  std::cout<<ans<<std::endl;
  return 0;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    cin.tie(0);cout.tie(0);
    ios::sync_with_stdio(false);
    int N;cin>>N;
    vl val(N);
    map<ll,ll> a;
    rep(i,N){
        cin>>val[i];
        a[val[i]]++;
    }
    ll sum=0;
    for(auto p:a){
        sum+=p.se*(p.se-1)/2;
    }
    rep(i,N){
        ll p=(a[val[i]])*(a[val[i]]-1)/2,q=(a[val[i]]-1)*(a[val[i]]-2)/2;
        cout<<sum-p+q<<endl;
    }
    return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for(int i = 0; i < N; i++)

signed main()
{
  int X;

  cin >> X;
  if(X >= 1200) {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<PII> v(N);
  vector<PII> w(N);
  set<PII> s;
  rep(i,N) cin >> v[i].second >> v[i].first;
  rep(i,N) cin >> w[i].first >> w[i].second;
  sort(all(v),greater<PII>());
  sort(all(w));

  int count = 0;
  rep(i,N){
    int x = w[i].first, y = w[i].second;
    rep(j,N){
      int x_ = v[j].second, y_ = v[j].first;
      if(x>x_ && y>y_ && !s.count(PII(x_,y_))){
        ++count;
        s.insert(PII(x_,y_));
        break;
      }
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma warning(disable:4996)
#ifdef _MSC_VER
#  define __builtin_popcount __popcnt
#endif
#define int long long
using namespace std;
using ll = long long;
using ld = long double;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const long double PI = acos(-1.0);
inline void my_io() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cout << fixed << setprecision(15);
}
const int INF = 1e9;
int n, t;
signed main() {
	my_io();
	cin >> n >> t;
	int ans = INF;
	for (int i = 0; i < n; i++) {
		int c, time;
		cin >> c >> time;
		if (time <= t) {
			ans = min(ans, c);
		}
	}
	if (ans == INF) {
		cout << "TLE" << endl;
	}
	else {
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
input = -> { gets.split.map(&:to_i) }
N, M = input[]
a = (1..M).map{ input[] }.sort
    
i = 1 
loop.with_index {|_, c|
    max = -1
    max = [max, a.shift[1]].max while a[0] && a[0][0] <= i
    
    if max < 0 
        puts 'Impossible'
        break
    elsif max == N
        puts c+1 
        break
    end 

    i = max + 1 
}

Measured memory_bytes: 6120
// A - 幅優先探索.
// https://atcoder.jp/contests/atc002/tasks/abc007_3
// -> 上記の解答を, 少し修正した版.
#include <bits/stdc++.h>
using namespace std;
// constexpr int MAX = 400;
constexpr int MAX = 2601;
constexpr int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
int R, C;
int sx, sy, gx, gy;
int board[MAX];
int memo[MAX];

// 幅優先探索.
// https://ja.wikipedia.org/wiki/幅優先探索
// 迷路を幅優先探索する.
// ※bfsの動作確認用.
// @param s: 探索開始地点の迷路上の座標.
// @return: 特に無し.
void bfs(int s){
    
    // 1. 空のキュー.
    queue<int> q;
    
    // 2. 訪問済みフラグ設定.
    // ※スタート地点は, 距離ゼロを指定.
    memo[s] = 0;
    
    // 3. 探索地点 s をキュー q に追加.
    q.push(s);
    while(!q.empty()){
        // 4. キューから取り出す.
        int v = q.front();
        q.pop();
        // 5. 取り出した要素を処理.
        // x: 列方向, y: 行方向 で考える.
        int nx, ny, n;
        int cx = v % C , cy = v / C;
        for(int i = 0; i < 4; ++i){
            nx = cx + dx[i];
            ny = cy + dy[i];
            n = nx + ny * C;
            // cout << "cx=" << cx << " nx=" << nx  << " cy=" << cy << " ny=" << ny << " n=" << n << " c=" << c << endl;
            // 6. 訪問不可能なマス であれば, 処理をスキップ.
            if(n < 0 || nx < 0 || nx >= C || ny < 0 || ny >= R) continue;
            if(board[n] == '#')                                 continue;
            
            // 7. 訪問先のマスで, 訪問可能 かつ スタート地点でない かつ 未訪問 であれば, 訪問済み(※最短ルート)を設定.
            if(board[n] == '.' && n != s && memo[n] == 0) memo[n] = memo[v] + 1, q.push(n);
        }
    }
    return;
}

int main() {
    
    // 1. 入力情報取得.
    cin >> R >> C;
    sy = 1, sx = 1, gy = R, gx = C;
    sy--, sx--, gy--, gx--;
    int dot = 0;
    for(int i = 0; i < R; ++i){
        string s;
        cin >> s;
        for(int j = 0; j < C; ++j){
            board[i * C + j] = s[j];
            // 白マスの個数をカウント.
            if(s[j] == '.') dot++;
        }
    }
    
    // 2. 探索を開始し, 探索距離を更新.
    bfs(sy * C + sx);
    // ゴールまでの最短距離(※ゼロの場合は, ゴールに辿り着けないと判定).
    int dist = memo[gy * C + gx];
    // for(int i = 0; i < R; ++i){
    //     for(int j = 0; j < C; ++j){
    //         cout << memo[i * C + j] << " ";
    //     }
    //     cout << endl;
    // }
    
    // 3. 出力.
    int ans = -1;
    // マス(1, 1), マス(H, W) の 色 は 変更できないので, (dist + 1) を 引く形に修正.
    if(dist > 0) ans = dot - (dist + 1);
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>










string s, t;
int sz;




void solve()
{
	cin >> s >> t;
	sz = s.size();
	for(int i = 0; i < sz; i++)
	{
		if(s[i] != t[i])
		{
			cout << "No\n";
			return;
		}
	}
	cout << "Yes\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 3640
use std::io;
use std::cmp;
use std::collections::BinaryHeap;

macro_rules! read {
    ($t:ty) => {
        {
            let mut buf = String::new();
            io::stdin().read_line(&mut buf);
            let mut sp = buf.trim().split(" ");
            sp.next().unwrap().parse::<$t>().unwrap()
        }
    };
    ( $( $t:ty ),* ) => {
        {
            let mut buf = String::new();
            io::stdin().read_line(&mut buf);
            let mut sp = buf.trim().split(" ");
            ($(
                {
                    sp.next().unwrap().parse::<$t>().unwrap()
                },
            )*)
        }
    };
}
macro_rules! read_vec {
    ($t:ty) => {
        {
            let mut buf = String::new();
            io::stdin().read_line(&mut buf);
            let mut sp = buf.trim().split(" ");
            let mut ret = vec![];
            for s in sp {
                ret.push(s.parse::<$t>().unwrap());
            }
            ret
        }
    }
}

fn main() {
    let a = read!(String).into_bytes();
    let n = a.len();

    let mut found = vec![false; 26];
    for c in a {
        found[(c - 'a' as u8) as usize] = true;
    }
    for i in 0..26 {
        if !found[i] {
            println!("{}", (i as u8 + 'a' as u8) as char);
            return;
        }
    }
    println!("None");
}


Measured memory_bytes: 4352
import bisect
n,k = map(int,input().split())
a = [int(_) for _ in input().split()]

a.sort()

b = [0]*(len(set(a)))

ind = 0
for i in set(a):
    b[ind] = bisect.bisect_right(a,i)-bisect.bisect_left(a,i)
    ind += 1

b.sort()

print(sum(b[:max(0,len(b)-k)]))

Measured memory_bytes: 28924
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

int main(){
  ll sx,sy,tx,ty;cin>>sx>>sy>>tx>>ty;
  ll x=tx-sx,y=ty-sy;
  rep(i,0,y){
    cout<<'U';
  }
  rep(i,0,x){
    cout<<'R';
  }
  rep(i,0,y){
    cout<<'D';
  }
  rep(i,0,x){
    cout<<'L';
  }
  
  cout<<'L';
  
  rep(i,0,y+1){
    cout<<'U';
  }
  rep(i,0,x+1){
    cout<<'R';
  }
  cout<<'D'<<'R';
  
  rep(i,0,y+1){
    cout<<'D';
  }
  rep(i,0,x+1){
    cout<<'L';
  }
  cout<<'U'<<endl;
}



Measured memory_bytes: 3588
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int N; cin >> N;
  int D, X; cin >> D >> X;
  for (int i = 0; i < N; ++i) {
    int A; cin >> A;
    int d = 1;
    while (d <= D) {
      ++X; d += A;
    }
  }
  cout << X << endl;
}


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

def main():
    N = int(input())
    a = []

    for i in range(N):
        n = int(input())
        a.append([n, i])
    
    a = sorted(a)

    ans = 0
    for i in range(N):
        _, index = a[i]
        if i&1 != index&1:
            ans += 1
    print(ans//2)

if __name__ == "__main__":
    main()

Measured memory_bytes: 20872
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    string s;
    cin >> s;
    int n = s.size();
    rep(i, n)if(s[i] == 'A')break;
    per(j, n)if(s[j] == 'Z')break;
    pri(j - i + 1);

/*/

//*/ break;
  }
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>

typedef long long ll;
using namespace std;
int n,a[100005],ans; 
int ng,nl,mi=12345,ma=-12345;
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;++i){
		scanf("%d",a+i);
		ans+=abs(a[i]);
		if(a[i]>ma)ma=a[i];
		if(a[i]<mi)mi=a[i];
		ng+=a[i]>0;
		nl+=a[i]<=0;
	}
	if(nl==0){
		ans-=mi*2;
	}else if(ng==0){
		ans+=ma*2;
	}
	
	sort(a,a+n);
	cout<<ans<<endl;
	int l=0,r=n-1;
	for(int i=1;i<n;++i){
		if(ng>1){
			printf("%d %d\n",a[l],a[r]);
			--ng;
			if(a[l]>0)--ng;
			else --nl;
			a[l]-=a[r];
			if(a[l]>0)++ng;
			else ++nl;
			--r;
		}else{
			printf("%d %d\n",a[r],a[l]);
			if(a[l]>0)--ng;
			else --nl;
			if(a[r]>0)--ng;
			else --nl;
			a[r]-=a[l];
			if(a[r]>0)++ng;
			else ++nl;
			++l;
		}
	}
	return 0;
} 

Measured memory_bytes: 2304