akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
 
class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] inputs = Console.ReadLine().Split(' ')
                    .Select(elem => int.Parse(elem))
                    .ToArray();
        int counter = 1;
        if(n == 1) 
        {
            Console.WriteLine(1);
            return;
        }
        bool isAscending = false, isDescending = false;
        if(inputs[0] < inputs[1]) isAscending = true;
        else if(inputs[0] > inputs[1]) isDescending = true;
        for (int i = 2; i < n; i++)
        {
            if(isAscending && !(inputs[i - 1] <= inputs[i]))
            {
                isAscending = false;
                isDescending = false;
                counter++;
            }
            else if(isDescending && !(inputs[i - 1] >= inputs[i]))
            {
                isAscending = false;
                isDescending = false;
                counter++;
            }
            else if(!isAscending && !isDescending)
            {
                if(inputs[i - 1] < inputs[i]) isAscending = true;
                else if(inputs[i - 1] > inputs[i]) isDescending = true;
            }
            else continue;
        }
        Console.WriteLine(counter);
    }
}

Measured memory_bytes: 21728
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define ll long long
#define INF 999999999

const ll mod = 1e9+7;

int main(){
	ll n;
	cin >> n;
	ll ans = 0;
	ll a;
	REP(i, n){
		cin >> a;
		ans += a;
	}
	cout << ans - n << endl;
}


Measured memory_bytes: 256
from collections import Counter

N = int(input())

n = N
counter = Counter()
while n % 2 == 0:
    counter[2] += 1
    n //= 2
p = 3
while p ** 2 <= N:
    if n % p == 0:
        counter[p] += 1
        n //= p
    else:
        p += 2
if n != 1:
    counter[N] += 1

ans = 0
for key in counter.keys():
    e = 1
    while counter[key] >= e:
        ans += 1
        counter[key] -= e
        e += 1

print(ans)


Measured memory_bytes: 9480
#include <iostream>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdio.h>
#include <vector>
#include <functional>
#include <map>
using namespace std;

int n;
bool list[4][13];
vector<int> v;
map<char, int> m;
int main(){
	m['S'] = 0;
	m['H'] = 1;
	m['C'] = 2;
	m['D'] = 3;

	cin >> n;

	for (int i = 0; i < n; ++i){
		int num;
		char c;
		cin >> c >> num;
		num--;
		list[m[c]][num] = true;
	}

	for (int i = 0; i < 4;++i){
		for (int j = 0; j < 13;++j){
			if (!list[i][j]){
				char c = 'z';
				switch (i)
				{
				case 0:
					c = 'S';
					break;
				case 1:
					c = 'H';
					break;
				case 2:
					c = 'C';
					break;
				default:
					c = 'D';
					break;
				}
				cout << c << " " << j + 1 << endl;
			}
		}
	}

	return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  int Answer = A + B;
  if(A-B > Answer){
  Answer = A - B;
  }
  if(A*B > Answer){
  Answer = A*B;
  }
  cout << Answer << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<queue>
#include<set>
#include<map>
using namespace std;
int main() {
	int n, h, w;
	cin >> n >> h >> w;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		if (a >= h && b >= w)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <map>

using namespace std;

int main()
{
    int N;
    if (scanf("%d", &N) < 1) return 0;

    map<string, int> B;
    for (int i = 0; i < N; i++)
    {
        char tmp[11];
        if (scanf("%s", tmp) < 1) return 0;
        B[tmp]++;
    }

    int M;
    if (scanf("%d", &M) < 1) return 0;
    
    map<string, int> R;
    for (int i = 0; i < M; i++)
    {
        char tmp[11];
        if (scanf("%s", tmp) < 1) return 0;
        R[tmp]++;
    }

    int val = -1000;

    for (pair<string, int> pB:B)
    {
        bool flg = false;
        for (pair<string, int> pR:R)
        {
            if (pB.first == pR.first)
            {
                flg = true;
                int now = pB.second - pR.second;
                if (val <= now) val = now;
            }
        }
        
        if (!flg)
        {
            if (val <= pB.second) val = pB.second;
        }
    }

    printf("%d\n", val < 0 ? 0 : val);

    return 0;
}


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

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "yes" << endl) : (cout << "no" << endl))
#define Yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " : " << p.second << "}";
	return os;
}

template<typename T>
ostream& operator << (ostream& os, const set<T>& s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/

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

	int ans = 0;
	int x = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'I') x++;
		else x--;
		ans = max(ans, x);
	}

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

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

double dp[310][310][310];

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

   vector<int> cnt(4);
   for(int i=0;i<N;i++) cnt[a[i]]++;

   memset(dp,-1,sizeof(dp));
   function<double(int,int,int)> rec=[&](int i,int j,int k)
   {
      if(i==0 and j==0 and k==0) return 0.0;
      if(dp[i][j][k]>=0) return dp[i][j][k];

      double res=(double)N/(i+j+k)-1;
      if(i>0) res+=(rec(i-1,j,k)+1)*i/(i+j+k);
      if(j>0) res+=(rec(i+1,j-1,k)+1)*j/(i+j+k);
      if(k>0) res+=(rec(i,j+1,k-1)+1)*k/(i+j+k);
      return dp[i][j][k]=res;
   };
   cout<<fixed<<setprecision(10)<<rec(cnt[1],cnt[2],cnt[3])<<endl;
   return 0;
}


Measured memory_bytes: 233088
a,b,c,d=input()
n,m=int(a+b),int(c+d)
if((1<=m<=12) and (1<=n<=12)):
    print('AMBIGUOUS')
