akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		boolean[][] v = new boolean[N][N];
		for(int i=0; i<N; i++) {
			char[] s = sc.next().toCharArray();
			for(int j=0; j<N; j++)
				v[i][j] = s[j]=='#';
		}
		
		int filledColumn = 0;
		boolean atLeastOneBlack = false;
		for(int i=0; i<N; i++) {
			boolean ok = true;
			for(int j=0; j<N; j++) {
				atLeastOneBlack |= v[j][i];
				ok &= v[j][i];
			}
			if(ok)
				filledColumn++;
		}

		if(!atLeastOneBlack) {
			System.out.println(-1);
			sc.close();
			return;
		}
		
		int ans = Integer.MAX_VALUE;
		for(int i=0; i<N; i++) {
			boolean found = false;
			for(int j=0; j<N; j++) {
				if(v[j][i]) {
					found = true;
					break;
				}
			}
			int needToPaint = 0;
			for(int j=0; j<N; j++) {
				if(!v[i][j])
					needToPaint++;
			}
			ans = Math.min(ans, (found ? 0 : 1) + needToPaint + N - filledColumn);
		}
		
		System.out.println(ans);
		sc.close();
	}
}



Measured memory_bytes: 28756
def resolve():
    '''
    code here
    '''
    import math
    N = int(input())

    num_max = int(math.sqrt(N)) +1

    n_list = [[] for _ in range(N+1)]
    for i in range(1, num_max+1):
        for j in range(1, num_max+1):
            for k in range(1, num_max+1):
                if i**2+j**2+k**2+i*j+j*k+k*i <= N:
                    n_list[i**2+j**2+k**2+i*j+j*k+k*i] += [[i, j, k]]
    
    
    for i in range(1, N+1):
        temp = n_list[i]
        if temp:
            print(len(temp))
        else:
            print(0)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 36368
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

template <class T> void max_swap(T& a, const T b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


struct swap_info { int no1, no2, p1, p2; };
int main()
{
	int n, m, h, k;
	while (scanf("%d%d%d%d", &n, &m, &h, &k), n | m | h | k)
	{
		int s[1024];
		static pint stick[100100];
		for (int i = 0; i < n; ++i)
			scanf("%d", s + i);
		for (int i = 0; i < m; ++i)
		{
			int a, b;
			scanf("%d%d", &a, &b);
			stick[i] = pint(b, a - 1);
		}
		sort(stick, stick + m);


		static pint swap_pair[100100];
		int no[1024];
		for (int i = 0; i < n; ++i)
			no[i] = i;
		for (int i = 0; i < m; ++i)
		{
			int x = stick[i].second;
			swap_pair[i].first = no[x];
			swap_pair[i].second = no[x + 1];
			
			swap(no[x], no[x + 1]);
		}

		int p[1024];
		for (int i = 0; i < n; ++i)
			p[i] = s[i];

		int max_sub = 0;
		for (int i = m - 1; i >= 0; --i)
		{
			int x = stick[i].second;
			swap(p[x], p[x + 1]);

			pint a(swap_pair[i].first, p[x]);
			pint b(swap_pair[i].second, p[x + 1]);
			if (a > b)
				swap(a, b);
			if (a.first < k && k <= b.first)
				max_swap(max_sub, a.second - b.second);
		}

		printf("%d\n", accumulate(p, p + k, 0) - max_sub);
	}
}

Measured memory_bytes: 2452
n = int(input())
s = input()
rl = s.count('R')
gl = s.count('G')
bl = s.count('B')
rr = 0
gr = 0
br = 0
if s[0] == 'R':
    rl -= 1
    rr += 1
elif s[0] == 'G':
    gl -= 1
    gr += 1
else:
    bl -= 1
    br += 1

ans = 0
for i in range(1, n-1):
    for j in range(1, n//2+1):
        if i-j < 0 or i+j > n-1:
            break
        if s[i+j] != s[i-j] and s[i+j] != s[i] and s[i-j] != s[i]:
            ans -= 1
    if s[i] == 'R':
        ans += bl*gr + br*gl
        rl -= 1
        rr += 1
    elif s[i] == 'G':
        ans += rr*bl + rl*br
        gl -= 1
        gr += 1
    else:
        ans += gr*rl + gl*rr
        bl -= 1
        br += 1
print(ans)


Measured memory_bytes: 9260
import java.util.* ; 
import java.math.*;
class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner (System.in);
	int n = scan.nextInt();
 	int arr[] = new int[n+1] ;
    for(int i = 1 ;i<= n ; i++){
      arr[i] = scan.nextInt();
    }
    int m = scan.nextInt(); 
    int arr2[] = new int[m+1];
    int arr3[] = new int[m+1];
     for(int i = 1 ;i<= m ; i++){
      arr2[i] = scan.nextInt();
       arr3[i] = scan.nextInt();
    }
    int temp = 0 ;
    for(int i = 1 ; i<= m ;i++){
      temp = arr[arr2[i]] ; 
      arr[arr2[i]] = arr3[i];
      //System.out.println(arr[arr2[i]]);
      int sum = 0 ;
      for(int j = 1 ; j <= n ; j++){
        sum+=arr[j];
      }
      System.out.println(sum);
      arr[arr2[i]] = temp ;  
    }
   
    
    
  }
}


Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,n,s) for(int i=(int)(s);i<(int)(n);++i)
#define RREP(i,n,s) for(int i=(int)(s);i>=(int)(n);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

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

    int cnt = 0;
    vector<string> v;
    for(char c = 'a'; c <= 'z'; c++) {
        int l_ind = 0;
        vector<pair<int, string>> indexes;
        while(true) {
            int index = (int)s.find(c, l_ind); // 開始位置初期値は0，見つからなければ-1
            if (index != -1) {
                indexes.push_back(make_pair(index, s.substr(index, s.size()-index)));
                l_ind = index+1;
            } else {break;}
        }
        sort(ALL(indexes), [](const pair<int, string>& a, const pair<int, string>& b) {
            return a.second < b.second;
        });

        FOR(d, indexes) {
            int index = d->first;
            for(int i = index; i <= s.size(); i++) {
                v.push_back(s.substr(index, i-index+1));
            }

            sort(ALL(v));
            v.erase(unique(ALL(v)), v.end());
            if(v.size() >= k) break;
        }

        if(v.size() >= k) break;
    }

    cout << v[k-1] << endl;
}


