akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second

int32_t main(){
	boost;
	int n;
	cin >> n;
	int a[n+1];
	for(int i=1; i <= n; i++) 
		cin>>a[i];
	int ball[n+1] = {0};
	vector<int>ans;
	for(int i=n;i>0;i--){
		int tot = 0;
		for(int j=i;j<=n;j+=i)
			tot += ball[j];
		tot %= 2;
		if(tot == a[i])
			continue;
		tot = (tot + 1)%2;
		ball[i] = 1;
		if(a[i] != tot){
			cout<<-1<<endl;
			return 0;
		}
		ans.push_back(i);
	}

	cout<<ans.size()<<endl;
	for(int i : ans)
		cout<<i<<" ";
	cout<<endl;
}



Measured memory_bytes: 7200
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;

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

const int MAX_N = 1e5 + 300;

int N, Nr[MAX_N * 3];
ll Ans = 0;

int main() {
	scanf("%d", &N); for(int i=0; i<3*N; i++) scanf("%d", &Nr[i]);
	sort(Nr, Nr+3*N);
	for(int i=N; i<3*N; i+=2) Ans += 1ll * Nr[i];
	printf("%lld\n", Ans);
	return 0;
}

Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        int max = int.MaxValue;
        int N = cin.nextint;
        var A = cin.scanint;
        for (int i = 0; i < N; i++)
        {
            int cnt = 0;
            while (A[i] % 2 == 0)
            {
                A[i] /= 2;
                cnt++;
            }
            max = Math.Min(cnt, max);
        }
        WriteLine(max);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 11204
#coding: utf-8

i1, i2, i3 = map(int, input().split())
mList = []
mList.append(abs(i2 - i1))
mList.append(abs(i3 - i2))
mList.append(abs(i1 - i3))

mList.sort()
print(mList[1] + mList[0])



Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <math.h>
#define pi atan(1.0)*4
using namespace std;

double angle(int hour,int min)
{
	double h,m,ret;
	h = (hour+min/60.0)*30;//时针的角度复，制每小时30度
	m = 6*min;//分针的角度，每分钟知6度
	ret = fabs(h-m);
	ret = ret>180?360-ret:ret;
	return ret;
}

int main()
{
	int a,b,h,m;
	double f=1,t=1,sum1=1,sum2=1;
	double t_angle,ans;
	cin>>a>>b>>h>>m;
	t_angle = angle(h,m);
	ans = a*a + b*b - 2*a*b*cos(t_angle*pi/180);
	printf("%.20lf",sqrt(ans));
	//getchar();getchar();

	
	
	return 0;
}


Measured memory_bytes: 4188
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n;

string calc(llint n, llint len)
{
	string ret;
	for(;n;n/=26){
		ret += n%26+'a';
	}
	while(ret.size() < len) ret += 'a';
	reverse(ret.begin(), ret.end());
	
	return ret;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	n--;
	
	llint mul = 26, len = 0;
	for(int i = 1; ; i++){
		if(n < mul){
			len = i;
			break;
		}
		n -= mul;
		mul *= 26;
	}
	
	cout << calc(n, len) << endl;
	
	return 0;
}

Measured memory_bytes: 3652
N = int(input())
A = list(map(int,input().split()))
from collections import Counter
ctr = Counter(A)

e = -1
for k,v in sorted(ctr.items(), reverse=True):
    if v < 2: continue
    if e > 0:
        print(e*k)
        exit()
    elif v >= 4:
        print(k*k)
        exit()
    else:
        e = k
print(0)

Measured memory_bytes: 21412
# import bisect
# from collections import Counter, deque
# from copy import copy, deepcopy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
# from operator import xor
import re
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    def main():
        S=str(input())
        T=str(input())

        ls=len(S)
        lt=len(T)
        if ls<lt:
            return 'UNRESTORABLE'
        else:
            ans=[]
            S=S.replace('?','.')
            for i in range(ls-lt+1):
                m=re.match(S[i:i+lt],T)
                if m is None:
                    continue
                else:
                    ans.append((S[:i]+T+S[i+lt:]).replace('.','a'))

            if not ans:
                return 'UNRESTORABLE'
            else:
    
                return min(ans)

    print(main())








resolve()

Measured memory_bytes: 38384
# include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, x = -1;
	cin >> n;
	x = n % 10;
	if(x == 2 || x == 4 || x == 5 || x == 7 || x == 9){
		cout << "hon\n";
	}else{
		if(x == 0 || x == 1 || x == 6 || x == 8){
			cout << "pon\n";
		}else{
			cout << "bon\n";
		}
	}
}

Measured memory_bytes: 3652
#include <cstdio>
#include <algorithm>
typedef long long int64;
static const int MAXN = 1e5 + 2;
static const int MAXM = 1e5 + 3;

int n, m, a[MAXN];