elif((1<=m<=12)):
    print('YYMM')
elif((1<=n<=12)):
    print('MMYY')
else:
    print('NA')


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

using namespace std;



int main(void) 
{
	string s;
	cin >> s;
	
	while (true)
	{
		bool ok = true;
		s = s.substr(0, s.length() - 2);
		if (s.length() % 2 != 0) continue;

		for (int i = 0; i < s.length()/2; i++)
		{
			if (s[i] != s[s.length() / 2 + i])
			{
				ok = false;
				break;
			}
		}
		if (!ok) continue;
		if (ok) break;
	}

	printf("%d\n", s.length());




	return false;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n, m = LI()
S = sorted(LIR(m), key=lambda x:x[1])



cnt = 0
ret = 0
for i in S:
    if i[0] >= ret:
        cnt += 1
        ret = i[1]


print(cnt)

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

int main() {
  int K;
  string S;
  cin >> K >> S;
  if (S.size() <= K) cout << S << endl;
  else {
    for (int i = 0; i < K; i++) cout << S.at(i);
    cout << "..." << endl;
  }
}


Measured memory_bytes: 3600
//agc033_a.cpp
//Tue May  7 22:22:29 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;



int main(){
	int h,w;
	cin >> h >> w;

	char grid[h][w];
	queue<int> a;
	queue<int> b;
	for (int i=0;i<h;i++){
		for (int j=0;j<w;j++){
			cin >> grid[i][j];
			if (grid[i][j]=='#'){
				a.push(i);b.push(j);
			}
		}
	}

	int da[4] = {0,1,0,-1};
	int db[4] = {1,0,-1,0};

	int count = 0;
	while (a.size()){
		count++;
		int num = a.size();
		for (int i=0;i<num;i++){
			int tempa = a.front();a.pop();
			int tempb = b.front();b.pop();
			for (int l=0;l<4;l++){
				if (tempa+da[l]>=0 &&
					tempa+da[l]< h &&
					tempb+db[l]>=0 &&
					tempb+db[l]< w){
					if (grid[tempa+da[l]][tempb+db[l]]=='.'){
						a.push(tempa+da[l]);
						b.push(tempb+db[l]);
						grid[tempa+da[l]][tempb+db[l]]='#';
					}
				}
			}
		}
	}

	cout << count-1 << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 9472
#include<iostream>
#include<cmath>
#define N 5
using namespace std;

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

  int k;
  cin >> k;

  for(int i = 0; i < N; i++){
    for(int j = i+1; j < N; j++){
      if(abs(a[i]-a[j]) > k){
        cout << ":(" << endl;
        return 0;
      }
    }
  }

  cout << "Yay!" << endl;

  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
ll n;
ll x[100],y[100];
string solve(){
    int cnt =0;
    for(int i=0;i<n;i++)
    {  cnt=0;
        for(int j=i;j<i+3 && j<n;j++)
         {
              if(x[j]==y[j])
              cnt++;
         }
         if(cnt>=3)
           return "Yes"; 
    }
  return "No";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i=0;i<n;i++)
    cin>>x[i]>>y[i];
    cout<<solve();
    return 0;
}

Measured memory_bytes: 3652
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int x = scn.nextInt();
		int xx = x/500;
      	int num = x - xx*500;
      	int xxx = num/5;
      	int ans = xx*1000 + xxx*5;
        System.out.println(ans);
	}
}

Measured memory_bytes: 35628
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x,y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x,y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define d4(x,y,z,w)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z << " | "<< #w << "--> " << w <<endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;
ll mode=1e9+7;
const ll maxn=5*1e5+10;
const ll inf=99999999999;
ll __lcm(ll a, ll b){ return (a*b)/__gcd(a,b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll getRand(ll l, ll r){ uniform_int_distribution<int> uid(l, r); return uid(rng); }
template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) { return out << "(" << a.F << ", " << a.S << ")"; }
template <class A> ostream& operator << (ostream& out, const vector<A> &v) { 
out << "["; for (int i=0;i<v.size();i++) { if(i) out << ", "; out << v[i]; } return out << "]"; } 
	


void solve(){
	
	ll n,k;
	cin>>n>>k;
	vector<ll> a(n+1);
	for (int i=1;i<=n;i++) cin>>a[i];
	for (int i=0;i<k;i++){
		
		vector<ll> pre(n+1, 0);
		for (int j=1;j<=n;j++){
			ll x=max(1ll, j-a[j]);
			ll y=min(n, j+a[j]);
			pre[x]++;
			if ((y+1)<=n) pre[y+1]--;
		}
		for (int j=1;j<=n;j++){
			pre[j]+=pre[j-1];
		}
	
		ll mn=n;
		for (int j=1;j<=n;j++){
			a[j]=pre[j];
			mn=min(mn, a[j]);
		}
		if (mn==n){
			for (int j=1;j<=n;j++) cout<<a[j]<<" ";
			return;
		}
	}
	
	for (int j=1;j<=n;j++){
		cout<<a[j]<<" ";
	}
	
	return;
}
 
int main(){ 
    
    #ifndef ONLINE_JUDGE
		//freopen("input.txt", "r", stdin);
    #endif
    srand(time(0)); 
    
    ios::sync_with_stdio(0);
    cin.tie(0);
 
 	
	//T{ solve(); }
	solve();
	
	return 0;
}

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

const int N = 2 * 1e5 + 5, M = 8e3 + 10, S = 2002, L = 4e3 + 5;
const int mod = 1e9 + 7;

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

int sum(int a, int b) {
	ll k = a + b;
	if(k < 0)
		k += mod;
	if(k >= mod)
		k -= mod;
	return k;
}

ll pw(int a, int b) {
	if(!b)
		return 1;
	ll ans = pw(a, b / 2);
	ans *= ans;
	ans %= mod;
	if(b & 1)
		ans *= a;
	ans %= mod;
	return ans;
}

int a[N], b[N], dp[L][L];
ll fact[N], rev[N];

void prep() {
	fact[0] = 1;
	for (int i = 1; i < N; i++)
		fact[i] = (fact[i - 1] * i) % mod;
	rev[N - 1] = pw(fact[N - 1], mod - 2);
	for (int i = N - 2; ~i; i--)
		rev[i] = (rev[i + 1] * (i + 1)) % mod;
}

ll c(int n, int k) {
	if(k > n)
		return 0;
	ll ans = fact[n] * rev[k];
	ans %= mod;
	ans *= rev[n - k];
	return ans % mod;
}

int n;

int main() {
	cin >> n;
	prep();
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		dp[-a[i] + S][-b[i] + S]++;
	}
	for (int i = -2000; i <= 2000; i++) {
		for (int j = -2000; j <= 2000; j++) {
			dp[i + S][j + S] = sum(dp[i + S][j + S], sum(dp[i - 1 + S][j + S], dp[i + S][j - 1 + S]));
		}
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ll x = a[i], y = b[i];
		ans = sum(ans, dp[x + S][y + S]);
		ans = sum(ans, -c(x + x + y + y, x + x));
	}
//	cout << ans << "\n";
	cout << (ans * pw(2, mod - 2)) % mod << "\n";
}

