akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
	int n,a,b,c,d;
	string s;
	cin >> n >> a >> b >> c >> d;
	cin >> s;
	a--;
	b--;
	c--;
	d--;
	for(int i = a;i<c;i++)
	{
		if(s[i]=='#'&&s[i+1]=='#')
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	for(int j = b;j<d;j++)
	{
		if(s[j]=='#'&&s[j+1]=='#')
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	if(d<c)
	{
		bool is = true;
		for(int i = b;i<=d;i++)
		{

			if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.')
			{
				is = false;
			}
		}
		if(is)
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 640
"""A問題
x= list(map(int,input().split()))
a = 1
for i in x:
    if i == 0:
        print(a)
    a+=1
"""
"""B問題
[x,y]= list(map(int,input().split()))
if (y-2*x)%2==0 and y-2*x>=0 and 4*x-y>=0 :
    print("Yes")
else:
    print("No")
"""
[x,n]= list(map(int,input().split()))
p= list(map(int,input().split()))
q= [i for i in range(102)]
p= [i for i in q if i not in p]
r = [abs(i-x) for i in p]
print(p[r.index(min(r))])
    


Measured memory_bytes: 9136
#include <bits/stdc++.h>
//#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
//#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
//#include <string.h>
#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define LL long long
#define pii pair<int,int>
#define pb push_back
using namespace std;
const LL MOD=1e9+7;
LL ans;
int main()
{
	int n;
	cin>>n;
	vector <int> a(n);
	rep(i,n) cin>>a[i];
	int xorsum=0,right=0;
	rep(i,n)
	{
		while(right<n&&(xorsum&a[right])==0)
		{
			xorsum^=a[right];
			right++;
		}
		ans+=(right-i);
		xorsum^=a[i];
	}
	cout<<ans;
    rt0;
}

Measured memory_bytes: 1152
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e9
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

ll fact(ll n);

int main() {
	ll n, m;
	cin >> n >> m;

	if (abs(n - m) >= 2) {
		cout << 0 << endl;
	} else if (abs(n - m) == 0) {
		cout << fact(n)*fact(m) * 2 % NUM << endl;
	} else {
		cout << fact(n)*fact(m) % NUM << endl;
	}
}

ll fact(ll n) {
	if (n == 0) {
		return 1;
	} else {
		return (n%NUM * fact(n - 1)%NUM);
	}
}





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

int main()
{
	ll n,d,i,j,b;
	cin>>d>>n;
	b = 100;
	ll extras = n/b;
	n += extras;
	cout<<fixed<<setprecision(0)<<n*pow(b,d);
	return 0;
}

Measured memory_bytes: 256
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
s = [0]*n
c = 0
for i in range(n):
    s[i]+=a[i]
    x=x-a[i]
    if x<0:
        break
    if s[i] == a[i]:
        c+=1

if x>0:
    c-=1
print(c)

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

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

    if(A+B > C+D){
        cout << "Left" << endl;
    }
    
    if(A+B < C+D){
        cout << "Right" << endl;
    }

    if(A+B == C+D){
        cout << "Balanced"<< endl;
    }
}

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

using Int = int;
using namespace std;

#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; };
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; };
template<class T> T th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

int main(){
	std::string s, t;
	std::cin >> s >> t;
	std::cout << t << s << std::endl;
}


Measured memory_bytes: 256
N,W = [int(i) for i in input().split()]
data = [[int(i) for i in input().split()] for j in range(N)]


DP= [[0 for i in range(W+1)] for j in range(N+1)]

for i in range(N):
    for j in range(W+1):
        if j >= data[i][1]:
            DP[i+1][j] = (max(DP[i][j-data[i][1]]+data[i][0],DP[i][j]))
        else:
            DP[i+1][j] = DP[i][j]
            
print(DP[-1][-1])



Measured memory_bytes: 42468
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int a[m],b[m];
  vector<int> v[n+1];
  set<int> se;
  for(int i=0;i<m;i++){
    cin>>a[i]>>b[i];
    v[a[i]].push_back(b[i]);
    se.insert(a[i]);
  }
  for(auto au:se){
    sort(v[au].begin(),v[au].end());
  }
  for(int i=0;i<m;i++){
    cout<<setfill('0')<<right<<setw(6)<<a[i];
    cout<<setfill('0')<<right<<setw(6)<<lower_bound(v[a[i]].begin(),v[a[i]].end(),b[i])-v[a[i]].begin()+1<<endl;
  }
}

Measured memory_bytes: 12416
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll>Q;



