akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<vector>
#include <algorithm>
using namespace std;

int main(){ ; 
    int n;
    string a;
    int ans = 0;
    cin >> n;
    for(int i = 1; i < n+1 ; i++){
        a = to_string(i);
        if(a.length()%2 == 1){
            ans++ ;
        }
    }
    printf("%d",ans);
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m,q;cin>>n>>m>>q;
    vector<vector<ll>> lr = vector<vector<ll>>(n,vector<ll>(n,0));
    vector<vector<ll>> dp = vector<vector<ll>>(n,vector<ll>(n,0));
    rep(i,m){
        ll l,r;cin>>l>>r;
        l--;r--;
        lr[l][r]++;
    }
    rep(i,n){
        rep2(j,i,n){
            if(i==j)dp[i][j]=lr[i][j];
            else{
                dp[i][j]=dp[i][j-1];
                rep2(k,i,j+1){
                    dp[i][j]+=lr[k][j];//累積和使ったほうがよさげ
                }
            }
        }
    }
    rep(i,q){
        ll p,q;cin>>p>>q;
        cout<<dp[p-1][q-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 4864
<?php
fscanf(STDIN, "%d %d", $h, $w);

$map = [];
for ($i = 0 ; $i < $h; $i++) {
    $map[$i] = fgets(STDIN);
}

if ($map[0][0] === "#" || $map[$h-1][$w-1] === "#") {
    echo -1;
    return;
}
$memo = [];
$memo[0][0] = 1;

$queues = [new Queue(1, 0, 0)];
while (!empty($queues)) {
    $cursor = array_shift($queues);
    if ($cursor->i === $h && $cursor->j === $w) {
        echo $memo[$cursor->i][$cursor->j];
        return;
    }
    $i = $cursor->i;
    $j = $cursor->j;
    if ($map[$i][$j] === "#") {
        continue;
    }
    if ($i > 0) {
        if (!isset($memo[$i - 1][$j])) {
            $memo[$i - 1][$j] = $memo[$i][$j] + 1;
            $queues[] = new Queue($memo[$i][$j] + 1, $i - 1, $j);
        } else if ($map[$i - 1][$j] === "#") {
            $memo[$i - 1][$j] = "x";
        }
    }
    if ($j > 0) {
        if (!isset($memo[$i][$j - 1])) {
            $memo[$i][$j - 1] = $memo[$i][$j] + 1;
            $queues[] = new Queue($memo[$i][$j] + 1, $i, $j - 1);
        } else if ($map[$i][$j - 1] === "#") {
            $memo[$i][$j - 1] = "x";
        }
    }
    if ($i + 1 < $h) {
        if (!isset($memo[$i + 1][$j])) {
            $memo[$i + 1][$j] = $memo[$i][$j] + 1;
            $queues[] = new Queue($memo[$i][$j] + 1, $i + 1, $j);
        } else if ($map[$i + 1][$j] === "#") {
            $memo[$i + 1][$j] = "x";
        }
    }
    if ($j + 1 < $w) {
        if (!isset($memo[$i][$j + 1])) {
            $memo[$i][$j + 1] = $memo[$i][$j] + 1;
            $queues[] = new Queue($memo[$i][$j] + 1, $i, $j + 1);
        } else if ($map[$i][$j + 1] === "#") {
            $memo[$i][$j + 1] = "x";
        }
    }
}
if (!isset($memo[$h-1][$w-1])) {
    echo -1;
    return;
}

$black = 0;
foreach ($map as $line) {
    $black += substr_count($line, "#");
}

echo ($h * $w) - $memo[$h-1][$w-1] - $black;
return;
class Queue
{
    public function __construct($point, $i, $j)
    {
        $this->point = $point;
        $this->i = $i;
        $this->j = $j;
    }
}


Measured memory_bytes: 4728
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

int main() {
    vector<int> a(3);
    int cnt = 0;
    for (int i = 0; i < 3; ++i) cin >> a.at(i);
    if (*max_element(a.begin(), a.end()) == *min_element(a.begin(), a.end())) cout << a.front() % 2 - 1 << endl;
    else {
        int sum = accumulate(a.begin(), a.end(), 0);
        while (accumulate(a.begin(), a.end(), 0, [](int init, int i) { return init + i % 2; }) == 0) {
            ++cnt;
            for (int i = 0; i < 3; ++i) a.at(i) = (sum - a.at(i)) / 2;
        }
        cout << cnt << endl;
    }
    return 0;
}


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

namespace DP
{
    class B
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]), K=int.Parse(s[1]);
            List<int> h = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            List<int> costList = new List<int>();
            costList.Add(0);

            for (int i = 0; i < h.Count - 1; i++)
            {
                if (i == 0)
                {
                    int cost1 = Math.Abs(h[N - 1] - h[N - 2]);
                    costList.Add(cost1);
                }
                else
                {
                    int k = N - i - 2;
                    int cmin = int.MaxValue;
                    for(int j = 1; j <= K; j++)
                    {
                        if (j > costList.Count) break;
                        int p = costList.Count-1;
                        int m = k + j;
                        int cn = Math.Abs(h[k] - h[m]);
                        int ch = costList[p - j+1];
                        int cost = cn + ch;
                        if (cost < cmin) cmin = cost;
                    }
                    costList.Add(cmin);
                }
            }
            int ctotal = costList.Last();
            Console.WriteLine(ctotal);
        }

    }
}


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