Measured memory_bytes: 67584
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

    while(1){
        int n; cin>>n;
        if(n == 0) break;
        vector<string> s(n);
        for(int i=0; i<n; i++) cin>>s[i];

        int ans = -1;
        for(int k=1; k<=60; k++){
            set<string> st;
            for(int j=0; j<n; j++){
                int sz = s[j].size();
                string t;
                t += s[j][0];
                for(int l=1; l<sz; l++){
                    if(t.size() == k) break;
                    if(s[j][l-1] == 'a') t += s[j][l];
                    if(s[j][l-1] == 'i') t += s[j][l];
                    if(s[j][l-1] == 'u') t += s[j][l];
                    if(s[j][l-1] == 'e') t += s[j][l];
                    if(s[j][l-1] == 'o') t += s[j][l];
                }

                st.emplace(t);
            }

            if(st.size() == n){
                ans = k;
                break;
            }
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e2 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

ll n, W, w[MAX_N], v[MAX_N], dp[MAX_N][100005];

int main() {
    cin >> n >> W;
    REP(i,n) cin >> w[i] >> v[i];
    REP(i,n+1)fill(dp[i],dp[i]+100005,LLINF/2);
    dp[0][0] = 0;
    REP(i,n){
        REP(j,100005){
            dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
            if(j>=v[i]) dp[i+1][j] = min(dp[i+1][j],dp[i][j-v[i]]+w[i]);
        }
    }
    ll ans=0;
    REP(i,100001){
        if(dp[n][i] <= W) ans = i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 80256
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - Teleporter
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

typedef long long ll;

/* global variables */

int as[MAX_N], cs[MAX_N], ps[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  ll k;
  scanf("%d%lld", &n, &k);

  for (int i = 0; i < n; i++) scanf("%d", as + i), as[i]--;

  memset(cs, -1, sizeof(cs));
  int u = 0, m = 0;
  while (cs[u] < 0) {
    ps[m] = u;
    cs[u] = m++;
    u = as[u];
  }
  //printf("u=%d, m=%d, cs[u]=%d\n", u, m, cs[u]);

  int q;
  if (k < cs[u])
    q = k;
  else
    q = cs[u] + (k - cs[u]) % (m - cs[u]);

  printf("%d\n", ps[q] + 1);
  return 0;
}


Measured memory_bytes: 5480
#include<stdio.h>

int main()
{
    int i,n,count=1,max;
    scanf("%d",&n);
    int ara[n];
    for(i=0;i<n;i++)
        scanf("%d",&ara[i]);
    max=ara[0];
    for(i=1;i<n;i++){
        if(ara[i]<max){
            max=ara[i];
            count++;
        }
    }
    printf("%d",count);
}


Measured memory_bytes: 2508
package main

import (
	"fmt"
)

func main() {
	var s, t, u string
	var a, b int
	fmt.Scan(&s, &t)
	fmt.Scan(&a, &b)
	fmt.Scan(&u)

	if a == 0 && b == 0 {
		fmt.Println(a, b)
		return
	}

	if a > 0 && u == s {
		a = a - 1
	} else if b > 0 && u == t {
		b = b - 1
	}

	fmt.Println(a, b)
}


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

const int N = 2e5 + 7;

long long f[N], b, w, p[N], d[N], M = 1e9 + 7;

long long power(long long a, long long b) {
	if (b == 0)
		return 1;
	long long t = power(a, b / 2);
	t = (t * t) % M;
	if (b % 2)
		t = (t * a) % M;
	return t;
}	
long long ch(long long a, long long b) {
	if (b < a)
		return 0;
	long long t = f[b];
	t = (power(f[a], M - 2) * t) % M;
	t = (power(f[b - a], M - 2) * t) % M;
	return t;
}

int main() {
	f[0] = 1;
	for (long long i = 1; i < N; i++)
		f[i] = (f[i - 1] * i) % M;
	cin >> b >> w;
	for (int i = 1; i <= b + w; i++) {
		p[i] = p[i - 1];
		p[i] = (p[i] + ch(b - 1, i - 1)	* power(power(2, i), M - 2)) % M;
		d[i] = d[i - 1];
		d[i] = (d[i] + ch(w - 1, i - 1) * power(power(2, i), M - 2)) % M;
		cout << (((d[i - 1] + (1 - d[i - 1] - p[i - 1]) * power(2, M - 2)) % M) + M) % M << " ";  	
	}

	return 0;
}


Measured memory_bytes: 6912
from collections import deque

N, D, A = map(int, input().split())
M = [tuple(map(int, input().split())) for i in range(N)]

M.sort()
X = [M[i][0] for i in range(N)]
H = [M[i][1] for i in range(N)]
ans = 0
diff = 0
q = deque()
for i in range(N):
    Xi, Hi = M[i]
    while len(q) > 0 and q[0][0] < Xi:
        diff += q.popleft()[1]
    Hi += diff
    if Hi <= 0:
        continue
    c = (Hi + A - 1) // A
    ans += c
    diff -= A * c
    q.append((Xi + 2 * D, A * c))
print(ans)


Measured memory_bytes: 47700
#include <algorithm>
#include<iomanip>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include<stack>
#include <string>
#include <vector>

// author:Swastik Banerjee

using namespace std;

typedef long long ll;
#define MOD 1000000007

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



  
 

    ll N; cin>>N;
    set<string> s1;
    while(N--){
      string s; cin>>s;
      s1.insert(s);
    }

    cout<<s1.size();





}

Measured memory_bytes: 19184
def Check_Num(i):
    x = i
    if(x%3==0):
        print(" ",i,sep="",end="")
        return False
    return True

def Include_3(i,j):
    x = i
    y = j
    
    if(x%10==3):
        print(" ",j,sep="",end="")
        return True 
    x = (int)(x/10)       
    if(x!=0):
        Include_3(x,y)

s = input()
n = int(s)

for i in range(1,n+1):
    boolean = Check_Num(i)

    if boolean:
        Include_3(i,i)

print()
    




Measured memory_bytes: 6244
#include <iostream>
#include <string>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    string w, t;
    cin >> w;
    for (auto &x : w)
        if (isupper(x))
            x = tolower(x);
    int ans = 0;
    while (cin >> t, t != "END_OF_TEXT") {
        for (auto &x : t)
            if (isupper(x))
                x = tolower(x);
        if (w == t)
            ans++;
    }
    cout << ans << endl;
}


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

using namespace std;

const int maxN = 3003;

long long DP[maxN][maxN];

string s1, s2;
pair<int, int> ans_rec[maxN][maxN];



void solve() {
    cin >> s1 >> s2;
    for(int i = 0; i <= s1.size(); i++)
        DP[i][0] = 0;
    for(int i = 0; i <= s2.size(); i++)
        DP[0][i] = 0;
    for(int i = 0; i <= s1.size(); i++)
        for(int j = 0; j <= s2.size(); j++)
            ans_rec[i][j] = {-1, -1};
    for(int i = 1; i <= s1.size(); i++){
        for(int j = 1; j <= s2.size(); j++){
            if(DP[i][j] < DP[i-1][j]){
                DP[i][j] = DP[i-1][j];
                ans_rec[i][j] = {i-1, j};
            }
            if(DP[i][j] < DP[i][j-1]){
                DP[i][j] = DP[i][j-1];
                ans_rec[i][j] = {i, j-1};
            }
            if(s1[i-1] == s2[j-1] && DP[i][j] < DP[i-1][j-1]+1){
                DP[i][j] = DP[i-1][j-1]+1;
                ans_rec[i][j] = {i-1, j-1};
            }
        }
    }
    int i = ans_rec[s1.size()][s2.size()].first, j = ans_rec[s1.size()][s2.size()].second;
    string ans;
    //if(s1[s1.size()-1] == s2[s2.size()-1]) ans += s1[s1.size()-1];
    while(i != -1 && j != -1){
        if(s1[i] == s2[j]) ans += s1[i];
        auto v = ans_rec[i][j];
        i = v.first;
        j = v.second;

    }
    reverse(ans.begin(), ans.end());
    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    bool multitest = false;
    //multitest = true;
    if (multitest) {
        int t; cin >> t;
        while (t--)
            solve();
    }
    else
        solve();
}


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

using namespace std;

constexpr int MAXK = 1e5;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (auto &x : v)
    cin >> x;
  vector<bool> dp(k+1);
  for (int i=0; i<=k; ++i)
    for (int x : v)
      if (i>=x && !dp[i-x])
        dp[i] = 1;
  cout << (dp[k] ? "First\n" : "Second\n");
  return 0;
}


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

int main() {
	int a, b;
	cin >> a >> b;

	if (a + 1 == b || a == b + 1) {
		cout << a + b << endl;
	}
	else if (a == b) {
		cout << a + b << endl;
	}
	else {
		int ax = max(a, b);
		cout << ax + ax - 1 << endl;
	}
}

Measured memory_bytes: 256
n = int(input())

ab = []
for i in range(n):
    ab.append(list(map(int, input().split())))
ab.sort(key=lambda x: x[1])

time_sum = 0
flag = True
for i in range(n):
    time_sum = time_sum + ab[i][0]
    if time_sum > ab[i][1]:
        flag = False
        break

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 53724
#include <iostream>
#include <vector>
#include <list>
#include <chrono>

using namespace std;
typedef long long ll;

int DAYS;
const int TYPES = 26;

vector<int> c;
vector<vector<ll>> s;
chrono::system_clock::time_point startTime, endTime;

vector<ll> simulate(vector<int> &t) {
    vector<list<int>> last(TYPES, {-1});
    vector<ll> ret(DAYS);
    ll now = 0;
    for (int i = 0; i < DAYS; i++) {
        now += s[i][t[i]], last[t[i]].push_back(i);
        for (int j = 0; j < TYPES; j++) {
            now -= c[j] * (i - last[j].back());
        }
        ret[i] = now;
    }
    return ret;
}

ll scoring(vector<ll> &&satisfying) {
    return max(1000000 + satisfying.back(), 0LL);
}

int main() {
    startTime = chrono::system_clock::now();

    cin >> DAYS;
    c.resize(TYPES);
    for (int i = 0; i < TYPES; i++)cin >> c[i];
    s.assign(DAYS, vector<ll>(TYPES));
    for (int i = 0; i < DAYS; i++) {
        for (int j = 0; j < TYPES; j++) {
            cin >> s[i][j];
        }
    }

    vector<int> t(DAYS);
    for (int i = 0; i < DAYS; i++) {
        int maxScore = -1, maxContest = -1;
        for (int j = 0; j < TYPES; j++) {
            if (maxScore < s[i][j])maxScore = s[i][j], maxContest = j;
        }
        t[i] = maxContest;
    }

    ll currentScore = scoring(simulate(t));
    while (false) {
        endTime = chrono::system_clock::now();
        if (chrono::duration_cast<chrono::milliseconds>(endTime - startTime).count() > 1850) break;
    }

    for (auto &x:t)cout << x + 1 << endl;
    return 0;
}

Measured memory_bytes: 3736
H, W = map(int,input().split())
l = []
for h in range(H):
    s = list(input())
    if s != ["."]*W:
        l.append(s)

for w in range(W-1, -1, -1):
    cnt = 0
    for h in range(len(l)):
        if l[h][w] == "#":
            break
        else:
            cnt += 1
    if cnt == len(l):
        for h in range(len(l)):
            del l[h][w]
for h in range(len(l)):
    print("".join(l[h]))
        

Measured memory_bytes: 65864
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if((abs(a - b) <= d && abs(b - c) <= d) || abs(a - c) <= d) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
t = gets.to_i
t.times do
  n = gets.to_i
  x = gets.chomp.split(" ")
  a = Array.new(10)
  for i in 0..n-1
    a[i] = x[i].to_i
  end
  max=0;min=0
  for i in 1..n-1
    z = a[i] - a[i-1]
    max=z if z>=0 && max<z
    min=z if z<0 && min>z
  end
  print(max," ",-min,"\n")
end


Measured memory_bytes: 6116
#include <iostream>
#include <stdio.h>

using namespace std;

int main(void){
  int a_1 = 2;
  int x;
  int s = 0;

  while(scanf("%d", &x) != EOF ){
    if(x == 1){
      printf("%d\n", a_1);
    }else{

      s += a_1;
      for(int i = 2; i <= x; i++){
        s += i;
      }
      printf("%d\n", s);
    }
    s = 0;
  }

  return 0;
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	std::string s;
	std::cin >> s;
	std::reverse(s.begin(), s.end());
	for (auto &i : s) i -= '0';
	int sum = std::accumulate(s.begin(), s.end(), 0);
	int r0 = 0;
	int r0_cur = 1;
	int r1 = 0;
	int r1_cur = 1;
	for (int i = 0; i < n; i++) {
		if (sum > 1) {
			r0 = (r0 + r0_cur * s[i]) % (sum - 1);
			r0_cur = r0_cur * 2 % (sum - 1);
		}
		r1 = (r1 + r1_cur * s[i]) % (sum + 1);
		r1_cur = r1_cur * 2 % (sum + 1);
	}
	int res[n];
	int cur[n];
	memset(res, 0, sizeof(res));
	
	r0_cur = r1_cur = 1;
	for (int i = 0; i < n; i++) {
		if (s[i]) { // % (sum - 1)
			if (sum > 1) cur[i] = (r0 - r0_cur + sum - 1) % (sum - 1), res[i]++;
		} else cur[i] = (r1 + r1_cur) % (sum + 1), res[i]++;
		
		if (sum > 1) r0_cur = r0_cur * 2 % (sum - 1);
		r1_cur = r1_cur * 2 % (sum + 1);
	}
	std::reverse(res, res + n);
	std::reverse(cur, cur + n);
	auto calc = [&] (int n) {
		int res = 0;
		while (n) n %= __builtin_popcount(n), res++;
		return res;
	};
	for (int i = 0; i < n; i++) {
		if (res[i]) res[i] += calc(cur[i]);
		printf("%d\n", res[i]);
	}
	return 0;
}


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

int main(){
    string strA = "";
    cin >> strA;

    if(strA.at(0) == strA.at(1)){
        if(strA.at(0) == strA.at(2)){
            cout << "No" << endl;
        }
        else{
            if(strA.at(2) == strA.at(3))
                cout << "Yes" << endl;
            else
                cout << "No" << endl;
        }
    }
    else{
        if(strA.at(0) == strA.at(2)){
            if(strA.at(1) == strA.at(3))
                cout << "Yes" << endl;
            else
                cout << "No" << endl;            
        }
        else{
            if(strA.at(0) == strA.at(3)){
                if(strA.at(1) == strA.at(2))
                    cout << "Yes" << endl;
                else
                     cout << "No" << endl;    
            }
            else
                cout << "No" << endl;  
        }
    }
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int N,M;
    cin >> N >> M;
    vector<int> A(N);
    rep(i,N) cin >> A.at(i);
    int total = 0;
    rep(i,N){
        total += A.at(i);
    }
    int ans = 0;
    rep(i,N){
        if(A[i]*4*M >= total){
            ans++;
        }
    }
    if(ans >= M) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
/*input
2 2 2
2 1 2
2 2 2
*/
#include<bits/stdc++.h>
using namespace std;
const int N=55600;
#define int long long
#define pii pair<int, int>
#define f first
#define s second
inline pii mp(int a, int b)
{
	pii temp;temp.f=a;temp.s=b;return temp;
}
int read_int(){
	char r;
	bool start=false,neg=false;
	int ret=0;
	while(true){
		r=getchar();
		if((r-'0'<0 || r-'0'>9) && r!='-' && !start){
			continue;
		}
		if((r-'0'<0 || r-'0'>9) && r!='-' && start){
			break;
		}
		if(start)ret*=10;
		start=true;
		if(r=='-')neg=true;
		else ret+=r-'0';
	}
	if(!neg)
		return ret;
	else
		return -ret;
}
bool check(int i)
{
	i--;if(i%6==0) return true;i+=2;if(i%6==0) return true;return false;
}
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int arr[3][3];
	vector<int> temp;
	int sum=0;
	for(int i=0;i<3;i++) 
		{for(int j=0;j<3;j++) cin>>arr[i][j];
			temp.push_back(i);sum+=arr[i][i];
		}
		bool check=false;
	do
	{
		int ts=0;
		for(int i=0;i<3;i++)
		{
			ts+=arr[i][temp[i]];
		}
		if(ts!=sum) check=true;
	}while( next_permutation(temp.begin(), temp.end()));
	if(check) cout<<"No";
	else cout<<"Yes";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

#define INSERT_COST 1
#define DELETE_COST 1
#define CHANGE_COST 1

int main(){
  string S,T;
  cin>>S>>T;
  int sl = S.size();
  int tl = T.size();

  vvi dp(sl+1, vi(tl+1));

  for(int i=0; i<=sl; i++)dp[i][0] = i*INSERT_COST;
  for(int j=0; j<=tl; j++)dp[0][j] = j*INSERT_COST;

  for(int i=1; i<=sl; i++){
    for(int j=1; j<=tl; j++){
      int D = dp[i-1][j] + DELETE_COST;
      int I = dp[i][j-1] + INSERT_COST;
      int C = dp[i-1][j-1] + (S[i-1]==T[j-1]? 0: CHANGE_COST);

      dp[i][j] = min({D,I,C});
    }
  }

  /*
  for(vi x: dp){
    for(int y: x){
      cout<<y<<",";
    }
    cout<<endl;
  }//*/

  int ans = dp[sl][tl];

  cout<<ans<<endl;
}


Measured memory_bytes: 6864
/** Author : Parth Prajapati
 * 	Institute : Pandit Deendayal Petroleum University
**/
#include<bits/stdc++.h>

using namespace std;

int main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int a,b;
    cin>>a>>b;
    if(a <= b)  cout<<1;
    else
    {
        if(a%b == 0)    cout<<a/b;
        else    cout<<(a/b)+1;
    }
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    string S;
    read(S);
    string ans = "Good";
    if(S[0] == S[1] || S[1] == S[2] || S[2] == S[3]){
        ans = "Bad";
    }
    write(ans);
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

Measured memory_bytes: 256
def resolve():
    N, M = list(map(int, input().split()))
    factors = []
    i = 1
    while i <= M**(1/2):
        if M%i==0:
            factors.append(i)
            factors.append(M//i)
        i += 1
    factors = sorted(factors, reverse=True)
    #print(factors)
    for fac in factors:
        if N*fac <= M and (M-N*fac)%fac == 0:
            print(fac)
            break


if '__main__' == __name__:
    resolve()

Measured memory_bytes: 3188
import math
N = int(input())
A = [0]
A.extend(list(map(int, input().split())))
A.append(0)

hoge = sum([abs(A[i] - A[i-1]) for i in range(1, N+2)])

for i in range(1, N+1):
  print(hoge + abs(A[i-1] - A[i+1]) - (abs(A[i-1] - A[i]) + abs(A[i] - A[i+1])))
 


Measured memory_bytes: 14048
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))

gcd_l = [0]
gcd_r = [0]
for i in range(N):
    gcd_l.append(gcd(gcd_l[i], A[i]))
    gcd_r.append(gcd(gcd_r[i], A[-(i+1)]))

gcds = []
for i in range(N):
    gcds.append(gcd(gcd_l[i], gcd_r[-(i+2)]))
ans = max(gcds)
print(ans)

Measured memory_bytes: 16112
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

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

        System.out.println(A - B >= C ? 0 : C - (A - B));
    }
}