int main(void){
    int k;
    int a,b;
    cin>>k>>a>>b;
    int ans =k;
    while(true){
      if(ans>=a){
        if(ans<=b){
          cout<<"OK"<<endl;
          return 0;
        }
      }
      if(ans>b){
        cout<<"NG"<<endl;
        return 0;
      }
      ans+=k;
    }
    return 0;
}

Measured memory_bytes: 3596
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();
    let c: i32 = iter.next().unwrap().parse().unwrap();
    println!("{}", std::cmp::min(b / a, c));
}


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

int main(void){
    int a[5];
    int flag;
    rep(i,5){
        cin >> a[i];
        if(a[i]==0){
            flag = i;
        }
    }

    cout << flag + 1 << endl;
}

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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

const int INF = 1e9;
const ll LINF = 1e18;


int main() {
    bool rev = false;

    string sf = "";

    string s;
    cin >> s;

    int n;
    cin >> n;

    rep(i, n) {
        int t;
        cin >> t;

        if (t == 1) {
            rev = !rev;
        } else {
            int f;
            char c;
            cin >> f >> c;

            if (f == 1) {
                if (rev)
                    s.push_back(c);
                else
                    sf.push_back(c);
            } else {
                if (rev)
                    sf.push_back(c);
                else
                    s.push_back(c);
            }
        }
    }

    if (rev) {
        rrep(i, s.length())
            cout << s[i];
        cout << sf << endl;
    } else {
        rrep(i, sf.length())
            cout << sf[i];
        cout << s << endl;
    }

    return 0;
}


Measured memory_bytes: 1088
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	int N = 0, K = 0;
	string S;
	char a;
	cin >> N>>S >> K;
	a = S[K-1];
	for (int i = 0; i < N; i++)
	{
		if (S[i] != a)
		{
			S[i] = '*';
		}
	}
	cout << S;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main(void){
  int A,B,C;
  scanf("%d %d %d\n",&A,&B,&C );
  if((A == B)&& (B != C)){
    printf("Yes");
    exit(0);
  }
  if((B == C)&& (B != A)){
    printf("Yes");
    exit(0);
  }
  if((A == C)&& (B != A)){
    printf("Yes");
    exit(0);
  }
  printf("No" );
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        // long startTime = System.currentTimeMillis();

        Scanner scanner = new Scanner(System.in);

        int d = scanner.nextInt();
        int n = scanner.nextInt();

        scanner.close();

        long base = (long) Math.pow(100, d);

        int count = 0;

        int t = 0;

        while (count < n) {
            t++;
            if (t % 100 != 0) {
                count++;
            }
        }

        System.out.println(t * base);

        // System.out.println(System.currentTimeMillis() - startTime);
    }
}

Measured memory_bytes: 23124
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		String[] s = br.readLine().split("\\s+");
		
		int[] arr = new int[n];
		long sum = 0;
		for(int i=0;i<n;i++)
		{
			arr[i] = Integer.parseInt(s[i]);
			sum += arr[i];
		}
		sum = Math.round((double)sum/n);
		long res = 0;
		for(int i=0;i<n;i++)
		{
			res += (long)Math.pow((arr[i]-sum),2);
		}
		System.out.println(res);
	}
}


Measured memory_bytes: 33948
n,k=map(int,input().split())
s=input()
t=s[0]
c=[-1,1][s[0]=="R"]
d=[]

for i in range(1,n):
    if t!=s[i]:
        d.append(c)
        c=0
    t=s[i]
    c+=[-1,1][s[i]=="R"]
d.append(c)
c=len(d)
for i in range(k):
    if i*2+1>=c: break
    d[i*2+1]*=-1
chk=0
ans=0
for i in d:
    if (i>0 and chk>0) or (i<0 and chk<0):
        chk+=i
    else:
        if chk!=0: ans+=abs(chk)-1
        chk=i

print(ans+(abs(chk)-1))

Measured memory_bytes: 45552
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
	vector<int> A;
	vector<int> dp;
	
	cin>>N;
	
	A.resize(N);
	dp.resize(N+1);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
	}
	
	dp[0] = 1000;
	
	for(int i = 0; i < N; i++){
		int maximum = dp[i];
		
		for(int j = 0; j < i; j++){
			maximum = max(maximum, dp[j]/A[j] * A[i] + dp[j] % A[j]);
		}
		
		dp[i+1] = maximum;
	}
	
	cout<<dp[N]<<endl;
	
	return 0;
}

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

vector<pair<long long,long long>> p;