const long long INF = 1e17 + 10;

struct edge { int to; int cost; };
typedef pair<int, int> P; // 最短距離、頂点番号

void Main() {
  int N;
  cin >> N;

  vector<edge> e[N];
  for (int i = 0; i < N - 1; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    e[a - 1].push_back({b - 1, c});
    e[b - 1].push_back({a - 1, c});
  }
  /*
  for (int i = 0; i < N; i++) {
    for (auto j: e[i]) {
      cout << i << " -> " << j.to << " = " << j.cost << endl;
    }
  }
  return;
  */

  int Q, K;
  cin >> Q >> K;

  priority_queue<P, vector<P>, greater<P>> que;
  long long d[N];
  for (int i = 0; i < N; i++) d[i] = INF;
  d[K - 1] = 0;
  que.push(P(0, K - 1));

  while (!que.empty()) {
    P p = que.top(); que.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (int i = 0; i < e[v].size(); i++) {
      edge ee = e[v][i];
      if (d[ee.to] > d[v] + ee.cost) {
        d[ee.to] = d[v] + ee.cost;
        que.push(P(d[ee.to], ee.to));
      }
    }
  }

  for (int i = 0; i < Q; i++) {
    int x, y;
    cin >> x >> y;
    cout << d[x - 1] + d[y - 1] << endl;
  }
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 10356
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  string s,t;
  cin>>s>>t;
  cout<<t<<s<<endl;


}

Measured memory_bytes: 764
import itertools
import math
import numpy as np
import fractions
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
import bisect
import sys
import math
sys.setrecursionlimit(10**9)

def main():
    x = input()
    abc = "ABC"
    arc = "ARC"

    print(abc if x == arc else arc)

if __name__ == "__main__":
  main()


Measured memory_bytes: 27196
n=int(input())
arr=list(map(int,input().split()))
arr.sort()
if(arr[0]>=0):
	sumx=sum(arr)-2*(arr[0])
	ansarr=[]
	if(n==2):
		ansarr.append(arr[1])
		ansarr.append(arr[0])
		val=arr[1]-arr[0]
	else:
		ansarr.append(arr[0])
		ansarr.append(arr[1])
		val=arr[0]-arr[1]
		for i in range(2,n-1):
			ansarr.append(val)
			ansarr.append(arr[i])
			val=val-arr[i]
		ansarr.append(arr[n-1])
		ansarr.append(val)
		val=arr[n-1]-val
	print(val)
	print(*ansarr)

elif(arr[-1]<=0):
	sumx=0
	for i in range(n-1):
		sumx+=abs(arr[i])
	sumx-=abs(arr[n-1])
	ansarr=[]
	if(n==2):
		ansarr.append(arr[1])
		ansarr.append(arr[0])
		val=arr[1]-arr[0]
	else:
		ansarr.append(arr[n-1])
		ansarr.append(arr[n-2])
		val=arr[n-1]-arr[n-2]
		for i in range(n-3,-1,-1):
			ansarr.append(val)
			ansarr.append(arr[i])
			# ansarr.append(val,arr[i])
			val=val-arr[i]

	print(val)
	print(*ansarr)
else:
	val=0
	index=-1
	for i in range(n):
		if(arr[i]>0):
			index=i
			break
	val=arr[0]
	ansarr=[]
	for i in range(index,n-1):
		ansarr.append(val)
		ansarr.append(arr[i])
		# ansarr.append(val,arr[i])
		val-=arr[i]

	ansarr.append(arr[n-1])
	ansarr.append(val)
	val=arr[n-1]-val
	for i in range(1,index):
		ansarr.append(val)
		ansarr.append(arr[i])
		# ansarr.append(val,arr[i])
		val-=arr[i]

	print(val)
	print(*ansarr)

Measured memory_bytes: 18436
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>

using namespace std;


int main() {
	
	int n, m;
	cin >> n >> m;
	if (n >= 10)cout << m;
	else cout << m + 100 * (10 - n);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int n,m;
    cin >> n >> m;
    int h[n];
    REP(i,n) cin >> h[i];
    vector<int> to[100010];
    REP(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    int cnt=0;
    REP(i,n){
        bool flag=true;
        for(int v : to[i]){
            if(h[i]<=h[v]){
                flag=false;
                break;
            }
        }
        if(flag) cnt++;
    }

    cout << cnt;

    return 0;
}

Measured memory_bytes: 9104
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int K = scanner.nextInt();
        
        System.out.println(check(N, M, K) ? "Yes" : "No");
        
        return;
    }
    
    private static boolean check(long N, long M, long K) {
        for (long col = 0; col <= M; col++) 
        for (long row = 0; row <= N; row++) {
            long sum = col * N + M * row - 2 * col * row;
            //System.err.printf("(r, c) = (%d, %d) : sum = %d%n", row, col, sum);
            if (sum == K) return true;
        }
        return false;
    }
    
}