Measured memory_bytes: 16128
#include<bits/stdc++.h>
#define mx 100000
#define pb push_back
#define siz(v) v.size();
typedef unsigned long  ull;
typedef long long  ll;
using namespace std;

int main()
{
 	ios_base::sync_with_stdio(0);
 	cin.tie(0); cin.tie(0);
	
	string id,pass;
	cin>>id>>pass;
	
	if (id.length()+1==pass.length()){
		bool f=1;
		for(int i=0;i<id.length();++i){
			if (id[i]!=pass[i]){
				f=0;
				break;
			}
		}
		if (f)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
	else 
		cout<<"No\n";

	




 return 0;
 }


Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main()
{
    int N;
    cin >> N;
    string s[110];
    REP(i, N) cin >> s[i];
    map<string, int> dicts;
    REP(i, N) dicts[s[i]] = 0;
    REP(i, N) dicts[s[i]] += 1;
    int M;
    cin >> M;
    string t[110];
    REP(i, M) cin >> t[i];
    map<string, int> dictt;
    REP(i, N) dictt[s[i]] = 0;
    REP(i, M) dictt[t[i]] = 0;
    REP(i, M) dictt[t[i]] += 1;
    int ans = 0;
    REP(i, N){
        if (dicts[s[i]] - dictt[s[i]] > ans){
            ans = dicts[s[i]] - dictt[s[i]];
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
#define int long long int
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define vi vector <int>
#define sz(s) (int)s.size()
#define pii pair<int,int>
#define piii pair< int,pair<int,int> >
#define tiii tuple <int,int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define rall(v) v.rbegin(),v.rend()
#define endl '\n'
#define matrix vector <vector <int> >
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define NAYAN freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define N 100001
#define mod 1000000007
#define mod2 998244353
#define inf 1e18


vector <int> g[N];

pii dp[N];

void dfs(int u,int p)
{
    dp[u]={1,1};
    for(int v:g[u])
    {
        if(v!=p)
        {
            dfs(v,u);
            dp[u].ff=(dp[u].ff*dp[v].ss)%mod;
            dp[u].ss=(dp[u].ss*(dp[v].ff+dp[v].ss))%mod;
            
        }
    }
}

int32_t main()
{
    boost
    // #ifndef ONLINE_JUDGE 
    // NAYAN
    // #endif

    int n;
    
    cin >> n;
    
    int u,v;
    int i;
    for(i=0;i<n-1;i++)
    {
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }

    dfs(1,0);

    int ans=(dp[1].ff+dp[1].ss)%mod;

    cout << ans << endl;

    
    
    
}

Measured memory_bytes: 14208
#include <iostream>
#include <vector>
#include <stack>
#include <cmath>
#include <algorithm>
using namespace std;
int n;
vector<int> a(500000);

void maxheapify(int i){
  int largest = i;
  if(2 * i <= n){
    if(a[largest] < a[2 * i]) largest = 2 * i;
  }
  if(2 * i + 1 <= n){
    if(a[largest] < a[2 * i + 1]) largest = 2 * i + 1;
  }
  if(largest == i) return;
  int t = a[i];
  a[i] = a[largest];
  a[largest] = t;
  maxheapify(largest);
}

void solve(){
  cin >> n;
  for(int i = 1; i <= n; i++){
    cin >> a[i];
  }
  for(int i = n / 2; i >= 1; i--){
    maxheapify(i);
  }
  for(int i = 1; i <= n; i++){
    cout << " " << a[i];
  }
  cout << endl;
}

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



Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  string strA, strB;
  cin >> N;
  cin >> strA >> strB;
  for(int i = 0; i < N; i++){
    cout << strA.at(i) << strB.at(i);
  }
}
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,M;
  cin>>N>>M;
    
  vector<pair<int,int>> s(N);
  vector<pair<int,int>> c(M);
  
  for(int i=0;i<N;i++){
    cin>>s[i].first>>s[i].second;
  }
  
  for(int i=0;i<M;i++){
    cin>>c[i].first>>c[i].second;
  }
  
  vector<int> ans(N);
  for(int n=0;n<N;n++){
    int x=0,y=0,d=0,min=0;
    for(int m=0;m<M;m++){
      x=s[n].first-c[m].first;
      y=s[n].second-c[m].second;
      if(x<0) x*=-1;
      if(y<0) y*=-1;
      d=x+y;
      if(m==0||d<min){
        min=d;
        ans[n]=m+1;
      }
    }
  }
  
  for(int i=0;i<N;i++){
    cout<<ans[i]<<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int a, b, c, d;
  cin>>a>>b>>c>>d;
  cout<<max(a*b, c*d)<<endl;
}


Measured memory_bytes: 3464
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

check = [0] * n
check[0] = 1

i = 0
count = 0
is_success = False
while True:
    count += 1
    i = a[i]
    if i == 2:
        is_success = True
        break
    i -= 1
    if check[i] != 0:
        break
    check[i] = 1
print(str(count) if is_success else '-1')

Measured memory_bytes: 7852
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    K=ii()
    A,B=mi()

    for x in range(A,B+1):
        if x % K == 0:
            print("OK")
            exit()

    print("NG")





if __name__ == "__main__":
    main()

Measured memory_bytes: 61644
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
    
int n, k;
vector<int> v, w;

void bundle() {
    int prev = v[0];
    int cnt = 1;
    for (int i=1; i<n; i++) {
        if (prev != v[i]) {
            w.push_back(cnt);
            prev = v[i];
            cnt = 1;
        } else {
            cnt++;
        }
    }
    w.push_back(cnt);
}

int main() {
    cin >> n >> k;
    v.resize(n);
    for (int& x: v) cin >> x;
    sort(v.begin(), v.end());

    bundle();
    sort(w.begin(), w.end());
    int sum = 0;
    if (w.size() > k) {
        int del_kinds = w.size() - k;
        for (int i=0; i<del_kinds; i++) {
            sum += w[i];
        }
        cout << sum << endl;
    } else {
        cout << '0' << endl;
    }
}

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

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

  if( a > b ) swap(a, b);
  if( b > c ) swap(b, c);
  if( a > b ) swap(a, b);

  cout<<a<<" "<<b<<" "<<c<<endl;
  return 0;
}



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

class Program
{
    static void Main(string[] args)
    {
        string[] nk = Console.ReadLine().Split(' ');
        int N = int.Parse(nk[0]);
        int K = int.Parse(nk[1]);
        string[] Hstr = Console.ReadLine().Split(' ');
        int len = Hstr.Length;
        long[] H = new long[len];
        for(int i=0; i<len; i++){
            H[i] = long.Parse(Hstr[i]);
        }

        Array.Sort(H);
        Array.Reverse(H);

        long result = 0;

        if(K < N){
            for(int i=K; i<N; i++){
                result += H[i];
            }
        }

        Console.WriteLine(result);
    }
}

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

int main(){
  int N,X,Y;
  cin >> N >> X >> Y;
  const int INF=1e8;
  vector< vector<int> > v(N+1);
  for(int i=1;i<N;i++){
    v.at(i).push_back(i+1);
    v.at(i+1).push_back(i);
  }
  v.at(X).push_back(Y);
  v.at(Y).push_back(X);

  vector<int> ans(N,0);
  for(int i=1;i<=N;i++){
    queue<int> que;
    vector< int > dist(N+1,INF);
    que.push(i);
    dist.at(i)=0;
    while(!que.empty()){
      int a=que.front();
      que.pop();
      for(auto b:v.at(a)){
        if(dist.at(b)==INF){
          que.push(b);
          dist.at(b)=dist.at(a)+1;
          ans.at(dist.at(b))++;
        }
      }
    }
  }
  for(int i=1;i<=N-1;i++){
    cout << ans.at(i)/2 << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
const int N = 503, mod = 998244353;
typedef long long LL;
int n, sa, sb, ans, a[N], b[N], fac[N], ifac[N], inv[N], dp[2][N][N], cur, pw[N];
inline void upd(int &a, int b){a += b; if(a >= mod) a -= mod;}
inline int kasumi(int a, int b){
	int res = 1;
   	while(b){
   		if(b & 1) res = (LL) res * a % mod;
   		a = (LL) a * a % mod; b >>= 1;
   	}
   	return res;
}
inline void init(int m){
 	fac[0] = 1;
   	for(Rint i = 1;i <= m;++ i) fac[i] = (LL) fac[i - 1] * i % mod;
   	ifac[m] = kasumi(fac[m], mod - 2);
   	for(Rint i = m;i;-- i){
   		ifac[i - 1] = (LL) ifac[i] * i % mod;
   		inv[i] = (LL) ifac[i] * fac[i - 1] % mod;
   	}
}
inline int C(int n, int m){
   	if(n < 0 || m < 0 || n < m) return 0;
   	return (LL) fac[n] * ifac[m] % mod * ifac[n - m] % mod;
}
int main(){
   	scanf("%d", &n);
   	for(Rint i = 1;i <= n;++ i){
   		scanf("%d%d", a + i, b + i);
   		sa += a[i]; sb += b[i];
   	}
   	init(max(sa, sb) + 10);
   	dp[0][0][0] = mod - 1;
   	for(Rint i = 1;i <= n;cur ^= 1, ++ i){
   		memcpy(dp[cur ^ 1], dp[cur], sizeof dp[cur]);
   		int v = (LL) a[i] * inv[sa] % mod; pw[0] = 1;
   		for(Rint j = 1;j <= sb - n;++ j) pw[j] = (LL) pw[j - 1] * v % mod;
   		for(Rint j = 0;j <= sb - n;++ j)
   			for(Rint k = a[i];k <= sa;++ k)
   				for(Rint t = 0;t <= j && t < b[i];++ t)
   					upd(dp[cur ^ 1][j][k], mod - (LL) C(j, t) * dp[cur][j - t][k - a[i]] % mod * pw[t] % mod);
   	}
   	for(Rint i = 0;i <= sb - n;++ i)
   		for(Rint j = 1;j <= sa;++ j)
   			upd(ans, (LL) dp[cur][i][j] * kasumi((LL) sa * inv[j] % mod, i + 1) % mod);
   	printf("%d\n", ans);
} // ntftwfx

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

vector<int> Z_algorithm(const string &S) {
    int N = (int)S.size();
    vector<int> lcp(N);
    lcp[0] = N;
    int i = 1, j = 0;
    while (i < N) {
        while (i+j < N && S[j] == S[i+j]) ++j;
        lcp[i] = j;
        if (j == 0) {++i; continue;}
        int k = 1;
        while (i+k < N && k+lcp[k] < j) lcp[i+k] = lcp[k], ++k;
        i += k, j -= k;
    }
    return lcp;
}

int main () {
    int N;
    string S;
    cin >> N >> S;
    
    int ans = 0;
    // Z_algorithmを部分文字列に適用してlcp(i, j)を求める
    for (int i = 0; i < N; ++i) {
        string T = S.substr(i);
        auto lcp = Z_algorithm(T);
      
        for (int j = 0; j < (int)T.size(); ++j) {
            int num = min(lcp[j], j);
            ans = max(ans, num);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

struct City {
  City(int64_t i, int64_t p, int64_t y, int64_t n)
    : id(i), p(p), year(y), no(n) {}
  int64_t id;
  int64_t p;
  int64_t year;
  int64_t no;
};

string Output(int64_t n) {
  string str = to_string(n);
  string pref = "";
  for (size_t i = str.size(); i < 6; ++i) {
    pref += '0';
  }
  return pref + str;
}

int main() {
  int64_t N, M;
  cin >> N >> M;

  vector<City> cities;
  cities.reserve(M);
  for (int64_t m = 0; m < M; ++m) {
    int64_t P, Y;
    cin >> P >> Y;
    cities.emplace_back(m, P, Y, 0);
  }
  sort(cities.begin(), cities.end(),
       [] (const City& lhs, const City& rhs) {
         if (lhs.p != rhs.p) {
           return lhs.p < rhs.p;
         }
         return lhs.year < rhs.year;
       });
  int64_t no = 1;
  int64_t cur_p = 0;
  for (City& city : cities) {
    if (cur_p != city.p) {
      no = 1; cur_p = city.p;
    }
    city.no = no++;
  }
  sort(cities.begin(), cities.end(),
       [] (const City& lhs, const City& rhs) {
         return lhs.id < rhs.id;
       });
  for (const City& city : cities) {
    cout << Output(city.p) << Output(city.no) << endl;
  }

  return 0;
}


Measured memory_bytes: 6428
//デバッグ用オプション：-fsanitize=undefined,address

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//インクルードなど
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

// vector set 等
#include <map>
#include <set>
#include <vector>

//マクロ
// forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
// FORAは範囲for文(使いにくかったら消す)
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto& i : I)
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF 1000000000000  // 10^12:∞
#define MOD 1000000007     // 10^9+7:合同式の法
#define MAXR 100000        // 10^5:配列の最大のrange
//略記
#define PB push_back  //挿入
#define MP make_pair  // pairのコンストラクタ
#define F first       // pairの一つ目の要素
#define S second      // pairの二つ目の要素

// 負の数にも対応した % 演算
ll mod(ll x) {
  ll res = x % MOD;
  if (res < 0) x += MOD;
  return res;
}

ll mpow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}
// a^{-1} mod を計算する
ll minv(ll a) { return mpow(a, MOD - 2); }

signed main() {
  //入力の高速化用のコード
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  ll n, ans = 0;

  cin >> n;
  ans = mod(mpow(10, n) - mpow(9, n) - mpow(9, n) + mpow(8, n));

  ans = (ans + MOD) % MOD;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
string s;
cin >>s;
if(s[5]=='0'){
    if(s[6]=='4'||s[6]=='3'||s[6]=='2'||s[6]=='1'){
        cout << "Heisei"<<endl;
    }
    else
    {
        cout << "TBD"<<endl;
    }
    
}
else {
    cout << "TBD"<<endl;
}

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e17;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
int nx[2] = {0,1};
int ny[2] = {1,0};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    vector<string> grid(h);
    rep(i,h) cin >> grid[i];
    queue<P> p,q;
    bool flag = 1;
    if (grid[0][0] == '#') flag = 0;
    vector<vector<int>> d(h,vector<int>(w,-1));
    if (flag){
        q.push(P(0,0));
        d[0][0] = 0;
    }
    else{
        p.push(P(0,0));
        d[0][0] = 1;
    }
    while(!p.empty() || !q.empty()){
        if(flag){
            while(!q.empty()){
                int x = q.front().first;
                int y = q.front().second;
                q.pop();
                rep(i,2){
                    int xn = x+nx[i];
                    int yn = y+ny[i];
                    if (xn >= 0 && xn < h && yn >= 0 && yn < w && d[xn][yn] == -1){
                        if (grid[xn][yn] == '.'){
                            q.push(P(xn,yn));
                            d[xn][yn] = d[x][y];
                        }
                        else{
                            p.push(P(xn,yn));
                            d[xn][yn] = d[x][y]+1;
                        }
                    }
                }
            }
            flag = 0;
        }else{
            while(!p.empty()){
                int x = p.front().first;
                int y = p.front().second;
                p.pop();
                rep(i,2){
                    int xn = x+nx[i];
                    int yn = y+ny[i];
                    if (xn >= 0 && xn < h && yn >= 0 && yn < w && d[xn][yn] == -1){
                        if (grid[xn][yn] == '#'){
                            p.push(P(xn,yn));
                            d[xn][yn] = d[x][y];
                        }
                        else{
                            q.push(P(xn,yn));
                            d[xn][yn] = d[x][y];
                        }
                    }
                }
            }
            flag = 1;
        }
    }
    PRINT(d[h-1][w-1]);
}


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

int main() {
  long n,m,ans=0;
  cin >> n >> m;
  if(n*2<=m) ans+=n,m-=n*2;
  else ans+=m/2,m=0;
  ans+=m/4;
  cout << ans << endl;
}

Measured memory_bytes: 256
function main(input) {
    var line = input.split(/\r?\n/g);
    const A = line[1].split(" ").map(Number);
    var flg = true;
    for (var i in A)
        if (!(A[i] % 2) && A[i] % 3 && A[i] % 5) {
            flg = false;
            break;
        }
    console.log(flg ? "APPROVED" : "DENIED");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll a,b,k;cin>>a>>b>>k;
  for(ll i=0;i<k;i++){
    if(i%2==0){
    if(a%2==1)a--;
    b+=a/2;
    a/=2;
}if(i%2==1){
    if(b%2==1)b--;
    a+=b/2;
    b/=2;
}
}
   cout<<a<<" "<<b<<endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;  //初期化数列を宣言してカウントしていく
  vector<int> count(N);
  for (int i=0; i<M ; i++) {
    int a,b;
    cin >> a >> b;
    count.at(a-1)++;
    count.at(b-1)++;
  }
  for (int i = 0; i < N; i++) {
    cout << count.at(i) << endl;
  }
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,j,N) for(int i = (N-1);i >= (j);i--)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

int N,M;

int digit[10] = {0,2,5,5,4,5,6,3,7,6};

vector<int> vi;

const int maxn = 1e4+10;
int dp[maxn];
int opt[maxn];

int main()
{
    cin >> N >> M;
    _for(i,0,M){
        int num;scanf("%d",&num);
        vi.PB(num);
    }

    sort(ALL(vi));
    memset(dp,-1,sizeof(dp));
    dp[0] = 0;
    _rep(i,0,N){
        if(dp[i] >= 0){
            _for(j,0,vi.size()){
                int num = vi[j];
                int di = digit[num];
                if(dp[i]+1 > dp[di+i]){
                    dp[di+i] = dp[i] + 1;
                    opt[di+i] = num;
                }
                else if(dp[i]+1 == dp[di+i]){
                    opt[di+i] = max(opt[di+i],num);
                }
            }
        }
    }

    vector<int> ans;
    int index = N;
    while(index){
        int num = opt[index];
        ans.push_back(num);
        index -= digit[num];
    }

    sort(ALL(ans),greater<int>());

    for(auto a:ans){
        printf("%d",a);
    }
    printf("\n");
    return 0;
}

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

int main() {
    ll n;
    std::cin >> n;
    vector<ll> p(n);
    for (int i = 0; i < n; i++) {
        ll r;
        std::cin >> r;
        r--;
        p[r] = i;
    }
    
    for (int i = 1; i <= n-1; i++) {
        std::cout << i*20010<<" ";
    }
    std::cout <<  n*20010 << std::endl;
    for (int i = 1; i <= n-1; i++) {
        std::cout << (n+1-i)*20010+p[i-1]<<" ";
    }
    std::cout << 20010+p[n-1] << std::endl;
}
 


Measured memory_bytes: 768
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from bisect import bisect_left
from itertools import accumulate

n = ni()
a = list(li())
b = list(li())

a_larger = []
lack = 0
ans = 0

# ai > bi のものを降順にならべ、累積和
# ai < bi のものは総和
for ai, bi in zip(a, b):
    if ai > bi:
        a_larger.append(ai - bi)
    elif ai < bi:
        lack += (bi - ai)
        ans += 1

a_larger.sort(reverse=True)
a_larger_cum = [0] + list(accumulate(a_larger))

# 二分探索
idx = bisect_left(a_larger_cum, lack)
if idx >= len(a_larger_cum):
    print(-1)
else:
    print(ans + idx)

Measured memory_bytes: 19112
#include <iostream>

using namespace std;

long long a, b, c, d, n; char op;

int main()
{
    cin >> n;
    
    for(int i = 0; i < n; i++)
    {
        cin >> c >> op >> d;
        
        if(op == '(')
        {
            a += d;
        }
        else
        {
            b += d;
        }
        
        if(a == b)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long int ll;
const int MOD=1000000007;

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

    vector<ll> a(n),x(q),ans(q,0);
    rep(i,n)cin>>a[i];
    rep(i,q)cin>>x[i];
    ll u,sum=0,r=0;
    rep(i,q){
        sum = 0;r = 0;
        u = x[i];
        rep(l,n){
            while(sum+a[r]<=u&&r<n){
                sum += a[r];
                r++;
            }
            if(sum<=u)ans[i] += r-l;
            if(r==l){
                r++;
            }else{
                sum -= a[l];
            }
        }
    }
    rep(i,q)cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 3552
#include <iostream>
 
using namespace std;
 
int main()
{
   string s;
   cin >> s;
 
   if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
   {
       cout << "Bad" << endl;
   }
   else
   {
       cout << "Good" << 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);
		
		final long a = sc.nextLong();
		final long b = sc.nextLong();
		
		System.out.println((a * b) + " " + (2 * (a + b)));
		
	}
	
}

Measured memory_bytes: 17156
#include <stdio.h>
int main(void) {
    int hand[5],kind[3][2],i,num;
    while (1) {
        scanf("%d",&hand[0]);
        if (hand[0]==0) break;
        for (i=0; i<3; i++) kind[i][0]=0,kind[i][1]=0;
        scanf("%d %d %d %d",&hand[1],&hand[2],&hand[3],&hand[4]);
        for (i=0; i<5; i++) kind[hand[i]-1][0]++;
        if ((kind[0][0]>0&&kind[1][0]>0&&kind[2][0]>0)||kind[0][0]==5||kind[1][0]==5||kind[2][0]==5) {
            kind[0][1]=3,kind[1][1]=3,kind[2][1]=3;
        } else if (kind[0][0]>0&&kind[1][0]>0) {
            kind[0][1]=1,kind[1][1]=2;
        } else if (kind[1][0]>0&&kind[2][0]>0) {
            kind[1][1]=1,kind[2][1]=2;
        } else if (kind[2][0]>0&&kind[0][0]>0) {
            kind[2][1]=1,kind[0][1]=2;
        }
        for (i=0; i<5; i++) {
            printf("%d\n",kind[hand[i]-1][1]);
        }
    }
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
long long k,a,b,tian;
int main()
{
	cin>>k>>a>>b;
	if(a>=k)
	{
		cout<<1<<endl;
		exit(0);
	}
	if(a<=b)
	{
		cout<<-1<<endl;
		return 0;
	}
	if((k-a)%(a-b)>=1) tian=1;
	cout<<((k-a)/(a-b)+tian)*2+1<<endl;
	
	}

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;
using P=pair<int,int>;


int main(){
   int n; cin>>n;
   vector<int> a(n+1);
   vector<int> b(n);
   rep(i,n+1) cin>>a[i];
   rep(i,n) cin>>b[i];
   ll ans=0;
   rep(i,n){
       //左に残っているのと自分の戦力の小さいほう
       int left=min(a[i],b[i]);
       ans+=left;
       a[i]-=left;
       b[i]-=left;

       //残った戦力で右を倒す
       int right= min(a[i+1],b[i]);
       ans+=right;
       a[i+1]-=right;
       b[i]-=right;
   }
   cout<<ans<<endl;
   return 0;
}

   


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#include<algorithm>
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	vector<ll>p,q,a;
	for(ll i=0;i<n;i++){
		a.push_back(i+1);
	}	
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		p.push_back(x);
	}
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		q.push_back(x);
	}
	ll A=0;
	ll B=0;
	ll j=0;
	do{
		for(ll i=0;i<n;i++){
			if(a[i]!=p[i]){
				break;
			}
			if(i==n-1){
				A=j;
			}
		}
		for(ll i=0;i<n;i++){
			if(a[i]!=q[i]){
				break;
			}
			if(i==n-1){
				B=j;
			}
		}		
		j++;
	}while(next_permutation(a.begin(),a.end()));
	cout << abs(A-B);
	// your code goes here
	return 0;
}

Measured memory_bytes: 3628
/*****Here we go again!******/

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

#define pi 3.1415926535
#define endl "\n"
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ll long long
#define llu unsigned long long
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define tc int test_case; cin >> test_case; while(test_case--)
#define f(i,a,n) for(int i = a ; i < n ; i++)
#define rf(i,n,a) for(int i = n-1 ; i >= a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define get(a,n) f(i,0,n) cin >> a[i];
#define show(a,n) f(i,0,n) cout << a[i] << " "; cout << endl;
#define fast ios:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define trace(x) cerr << '>' << #x << ':' << (x) << "\n"
#define trace2(x,y) cerr<< '>' << #x << ':' << (x) << " | " << #y << ':' << (y) << "\n"
#define trace3(a,b,c) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"

typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
typedef map<int,int> mii;
typedef map<ll,ll> mll;

const int inf = 1e9;
const ll inf64 = 1e18;
const int mod = inf + 7;
const int N = 1e5 + 10;

int main()
{
    fast;
    string n;
    cin >> n;
    ll sum = 0;
    f(i,0,sz(n))
        sum += n[i] - '0';
    if(sum % 9)
        cout << "No";
    else
        cout << "Yes";
}


Measured memory_bytes: 3752
a,b,c,d,e,f = input().split()
A = int(a)
B = int(b)
C = int(c)
D = int(d)
E = int(e)
F = int(f)

dictmax = {} 
for i in range(31):
	for j in range(31):
		for p in range(101):
			for q in range(101):
				ans_list = []
				if((100*(A*j+B*i))==0):
					break
				elif((100*(A*j+B*i)+(C*q+D*p))>F):
					break

				else:
					if((C*q+D*p) <=E*(A*j+B*i)):
						nodo = (C*q+D*p)/(100*(A*j+B*i)+(C*q+D*p))
						max_ans = 100*(A*j+B*i)+(C*q+D*p)
						sugar = C*q+D*p
	
						dictmax[nodo] = (max_ans,sugar)

max_nodo = max(dictmax.keys())
souryou = dictmax[max_nodo][0]
satou = dictmax[max_nodo][1]
print(souryou,satou)


Measured memory_bytes: 4512
import kotlin.math.sqrt

fun main(args: Array<String>) {
  val n: Int = readLine()!!.toInt()
  val memo: MutableList<Int> = mutableListOf()
  for (i in 1..n - 1) {
    memo.add(calc(i))
  }
  println(memo.sum())
}

fun calc(i: Int): Int {
  var answer = 0
  val n = sqrt(i.toDouble()).toInt()

  for (j in 1..n) {
    if (i % j == 0) {
      answer += 1
    }
  }
  if (i == n * n) {
    answer = answer * 2 - 1
  } else {
    answer = answer * 2
  }
  return answer
}

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

using namespace std;

int main()
{
 long long int a,b,c,k;
    cin>>a>>b>>c>>k;

    if(k>a){
        if(k-a>b)
        {
            cout<< a-(k-a-b)<<endl;
        }
        else{
            cout<< a << endl;
        }

    }
    else{
        cout<< k << endl;
    }

return 0;
}


Measured memory_bytes: 3636
N = int(input())
A = list(map(int, input().split()))

dic1 = {}
dic2 = {}

sum = 0

for i in range(N):
    v = i-A[i]
    if v < 0:
        continue
    if not v in dic1:
        dic1[v] = 0
    dic1[v] += 1

for i in range(N):
    v = i+A[i]
    if not v in dic2:
        dic2[v] = 0
    dic2[v] += 1


for k, v in dic1.items():
    if not k in dic2:
        continue
    sum += dic1[k]*dic2[k]

print(sum)

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


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

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

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

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

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

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

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

using mint = modint998244353;

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

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

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

int main() {
	ll N, Q;
	cin >> N >> Q;

	vll a(N);
	rep(i, N)cin >> a[i];

	fenwick_tree<ll> fw(N);
	rep(i, N)fw.add(i, a[i]);

	rep(q, Q) {
		ll t;
		cin >> t;

		if(t==0){
			ll p, x;
			cin >> p >> x;
			fw.add(p, x);
		}
		else {
			ll l, r;
			cin >> l >> r;
			cout << fw.sum(l, r) << endl;
		}
	}
}


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

#define MAXN (110)

int n;
int s[MAXN];
bool dp[MAXN][MAXN * MAXN];

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++ i){
		scanf("%d", s + i);
	}
	dp[0][0] = true;
	for(int i = 1; i <= n; ++ i) dp[i][0] = true;
	for(int i = 1; i <= n; ++ i){
		for(int j = 0; j < MAXN * MAXN; ++ j){
			for(int ii = 0; ii < i; ++ ii){
			    if(!dp[ii][j]) continue;
			    int jj = j + s[i];
			    //if(jj % 10 == 0) jj = 0;
			    if(jj < MAXN * MAXN){
				    dp[i][jj] = true;
			    }
			}
		}
	}
	int ans = INT_MIN;
	for(int i = MAXN * MAXN - 1; i + 1; -- i){
		if(dp[n][i]){
			ans = std::max(ans, i % 10 ? i : 0);
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m,l[100005],r[100005],mi,ma;
  cin>>n>>m;
  for(int i=0; i<m; i++){
    cin>>l[i]>>r[i];
  }
  mi=l[0];
  ma=r[0];
  for(int i=1; i<m; i++){
    if(mi<l[i]){
      mi=l[i];
    }
    if(r[i]<ma){
      ma=r[i];
    }
  }

  if(ma-(mi-1)>=0){
    cout<<ma-(mi-1)<<'\n';
  }else{
    cout<<0<<'\n';
  }
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(){
  	int n;
  	int p[20];
  	int arr[3];
  	int cnt= 0;
  
  	scanf("%d\n",&n);
  
  	for(int i = 0; i < n; i++){
    	scanf("%d\n",&p[i]);
    }
  
  	for(int i = 0; i < n-2; i++){
    	for(int j = 0; j < 3; j++){
        	arr[j] = p[i + j];
        }
      	if((arr[0] < arr[1] && arr[1] < arr[2]) || (arr[0] > arr[1] && arr[1] > arr[2])){
        	cnt++;
        }
    }
  
  	printf("%d\n",cnt);
	return 0;
}

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

int main() {
  int N;
  string color;
  
  cin >> N;
  
  for (int i=0; i<N; i++) {
    cin >> color;
    if (color=="Y") {
      cout << "Four" << endl;
      break;
    }
    if (i==N-1) {
      cout << "Three" << endl;
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
char mem[214514];
char t[214514];
char c[214514];
string s[214514];
int l[214514],r[214514];
int a[214514];
int sa[214514];
signed main(){
	ic(m) ic(n)
	rep(0,i,n)cin>>a[i];
	sort(a,a+n);
	rep(0,i,n-1)sa[i]=a[i+1]-a[i];
	sort(sa,sa+n);
	reverse(sa,sa+n);
	int ans=0;
	rep(0,i,min(m-1,n))ans+=sa[i];
	c(a[n-1]-a[0]-ans)
}			
			
			

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  string op;
  cin >> A >> op >> B;
  if(op == "+"){
    cout << A + B  << endl;
  }
  if(op == "-"){
    cout << A - B << endl;
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <climits>

using namespace std;

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

    int i = 0;
    vector<char> ans(12,0);
    while (n > 0) {
        int mod = (n - 1) % 26;
        ans[i] = mod + 0x61;
        n -= mod;
        n /= 26;
        i++;
    }

    for (int j = i-1; j >= 0; j--) cout << ans[j];
    cout << endl;

    return 0;
}

Measured memory_bytes: 3600
Scanf.scanf "%d %d" (fun n k ->
    Printf.printf "%d\n" @@
        if k mod 2 = 1 then let c = n / k in c * c * c else
            let q1 = n / k in
            let q2 = (n / (k / 2) + 1) / 2 in
            q1 * q1 * q1 + q2 * q2 * q2
)

Measured memory_bytes: 3784
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using ll = long long;
using namespace std;
const ll MM = 1000000000;
const ll mod = MM + 7;
int main(){
    int x; cin >> x;
    if(x == 7|| x == 5|| x == 3){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {

        Scanner sc  = new Scanner(System.in);

        int cnt = 0;
        String str = "";


        

        int N1 = Integer.parseInt(sc.next());
        int N2 = Integer.parseInt(sc.next());
        int W1 = Integer.parseInt(sc.next());
        int W2 = Integer.parseInt(sc.next());



        System.out.print(Math.max(N1*N2,W1*W2));
        System.out.println();
    }

}

Measured memory_bytes: 10064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int h = scan.nextInt();
        int w = scan.nextInt();
        String[] str = new String[h+1];
        for(int i=0; i<h+1; i++) {
            str[i] = scan.nextLine();
        }

            for(int j=0; j<w+2; j++) {
                System.out.print("#");
            }
            System.out.println();

            for(int k=1; k<h+1; k++) {
                System.out.println("#" + str[k] + "#");
            }

            for(int j=0; j<w+2; j++) {
                System.out.print("#");
            }
        System.out.println();


    }

}


Measured memory_bytes: 22868
#include <stdio.h>

int main (int argc, char ** argv)
{
	int r,g,b;
	int k = 0;

	scanf("%d%d%d",&r,&g,&b);

	k = 100 * r + 10 * g + b;

	if (k % 4 == 0)
	{
		printf("YES\n");
	}

	else 
	{
		printf("NO\n");
	}

	return 0;


}

Measured memory_bytes: 128
import collections
N,M = map(int,input().split())
H=list(map(int,input().split()))
A=[None for _ in range(M)]
B=[None for _ in range(M)]
for i in range (M):
    A[i],B[i] = map(int,input().split())

C=[None for _ in range(N)]
for i in range(M):
    if H[A[i]-1]<H[B[i]-1]:
        C[A[i]-1]="bad"
    elif H[A[i]-1]>H[B[i]-1]:
        C[B[i]-1]="bad"
    elif H[A[i]-1]==H[B[i]-1]:
        C[A[i]-1]="bad"
        C[B[i]-1]="bad"
c = collections.Counter(C)
cook=c["bad"]
ans=N-cook
print(ans)

Measured memory_bytes: 22000
#include <iostream>
#include <map>
#include <set>
#include <string>
using namespace std;
int main() {
  char S;
  map<char,int> L;
  set<char> V;
  for(int i=0; i<4; i++){
    cin >> S;
    V.insert(S);
    L[S]++;
  }
  if(V.size()==2){
    set<char>::iterator it=V.begin();
    if(L[*it]==2 && L[*it++]==2)
      cout << "Yes";
    else  cout << "No";
  } else  cout << "No"; 
}

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

int c[10][10];

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

    for (int i = 1; i <= n; i++) {
        string s = to_string(i);
        c[s[0] - '0'][s.back() - '0']++;
    }

    ll ans = 0;
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            ans += c[i][j] * c[j][i];
        }
    }

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


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
typedef long long ll;
int main(){
	string s;
	cin >> s;
	int len = s.size();

	int num1 = 0;
	rep(i,len){
		if(i%2==0 && s[i]=='0'){
			num1 += 1;
		}
		if(i%2==1 && s[i]=='1'){
			num1 += 1;
		}
	}

	int num2 = 0;
	rep(i,len){
		if(i%2==0 && s[i]=='1'){
			num2 += 1;
		}
		if(i%2==1 && s[i]=='0'){
			num2 += 1;
		}
	}

	cout << min(num1,num2);

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 3e5 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r; 
}
int dp1[8008][8008], dp2[8008][8008];
vector<int> ud, rl;
void solve()
{
	string s;
	cin >> s;
	int cnt = 0, dr = 0, l = 0, sum1 = 0, sum2 = 0, le = 0, ri = 0, x, y, n;
	cin >> x >> y;
	n = sz(s);
	while(ri < n && s[ri] == 'F') ++ri;
	for(int j = ri + 1; j < n; ++j){
		if(s[j] == 'F') ++cnt;
		if((s[j] == 'T' || j == n - 1)) {
			if(!dr) ud.pb(cnt), sum1 += cnt;
			else rl.pb(cnt), sum2 += cnt;
			cnt = 0;
			dr ^= 1;
		}
	}
	// rep(i, sz(rl)) cout << rl[i] << " ";
	bool c1 = 0, c2 = 0;
	dp1[0][0] = 1;
	for(int i = 0; i < rl.size(); ++i){
		for(int j = 0; j <= 8000; ++j){
			if(dp1[i][j]){
				dp1[i + 1][j] = 1;
				dp1[i + 1][j + rl[i]] = 1;
			}
		}
	}
	dp2[0][0] = 1;
	for(int i = 0; i < ud.size(); ++i){
		for(int j = 0; j <= 8000; ++j){
			if(dp2[i][j]){
				dp2[i + 1][j] = 1;
				dp2[i + 1][j + ud[i]] = 1;
			}
		}
	}
	rep(i, sz(ud) + 1) rep(j, 8001) 
				if(dp2[i][j]){
					if(j + j - sum1 + le == y) c1 = 1;
					else if(-j - j + sum1 + le == y) c1 = 1;
			  }
	rep(i, sz(rl) + 1) rep(j, 8001) 
				if(dp1[i][j]){
					if(j + j - sum2 + ri == x) c2 = 1;
					else if(-j - j + sum2 + ri == x) c2 = 1;
				}
	if(c1 && c2) cout << "Yes";
	else cout << "No";

}
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    // Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

Measured memory_bytes: 38796