int main() {
    int N;
    cin >> N;
    rep(i,N){
        long long x,l;
        cin >> x >> l;
        p.emplace_back(make_pair(x+l,x-l));
    }
    sort(p.begin(),p.end());
    long long t = LONG_LONG_MIN;
    long long count = 0;
    rep(i,N){
        if(t <= p[i].second){
            count++;
            t = p[i].first;
        }
    }
    cout << count << endl;

    return 0;
}

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

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

    int n, m, wans = 0, ans = 0;
    cin >> n >> m;
    vector<int> p(m), ac(n, 0), wa(n, 0);
    vector<string> s(m);
    rep(i, m)
    {
        cin >> p.at(i) >> s.at(i);
        if (ac.at(p.at(i) - 1) == 0)
        {
            if (s.at(i) == "WA")
            {
                wans++;
                wa.at(p.at(i) - 1)++;
            }
            if (s.at(i) == "AC")
            {
                ans++;
                ac.at(p.at(i) - 1)++;
            }
        }
    }
    rep(i, n)
    {
        if (ac.at(i) == 0)
        {
            wans -= wa.at(i);
        }
    }
    cout << ans << ' ' << wans << endl;

    return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector <ll>
#define vii vector <int>
#define vpii vector <pii>
#define vpll vector <pll>
#define ff first
#define ss second
#define matrix vector <vll>
#define all(v) v.begin(),v.end()
#define PQ priority_queue
using namespace std;
ll pow(ll a, ll b){
	ll res = 1;
	while(b > 0){
		if(b&1) res*=a;
		b/=2;
		a*=a;
	}
	return res;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int arr[n+1];
	for(int i = 1; i  <= n; i++) cin >> arr[i];
	int b[n+1] = {0};
	for(int i = n/2+1; i <= n; i++){
		b[i] = arr[i];
	}
	for(int i = n/2; i > 0; i--){
		int sum = 0;
		for(int j = i; j <= n; j+=i){
			sum+=b[j];
		}
		if((sum%2) != arr[i]) b[i]++;
	}
	int m = 0;
	for(int i = 1; i <= n; i++){
		m+=b[i]; 
	}
	cout << m << "\n";
	for(int i = 1; i <= n; i++){
		if(b[i]) cout << i << " ";
	}
	return 0;
}


Measured memory_bytes: 2560
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

s = input()
print(s.count("o")*100+700)




Measured memory_bytes: 8944
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define PI acos(-1.0)
#define INF 1000000000
#define pow10 tipa_pow10
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;
int q , a , b;
ll score;
bool good(int x)
{
    int m = x / 2 + x % 2;
    for(int idx =  max(1 , m - 1000); idx <= min(x , m + 1000); idx++)
    {
        ll l = idx;
        if(l >= a)
        {
            l++;
        }
        ll r = x - idx + 1;
        if(l <= 0 || r <= 0)
            continue;
        if(r >= b)
            r++;
        if(l * r >= score)
            return false;

    }
    return true;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin >> q;
    while(q--)
    {
        cin >> a >> b;
        score = (ll)a * b;
        int ans =  0;
        for(int i = 30; i >= 0; i--)
        {
            if(good(ans + (1 << i)))
                ans += (1 << i);
        }
        cout << ans << endl;
    }


}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
char T[30]="XYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
main(){
string S;cin>>S;
for(int i=0;i<S.size();i++){for(int j=3;j<29;j++){if(S[i]==T[j]){cout<<T[j-3];}}}
cout<<endl;}

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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  int N;
  cin >> N;

  vector<int> v(N);
  vector<int> ans(N);
  vector<int> ret;

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

  for(int i = N-1; i >= 0; i--){
    int num = i + 1;

    int sum = 0;
    for(int j = 2; num * j <= N; j++){
      sum += ans[num*j-1];
    }
    if(v[i] == (sum % 2)){
      ans[i] = 0;
    } else { 
      ans[i] = 1;
      ret.push_back(num);
    }
  }
  if(ret.size() == 0){
    cout << 0 << endl;
  } else { 
    cout << ret.size() << endl;
    for(int i = 0; i < ret.size(); i++){
      if(i == ret.size() - 1){
        cout << ret[i] << endl;
      } else { 
        cout << ret[i] << " ";
      }
    }
  }
}


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