Measured memory_bytes: 23764
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, k, n, h, ans = 0;
  scanf("%lld%lld", &n, &k);
  for(i = 0; i < n; ++i) {
    scanf("%lld", &h);
    if(h >= k) ++ans;
  }
  printf("%lld", ans);
  return 0;
}

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

namespace tenka1_2018_c
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			int[] x = new int[n];
			for (int i = 0; i < n; i++)
			{
				x[i] = int.Parse(Console.ReadLine());
			}
			long ret = 0;
			for (int count = 0; count <= 1; count++)
			{
				int v = (n + count) / 2;
				Array.Sort(x);
				LinkedList<int> a = new LinkedList<int>();
				for (int i = 0; i < v; i++)
				{
					if (i % 2 == 0) a.AddFirst(x[i]);
					else a.AddLast(x[i]);
				}
				Array.Reverse(x);
				LinkedList<int> b = new LinkedList<int>();
				for (int i = 0; i < n - v; i++)
				{
					if (i % 2 == 0) b.AddLast(x[i]);
					else b.AddFirst(x[i]);
				}
				var c = a.ToArray(); var d = b.ToArray();
				int[] arr = new int[n];
				for (int i = 0; i < n; i++)
				{
					if (count == 0) arr[i] = i % 2 == 0 ? d[i / 2] : c[i / 2];
					else arr[i] = i % 2 == 0 ? c[i / 2] : d[i / 2];
				}
				long now = 0;
				for (int i = 1; i < n; i++)
				{
					now += Math.Abs(arr[i] - arr[i - 1]);
				}
				ret = Math.Max(ret, now);
			}
			Console.WriteLine(ret);
		}
	}
}

Measured memory_bytes: 29524
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, K;
    cin >> N >> K;
    int ans = 0;
    rep(i, N) {
        int h;
        cin >> h;
        ans += h >= K;
    }

    write(ans);
}

Measured memory_bytes: 256
## coding: UTF-8
import math

N, K = map(int,input().split())
A = list(map(int,input().split()))
#A = sorted(A)
#print(A)


ok = max(A)
ng = 0
#print(ok, ng)

#print(math.ceil(40 / 10.0) - 1)

def hantei(p):
    cnt = 0
    for i in range(N):
        cnt += math.ceil(A[i] / p) - 1
        #print(A[i], 'done', cnt)
    #print(p, cnt, K)
    if(cnt > K):
        #ng
        return 'ng'
    else:
        return 'ok'