Measured memory_bytes: 21844
import sys
sys.setrecursionlimit(10 ** 8)

N, W = map(int, input().split())
A = [[int(i) for i in input().split()] for i in range(N)]
memo = {i : {} for i in range(N)}

def dfs(i, j):
    if i == N:
        return 0
    elif j in memo[i]:
        return memo[i][j]
    elif A[i][0] > j:
        ans = dfs(i + 1, j)
    else:
        ans  = max(dfs(i + 1, j), A[i][1] + dfs(i + 1, j - A[i][0]))
    memo[i][j] = ans
    return ans
        
print(dfs(0, W))

Measured memory_bytes: 10728
import sys,queue,math,copy,itertools,bisect,collections,heapq
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

N,K = LI()
A = LI()
max_bit = (10**12).bit_length()
bit = [0 for _ in range(max_bit)]
for x in A:
    b = 1
    for j in range(max_bit):
        if x & b: bit[j] += 1
        b <<= 1

ans = 0
k = 0
for i in range(max_bit-1,-1,-1):
    b = bit[i]
    if k + 2**i <= K and bit[i]*2 < N:
        b = N - b
        k += 2**i
    ans += b * 2**i
print (ans)




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

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define eof !cin.eof()
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define ull unsigned long long
#define ll long long
#define ld long double
#define sz(a) a.size()
#define all(s) s.begin(), s.end()
#define rall(s, n) s, s + n
#define x first
#define y second
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ii pair <int, int>
#define iii pair <int, ii>
#define vi vector <int>
#define vit vector <int> :: iterator
#define vlt vector <ll> :: iterator
#define vl vector <ll> 
#define vii vector <ii>
#define viii vector <iii>
#define vd vector <double>
#define vull vector <ull>
#define vc vector <char>
#define vs vector <string>
#define vvi vector <vector <int>>
#define vvl vector <vector <ll>>
#define EPS 1e-10
#define INF 1000000000
#define mod 1000000007
#define reset(a, nilai) memset(a, nilai, sizeof(a))
#define minof min_element
#define maxof max_element
using namespace std;