namespace dpsheet
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[,] arr = new int[n+1,4];
            int[,] temp = new int[n + 1, 4];
            for (int i = 0; i < n; i++) {
              string[] st1 = Console.ReadLine().Split(' ');
                for (int j=0;j<3;j++)
                {
                    arr[i,j] = int.Parse(st1[j]);
                }
            }
            for (int i = 0; i < n; i++)
                for(int j=0;j<3;j++)
                 temp[i,j] = -1;
            int max1=Vacation(arr, 0, n,0,temp);
            int max2 = Vacation(arr, 0, n, 1,temp);
            int max3 = Vacation(arr, 0, n, 2,temp);
            int max = Math.Max(max1, max2);
            max = Math.Max(max3, max);
            Console.WriteLine(max);


        }
        static int Vacation(int[,] arr, int i, int n,int j,int[,] temp)
        {
            if (temp[i, j] != -1)
                return temp[i, j];
            if (i == n)
                return temp[i,j]=0;
                int max1 = 0;
                int max2 = 0;
                int max3 = 0;
                if(j==0)
                {
                    max1 = Math.Max(arr[i,j] + Vacation(arr, i + 1, n, 1,temp), arr[i,j] + Vacation(arr, i + 1, n, 2,temp));
                }
                if(j ==1)
                {
                    max2 = Math.Max(arr[i,j] + Vacation(arr, i + 1, n, 0,temp), arr[i,j] + Vacation(arr, i + 1, n, 2,temp));
                }
                if (j ==2)
                {
                    max3 = Math.Max(arr[i,j] + Vacation(arr, i + 1, n, 0,temp), arr[i,j] + Vacation(arr, i + 1, n, 1,temp));
                }
                int max = Math.Max(max1, max2);
                return temp[i,j]=Math.Max(max, max3);

           
        }
    }
}


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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  bool Awin = true;
  while (true) {
    C -= B;
    if (C <= 0 ) {
      Awin = true;
      break;
    }
    A -= D;
    if (A <= 0 ) {
      Awin = false;
      break;
    }
  }
  if (Awin) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<math.h>