def shisya(ans):
    if((ans - ans // 1) >= 0.5):
        return(int(ans//1+1))
    else:
        return(int(ans//1))   



while shisya(ok)-shisya(ng) > 1:
    #if(ok - ng < 3.5 - 3.49999999):
        #break
    mid = shisya((ok+ng)/2)
    #print('~~~')    
    #print(ok, ng, mid)
    if(hantei(mid) == 'ng'):
        ng = mid
    else:
        ok = mid
    #print(ok, ng)

#print('ans')
print(shisya(ok))


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

#define sqrInf 999999999

using namespace std;

typedef long long lint;

int dp[101][101];
int mn[101][101];

int vizz[51];

void dfs(int a)
{
    if(a == 0)
        return;

    if(vizz[a] == 1)
        return;

    vizz[a] = 1;

    //cout << "SUNTEM " << a << "\n";

    int i, j;
    for(i = 1; i <= a; i ++)
    {
      //  cout << "DIN " << a << " MERGEM " << a % i << "\n";
        dfs(a % i);
        mn[a][a % i] = min(mn[a][a % i], i);

        for(j = 0; j <= a % i; j ++)
        {
            mn[a][j] = min(mn[a][j], max(i, mn[a % i][j]));
            dp[a][j] += dp[a % i][j];
        }

       // cout << "AVEM 10 3 " << dp[10][3] << "\n";
    }
}

int n;
int a[51];
int v[51];

int viz[51][51];

lint rez;

bool diff()
{
    int ok = 0;
    for(int i = 1; i <= n; i ++)
        ok = ok || (viz[i][a[i]] == 0);

    return ok;
}

int main()
{
    int i, j;
    for(i = 0; i <= 50; i ++)
    {
        dp[i][i] = 1;
        mn[i][i] = 0;

        for(j = 0; j <= 50; j ++)
            mn[i][j] = sqrInf;
    }

    for(i = 0; i <= 50; i ++)
        dfs(i);

   /* for(i = 0; i <= 50; i ++)
    {
        for(j = 0; j <= 50; j ++)
        if(dp[i][j] != 0)
            cout << i << " " << j << " DP " << dp[i][j] << " MN " << mn[i][j] << "\n";
    }*/

    cin >> n;
    for(i = 1; i <= n; i ++)
        cin >> v[i];

    for(i = 1; i <= n; i ++)
        cin >> a[i];

    for(i = 1; i <= n; i ++)
    {
        if(dp[v[i]][a[i]] == 0)
        {
            cout << "-1\n";

            return 0;
        }
    }

    for(i = 1; i <= n; i++)
        viz[i][v[i]] = 1;

    while(diff())
    {
        int mx = 0;
        for(i = 1; i <= n;i ++)
        {
            if(viz[i][a[i]] == 0)
            {
                int mna = sqrInf;
                for(j = 0; j <= 50; j ++)
                {
                    if(viz[i][j] == 1)
                    {
                     //   cout << i << " " << j << " MIN " << mn[j][a[i]] << "\n";
                        mna = min(mna, mn[j][a[i]]);
                    }
                }

                mx = max(mx, mna);
            }
        }

       // cout << mx << "\n";

        for(i = 1; i <= n; i ++)
        {
            if(viz[i][a[i]] == 0)
            {
                for(j = 0; j <= 50; j ++)
                {
                    if(viz[i][j] == 1)
                        viz[i][j % mx] = 1;//, cout << "MERGEM " << j % mx << "\n";
                }
            }
        }

        rez += (1LL << mx);
    }

    cout << rez << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>
#include <cassert>
using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int a;
    string b;
    cin >> a >> b;
    ld ans = a*(b[0]-'0');
    ans += a*(b[2]-'0')/10.0;
    ans += a*(b[3]-'0')/100.0;
    cout << (int)ans << endl;
}


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

using namespace std;
typedef long long ll;
#define DBG(v) cerr << #v << " = " << (v) << endl;

vector<int> f() {
	vector<int> v;
	set<int> s;

	auto ok = [&](const int i) {
		if(s.count(i))
		return false;
		for(int x : v)
		if(s.count(x +i))
		return false;
		return true;
	};

	for (int i = 1; (int) v.size() < 10; ++i)
		if (ok(i)) {
			s.insert(i);
			for (int x : v)
				s.insert(x + i);
			v.push_back(i);
		}

	assert(s.size() == 10 + 10 * 9 / 2);
	return v;
}

ll M[111][111];

ll getMx(const ll n) {
	vector<int> v(n);
	for (int i = 0; i < n; ++i)
		v[i] = i + 1;
	ll mx = 0;
	do {
		ll temp = 0;
		for (int i = 1; i < n; ++i)
			temp += M[v[i - 1]][v[i]];
		mx = max(mx, temp);
	} while (next_permutation(v.begin(), v.end()));
	return mx;
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);

	int n;
	cin >> n;
	assert(2 <= n && n <= 10);
	M[1][2] = M[2][1]= 1;

	const vector<int> v = f();

	for (int i = 3; i <= n; ++i) {
		ll mx = getMx(i - 1);

		for (int j = 1; j < i; ++j)
			M[i][j] = M[j][i] =(mx + 1) * v[j - 1];
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j)
			cout << M[i][j] << ' ';
		cout << endl;
	}
	cerr << "mx: " << getMx(n);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N,M;
  cin>>N>>M;
  vector<string> A(N),B(M);
  for(string &S:A)cin>>S;
  for(string &S:B)cin>>S;
  for(int i=0;i+M<=N;i++)
    for(int j=0;j+M<=N;j++){
      for(int k=0;k<M;k++)
        for(int l=0;l<M;l++)
          if(A[i+k][j+l]!=B[k][l])goto home;
      puts("Yes");
      return 0;
      home:;
    }
  puts("No");
}

Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
  static void Main(string[] args)
  {
    var a = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    var n = a[0];
    var p = a[1];

    List<long> yakuList = new List<long>();
    while (p % 2 == 0)
    {
      p /= 2;
      yakuList.Add(2);
    }

    while (true)
    {
      var b = IsPrime(p);
      if (b.IsPrime)
      {
        yakuList.Add(b.Num);
        break;
      }
      while (p % b.Num == 0)
      {
        p /= b.Num;
        yakuList.Add(b.Num);
      }
    }
    var aa = yakuList.GroupBy(x => x);

    long ans = 1;
    foreach (var j in aa)
    {
      ans *= (long)Math.Pow(j.Key, (long)(j.Count() / n));
    }
    Console.WriteLine(ans);
  }

  public static IsPrimeClass IsPrime(long num)
  {
    if (num < 2) return new IsPrimeClass()
    {
      IsPrime = true,
      Num = num
    };

    double sqrtNum = Math.Sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
      if (num % i == 0)
      {
        return new IsPrimeClass()
        {
          IsPrime = false,
          Num = i
        };
      }
    }
    // 素数である
    return new IsPrimeClass()
    {
      IsPrime = true,
      Num = num
    };
  }
}
public class IsPrimeClass
{
  public bool IsPrime;
  public long Num;

}

Measured memory_bytes: 13404
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define mod 1000000007
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'

using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;
int a[maxn];
int main()
{
	int n, m;cin >> n >> m;
	double sum = 0;
	for (int i = 1;i <= n;++i) {
		cin >> a[i];
		sum += a[i];
	}
	int ans = 0;
	sum /= 4 * m;
	for (int i = 1;i <= n;++i) {
		if (a[i] >= sum)++ans;
	}
	if (ans >= m)printf("Yes\n");
	else printf("No\n");
}



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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h,w;
    cin >> h >> w;
    char c[52][52];
    string ans = "Yes";
    for(int i = 0;i < h;i ++){
        for(int j = 0;j < w;j ++){
            cin >> c[i+1][j+1];
        }
    }
    for(int i = 0;i < h;i ++){
        for(int j = 0;j < w;j ++){
            if(c[i+1][j+1]=='#'&&c[i][j+1]!='#'&&c[i+2][j+1]!='#'&&c[i+1][j]!='#'&&c[i+1][j+2]!='#') ans = "No";
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
a = input()
for i in a:
    i 
if i == "2" or i == "4" or i == "5" or i == "7" or i == "9":
    print('hon')
    
elif i == "0" or i == "1" or i == "6" or i == "8":
    print('pon')
    
else:
    print('bon')

Measured memory_bytes: 8948
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;

int main(){
    int n;
    cin >> n;
    char c[n];
    int cnt=0;
    for(int i=0;i<n;i++){
        cin >> c[i];
        if(c[i]=='R') cnt++;
    }

    int ans=0;
    for(int i=0;i<cnt;i++){
        if(c[i]=='W') ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3796
import java.util.Scanner;
public class Main{
  public static void main (String args[]){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    System.out.print(Logic.run(x,a,b));
  }
}
class Logic{
  public static String run(int x,int a,int b){
    String resMes="";
    for ( int i = a; i<=b;i++){
      if ( i%x == 0 ){
        resMes="OK";
        break;
      }
    }
    if (resMes.equals("")){
      resMes = "NG";
    }
    return resMes;
  }
}

Measured memory_bytes: 27088
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    vector<int> s(3);
    REP(i, 3) cin >> s[i];
    sort(s.begin(), s.end());
    if (s[0]==5 && s[1]==5 && s[2]==7) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    //cout << ans << endl;
}

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

using namespace std;

int64_t memo[3001][3001][2];
int64_t a[3000];
//
int64_t f(int l, int r, int state) {
	if (l > r) return 0;
	if (memo[l][r][state] != 0) return memo[l][r][state];
	int64_t ret = 0;
	if (state == 0) {
		ret = max(f(l+1, r, 1) + a[l], f(l, r-1, 1) + a[r]);
	} else {
		ret = min(f(l+1, r, 0) - a[l], f(l, r-1, 0) - a[r]);
	}
	return memo[l][r][state] = ret;
	return ret;
}

int main(int argc, char **argv) {

	cin.tie(0);
  	ios::sync_with_stdio(false);

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

  	cout << f(0, n-1, 0) << endl;

}


Measured memory_bytes: 139776
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int m = saori.saori_hayami();
		System.out.println(24-m + 24);
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    bool within_x = 0 <= (x - r) && (x + r) <= W;
    bool within_y = 0 <= (y - r) && (y + r) <= H;
    // cout << within_x << " and " << within_y << endl;
    if (within_y == 1 && within_x == 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3212
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    s = input()
    print('x'*len(s))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
using namespace std;

int A[20];
int B[50],C[50];

int main(){
  int N = 3;
  cin >> N;
  int ans = 0;
  for(int t=0;t<N;t++)
  {
    cin >> A[t];
  }
  for(int t=0;t<N;t++)
  {
    cin >> B[t];
  }
  for(int t=0;t<N-1;t++)
  {
    cin >> C[t];
  }
  
  for(int t = 0; t < N; t++)
  {
     ans += B[t];
    if(t > 0 && A[t] == A[t-1] + 1)
    {
      ans += C[A[t-1]-1];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
int main() {
    long long n, m, k;
    cin >> n >> m >> k;
    long long sa[n + 1], sb[m + 1];
    sa[0] = 0;
    sb[0] = 0;
    long long maxa = 0, maxb = 0;
    long long sum = 0;
    long num;
    for (int i = 1; i <= n; i++) {
        cin >> num;
        sum += num;
        sa[i] = sum;
        if (sum <= k) {
            maxa = i;
        }
    }
    sum = 0;
    for (int i = 1; i <= m; i++) {
        cin >> num;
        sum += num;
        sb[i] = sum;
        if (sum <= k) {
            maxb = i;
        }
    }
    
    sum = 0;
    int max = 0;
    int j = maxb;
    for (int i = 0; i <= maxa; i++) {
        while (j > 0 && sb[j] > k - sa[i]) {
            j--;
        }
        if (i + j > max) {
            max = i + j;
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 6692
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

int[][1000] G, RG;
int[1000] MEMO;

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];
    foreach (_; 0..M) {
        auto ab = readln.split.to!(int[]);
        auto A = ab[0]-1;
        auto B = ab[1]-1;
        G[A] ~= B;
        RG[B] ~= A;
    }

    int[] walk(int i, int p, int n) {
        foreach (j; RG[i]) if (j != p && MEMO[j] == n) return [];
        int[] js;
        foreach (j; G[i]) if (MEMO[j] == n) js ~= j;
        if (js.length == 1) {
            return [js[0]+1, i+1];
        } else if (js.length > 1) {
            return [];
        }
        foreach (j; G[i]) {
            MEMO[j] = n;
            auto r = walk(j, i, n);
            if (!r.empty) return r ~= i+1;
            MEMO[j] = 0;
        }
        return [];
    }
    
    foreach (i; 0..N) {
        MEMO[i] = i+1;
        auto r = walk(i, -1, i+1);
        if (!r.empty) {
            auto top = r[0];
            int[] rr = [top];
            foreach (p; r[1..$]) {
                if (p == top) break;
                rr ~= p;
            }
            reverse(rr);
            writeln(rr.length);
            writeln(rr.to!(string[]).join(" "));
            return;
        }
    }
    writeln("-1");
}

Measured memory_bytes: 3284
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>

#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <random>
#include <complex>
#include <utility>
#include <tuple>
#include <memory>

#include <array>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <csignal>
#include <cstdint>
#include <cstddef>

#ifdef ONLINE_JUDGE
#define NDEBUG
#endif
#include <cassert>
#include <stdexcept>
#include <exception>

// << pair
template <typename T1, typename T2>
std::ostream&operator<<(std::ostream&os,const std::pair<T1,T2>&p){return os<<"("<<p.first<<", "<<p.second<<")";}
// << container
template <typename C>
std::ostream&_debug_go(std::ostream&os,const C&v) {bool first=true;os<<"[";for(auto i:v){if(!first)os<<", ";os<<i;first=false;}return os<<"]";}
// << {vector, set, map} delegating to _debug_go
template<typename T> std::ostream&operator<<(std::ostream&os,const std::vector<T>&v){return _debug_go(os, v);}
template<typename T> std::ostream&operator<<(std::ostream&os,const std::set<T>&v){return _debug_go(os, v);}
template<typename T1, typename T2> std::ostream&operator<<(std::ostream&os,const std::map<T1,T2>&v){return _debug_go(os, v);}
struct Debugger{template<typename T>Debugger&operator,(const T&v){std::cerr<<v<<" "; return *this;}} dbg;
#ifndef NDEBUG
#define debug(args...) do {dbg,args; cerr << "\n";} while(0)
#else
#define debug(args...)
#endif

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ITER(i, s, e) for (auto i((s)); i != (e); ++i)
#define IT(i, c) ITER(i, (c).begin(), (c).end())

using namespace std;

using ui = uint32_t;
using ll = int64_t;
using ull = uint64_t;
template <typename T = int> using Pt = complex<T>;

template <typename T>
T cross(const Pt<T>& a, const Pt<T>& b) { return a.real() * b.imag() - a.imag() * b.real(); }

template <typename T>
bool cmpPt(const Pt<T>& a, const Pt<T>& b) {
    return a.real() < b.real() || (a.real() == b.real() && a.imag() < b.imag());
}
// END TEMPLATE


ll solve(const int N, const vector<string>& S) {
    map<vector<pair<char, int>>, int> ctCts;
    for (const auto& s : S) {
        map<char, int> ct;
        for (char c : s) ++ct[c];
        vector<pair<char, int>> v(ct.begin(), ct.end());
        ++ctCts[v];
    }
    ll ans = 0;
    for (const auto& kv : ctCts) ans += 1LL * kv.second * (kv.second - 1) / 2;
    return ans;
}

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

    int N; cin >> N;
    vector<string> S(N);
    for (auto& s : S) cin >> s;
    cout << solve(N, S) << '\n';

    return 0;
}


Measured memory_bytes: 21248
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

lint dp[20][2][3][5][20];

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  auto len = [&](lint x) -> lint {
    string s = to_string(x);
    int n = s.size();
    memset(dp, 0, sizeof dp);
    dp[0][1][0][0][0] = 1;
    for (int i = 0; i < n; ++i) for (int d = 0; d < 10; ++d) {
      for (int r3 = 0; r3 < 3; ++r3) for (int r5 = 0; r5 < 5; ++r5) for (int l = 0; l < 20; ++l) {
        if (dp[i][0][r3][r5][l]) {
          dp[i + 1][0][(r3 + d) % 3][d % 5][l + (l or d)] += dp[i][0][r3][r5][l];
        }
        if (d <= s[i] - '0' and dp[i][1][r3][r5][l]) {
          dp[i + 1][d == s[i] - '0'][(r3 + d) % 3][d % 5][l + (l or d)] += dp[i][1][r3][r5][l];
        }
      }
    }
    lint res = 0;
    for (int f = 0; f < 2; ++f) for (int r3 = 0; r3 < 3; ++r3) for (int r5 = 0; r5 < 5; ++r5) for (int l = 1; l < 20; ++l) {
      int c = 0;
      if (!r3) c += 4;
      if (!r5) c += 4;
      if (!c) c = l;
      if (!dp[n][f][r3][r5][l]) continue;
      res += c * dp[n][f][r3][r5][l];
    }
    return res;
  };
  lint s; cin >> s, --s;
  lint ng = 0, ok = 1e17;
  while (ok - ng > 1) {
    lint mid = ng + ok >> 1;
    (s < len(mid) ? ok : ng) = mid;
  }
  s -= len(ok - 1);
  string res;
  for (lint i = ok; (int)res.size() < s + 20; ++i) {
    string curr;
    if (!(i % 3)) curr += "Fizz";
    if (!(i % 5)) curr += "Buzz";
    if (curr.empty()) curr = to_string(i);
    res += curr;
  }
  cout << res.substr(s, 20) << '\n';
}


Measured memory_bytes: 3384
#include <iostream>

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

  std::sort(v, v+3);
  const bool ok = (
    v[0] == 5 &&
    v[1] == 5 &&
    v[2] == 7
  );
  if( ok ) {
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }
}

Measured memory_bytes: 3096
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main()
{
  while(true){
    int N,Q;
    cin >> N >> Q;
    if(N==0&&Q==0)break;
    map<long long int,string> M;
    for(int i = 0; i < N; ++i){
      string era;
      long long int now;
      long long int y;
      cin >> era >> now >> y;
      M[y-now+1]=era;
      M[y]=era;
    }
    for(int i = 0; i < Q; ++i){
      long long int y;
      long long int res=-1;
      string res_era;
      cin >> y;
      map<long long int,string>::iterator itm = M.lower_bound(y);
      if(itm==M.end())itm=M.begin();
      if(itm!=M.begin()){
	--itm;
      }
      while(true){
	if(itm==M.end())break;
	if(itm->first==y){
	  res = 1;
	  res_era = itm->second;
	  break;
	}
	if(itm->first>y){
	  break;
	}else{
	  map<long long int,string>::iterator itm2 = itm;
	  itm2++;
	  if(itm2==M.end())break;
	  if( y >= itm->first && y <= itm2->first && itm->second == itm2->second ){
	    res = y - itm->first + 1;
	    res_era = itm->second;
	    break;
	  }
	}
	++itm;
      }
      if(res>0){
	cout << res_era << ' ' << res << endl;
      }else{
	cout << "Unknown" << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1032
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<map>
using namespace std;
#define ll long long
int main(){
    int N,A,B;
    cin >> N >> A >> B;
    if(N*A<B){
      cout << N*A;
    }else{
      cout <<B;
    }
    return 0;
}


Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	s := getNextString(scanner)
	n := len(s)
	if s[n-1] == '1' || s[0] == '0' {
		fmt.Println(-1)
		return
	}
	for i := 0; i < n/2; i++ {
		if s[i] != s[n-2-i] {
			fmt.Println(-1)
			return
		}
	}

	p := -1
	for i := 0; i < n-1; i++ {
		fmt.Fprintln(writer, fmt.Sprintf("%d %d", p+2, i+2))
		if s[i] == '0' {
			continue
		}
		p = i
	}

	writer.Flush()
}


Measured memory_bytes: 6656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Comparator;import java.util.Collections;

 
public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
	    int word=Integer.parseInt(reader.readLine());
	    System.out.println(word*32);
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}



Measured memory_bytes: 24448
S = input()
N = int(len(S))

x = int((N-1)/2) - 1
y = int((N+3)/2) - 1

S_lead = S[0: x + 1]
S_end = S[y : N+1]

if S_lead == S_lead[::-1] and S_end == S_end[::-1] and S == S[::-1]:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h> 
using namespace std;
#define pb push_back
#define vi vector<int>
#define ss second
#define ff first
#define ll long long
#define pii pair<int,int>
#define mii map<int,int>
#define mod 1000000007
#define w(x) int x; cin>>x; while(x--)
#define ps(x,y) fixed<<setprecision(y)<<x;
ll ab(ll a,ll b)
{
      if(a>b)
      return a-b;
return b-a;
}
int main() 
{
      ll n,i=0;
      cin>>n;
      ll a[n];
      while(i<n)
      {
            cin>>a[i];
            i++;
      }
      ll dp[n];
      dp[0]=0;
      dp[1]=ab(a[0],a[1]);
      for(ll i=2;i<n;i++)
      {
            dp[i]=min(dp[i-1]+ab(a[i],a[i-1]),dp[i-2]+ab(a[i-2],a[i]));
      }
      cout<<dp[n-1];
      return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i=0;i<N;i++) {
		cin >> A[i];
	}

	long all_money = 1000;
	long stock = 0;
	long sub_money = 1000;
	for (int i=0;i<N;i++) {
		long x = all_money/A[i];
		long y = all_money%A[i];
		long z = stock*A[i]+sub_money;
		if (x > stock || (x == stock && y > sub_money)) {
			stock = x;
			sub_money = y;
		}
		if (z > all_money) {
			all_money = z;
		}
	}
	cout << all_money << endl;
}

Measured memory_bytes: 3632
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <vector>
#include <stdio.h>
#include <iostream>
#include <unordered_set>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <random>
#include <time.h>
#include <cassert>
// #include <multiset>

#define prev askdnsajd
#define rank asasdmdnasd
#define next lsjndajbs
#define hash asmdklansd
#define index asdklnas
#define right sld
#define left sldl
using namespace std;

typedef long long ll;
typedef long double dbl;

template<class T>
void print(vector<T> s){
	for (T x : s)
		cout << x << " ";
	cout << endl;
}

ll gcd(ll a, ll b){
	return b > 0 ? gcd(b, a % b) : a;
}

const int maxn = 1e5 + 7;

int get(int n, int l, int x){
	ll summa = 0;
	for (int i = 0; i < n; i++){
		if (i + l != x)
			summa += i + l;
	}
	return summa;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);	
	int n, l;
	cin >> n >> l;
	ll summa = n * (l + (l + n - 1)) / 2;
	if (l <= 0 && l + n - 1 >= 0){
		cout << summa << endl;
		return 0;
	}
	if (summa > 0)
		cout << summa - l << "\n";
	else
		cout << summa - (l + n - 1) << "\n";
	return 0;	
}	


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 ans=0;
    string s;
    cin >> s;
    vector<string> x;
    x.emplace_back("SAT");
    x.emplace_back("FRI");
    x.emplace_back("THU");
    x.emplace_back("WED");
    x.emplace_back("TUE");
    x.emplace_back("MON");
    x.emplace_back("SUN");
    for(int i = 0; i<7; i++){
        if(x[i] == s) ans = i + 1;
    }
    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h,w,i,a,b,c,d;

		for(i=0;i<=1;){
			h = sc.nextInt(); w = sc.nextInt();
			if(h<=0){
				if(w<=0){
					i =2;
				}
			}
			for(a=0;a<h;a++){
				for(b=0;b<w;b++){
					System.out.print("#");
				}
				System.out.println("");
			}
			if(i!=0){
				break;
			}


			System.out.println("");



		}

		sc.close();
	}

}


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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL,LL> PLL;
typedef map<int,int> MII;
typedef queue<int> QI;
typedef queue<PII> QPII;
typedef stack<int> SI;
typedef stack<PII> SPII;
typedef deque<int> DI;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<double> VD;
typedef vector<VD> VVD;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef vector<PII> VPII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define PF push_front
#define POB pop_back()
#define POF pop_front()
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REPR(i,n) FORR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = INT_MAX;
const LL LINF = LLONG_MAX;
const LL MOD = 1e9+7;
const LL MODD = 998244353;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// << fixed << setprecision()

VI dx = {1,0,-1,0,1,1,-1,-1};
VI dy = {0,1,0,-1,1,-1,1,-1};

LL Gcd(LL a, LL b) {
  return __gcd(a,b);
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(N == 0) {
    return 0;
  }
  
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}


int main() {
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N, sum=0;
  cin >> N;
  VI s(N);
  REP(i,N){
    cin >> s.at(i);
    sum += s.at(i);
  }
  
  VVB DP(N+1,VB(sum+1,false));
  REP(i,N+1) DP.at(i).at(0) = true;
  
  REP(i,N){
    REP(j,sum+1){
      if(DP.at(i).at(j))DP.at(i+1).at(j)=true;
      if(s.at(i)+j<=sum){
        if(DP.at(i).at(j))DP.at(i+1).at(j+s.at(i))=true;
      }
    }
  }
  REPR(i,sum+1){
    if(DP.at(N).at(i) && i%10 != 0){
      cout << i << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <tuple>
#include <iomanip>
#include <iterator>
#define PB push_back
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(c) c.begin(),c.end()
#define SHOWVEC(v) for (auto e : v) cerr << e << ' '; cerr << endl;
#define SHOWP(p) cerr << "[" << p.first << "," << p.second << "]" << endl;
#define FI first
#define SE second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
constexpr int INF = 1100000000;
constexpr ll LLINF = 1100000000000000000;

vector<int> v[210000];
ll num[210000];

void dfs(int i, int par)
{
  for (auto j : v[i]) {
    if (j != par) {
      num[j] += num[i];
      dfs(j, i);
    }
  }
}
int main()
{
  int N, Q;
  cin >> N >> Q;
  REP(i, N - 1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    v[a].PB(b);
    v[b].PB(a);
  }
  REP(i, Q) {
    int p, x;
    cin >> p >> x;
    p--;
    num[p] += x;
  }
  dfs(0, -1);
  REP(i, N) {
    cout << num[i] << ' ';
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 24448
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    // ll ll=0;
    // cout << ll;
    int a,b;
    cin >>a>>b;
    if(b==1){ cout << "0" << endl; return 0;}
    int t=a-1;
    int i=1;
    while(1){
        if(a>=b) break;
        a+=t;
        i++;
    }
    // if(i>20) i=20;
    cout << i << endl;
    return 0;
}


Measured memory_bytes: 256