int n, ans;
int main () {
	IOS;
	
	scanf("%d", &n);
	vi a(n), b(n), c(n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d%d", &a[i], &b[i], &c[i]);
	}
	ans = max(a[0], max(b[0], c[0]));
	for (int i = 1; i < n; i++) {
		a[i] += max(b[i - 1], c[i - 1]);
		b[i] += max(a[i - 1], c[i - 1]);
		c[i] += max(a[i - 1], b[i - 1]);
		ans = max(a[i], max(b[i], c[i]));
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1408
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
static const ll INF = 1LL << 60;
static const int MAX_N = 20000;
 
int N, M; ll K;
ll A[MAX_N + 1];
 
ll memo[MAX_N + 1];
 
int main(){
    scanf("%d %d %lld", &N, &M, &K);
    fill(memo + 1, memo + N + 1, INF);
    for(int i = 1; i < N + 1; i++) scanf("%lld", &A[i]);
    for(int i = 0; i < N + 1; i++){
        ll a, b;
    	for(int j = 0; j < M; j++){
    	    if(i + j > N) continue;
    	    if(j == 0) a = A[i], b = A[i];
            else a = max(a, A[i + j]), b = min(b, A[i + j]);
            memo[i + j] = min(memo[i + j], 
memo[i - 1] + K + (j + 1) * (a - b));
        }
    }
    printf("%lld\n", memo[N]);
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int sum=0,X=N;
  while(X!=0){
    sum+=X%10;
    X/=10;
  }
  if(N%sum==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
package main

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

const divisor = 1000000007

func main() {
	h := readInt()
	w := readInt()
	a := make([]string, 2)
	a[0] = readString()
	a[1] = readString()
	dp := make([][]int, 2)
	dp[0] = make([]int, w)
	dp[1] = make([]int, w)
	dp[0][0] = 1
	for i := 0; i < h-1; i++ {
		for j := 0; j < w-1; j++ {
			if a[0][j+1] != '#' {
				dp[0][j+1] = (dp[0][j+1] + dp[0][j]) % divisor
			}
			if a[1][j] != '#' {
				dp[1][j] = dp[0][j]
			}
		}
		if a[1][w-1] != '#' {
			dp[1][w-1] = dp[0][w-1]
		}
		a[0], a[1] = a[1], readString()
		dp[0], dp[1] = dp[1], dp[0]
		for j := 0; j < w; j++ {
			dp[1][j] = 0
		}
	}
	for j := 0; j < w-1; j++ {
		if a[0][j+1] != '#' {
			dp[0][j+1] = (dp[0][j+1] + dp[0][j]) % divisor
		}
	}
	fmt.Println(dp[0][w-1])
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


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

const int WIDTH = 3200;
const int DEBUG = 0;

struct State {
	int score;
	int prevs;
	int sousa;
	int Last[29];
};

bool operator<(const State& a1, const State& a2) {
	if (a1.score < a2.score) return true;
	return false;
}

int N;
int C[29], S[409][29];
int cnts[409];
int Last[409];
int BORDER;
State G[409][WIDTH + 9];
State H[(WIDTH * 26) + 9];

int getscore(vector<int> vec) {
	for (int i = 1; i <= 26; i++) Last[i] = 0;
	int t = 0;
	for (int i = 0; i < vec.size(); i++) {
		Last[vec[i]] = i + 1; t += S[i + 1][vec[i]];
		for (int j = 1; j <= 26; j++) t -= C[j] * ((i + 1) - Last[j]);
	}
	return t;
}

void solve(int pos, int num, int i) {
	int NewScore = G[pos][num].score;
	NewScore += S[pos + 1][i];
	for (int j = 1; j <= 26; j++) {
		if (i != j) NewScore -= C[j] * ((pos + 1) - G[pos][num].Last[j]);
	}
	if (NewScore < BORDER) return; // 門前払い

	H[cnts[pos + 1]].score = NewScore;
	H[cnts[pos + 1]].prevs = num;
	H[cnts[pos + 1]].sousa = i;
	for (int j = 1; j <= 26; j++) H[cnts[pos + 1]].Last[j] = G[pos][num].Last[j];
	H[cnts[pos + 1]].Last[i] = pos + 1;
	cnts[pos + 1]++;
}

int main() {
	// 入力
	if (DEBUG == 0) {
		cin >> N;
		for (int i = 1; i <= 26; i++) cin >> C[i];
		for (int i = 1; i <= N; i++) {
			for (int j = 1; j <= 26; j++) cin >> S[i][j];
		}
	}
	else {
		N = 365;
		for (int i = 1; i <= 26; i++) C[i] = rand() % 101;
		for (int i = 1; i <= N; i++) {
			for (int j = 1; j <= 26; j++) S[i][j] = ((rand() % 32768) * 32768 + (rand() % 32768)) % 20001;
		}
	}

	// ビームサーチ
	G[0][0].prevs = -1; cnts[0] = 1;
	for (int i = 0; i < N; i++) {
		// 適当に 800 個サンプリングする
		BORDER = -(1 << 28);
		for (int t = 0; t < 800; t++) {
			int r1 = rand() % cnts[i], r2 = (rand() % 26) + 1;
			solve(i, r1, r2);
		}
		vector<int> R;
		for (int j = 0; j < 800; j++) R.push_back(H[j].score);
		sort(R.begin(), R.end());
		reverse(R.begin(), R.end());
		if (cnts[i] == WIDTH) BORDER = R[R.size() / 10];
		else BORDER = -(1 << 28);

		// 枝刈りする
		cnts[i + 1] = 0;
		for (int j = 0; j < cnts[i]; j++) {
			for (int k = 1; k <= 26; k++) solve(i, j, k);
		}
		sort(H, H + cnts[i + 1]);
		reverse(H, H + cnts[i + 1]);
		cnts[i + 1] = min(cnts[i + 1], WIDTH);
		for (int j = 0; j < cnts[i + 1]; j++) G[i + 1][j] = H[j];
	}

	// 復元
	vector<int> Answer; int cx = 0;
	for (int i = N; i >= 1; i--) {
		Answer.push_back(G[i][cx].sousa);
		cx = G[i][cx].prevs;
	}
	reverse(Answer.begin(), Answer.end());

	// 山登り法
	vector<int> R;
	for (int i = 1; i <= N; i++) R.push_back(Answer[i - 1]);
	int CurrentMax = getscore(R), S = 0;
	for (int t = 1; t <= 80000; t++) {
		if (rand() % 10 < 5) {
			int v1 = rand() % (N - 1);
			swap(R[v1], R[v1 + 1]);
			int CandMax = getscore(R);
			if (CurrentMax <= CandMax) { CurrentMax = CandMax; S = 0; }
			else { swap(R[v1], R[v1 + 1]); S += 1; }
		}
		else {
			int v1 = rand() % N, v2 = rand() % 26 + 1;
			int moto = R[v1];
			R[v1] = v2;
			int CandMax = getscore(R);
			if (CurrentMax <= CandMax) { CurrentMax = CandMax; S = 0; }
			else { R[v1] = moto; S += 1; }
		}
	}
	for (int i = 1; i <= N; i++) cout << R[i - 1] << endl;
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
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) - 1;
const ll LINF = (1LL<<60) - 1;

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

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int y=d-b; int x=c-a;
  for(int i=0;i<y;i++){cout << "U";}
  for(int i=0;i<x;i++){cout << "R";}
  for(int i=0;i<y;i++){cout << "D";}
  for(int i=0;i<x;i++){cout << "L";}
  cout << "L";
  for(int i=0;i<y+1;i++){cout << "U";}
  for(int i=0;i<x+1;i++){cout << "R";}
  cout << "DR";
  for(int i=0;i<y+1;i++){cout << "D";}
  for(int i=0;i<x+1;i++){cout << "L";}
  cout << "U";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1000000000000005;
const int maxn=1e6+5;
ll n,m,p;
int main()
{
    scanf("%lld%lld",&n,&m);
    if(n==1&&m==2) printf("3\n");
    if(n==1&&m==3) printf("2\n");
    if(n==2&&m==3) printf("1\n");
    if(n==2&&m==1) printf("3\n");
    if(n==3&&m==1) printf("2\n");
    if(n==3&&m==2) printf("1\n");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int H,W;
  int i,j;
    
  int plus = 0;

  while(1){
    scanf("%d %d", &H, &W);

    if(W%2 == 1){
      plus = 1;
    }
	
    if(H == 0&& W ==0){
      break;
    }
    for(i =0;i<H;i++){
      if(W == 1){
	if(i%2 == 0){
	  printf("#");
	}else{
	  printf(".");
	}

      }

      
      for(j=0;j<W/2;j++){
	if(i%2 == 1 && j == 0){
	  printf(".");
	}
	      
	printf("#");
	if(j != W/2 - 1){
	  printf(".");
	}
	if(plus == 1){
	  if(j == W/2-1){
	    printf(".");
	  }
	}
	if(i%2 == 0 && j == W/2 -1){
	  if(W%2 == 0){
	    printf(".");
	  }else{
	    printf("#");
	  }
	}
      }
      printf("\n");
    }
    printf("\n");
    plus = 0;
  }
  return 0;
}



Measured memory_bytes: 2124
'use strict';
(function(stdin) {
    var inputs = stdin.toString();
    var r = parseFloat(inputs);
    var circlearea = Math.PI * Math.pow(r, 2);
    var circumference = 2 * Math.PI * r;
    console.log(circlearea, circumference);

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15840
N,K,Q = map(int,input().split())
finish = K - Q
A = [finish for _ in range(N)] 
for i in range(Q):
    a = int(input()) - 1
    A[a] += 1
for aa in A:
    if aa <= 0:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 6596