#define int long long
int min(int a,int b)
{
	if(a<b)
		return a;
	return b;
}
int main()
{ 
	int n;
	scanf("%lld",&n);
	int l=n+1;
	int h[l];
	int dp[l];
	for(int i=1;i<=n;i++)
	{scanf("%lld",&h[i]);}
	dp[1]=0;
	dp[2]=fabs(h[2]-h[1]);
	for(int i=3;i<=n;i++)
	{
		dp[i]=min((fabs(h[i]-h[i-1])+dp[i-1]),(fabs(h[i]-h[i-2])+dp[i-2]));
	}
	printf("%lld",dp[n]);
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <queue>
#define min(x,y) ((x)<(y)?(x):(y))
#define INFI 100000000

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

int Strength = 1;
char Maps[1010][1010];
int dist[1010][1010];
int H, W, N;
int hor[] = {1,0,-1,0};
int ver[] = {0,-1,0,1};
int ans;


void clear();
void show();
P bfs(int cheese,P n);

int main(void) {
    cin>>H>>W>>N;
    P s,e;
    for (int i = 0; i<H; i++)
        cin>>Maps[i];
    for (int i = 0; i<H; i++)
        for (int j = 0; j<W; j++)
            if (Maps[i][j]=='S') s.first = i, s.second = j;
    
    
    for (int i = 1; i<=N; i++) {
        clear();
        s = bfs(i, s);
    }
    
    cout<<ans<<endl;
    return 0;
}

P bfs(int cheese,P n) {
    queue<P> que;
    que.push(n);
    dist[n.first][n.second] = 0;
    
    P top;
    while (que.size()) {
        top = que.front();
        if (Maps[top.first][top.second]-'0'==cheese) {
            ans += dist[top.first][top.second];
            break;
        }
        
        que.pop();
        for (int i = 0; i<4; i++) {
            int nv = top.first+ver[i], nh = top.second+hor[i];
            if (nv>=0 && nv<H && nh>=0 && nh<W && dist[nv][nh]==INFI && Maps[nv][nh]!='X') {
                que.push(P(nv,nh));
                dist[nv][nh] = min(dist[nv][nh], dist[top.first][top.second]+1);
            }
        }
    }
    return top;
}

void clear() {
    for (int i = 0; i<H; i++)
        for (int j = 0; j<W; j++)
            dist[i][j] = INFI;
}

Measured memory_bytes: 6192
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.List (unfoldr)
import qualified Data.ByteString.Char8 as BS

main = do
  [n,a,b] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let sumDigits a = loop 0 a
        where loop !acc 0 = acc
              loop !acc a = case a `quotRem` 10 of
                              (q,r) -> loop (acc + r) q
  print $ sum [x | x <- [1..n], let s = sumDigits x, a <= s && s <= b]


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

namespace AtCoder.Abc
{
    // https://atcoder.jp/contests/abc172/tasks/abc172_b
    class A_αlphabet_171
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string s = Console.ReadLine();

            string result = "";

            if ( Regex.IsMatch(s ,"[a-z]") == true )
            {
                result = "a";
            }

            else
            {
                result = "A";
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 26792
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
const long long inf=1e18L;
int main(int argc, char const *argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    int n,w;
    cin>>n>>w;
    vector<int>weight(n),value(n);
    for(int i=0;i<n;i++) {
        cin>>weight[i]>>value[i];
    }
    long long max_profit=accumulate(value.begin(),value.end(),0);
    vector<vector<long long>>dp(2,vector<long long>(max_profit+1,inf));
    dp[0][0]=0;
    int cur=0;
    for(int i=1;i<=n;i++) {
        int val=value[i-1];
        int wt=weight[i-1];
        cur^=1;
        for(int j=0;j<=max_profit;j++) {
            if(j<val) {
                dp[cur][j]=dp[cur^1][j];
            }
            else {
                dp[cur][j]=min(dp[cur^1][j],dp[cur^1][j-val]+wt);
            }
        }
    }
    long long ans=0;
    for(long long val=0;val<=max_profit;val++) {
        if(dp[n&1][val]<=w) {
            ans=max(ans,val);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include<cstdio>
using namespace std;
int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
	int n;
	scanf("%d",&n);
	n--;
	printf("%d\n",a[n]);
	return 0;
 } 

Measured memory_bytes: 128
x=int(input())
c=0
if x%2==1:
    print(0)
else:    
    s=0
    l=1
    j=10
    while j<=x:
        s+=(x//j)
        #s+=(x//p)//2
        j*=5
        
    print(s)    
    #print(s+(x//50)//2)

Measured memory_bytes: 38384
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>

using namespace std;

typedef pair<string,int> P;
map<string,int> M;
vector<P> V;

bool comp(const P p1, const P p2){
  if(p1.first.length() != p2.first.length())return p1.first.length()<p2.first.length();
  return p1.first == min(p1.first,p2.first);
}

int main(){
  int n;
  cin >> n;
  while(n--){
    string s;
    int a;
    cin >> s >> a;
    M[s] += a;
  }

  map<string,int>::iterator ite;

  for(ite = M.begin(); ite != M.end(); ite++){
    V.push_back(P(ite->first,ite->second));
  }
  
  sort(V.begin(),V.end(),comp);
  
  for(int i = 0; i < V.size(); i++)
    cout << V[i].first << " " << V[i].second << endl;
  return 0;
}

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

int main(){
    int n, t;
    cin >> n >> t;
    vector<pair<int, int>> dish(n);
    for (int i = 0; i < n; i++) cin >> dish[i].first >> dish[i].second;
    //dp[i][j][k] -> i個目まで見た時、コストj以下で達成できる価値の最大値(おまけあり、なしをkで表す)
    vector<vector<int>> dp(t, vector<int>(2, 0));
    for (int i = 0; i < n; i++){
        vector<vector<int>> next_dp = dp;
        for (int k = 0; k < 2; k++){
            if (dish[i].first < t) next_dp[dish[i].first][k] = max(next_dp[dish[i].first][k], dish[i].second);
            for (int j = 0; j < t; j++){
                next_dp[j][k] = max(next_dp[j][k], dp[j][k]);
                if (j + dish[i].first < t) next_dp[j + dish[i].first][k] = max(next_dp[j + dish[i].first][k], dp[j][k] + dish[i].second);
                if (j != t - 1) next_dp[j + 1][k] = max(next_dp[j][k], next_dp[j + 1][k]);
            }
        }
        //おまけの辺は、i - 1個まで見た時の値に、おまけするという遷移でいける
        for (int j = 0; j < t; j++) next_dp[j][1] = max(next_dp[j][1], dp[j][0] + dish[i].second);
        dp = next_dp;
    }
    cout << max(dp[t - 1][0], dp[t - 1][1]) << endl;
}

Measured memory_bytes: 652
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

bool dfs(int X, int Y) {
  if (X >= 0 && Y == 0) {
    return true;
  }

  if (X < 0) {
    return false;
  }

  // C
  if (dfs(X - 1, Y - 2)) {
    return true;
  } 
  // T

  if (dfs(X - 1, Y - 4)) {
    return true;
  }

  return false;
}

int main() {
  int X, Y;
  cin >> X >> Y;

  if ((Y % 2) != 0) {
    cout << "No" << endl;
    return 0;
  }

  int T = Y / 4;
  int c = Y % 4;
  
  int C = c / 2;
  int r = c % 2;

  if (r != 0) {
     cout << "No" << endl;
     return 0;
  }

  if ((T + C) <= X) {
    int diff = X - (T + C);
    while (diff > 0 && T > 0 && C < X) {
      T--;
      C += 2;
      diff--;
    }
    if (diff == 0 && (T + C) <= X) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
    return 0;
  }
  
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<cstdio>
#include<string>
#include<set>

using namespace std;

int n;
int num[5];
int card[11];
set<string> ans;

void serch(int m,int k,int now)
{
	
	for(int i=0;i<m;i++)
	{
		for(int j=i+1;j<m;j++)
		{
			if(num[i]==num[j])
			{
				return;
			}
		}
	}
	
	if(m==k)
	{
		string str;
		char  ch[8];
		for(int i=0;i<m;i++)
		{
			sprintf(ch,"%d",card[num[i]]);
			str+=string(ch);
		}
		ans.insert(str);
		return ;
	}
	
	num[m]=now;
	
	for(int i=0;i<n;i++)
	{
		serch(m+1,k,i);
	}
	
	return ;
}

int main()
{
	int k;
	int i,j;
	
	for(;;)
	{
		cin >> n >> k;
		if(n==0 && k==0)
			break;
		
		ans.clear();
		
		for(i=0;i<n;i++)
			cin >> card[i] ;
		
		for(i=0;i<n;i++)
		{
			serch(0,k,i);
		}
		
		set<string>::iterator it = ans.begin();
		
/*
		for(;it!=ans.end();++it)
		{
			cout << "ans:" << *it << endl;
		}
*/
		
		cout << ans.size() << endl;
	}
	
}

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

using namespace std;



int main(){
long long int H,ans=0,i=0,A,B,C,cnt=0;

cin >> A>>B>>C;

if (A==B)
{
  cnt++;
}
if (C==B)
{
  cnt++;
}
if (A==C)
{
  cnt++;
}
if (cnt==1)
{
  cout <<"Yes";
}
else cout << "No";
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#define MAX 100005
using namespace std;

typedef struct pp{
    char name[100];
    int time;
}Task;

Task Q[MAX];
int head, tail,n;

void enqueue(Task x){
    Q[tail] = x;
    tail = (tail+1) % MAX;
}
Task dequeue(){
    Task x = Q[head];
    head = (head+1)% MAX;
    return x;
}

int min (int a, int b){
    return a < b ? a:b; 
}
int main(){
   int n,q; 
   int elaps  = 0;
   int c;
   
   Task x;
   scanf("%d %d",&n,&q);
   for(int i=0;i<n;i++){
       scanf("%s",Q[i].name);
       scanf("%d",&Q[i].time);
   }
   head = 0;
   tail = n;
   while(head != tail){
      x =dequeue();
      c = min(x.time,q);
      elaps += c;
      x.time -= c;
      if(x.time > 0){
          enqueue(x);
      }else
      {
          printf("%s %d\n",x.name,elaps);
      }
   }
   return 0;
}



Measured memory_bytes: 13352
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
int INF = 1e9+7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
unsigned day;
if(dow < dow1) dow += 7;
day = dow - dow1;
day += 7 * n - 6;
return day;
}
unsigned DayToWeekNumber(unsigned day)
{
  return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main(){
  int H,N; cin>>H>>N;
  int A[N];
  int ans=0;
  rep(i,N){
    cin>>A[i];
    ans+=A[i];
  }
  cout<<(ans<H? "No":"Yes")<<endl;
}

Measured memory_bytes: 3944
N,M = map(int,input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
def ic(x,y):
    for j in range(0,M):
        if B[j] != A[j+y][x:x+M]:return False
    else:return True
def sc():
    for j in range(0,N-M+1):
        for i in range(0,N-M+1):
            if ic(i,j):return True
    else:return False
print('Yes' if sc() else 'No')

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

ll factrial(ll n){
    if(n == 0) return 1;
    ll p = factrial(n-1)*n%MOD;
    return p;
}

//MOD逆元
ll farmat(ll n,ll p){    
    if(p == 0) return 1;
    else if(p == 1) return n%MOD;
    ll d = farmat(n,p/2);
    if(p%2 == 0){
        return (d*d)%MOD;
    }else{
        return ((n*d)%MOD*d)%MOD;
    }
}

ll conbination(ll n,ll k){
    ll a = factrial(n);
    ll b = factrial(k);
    ll c = factrial(n-k);
    return (a*farmat(b,MOD-2)%MOD*farmat(c,MOD-2))%MOD;
}

int n;
int memo[10000000];

int fib(int i){
    if(i <= 1) return i;
    if(memo[i] != 0) return memo[i];
    return memo[i] = fib(i-1)+fib(i-2);
}

ll dig(ll n){
    ll d = 0;
    while(n != 0){
        n/=10;
        d++;
    }
    return d;
}
map<char,int> a;
void solve() {
    string s;
    string a,b,c;
    b = "Cloudy";
    a = "Sunny";
    c = "Rainy";
    cin >> s;
    if(s == a){
        cout << b << endl;
    }else if(s == b){
        cout << c << endl;
    }else{
        cout << a << endl;
    }
}


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}



Measured memory_bytes: 256
#include<bits//stdc++.h>
using namespace std;
int main() {
	double n=0.5,m=6,n2=30;
	int a,b,n4,e=0;
	cin>>n4;
	for(int i=0;i<n4;i++){
		string d;
		cin>>d;
		d+=":";
		string h;
		e=0;
		for(int j=0;j<d.length();j++){
			if(d[j]==':'){
				if(e==0)
					a=atoi(h.c_str());
				else
					b=atoi(h.c_str());
				h="";
				e++;
			}
			else
				h+=d[j];
		}
		double n3,m3;
		n3=0;
		n3+=(a*n2+b*n);
		m3=0;
		m3+=b*m;
		double c=n3-m3;
		if(c<0)
			c=0-c;
		if(360-c<c){
			c=360-c;
		}
		if(c>=90&&c<=180)
			printf("safe\n");
		else if(c>=0&&c<30)
			printf("alert\n");
		else
			printf("warning\n");
	}
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  string s, t;
  cin >> s >> t;

  if (s == t) {
    cout << "Yes" << '\n';
    return 0;
  }

  bool ans = false;
  for (int i = 0; i < s.size(); ++i) {
    char last_ch = s.back();
    s = last_ch + s.substr(0, s.size() - 1);
    if (s == t) {
      ans = true;
      break;
    }
  }

  cout << (ans ? "Yes" : "No") << '\n';
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final List<Integer> list = IntStream.rangeClosed(0, n)
            .mapToObj(i -> scanner.nextInt())
            .collect(Collectors.toList());

        if (n == 0) {
            if (list.get(0) == 1) {
                System.out.println(1);
            } else {
                System.out.println(-1);
            }
            return;
        }

        if (list.get(0) != 0) {
            System.out.println(-1);
            return;
        }

        final long[] nodes = new long[n + 1];
        nodes[0] = 1;
        for (int depth = 1; depth <= n; depth++) {
            final int leaves = list.get(depth);

            if (leaves > nodes[depth - 1] * 2) {
                System.out.println(-1);
                return;
            }

            nodes[depth] = Math.min(nodes[depth - 1] * 2 - leaves, Long.MAX_VALUE / 2);
        }

        long all = 0;
        long rests = 0;
        for (int depth = n; depth > 0; depth--) {
            final int leaves = list.get(depth);
            all += leaves + rests;
            rests = Math.min(nodes[depth - 1], rests + leaves);
        }

        System.out.println(++all);
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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


Measured memory_bytes: 49188
/*
ID: zhaowei10
TASK:
LANG: C++
*/
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define pb push_back
#define MOD 1000000007
#define NDIG(x) floor(log10(x)) + 1
#define FOR(i, j, k, l) for (s32 i = j; i < k; i += l)
#define RFOR(i, j, k, l) for (s32 i = j; i >= k; i -= l)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(x) x.begin(), x.end()
#define MEAN(a, b) min(a, b) + (abs(b - a) >> 1)
#define FASTIO()    \
  cin.tie(nullptr); \
  ios::sync_with_stdio(false);

typedef long long ll;
typedef int64_t s64;
typedef uint64_t u64;
typedef int32_t s32;
typedef uint32_t u32;
typedef float f32;
typedef double f64;
typedef pair<s32, s32> II;
typedef pair<s64, s64> LL;
typedef vector<s32> VI;
typedef vector<II> VII;
typedef vector<char> VC;
typedef vector<VII> VVII;
typedef priority_queue<s32> PQI;
typedef priority_queue<s32, VI, greater<s32>> PQIA;
typedef priority_queue<s64> PQL;
typedef priority_queue<II> PQII;
typedef priority_queue<II, VII, greater<II>> PQIIA;
typedef priority_queue<LL> PQLL;
typedef unordered_set<s32> USI;
typedef unordered_set<s64> USL;
typedef set<II> SII;
typedef multiset<s32> MSI;

template <typename T, typename U>
inline void amin(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
inline void amax(T &x, U y) {
  if (x < y) x = y;
}

template <typename T>
inline s32 ndigits(T x, T b) {
  s32 r = 0;
  while (x) {
    x /= b;
    ++r;
  }
  return r;
}

int main() {
  FASTIO();

  int m, n;
  cin >> n >> m;
  cout << (n == m ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define int long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	const int N=2e5+5;
	int dp[N];

	int32_t main()
	{
		std::ios::sync_with_stdio(false);
		int n;
		cin>>n;
		int a[n+1];
		a[0]=0;
		for(int i=0;i<n;i++)
			cin>>a[i];
		
		dp[0]=0;
		dp[1]=abs(a[1]-a[0]);
		for(int i=2;i<n;i++)
		{
			dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
		}
		cout<<dp[n-1]<<endl;
		return 0;
	}


Measured memory_bytes: 1792
aa=[list(map(int,input().split())) for _ in range(3)]

count=[0,0,0,0]
for i in range(1,5):
    for a in aa:
        count[i-1] += a.count(i)
print('YES' if count.count(0)==0 and count.count(3)==0 else 'NO')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long long n,m;
long long w[110],v[110];
long long f[100010];
long long value;
int main()
{
	memset(f,0x3f,sizeof(f));
	scanf("%lld%lld",&n,&m);
	for(long long i=1;i<=n;i++)
	{
		scanf("%lld%lld",&w[i],&v[i]);
		value+=v[i];
	}
	f[0]=0;
	for(long long i=1;i<=n;i++)
	{
		for(long long j=value;j>=v[i];j--)
		{
			f[j]=min(f[j],f[j-v[i]]+w[i]);
		}
	}
	for(long long i=value;i>=1;i--)
	{
		if(f[i]<=m)
		{
			printf("%lld",i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    if(a.S==b.S)
        return a.F>b.F;

       return (a.S > b.S);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;

   cin>>n;

   ll ara[n+2];

   input(ara,n);

   for(i=0; i<n; ++i)
   {
       cin>>a;

        ara[i]-=a;

        ans+=max(0ll,ara[i]);
   }

   cout<<ans<<endl;



}



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

int main() {
  int n;
  cin >> n;
  int a[2][n];
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }
  vector<int> b(n + 2, 0), c(n + 2, 0);
  // b[0] = 0;
  // c[n + 1] = 0;
  for (int i = 1; i <= n; i++) {
    b[i] = b[i - 1] + a[0][i - 1];
  }
  for (int i = n; i >= 1; i--) {
    c[i] = c[i + 1] + a[1][i - 1];
  }
  int ans = 0, tmp;
  for (int i = 1; i <= n; i++) {
    tmp = b[i] + c[i];
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  // for (int i = 1; i <= n; i++) {
  //   cout << b[i] << " " << c[i] << endl;
  // }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;

int main()
{
    int n; cin >> n;
    while(n != 0){
        int sum = 0;
        for(int i = 1; i < n / 2 + 2; i++){
            sum += i;
            if(sum >= n){
                cout << i << endl;
                n -= i;
                break;
            }
        }
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#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>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define MOD 1000000007 //10^9+7
#define INF 1000000000 //10^9

int main (int argc, const char * argv[])
{
    vector<int> m;
    int n;
    for (int i=0; i<10; i++) {
        cin>>n;
        m.push_back(n);
    }
    sort(m.begin(), m.end(),greater<int>() );
    for (int i=0; i<3; i++) {
        cout<<m[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    ll a,b,c;
    cin>>a;
    ll sum=0;
    for(ll i=1;i<=a;i++){
        for(ll j=1;j<=a;j++){
            for(ll k=1;k<=a;k++){
                ll r=__gcd(i,j);
                ll r1=__gcd(r,k);
                sum+=r1;
            }
        }
    }
    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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 long long INF = 1LL << 60;

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

  int sum = 0;
  rep(i, m){
    int a; cin >> a;
    sum += a;
  }

  if(n - sum < 0){
    cout << -1 << endl;
    return 0;
  }

  cout << n - sum << endl;

  return 0;
}


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

#define int 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; }

signed main(){
	string s;
	cin >> s;
	if(s.back() == 's'){
		cout << s << "es" << endl;
	}else{
		cout << s << "s" << endl;
	}
	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
 int main(){
     int N;
     string S;
     int K;
     cin >> N >> S >> K;

     char T = S[K-1];

     for(int i=0;i<S.size();i++){
         if(S[i] != T) S[i] = '*';
     }

     cout << S << endl;

     return 0;
 }

Measured memory_bytes: 256
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
const int N = pow(10,7)+1;

vector<bool> isp(N+1, true);

void sieve() {
  isp[0] = false;
  isp[1] = false;
  for (int i=2; pow(i,2)<=N; i++) {
    if (isp[i]) for(int j=2; i*j<=N; j++) isp[i*j] = false;
  }
}//N以下の整数をふるってくれます
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll n;
    cin>>n;
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    sieve();
    V prime;
    rep(i,isp.size()+1){
        if(isp[i]){
            prime.push_back(i);
        }
    }
    ll res=0;
   // cout<<n<<endl;
    for(auto i:prime){
        ll cnt=0;
        while(n%i==0){
            n/=i;
            cnt++;
        }
        int index=0;
        while(1){
            index++;
            cnt-=index;
            if(cnt<0){
                break;
            }
            //cout<<i<<" "<<index<<endl;
            res++;
        }
    }
    if(n!=1){
        res++;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 12840