int64 slp[MAXM] = { 0 }, ofs[MAXM] = { 0 };

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++i) scanf("%d", &a[i]), --a[i];

    for (int i = 1; i < n; ++i) {
        int x = a[i - 1], y = a[i];
        if (y == x) continue;
        int dist = (y - x + m) % m;
        ofs[0] += dist;
        if (y < x) {
            slp[x + 1] -= 1;
            ofs[x + 1] += (x + 1);
            slp[0] -= 1;
            ofs[0] -= (m - (x + 1));
            slp[y + 1] += 1;
            ofs[y + 1] += (m - (x + 1));
        } else {
            slp[x + 1] -= 1;
            ofs[x + 1] += (x + 1);
            slp[y + 1] += 1;
            ofs[y + 1] -= (x + 1);
        }
    }

    int64 slp_s = 0, ofs_s = 0;
    int64 ans = 1LL << 62;
    for (int i = 0; i < m; ++i) {
        slp_s += slp[i];
        ofs_s += ofs[i];
        ans = std::min(ans, ofs_s + slp_s * i);
    }

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 2176
#include <cstdlib>
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <string>
#include <limits.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <typeinfo>
#include <stdlib.h>
#include <functional>

using namespace std;

#define ll long long

int main(int argc, char* argv[]){
  ll n,k,i,j, a, ret=0, over=0;
  // cout << count[0];

  cin >> n >> k;
  vector<ll> count(n+1,0);

  for(i=0; i<n; i++){
    cin >> a;
    count[a] ++ ;
  }
  // cout << count[5] << endl;

  sort(count.begin(), count.end(), std::greater<ll>());

  // cout << count[0] << endl;
  // cout << count[1] << endl;
  // cout << count[2] << endl;

  for(i=0; i<n; i++){
    if(count[i]==0){
      over = i;
      break;
    }
  }

  if(over==0){
    for(j=k; j<n; j++){
      ret += count[j];
    }
    cout << ret << endl;    
  }else if(over+1 <= k){
    cout << 0 << endl;
  }else{
    for(j=k; j<over; j++){
      ret += count[j];
    }
    cout << ret << endl;
  }

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair<int,int>   ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef set<int>        si;
typedef set<ii>         sii;

#define all(x) x.begin(),x.end()
#define clr(x,v) memset(x,v,sizeof x)
#define sz(x) (int)x.size()
#define re return


template<typename T> T sgn (T x)      {re x<0? -1:(x>0? 1:0); }
template<typename T> T gcd (T a, T b) {re a ? gcd (b % a, a) : b; }
template<typename T> T abs (T x)      {re x < 0 ? -x : x; }
template<typename T> T sqr (T x)      {re x*x;}

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define ins insert
#define y second
#define x first
#define endl "\n"
#define MOD (int)1e9+7
#define N (int)2e5+123

set<int> result;
int n, K, d;

void solve(){
	cin >> n >> K;
  for (int i = 0; i < K; ++i)
  {
    cin >> d;
    vector<int> A(d);
    for (int j = 0; j < d; ++j)
    {
      cin >> A[j];
      result.insert(A[j]);
    }
    A.clear();
  }
 
  cout << n - result.size() << endl;

}
int main(){_
    solve();
}

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

bool lessThan(int h1, int w1, int h2, int w2) {
  int d1 = h1*h1 + w1*w1;
  int d2 = h2*h2 + w2*w2;
  if(d1 != d2) return d1 < d2;
  return h1 < h2;
}

int main() {
  for(int h, w; cin >> h >> w && (h|w);) {
    int c, d;
    c = d = 150;
    for(int a = 1; a <= 150; ++a) {
      for(int b = a+1; b <= 150; ++b) {
        if(lessThan(h, w, a, b) && lessThan(a, b, c, d)) {
          c = a;
          d = b;
        }
      }
    }
    cout << c << " " << d << endl;
  }
  return 0;
}

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

string cmp_max(string s1, string s2)
{
  int len1 = s1.length();
  int len2 = s2.length();
  if (len1 > len2)
    return s1;
  else if (len1 < len2)
    return s2;
  else
  {
    for (int i = 0; i < len1; i++)
    {
      if (s1[i] > s2[i])
        return s1;
      else if (s1[i] < s2[i])
        return s2;
    }
    return s1;
  }
}

int main()
{
  int cost[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  for (int i = 0; i < M; i++)
    cin >> A[i];
  vector<string> dp(N + 100);
  for (int i = 0; i < N + 100; i++)
    dp[i] = "";
  for (int i = 0; i < N; i++)
  {
    if (i != 0 && dp[i] == "")
      continue;
    for (int j = 0; j < M; j++)
      dp[i + cost[A[j]]] = cmp_max(dp[i + cost[A[j]]], dp[i] + (char)(A[j] + '0'));
  }
  cout << dp[N] << endl;
  return 0;
}

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

typedef long long   ll;
typedef long double ld;

using namespace std;
const ld pi=2*acos(0.0);
ll mod = 998244353;
set<int>t;
int A[222222];
int main() {
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
  ios::sync_with_stdio(0);
  cin.tie(0);
    int n;
    priority_queue<pair<int, int> > a, b;
     cin >> n;
    ll sum1 = 0, sum2 = 0;
    for(int i = 0; i < n; i ++){
        cin >> A[i];
        sum1 += A[i];

    }
    ll dif = 0;
    for(int i = 0; i < n; i ++){
        int k;
        cin >> k;
        sum2 += k;
        if(A[i] < k){
            dif += A[i] - k;
            t.insert(i);
        }else
            b.push({A[i] - k, i});
//        cerr << A[i] << ' ' << k << ' ' << A[i] - k << endl;
    }
    if(sum1 < sum2)
        return puts("-1") * 0;
    ll sum = 0;
//    cerr << dif << endl;
    while(dif < 0){
        dif += b.top().first;
//        cerr << b.top().second << endl;
        t.insert(b.top().second);
        b.pop();
//        cerr << dif << endl;
    }
//    for(auto v : t)
//        cerr << v << endl;
    cout << t.size();
    return 0;
}


Measured memory_bytes: 4472
#include <bits/stdc++.h>
#define int long long
using namespace std;

int a,b;
int t=1;
int ans;
signed main() {
	cin>>a>>b;
	a--;
	while(t<b) {
		t+=a;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
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; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const int mod = 1000000007;

int main(){
    int h, w;
    cin >> h >> w;
    int board[600][600];
    vector<int> ans;
    rep(i,h)rep(j,w){
        cin >> board[i][j];
    }
    rep(i,h)rep(j,w-1){
        if(board[i][j] % 2 == 1){
            board[i][j]--;
            board[i][j+1]++;
            ans.pb(i+1);
            ans.pb(j+1);
            ans.pb(i+1);
            ans.pb(j+2);
        }
    }
    rep(i,h-1){
        if(board[i][w-1] % 2 == 1){
            board[i][w-1]--;
            board[i+1][w-1]++;
            ans.pb(i+1);
            ans.pb(w);
            ans.pb(i+2);
            ans.pb(w);
        }
    }
    int n = ans.size()/4;
    cout << n << endl;
    rep(i,n){
        rep(j,4){
        if(j)cout << " ";
        cout << ans[i*4+j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 5360
#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) ((x)&(-x))
typedef long long LL;

const int maxm = 2e5+5;
LL n, k;

LL buf[maxm];

bool check(LL x) {
    LL cnt = 0, i, j;
    for(i = 0; i < n; ++i) {
        if(buf[i]*buf[i] <= x) cnt--;
        if(buf[i] > 0) {
            j = floor((long double)x / buf[i]);
            LL pos = upper_bound(buf, buf+n, j) - buf;
            cnt += pos; 
        } else if(buf[i] < 0) {
            j = ceil((long double)x / buf[i]);
            LL pos = lower_bound(buf, buf+n, j) - buf;
            cnt += n - pos;
        } else {
            if(x >= 0) cnt += n;
        }
    }
    cnt /= 2;
    return cnt >= k;
}

void run_case() {
    cin >> n >> k;
    for(int i = 0; i < n; ++i) cin >> buf[i];
    sort(buf, buf+n);
    LL l = -(1LL<<60), r = 1LL<<60, ans, mid;
    while(l <= r) {
        mid = (l+r)>>1;
        if(check(mid)) {
            ans = mid;
            r = mid-1;
        } else
            l = mid+1;
    }
    cout << ans;
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    //cout.setf(ios_base::showpoint);cout.precision(8);
    run_case();
    cout.flush();
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        if(N % 2 != 0){
            System.out.println("No");
            return;
        }
        String T = S.substring(N/2);
        String S2 = T + T;
        if( S2.equals(S) ){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21204
N = int(input())


hash = {}
end = int(N ** (1/2))
for i in range(2, end + 1):
    while N % i == 0:
        hash[i] = hash.get(i, 0) + 1
        N = N // i
if N != 1:
        hash[i] = hash.get(i, 0) + 1



count = 0
trans = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]

res = 0
for i in hash.values():
    for j in range(len(trans)):
        if i > trans[j]:
            continue
        elif i == trans[j]:
            res += (j + 1)
            break
        else:
            res += j
            break



print(res)

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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  int height = 0;
  int count = 0;
  for(int j=0; j<N; j++){
    if(vec.at(j) >= height){
      height = vec.at(j);
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n;
    cin >> n;
    long long int x;
    cin >> x;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    vector<vector<int>> min_cost(n, vector<int>(n, 0x3f3f3f3f));
    for (int i = 0; i < n; i++) {
        int m = 0x3f3f3f3f;
        for (int j = 0; j < n; j++) {
            m = min(m, v[(i + j) % n]);
            min_cost[i][j] = m;
        }
    }
    long long int res = -1;
    long long int base = 1;
    for (int i = 0; i < n; i++) {
        long long int r = x * i;
        for (int j = 0; j < n; j++) {
            r += min_cost[j][i];
        }
        if (res == -1 || res > r) {
            res = r;
        }
    }
    cout << res << endl;
}




Measured memory_bytes: 19008
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define EVEL 1

#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 200000000000;


ll W, H;
ll ans = INF;
bool f = false;
int main() {
	ios_base::sync_with_stdio(false);
	cin >> H >> W;
	if (H % 3 == 0 || W % 3 == 0) {
		cout << "0";
		f = true;
	}
	else {
		EREP(i, W) {
			ll S1 = i*H, S2, S3;
			if ((H & 1) == 0 || ((W - i) &1) == 0) {
				S2 = S3 = (H* (W - i)) / 2;
			}
			else {
				S2 = H / 2 * (W - i);
				S3 = (H / 2 + 1)*(W - i);
			}
			ans = min((max({ S1, S2, S3 }) - min({ S1, S2, S3 })), ans);
			DEB(i)DEB(ans)DEB((max(S1, S3) - min(S1, S2)))END
		}
		END
		EREP(i, H) {
			ll S1 = i*W, S2, S3;
			if ((W & 1) == 0) {
				S2 = S3 = W / 2 * (H - i);
			}
			else if (((H - i) & 1) == 0) {
				S2 = S3 = W * ((H - i) / 2);
			}
			else {
				S2 = W / 2 * (H - i);
				S3 = (W / 2 + 1)*(H - i);
			}
			ans = min((max({ S1, S2, S3 }) - min({ S1, S2, S3 })), ans);
			DEB(i)DEB(ans)DEB((max(S1, S3) - min(S1, S2)))END
		}
	}
	if (!f)cout << ans;
	return 0;
}

Measured memory_bytes: 256
S = input()

l1 = []
l2 = []
total_area = 0
for i, j in enumerate(S):
    if j == '\\':
        l1.append(i)
    elif j == '/' and l1:
        i_p = l1.pop()
        v = i -i_p
        total_area += v
    
        while l2 and l2[-1][0] > i_p:
            v += l2.pop()[1]
        l2.append([i_p, v])
        
ans = [str(len(l2))] + [str(k[1]) for k in l2]
print(total_area)
print(' '.join(ans))


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

#define rep(i,m,n) for(int i = (m); i < (n); i++)
#define rrep(i,m,n) for(int i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]); if(i!=n-1) cout << " ";} cout << endl;
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll N = S.size();
    bool flg = false;
    if(S == "keyence") flg = true;
    rep(i,0,N){
        rep(j,0,N){
            string ss = "";
            ss += S.substr(0,i);
            if(j != N-1){
                ss += S.substr(j+1, N-j+1);
            }
            if(ss == "keyence") flg = true;
        }
    }
    if(flg){
        print("YES");
    }else{
        print("NO");
    }
    // ll idx = 0;
    // string str1 = "keyence";
    // rep(i,0,N){
    //     if(S[i] == str1[idx] && idx < 7){
    //         idx++;
    //     }
    // }
    // if(idx == 7){
    //     print("YES");
    // }else{
    //     print("NO");
    // }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    bool ok=false;
    for(int i=1; i<=9; ++i){
        for(int j=1; j<=9; ++j){
            if(i*j==n){
                ok=true;
            }
        }
    }
    cout<<(ok==true?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////
int main() {
	double a, b, x;
	cin >> a >> b >> x;

	x /= a;

	cout << fixed << setprecision(15);

	if (x < a * b/2) {
		double h = (x * 2) /b ;

		double ans = atan2(b, h);
		ans = ans / acos(-1) * 180.0;
		cout << ans << endl;
	}
	else {
		double h = (a * b - x) * 2 / a;
		double ans = atan2(h, a);
		ans = ans / acos(-1) * 180;
		cout << ans << endl;
	}
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}

signed main(){
    int A,B,C,D;
    cin>>A>>B>>C>>D;


    int x=abs(A-C);
    int y=abs(B-D);
    if(x==0||y==0){
        cout<<0<<endl;
        return 0;
    }
    cout<<x+y-1-gcd(x,y)+1<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.annotation.Target;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.FormatFlagsConversionMismatchException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Random;
import java.util.StringTokenizer;

import javax.naming.spi.DirStateFactory.Result;
import javax.swing.text.AbstractDocument.BranchElement;

import org.w3c.dom.css.Counter;
 
public class Main {

	
	public static void main(String[] args) {
		FastScanner fs=new FastScanner();
		int first = fs.nextInt();
		int [] a =fs.readArray(first);
		long sum=0;
		int max =a [0];
		for(int i :a) {
			max=Math.max(i, max);
			sum+=max-i;
		}
		System.out.println(sum);
	}
	
 
	static final Random random=new Random();
	
	static void ruffleSort(int[] a) {
		int n=a.length;//shuffle, then sort 
		for (int i=0; i<n; i++) {
			int oi=random.nextInt(n), temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
 
	
}

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

#define crap ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define CN cout<<"NO\n";
#define CY cout<<"YES\n";

using namespace std;
using ll = long long;

void solve()
{
    ll n; cin>>n;
    ll x=ceil(n/1000.0);
    cout<<1000*x-n;
}
int main()
{
    crap;
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r", stdin) ;
        freopen("output.txt","w", stdout) ;
        freopen("error.txt","w", stderr) ;
    #endif
    int t;t=1;
    //cin>>t;
    while(t--)
        {solve();}
    return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define INT long long
#define oo 987654321
using namespace std;
INT n, m, k, t[30], cnt1, cnt2, cnt4;
string s;
int main()
{
	ios::sync_with_stdio(false);
    cin>>n>>m;
    for(int i = 0 ; i < n ; i++ )
    {
        cin>>s;
        for(int j = 0 ; j < s.size() ; j++ )
            t[s[j]-'a']++;
    }
    if( n%2 == 0 and m%2 == 0 )
    {
        for(int i = 0 ; i < 26 ; i++ )
            if( t[i]%4 ) return cout<<"No\n", 0;
        return cout<<"Yes\n", 0;
    }
    if( n%2 == 0 and m%2 == 1 )
    {
        for(int i = 0 ; i < 26 ; i++ )
            if( t[i]%4 == 0 ) cnt4++;
            else if( t[i]%2 == 0 ) cnt2++;
            else return cout<<"No\n", 0;
        if( cnt2 <= n/2 ) return cout<<"Yes\n", 0;
        return cout<<"No\n", 0;
    }
    if( n%2 == 1 and m%2 == 0 )
    {
        for(int i = 0 ; i < 26 ; i++ )
            if( t[i]%4 == 0 ) cnt4++;
            else if( t[i]%2 == 0 ) cnt2++;
            else return cout<<"No\n", 0;
        if( cnt2 <= m/2 ) return cout<<"Yes\n", 0;
        return cout<<"No\n", 0;
    }
    if( n%2 == 1 and m%2 == 1 )
    {
        for(int i = 0 ; i < 26 ; i++ )
            if( t[i]%4 == 0 ) cnt4++;
            else if( t[i]%2 == 0 ) cnt2++;
            else if( t[i]%2 == 1 )
            {
                if( (t[i]-1)%4 != 0 ) cnt2++;
                cnt1++;
            }
        if( cnt1 != 1 ) return cout<<"No\n", 0;
        if( cnt2 <= n/2 + m/2 ) return cout<<"Yes\n", 0;
        return cout<<"No\n", 0;
    }
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
#define min(a,b) ((a)<(b)?(a):(b))
const int maxn=2e5+5;
struct Seg{int x,y;}a[maxn];
int n,m,ans;
inline int cmp(const Seg A,const Seg B) {return A.x==B.x?A.y>B.y:A.x<B.x;}
int l[maxn<<2],r[maxn<<2],tag[maxn<<2],mx[maxn<<2];
inline int max(int a,int b) {return a>b?a:b;}
inline void add(int i,int v) {tag[i]+=v,mx[i]+=v;}
inline void pushup(int i) {mx[i]=max(mx[i<<1],mx[i<<1|1]);}
void build(int x,int y,int i) {
	l[i]=x,r[i]=y;tag[i]=0;if(x==y){mx[i]=x;return;}
	int mid=x+y>>1;build(x,mid,i<<1),build(mid+1,y,i<<1|1);pushup(i);
}
inline void pushdown(int i) {
	if(!tag[i]) return;
	add(i<<1,tag[i]),add(i<<1|1,tag[i]);tag[i]=0;
}
void change(int x,int y,int v,int i) {
	if(x<=l[i]&&y>=r[i]) {add(i,v);return;}
	int mid=l[i]+r[i]>>1;pushdown(i);
	if(x<=mid) change(x,y,v,i<<1);
	if(y>mid) change(x,y,v,i<<1|1);
	pushup(i);
}
int query(int x,int y,int i) {
	if(x<=l[i]&&y>=r[i]) return mx[i];
	int mid=l[i]+r[i]>>1;pushdown(i);
	if(y<=mid) return query(x,y,i<<1);
	if(x>mid) return query(x,y,i<<1|1);
	return max(query(x,y,i<<1),query(x,y,i<<1|1));
}
int main() {
	//freopen("data.in","r",stdin);
	scanf("%d%d",&n,&m);
	for(re int i=1;i<=n;i++) scanf("%d%d",&a[i].x,&a[i].y);
	std::sort(a+1,a+n+1,cmp);int nl=0,nr=m+1;
	for(re int i=1;i<=n;i++) nl=max(nl,a[i].x),nr=min(nr,a[i].y);
    ans=n+(nl<nr?nr-nl-1:0);
	build(0,m+1,1);
	for(re int i=1;i<=n;i++) {
		int nw=query(a[i].x+1,a[i].y,1);
		ans=max(ans,nw-a[i].x);
		change(0,a[i].y,1,1);
	}
	for(re int i=1;i<=n;i++) a[i].x=m+1-a[i].x,a[i].y=m+1-a[i].y,std::swap(a[i].x,a[i].y);
	std::sort(a+1,a+n+1,cmp);
	build(0,m+1,1);
	for(re int i=1;i<=n;i++) {
		int nw=query(a[i].x+1,a[i].y,1);
		ans=max(ans,nw-a[i].x);
		change(0,a[i].y,1,1);
	}
	printf("%d\n",ans>m?ans-m:0);return 0;
}
//g++ arc076f.cpp -o arc076f


Measured memory_bytes: 14080
#pragma GCC optimize(2)
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#include <cstdio>
using namespace std;

inline char nc()
{
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}

inline void read(double& sum)
{
    char ch; sum=0;
    ch=nc();
    while(!(ch>='0'&&ch<='9')) ch=nc();
    while(ch>='0'&&ch<='9') sum=sum*10+ch-48,ch=nc();
}

int main()
{
	double a,b;
	read(a),read(b);
	printf("%.6lf\n",(a*b)/(a+b));
	return 0;
}

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

using namespace std;

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

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

const int M = 1e6 + 10;
const int N = 1e6;
const int INF = 1e9;
int pos[M], a[N], nxt[N];

vi t[4 * N];

void build(int v, int tl, int tr) {
    if (tl == tr) t[v].resize(1, nxt[tl]);
    else {
        int tm = (tl + tr) / 2;
        build(2 * v, tl, tm);
        build(2 * v + 1, tm + 1, tr);
        merge(all(t[2 * v]), all(t[2 * v + 1]), back_inserter(t[v]));
    }
}

int count_less(int v, int tl, int tr, int l, int r, int x) {
    if (l <= tl && tr <= r) return (int) (upper_bound(all(t[v]), x) - t[v].begin());
    if (tr < l || r < tl) return 0;
    int tm = (tl + tr) / 2;
    return count_less(2 * v, tl, tm, l, r, x) + count_less(2 * v + 1, tm + 1, tr, l, r, x);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, q;
    cin >> n >> q;
    forn(i, n) cin >> a[i];
    fill(pos, pos + M, INF);
    fornr(i, n) nxt[i] = pos[a[i]], pos[a[i]] = i;
    build(1, 0, n - 1);
    while (q--) {
        int l, r;
        cin >> l >> r;
        l--, r--;
        cout << (r - l + 1) - count_less(1, 0, n - 1, l, r, r) << "\n";
    }
    return 0;
}

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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb puah_back

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

int main(){
    int n; cin >> n;
    ll ans = 0;
    vector<ll> alis(n), blis(n), clis(n);
    REP(i, 0, n){
        cin >> alis[i] >> blis[i];
    }
    for(int i = n-1; i >= 0; i--){
        ll aa = alis[i] + ans;
        ll cc = aa % blis[i];
        if(cc != 0){cc = blis[i] - cc;}
        ans += cc;
    }
    cout << ans << endl;
}

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

//template
typedef long long int ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define repr(i,n) for(ll i=n;i>0;i--)
#define all(v) v.begin(),v.end()
#define in cin>>
#define out cout<<
#define en <<endl
const ll INF = 10000000000000;

int main()
{
	//ll n, ans;
	ll n;
	in n;
	out(n + 1) / 2 en;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
  int N, i, value;
  int A[100];

  scanf("%d", &N);
  for ( i = 0; i < N; i++ ) scanf("%d", &A[i]);

  for ( i = 0; i < N; i++ ) {
    int j, k;

    value = A[i];
    j = i - 1;

    while ( j >= 0 && A[j] > value ) {
      A[j + 1] = A[j];
      j--;
    }

    A[j+1] = value;

    for ( k = 0; k < N; k++ ) {
      if ( k > 0 ) printf(" ");
      printf("%d", A[k]);
    }

    printf("\n");
  }

  return 0;
 }


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/
std::vector<int> z_algorithm(const string &str) {
    std::vector<int> Z(str.size());
    Z[0] = str.size();
    int i = 1, j = 0;
    while(i < str.size()) {
        while(i + j < str.size() && str[j] == str[i+j]) ++j;  // 共通部分文字列の長さ(幅)を求める。
        Z[i] = j;
        if(j == 0) {  // 最初から不一致
            ++i;
        }
        else {  // ある程度一致
            int k = 1;
            while(i+k < str.size() && k+Z[k] < j) {
                Z[i+k] = Z[k];
                ++k;
            }
            i += k;
            j -= k;
        }
    }
    return Z;
}

/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    i32 n, answer = 0;
    string s, t;
    vec<int> Tmp;
    cin >> n >> s;
    for(int i = 0; i < n; ++i) {
        t = s.substr(i, n-i);
        Tmp = z_algorithm(t);
        for(int j = 0; j < Tmp.size(); ++j) if(Tmp[j] <= j) chmax(answer, Tmp[j]);
    }
    cout << answer << '\n';
}


Measured memory_bytes: 384
var s:String;
i,j:Longint;
begin
readln(s);
i:=1;
while(i<=length(s))and(s[i]<>'C')do inc(i);
j:=i+1;
while(j<=length(s))and(s[j]<>'F')do inc(j);
if j<=length(s)then writeln('Yes')else writeln('No');
end.

Measured memory_bytes: 128
using System;

namespace _0522
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string a = Console.ReadLine();
                if (a == null) { break; }
                int ioi = 0, joi = 0;
                for (int i = 0; i < a.Length - 2; i++)
                {
                    if (a.Substring(i + 1, 1) == "O" && a.Substring(i + 2, 1) == "I")
                    {
                        if (a.Substring(i, 1) == "I") { ioi++; }
                        if (a.Substring(i, 1) == "J") { joi++; }
                    }
                }
                Console.WriteLine(joi);
                Console.WriteLine(ioi);
         //       Console.ReadLine();
            }Console.ReadLine();
        }
    }
}

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

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

using namespace std;

typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<ll> vec(n);
  rep(i,n) cin >> vec[i];
  ll sum = 0;
  map<ll,int> mp;
  int maxi = 0;
  mp[0] = -1;
  rep(i,n) {
    sum += vec[i];
    if( !mp.count(sum) ) mp[sum] = i;
    maxi = max(maxi,i - mp[sum]);
  }
  cout << maxi << endl;
  return 0;
}

Measured memory_bytes: 16652
H,W=map(int,input().split())
dp=[[0 for i in range(W)] for k in range(H)]
ALL=[]
for i in range(H):
  S=input()
  ALL+=[S]
  for k in range(W):
    if i==0 and k==0:
      if S[k]=="#":
        dp[i][k]=1
      else:
        dp[i][k]=0
    elif i==0:
      if S[k]=="#" and S[k-1]==".":
        dp[i][k]=dp[i][k-1]+1
      else:
        dp[i][k]=dp[i][k-1]
    elif k==0:
      if S[k]=="#" and ALL[i-1][k]==".":
        dp[i][k]=dp[i-1][k]+1
      else:
        dp[i][k]=dp[i-1][k]
    else:
      if S[k]=="#":
        if S[k-1]=="#" and ALL[i-1][k]=="#":
          dp[i][k]=min(dp[i][k-1],dp[i-1][k])
        elif S[k-1]=="#" and ALL[i-1][k]==".":
          dp[i][k]=min(dp[i][k-1],dp[i-1][k]+1)
        elif S[k-1]=="." and ALL[i-1][k]=="#":
          dp[i][k]=min(dp[i][k-1]+1,dp[i-1][k])
        else:
          dp[i][k]=min(dp[i][k-1],dp[i-1][k])+1
      else:
        dp[i][k]=min(dp[i][k-1],dp[i-1][k])        
ans=dp[H-1][W-1]
print(ans)

Measured memory_bytes: 3192
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<queue>
using namespace std;
int n,m;
int main()
{
	cin>>n>>m;
	cout<<(n-1)*(m-1);
	return 0;
}


Measured memory_bytes: 256
program hrn;
 var
  s:string;
  i,l,sc,sf:longint; 
 begin
  read(s);
  l:=length(s);
  sc:=maxlongint; 
  for i:=1 to l do if s[i]='F'then sf:=i; 
  for i:=l downto 1 do if s[i]='C'then sc:=i;
  if sc<sf then writeln('Yes')
           else writeln('No');
           
 end.

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var A = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        var ans = new int[N + 1];

        for (int i = 1; i <= N; i++)
            ans[A[i - 1]] = i;

        for (int i = 1; i <= N; i++)
            Write($"{ans[i]} ");

        WriteLine();
    }
}


Measured memory_bytes: 38360
R, G, B, N = list(map(int, input().split()))
cnt = 0
rmax = N//R
gmax = N//G
bmax = N//B
for r in range(rmax+1):
    for g in range(gmax+1):
        temp = N-r*R-g*G
        if temp < 0:
            continue
        if temp%B == 0:
            cnt += 1
print(cnt)

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

int main()
{
	int a, b, sum, ans;
	while(cin >> a >> b)
	{
		sum = a + b;
		ans = (int)log10 ((double)sum)+ 1;
	    cout << ans << endl;
	}
	
	return 0;
}

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

#define mem(arr, i) fill(arr, arr + sizeof(arr), i)
#define MEM(arr, i) memset(arr, i, sizeof(arr))
#define Push push_back
#define Pair make_pair
#define ALL(x) x.begin(), x.end()
#define X first
#define Y second
#define ACCEL ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef pair<pll,lli> p3l;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
typedef vector<p3l> v3L;
typedef vector<vcL> vvL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
      lli   mod = 1000000007;

/// templates ///

const lli maxN = 2E5;

vcL inv(maxN+5, 1);
vcL fac(maxN+5, 1);

void ADD(lli &x, lli y) {
	x += y;
	if (x >= mod) x -= mod;
	if (x < 0) x += mod;
}

void MUL(lli &x, lli y) {
	x *= y;
	x = (x % mod + mod) % mod;
}

lli mypow(lli b, lli e) {
	lli ans = 1;
	while (e) {
		if (e & 1) MUL(ans, b);
		MUL(b, b);
		e >>= 1;
	}
	return ans;
}

lli modinv(lli n) {
	return mypow(n, mod - 2);
}

void calcInv(lli n) {
	for (int i = 2; i <= n; ++i) {
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	}
}

void calcFac(lli n) {
	for (int i = 2; i <= n; ++i) {
		fac[i] = fac[i - 1] * i % mod;
	}
}

lli cm(lli a, lli b) {
	lli ans = 1;
	if (a < b) return 0;

	MUL(ans, inv[fac[a - b]]);
	MUL(ans, inv[fac[b]]);
	MUL(ans, fac[a]);

	return ans;
}

lli Lucas(lli n, lli m) {
	if (m == 0) return 1;
	return cm(n % mod, m % mod) * Lucas(n / mod, m / mod) % mod;
}

lli doLucas(lli n, lli m) {
	calcInv(mod);
	calcFac(mod);
	return Lucas(n, m);
}

/// coding area ///

const lli maxn = 1E5;

void precal() {

	return;
}

void solve() {
	lli a, b, c;
	cin >> a >> b >> c;
	cout << max(0LL, c - (a - b)) << '\n';
}

int main() {
	precal();
	int t = 1;
	#ifdef LOCAL
		t = INT_MAX;
	#else
		ACCEL;
	#endif
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}



Measured memory_bytes: 3328
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
     
    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
     
//const ll MOD = INF + 7;
//Combination MOD
const int MOD = 1e9 + 7;
     
int main(){
   ll n, a, b;
   cin >> n >> a >> b;
   bool f = false;
   if(a > b)f = true;
   if(n == 1 && a != b)f = true;
   if(f){
      cout << 0 << endl;
      return 0;
   }
   else if(n == 1){
      if(a == b)cout << 1 << endl;
      else cout << 0 << endl;
      return 0;
   }
   else {
      ll mx = a + b + (n - 2) * b;
      ll mn = a + b + (n - 2) * a;
      cout << mx - mn + 1 << endl; 
   }
}

Measured memory_bytes: 3140
#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;
int main(){
	
	int arr[3];
	for(int i=0;i<3;i++){
		cin>>arr[i];
	}
	sort(arr,arr+3);
	cout<<arr[0]<<" "<<arr[1]<<" "<<arr[2]<<endl;
	
	return 0;
}

Measured memory_bytes: 1180
import java.util.*;
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
		int n = sc.nextInt();
        String s = sc.next();
        int k = sc.nextInt();
        
        //K番目の文字取得
        String kcha = s.substring(k - 1, k);


        for (int i = 0; i < s.length(); i++){
            String cha = s.substring(i, i + 1);

            if (cha.equals(kcha)) {

            } else {
              
                s = s.replace(cha,"*");
            } 

        }

        System.out.println(s);
     }
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mkp make_pair
#define f(i,l,h) for(ll i=l;i<h;i++)
#define fr(i,h,l) for(ll i=h;i>=l;i--)

using namespace std;

typedef pair<ll,ll> pll;
const ll INF=(ll)(1e9+7);
typedef vector<ll> vll;

int main()
{
    //cout << "Hello world!" << endl;
    ll n,k;
    cin>>n>>k;
    ll a[n+1];
    f(i,1,n+1) cin>>a[i];
    bool vis[n+1];
    memset(vis,false,sizeof(vis));
    ll temp=k;
    ll curr=1;
    while(k>0 && !vis[curr]){
        vis[curr]=true;
        curr=a[curr];
        k--;
    }
    if(k==0){
        cout<<curr<<endl;
        return 0;
    }

    ll firstjmp=temp-k;

    memset(vis,false,sizeof(vis));
    ll cyclesz=0;
    while(!vis[curr]){
        vis[curr]=true;
        curr=a[curr];
        cyclesz++;
    }

    ll rem=k%cyclesz;
    memset(vis,false,sizeof(vis));


    while(rem>0 && !vis[curr]){
        vis[curr]=true;
        curr=a[curr];
        rem--;
    }

    cout<<curr<<endl;

    return 0;
}


Measured memory_bytes: 5388