akhauriyash/Code-Regression huggingface dataset:
import sys
from collections import deque
import itertools

def input(): return sys.stdin.readline().strip()

icase=0
if icase==0:
    h,w=map(int,input().split())
    ch,cw=map(int,input().split())
    ch-=1
    cw-=1
    dh,dw=map(int,input().split())
    dh-=1
    dw-=1
    s=[[] for i in range(h)]
    for i in range(h):
        s[i]=input()
        
ij=[(1,0),(-1,0),(0,1),(0,-1)]
wpij=[(1,1),(-1,-1),(-1,1),(1,-1),
      (2,-2),(2,-1),(2,0),(2,1),(2,2),
      (-2,-2),(-2,-1),(-2,0),(-2,1),(-2,2),
      (1,2),(0,2),(-1,2),(1,-2),(0,-2),(-1,-2)]

hh=[i for i in range(h)]
ww=[i for i in range(w)]

g=[[[] for i in range(w)] for i in range(h)]
gg=[[[] for i in range(w)] for i in range(h)]
wpg2=[[0]*w for i in range(h)]
wpg=[]

hhww=[(i,j) for i,j in itertools.product(hh,ww) if s[i][j]=="."]
                
for i,j in hhww:
    g[i][j]=[(i+ii,j+jj) for ii,jj in ij if (0<=(i+ii)<h and 0<=(j+jj)<w and s[i+ii][j+jj]==".")] 
    if i+1<h and s[i+1][j]=="#": wpg2[i][j]=1
    elif 0<=i-1 and s[i-1][j]=="#": wpg2[i][j]=1
    elif j+1<w and s[i][j+1]=="#": wpg2[i][j]=1
    elif 0<=j-1 and s[i][j-1]=="#": wpg2[i][j]=1

for i,j in hhww:
    if wpg2[i][j]>=1:
        wpg.append((i,j))
                
for i,j in wpg:
    for ii,jj in wpij:
         if 0<=i+ii and i+ii<h and 0<=j+jj \
            and j+jj<w and s[i+ii][j+jj]==".":
                gg[i][j].append((i+ii,j+jj))        

q=deque([(ch,cw)])
qq=deque()
parent=[[-1]*w for i in range(h)]
parent[ch][cw]=0
dist=[[-1]*w for i in range(h)]
dist[ch][cw]=0
while True:
    while q:
#        print("q1:",q)
        hi,wi = q.popleft()
        if len(gg[hi][wi])>0:
            qq.append((hi,wi))
        for hj,wj in g[hi][wi]:
            if parent[hj][wj] !=-1:
                continue
            else:
                parent[hj][wj]=(hi,wi)
                dist[hj][wj]=dist[hi][wi]+1
                q.append((hj,wj))
                if hj==dh and wj==dw:
                    print(dist[dh][dw]//(10**7))   
                    sys.exit()

    while qq:
        hi,wi = qq.popleft()
        for hj,wj in gg[hi][wi]:
            if parent[hj][wj]!=-1:
                continue
            parent[hj][wj]=(hi,wi)
            dist[hj][wj]=dist[hi][wi]+10**7
            q.append((hj,wj))
            if hj==dh and wj==dw:
                print(dist[dh][dw]//(10**7))   
                sys.exit()

    if len(q)==0:
        break
print(-1)   


Measured memory_bytes: 476404
def main():
    import sys
    input=sys.stdin.readline
    L,R=map(int,input().split())

    if R-L>=2019:
        print(0)
    else:
        flag=False
        min_number=2019
        for i in range(L,R+1):
            for j in range(i+1,R+1):
                min_number=min(min_number,((i%2019)*(j%2019))%2019)
                if min_number==0:
                    print(0)
                    flag=True
                    break
            if flag:
                break
        if flag==False:
            print(min_number)
if __name__=="__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <string>

using namespace std;

int main()	{
  int h, w;
  cin >> h >> w;
  char field[h][w];
  for (int i = 0; i < h; i++)	{
	for (int j = 0; j < w; j++)	{
      cin >> field[i][j];
    }
  }
  for (int i = 0; i < h; i++)	{
    for (int j = 0; j < w; j++)	{
      if (field[i][j] == '#')	{
        cout << field[i][j];
        continue;
      }
      int mineCount = 0;
      for (int x = i - 1; x < i + 2; x++)	{
        for (int y = j - 1; y < j + 2; y++)	{
          if (x >= 0 && y >= 0 && x < h && y < w && field[x][y] == '#')	{
            mineCount++;
          }
        }
      }
      cout << mineCount;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
// ਅਗਮਜੋਤ ਸਿੰਘ
// AGAMJOT SINGH

#include <bits/stdc++.h>
using namespace std; 
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define int long long int
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

// a_gamer

int power(int x, unsigned int y, int p) { 
    int res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res; 
} 
  
int max(int a, int b){
    if (a > b)
        return a;
    else
        return b;
}
int maxSubArraySum(vector<int> &v){
    int size = v.size();
    int max_so_far = 0, max_ending_here = 0;
    int a[size];
    for (int i = 0; i < size; i++)
    {
        a[i] = v[i];
    }
    for (int i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_ending_here < 0)
            max_ending_here = 0;
        else if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;
    }
    return max_so_far;
}
int NcR(int n, int r) { 
   
    long long p = 1, k = 1;  
    if (n - r < r) 
        r = n - r;  
    if (r != 0) {   
        while (r) { 
            p *= n; 
            k *= r;  
            long long m = __gcd(p, k);  
            p /= m; 
            k /= m;  
            n--; 
            r--; 
        }  
    }  
    else
        p = 1;  
    return p; 
}
int dp[101][100000+1],till[101][100000+1];
signed main(){ 
    fastio;
    int n ,k;
    for(int i=0;i<101;i++)
    {
        for(int j=0;j<100000+1;j++)
        {
            dp[i][j] = 0;
            till[i][j] = 0;
        }
    }
    cin >> n >> k;
    vector<int>v(n);
    for(int i=0;i<n;i++){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    // unordered_map<int,int>dp[n],till[n]; 
    int ans = 0;
    for(int i=0;i<n;i++){
        dp[i][0] = 1;
        till[i][0] = 1;
    }
    for(int i=1;i<=k;i++){  
        // have to make sum i at every index of array
        for(int j=0;j<n;j++){ 
            if(j == 0){
                if(v[j] >= i)
                    dp[j][i] = 1;
                else{
                    dp[j][i] = 0;
                } 
                till[j][i] = (till[j][i]%mod + (till[j][i-1]%mod + dp[j][i]%mod)%mod)%mod; 
                continue;
            }   
            // have to take every possible number that arr[i] can take
            if(i-v[j]-1>=0)
            dp[j][i] = (dp[j][i]%mod + (till[j-1][i]%mod - till[j-1][i-v[j]-1]%mod + mod)%mod)%mod;
            else
            dp[j][i] = (dp[j][i]%mod + till[j-1][i]%mod)%mod;
            till[j][i] = (till[j][i]%mod + (till[j][i-1]%mod + dp[j][i]%mod)%mod)%mod;   
        }
    }
    ans = dp[n-1][k]%mod;
    cout << ans%mod << "\n";
}


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

int main()
{
  int a;
  int counter1 = 0;
  cin >> a;
  if(a / 500 != 0){
    counter1 = 1000 * (a / 500);
  }
  a = a % 500;
  if(a / 5 != 0){
    counter1 += (5 * (a / 5));
  }
  cout << counter1 << endl;
}
  

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

int main() {
  int N;
  cin >> N;
  
  bool flag = false;
  for (int i = 0; i <= 25; i++) {
    for (int j = 0; j <= 14; j++) {
      if ((4*i+7*j) == N) {
        flag = true;
        break;
      }
    }
    if (flag) break;
  }      
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5;
const int MOD = 1e9 + 7;

ll n,x,y,m,k,ans,cnt,mini=N,flag;
ll a[N],cost[N],dp[N];
vector<pair<ll,ll > > v;
string s;
map<char,ll>mp;
int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin>>n>>k;
    for(ll i=1;i<=n;i++)
        cin>>a[i];
    dp[1]=0;
    //dp[2]=abs(a[2]-a[1]);
    for(ll i=2;i<=n;i++){
        dp[i]=INT_MAX;
        for(int j=1;j<=k and i-j>=1;j++)
        dp[i]=min(dp[i],abs(a[i]-a[i-j])+dp[i-j]);
    }
    cout<<dp[n];
return 0;
}


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

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

Measured memory_bytes: 256
from math import factorial

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

pp = 0
qq = 0
pl = []
ql = []

for i in range(n):
    p_cnt = 0
    q_cnt = 0
    pn = p[i]
    qn = q[i]
    
    if i > 0:
        for j in range(len(pl)):
            if pn > pl[j]:
                p_cnt += 1
            if qn > ql[j]:
                q_cnt += 1

    pp+=(pn-p_cnt)*factorial(n-i-1)
    qq+=(qn-q_cnt)*factorial(n-i-1)

    pl.append(pn)
    ql.append(qn)
print(abs(pp-qq))


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

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

void solve() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i, sz(s)) ans += s[i] != t[i];
  cout << ans << endl;
}


Measured memory_bytes: 3876
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=3005;
const int Mod=998244353;
int n,m,x[N],sum;
ll ans=00000000;
int dp[9005];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>x[i];
	for(int i=1;i<=n;i++)
	{
		if(x[i]<=m)ans=(ans+1ll*dp[m-x[i]]*(n-i+1)%Mod+1ll*(x[i]==m)*(n-i+1)*i%Mod)%Mod;
		for(int j=m;j>=0;j--)
			dp[j+x[i]]+=dp[j],dp[j+x[i]]%=Mod;//grow
		dp[x[i]]+=i;//add
		dp[x[i]]%=Mod;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

n = INT()
f = [LIST() for _ in range(n)]
p = [LIST() for _ in range(n)]

def func(i, arr):
    if i == 10:
        if sum(arr) == 0:
            return -inf
        pp = 0
        for i in range(n):
            cnt = 0
            for j in range(10):
                if arr[j] == 1 and f[i][j] == 1:
                    cnt += 1
            pp += p[i][cnt]
        return pp
    tmp = deepcopy(arr)
    tmp[i] = 1
    return max(func(i + 1, arr), func(i + 1, tmp))

print(func(0, [0 for _ in range(10)]))



Measured memory_bytes: 68568
n,t = map(int,input().split())
ab = [list(map(int, input().split())) for i in range(n)]
ab.sort()
dp = [[0 for i in range(t+1)]for j in range(n+1)]

for i in range(n):
    ti,vi = ab[i]
    for j in range(t+1):
        if j + ti <= t:
            dp[i+1][j+ti] = max(dp[i+1][j+ti],dp[i][j]+vi)
        dp[i+1][j] = max(dp[i][j],dp[i+1][j])

ma = 0
for i,(ti,vi) in enumerate(ab):
    ma = max(ma,dp[i][t-1]+vi)
print(ma)

Measured memory_bytes: 124120
#include <bits/stdc++.h>
using namespace std;
int main() {
	int h, w; cin >> h >> w;
	string s[55];
	for(int i=0;i<h;i++){
		cin >> s[i];
	}
	int di[4] = {1, 0, -1, 0}, dj[4] = {0, 1, 0, -1};
	int d[55][55];
	int cnt = 0;
	queue<pair<int, int>> q;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			d[i][j] = 10000;
			if(s[i][j]=='.'){
				cnt++;
			}
		}
	}
	q.push({0, 0});
	d[0][0] = 0;
	while(q.size()){
		auto p = q.front(); q.pop();
		if(p.first==h-1 && p.second==w-1){
			break;
		}
		for(int k=0;k<4;k++){
			int ni = p.first + di[k];
			int nj = p.second + dj[k];
			if(ni<0 || ni>=h || nj<0 || nj>=w){
				continue;
			}else{
				if(s[ni][nj]!='#' && d[ni][nj]==10000){
					q.push({ni, nj});
					d[ni][nj] = d[p.first][p.second]+1;
				}
			}
			//if(0<=ni && ni<h && 0<=nj && nj<w && s[ni][nj]!='#' && d[ni][nj]==10000){
				//q.push({ni, nj});
				//d[ni][nj] = d[p.first][p.second]+1;
			//}
		}
	}
	if(d[h-1][w-1]==10000){
		cout << -1 << endl;
		return 0;
	}else{
		cout << cnt-d[h-1][w-1]-1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#include<vector>
#define pb push_back
#define mp make_pair
#define xx first
#define yy second
#define rep(i,a,b) for(int i=(a),i##_end_=(b);i<=i##_end_;i++)
#define dwn(i,a,b) for(int i=(a),i##_end_=(b);i>=i##_end_;i--)
using namespace std;
inline int read() {
    int x=0,f=1;char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar()) x=x*10+c-'0';
    return x*f;
}
typedef long long ll;
typedef pair<int,int> pii;
ll S[200010];
int main() {
	int n=read(),k=read();
	rep(i,1,n) S[i]=S[i-1]+read();
	double ans=0.0;
	rep(i,k,n) {
		ll sum=S[i]-S[i-k];
		ans=max(ans,(sum+k)*0.5);
	}
	printf("%.8lf\n",ans);
	return 0;
}


Measured memory_bytes: 1664
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  string s;
  cin >> s;
  int q;
  cin >> q;
  bool flag = true;
  char arr[1000000] = {};
  int b = 500000, e = b + s.size();
  for (int i = b; i < e; ++i)
  {
    arr[i] = s[i - b];
  }
  b--;
  for (int i = 0; i < q; ++i)
  {
    int a;
    cin >> a;
    if (a == 1)
    {
      flag = !flag;
    }
    else
    {
      int f;
      char c;
      cin >> f >> c;
      if (!((f == 1) ^ flag))
      {
        arr[b] = c;
        b--;
      }
      else
      {
        arr[e] = c;
        e++;
      }
    }
  }
  if (flag)
  {
    for (int i = b + 1; i < e; ++i)
    {
      cout << arr[i];
    }
  }
  else
  {
    for (int i = e - 1; i > b; --i)
    {
      cout << arr[i];
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast,unroll-loops,fast-math")

#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
	#define endl '\n'
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const ll mod = 1e9 + 7;
const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }

const int MAX_N = 1777;

vector<int> g[MAX_N];
int used[MAX_N], mark = 1337;
int n;

inline bool check(int v)
{
	if(g[v].empty())
		return false;

	int u = g[v].back();

	if(g[u].empty())
		return false;

	return g[u].back() == v;
}

set<int> good;

inline void update(int v, int u)
{
	good.erase(v);
	good.erase(u);

	g[v].pop_back();
	g[u].pop_back();

	if(check(v))
		good.insert(v);

	if(check(u))
		good.insert(u);
}

void solve()
{
	cin >> n;

	for(int v = 0; v < n; ++v)
	{
		for(int j = 0; j < n - 1; ++j)
		{
			int u;
			cin >> u;
			--u;

			g[v].push_back(u);
		}

		reverse(g[v].begin(), g[v].end());
	}

	int answ = 0;

	for(int v = 0; v < n; ++v)
	{
		if(check(v))
			good.insert(v);
	}

	while(!good.empty())
	{
		bool change = false;

		vector<int> good2;

		for(auto& v: good)
			good2.push_back(v);

		for(auto& v: good2)
		{
			if(used[v] == mark || g[v].empty())
				continue;

			int u = g[v].back();

			if(used[u] == mark || g[u].empty() || g[u].back() != v)
				continue;

			used[v] = used[u] = mark;
			update(v, u);

			change = true;
		}

		if(!change)
		{
			cout << NIL << endl;
			return;
		}

		++mark;
		++answ;
	}

	for(int v = 0; v < n; ++v)
	{
		if(!g[v].empty())
		{
			cout << NIL << endl;
			return;
		}
	}

	cout << answ << endl;
}

int main()
{
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int X,A,B;
  cin>>X>>A>>B;
  char ans='A';
  if(max(X,A)-min(X,A)>max(X,B)-min(X,B))
    ans='B';
  cout<<ans;
  }


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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const ll N = 1e18;
ll n,result;

int main () {
  // ios::sync_with_stdio(false);
  // cin.tie(nullptr);
  cin >> n;
  if(n%2) {
    cout << 0 << endl;
    return 0;
  }
  for(int i = 0; i<=50; i++) {
    ll temp = pow(5,i) * 10;
    if(temp > n) break;
    result += n / temp;
  }
  cout << result << endl;
}


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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
	char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
	vector<char*> v({token});
	while(token = strtok(NULL,", ")) v.push_back(token);
	return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
	debug() << " [" << args.back() << ": " << H << "] ";
	args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=1e9+7;
const int MX=0x3f3f3f3f;

int main(){
	IOS;
	int i,ans=0,temp;
	string s;
	cin>>s;
	REP(i,0,sz(s)-1){
		if(s[i]=='R'){
			temp=1;
			while(i<sz(s)-1&&s[i]==s[i+1]) temp++,i++;
			ans=max(ans,temp);
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define space " "
#define MOD (long long) 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename T> void __f(const char* variable_name, T&& value){cout << variable_name << ": " << value << endl;}
template <typename T1, typename... T2> void __f(const char* names, T1&& arg1, T2&&... args){const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);}

const ll N = 5e5 + 5;
ll *v;
ll n, x, y, a, b, c, k, q;

void solve(){
    cin >> a >> b;
    cout << a * b << endl;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    // cout << "\n\nBLAH BLAH BLAH\n\n";
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int R = sc.nextInt();
    if (N < 10) {
      System.out.println(R + (10-N)*100);
    }else{
      System.out.println(R);
    }
  }
}


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

int main(){
  ll h,w,ans;
  cin >> h >> w;
  ans=h*w/2;
  if(h==1 || w==1){
    ans=1;
    cout << ans << endl;
    return 0;
  }
  if(h*w%2==0){
    cout << ans << endl;
  }else{
    ans++;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll n, m, t, a[100005];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    string s;
    cin >> s;
    string k = s;
    ll ctr = 0;
    sort(s.begin(), s.end());
    for(int i = 0 ; i < n ; i++){
    	if( s[i] == 'R' and k[i] != 'R' )
    		ctr++;
    }
    cout << ctr << endl;
	return(0);
}


Measured memory_bytes: 3864
#include <stdio.h>
#define MAX_CARD 101

int main() {
  int i, turn = 1;
  char ch;
  scanf("%c", &ch);
  if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') {
    printf("vowel\n");
  } else {
    printf("consonant\n");
  }

  return 0;
}


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

int main(){
  long long int n,k;
  cin >> n >> k;
  
  if(k==0){
    cout << n << endl;
  }
  else{
    long long int a=max(k-n%k,n%k-k);
    cout << min(n%k,a) << endl;
  }
}

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

int Sound(int a, int b, int c){
  if (b < a)
    return 0;
  if ((c * a) < b)
    return c;
  return 1 + Sound(a, b-a, c-1);
}


int main() {
  ios_base::sync_with_stdio(false);

  int a, b, c;
  cin >> a >> b >> c;

  cout << Sound(a,b,c) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a[101][101]={0};
    int i=0,j=0;
    int n,m=0;
    scanf("%d %d",&m,&n);
    for(i=0;i<m;i++){
        for(j=0;j<n;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(i=0;i<m;i++){
        for(j=0;j<n;j++){
            a[i][n]+=a[i][j];
            printf("%d ",a[i][j]);
        }
        printf("%d\n",a[i][j]);
    }
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            a[m][i] += a[j][i];
        }
        printf("%d ",a[m][i]);
    }
    for(j=0;j<n;j++){
        a[m][n]+=a[m][j];
    }
    printf("%d\n",a[m][n]);
    
    return 0;
}

Measured memory_bytes: 648
haiku = list(map(int, input().split()))

f = 2
s = 1
flg = 1
for i in range(len(haiku)):
    if haiku[i] == 5:
        f -= 1
    elif haiku[i] == 7:
        s -= 1
    else:
        flg = 0
        break

if f == 0 and s == 0 and flg == 1:
    print("YES")
else:
    print("NO")

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

int N;
int ary[10010];
//a???c???????????¨
int puyo(int a,int c){
	int motoc=ary[a];
	int C=c;
	ary[a]=C;
	int l,r,ml,mr,tmp,cnt;
	ml=mr=l=r=a;
	cnt=0;
	while(ary[l]==C){
		l--;
		if(l<0) break;
	}
	while(ary[r]==C){
		r++;
		if(r>=N) break;
	}
	tmp=abs(ml-l)+abs(mr-r)-1;
	if(tmp<4){
		ary[a]=motoc;
		return N;
	}
	if(l<0){
		ary[a]=motoc;
		return N-r;
	}
	if(r>=N){
		ary[a]=motoc;
		return l+1;
	}
	cnt=tmp;
	if(ary[l]!=ary[r]){
		ary[a]=motoc;
		return N-cnt;
	}
	while(1){
		C=ary[l];
		ml=l;
		mr=r;
		while(ary[l]==C){
			l--;
			if(l<0) break;
		}
		while(ary[r]==C){
			r++;
			if(r>=N) break;
		}
		tmp=abs(ml-l)+abs(mr-r);
		if(tmp<4){
			ary[a]=motoc;
			return N-cnt;
		}
		if(l<0){
			ary[a]=motoc;
			return N-r;
		}
		if(r>=N){
			ary[a]=motoc;
			return l+1;
		}
		cnt+=tmp;
		if(ary[l]!=ary[r]){
			ary[a]=motoc;
			return N-cnt;
		}
	}
}

int main(){
	int cnt;
	while(1){
		cin>>N;
		if(N==0) break;
		for(int i=0;i<N;i++){
			cin>>ary[i];
		}
		cnt=N;
		for(int i=0;i<N;i++){
			for(int j=1;j<=3;j++){
				//cout<<i<<"???"<<j<<"?????????????????¨"<<puyo(i,j)<<"????????????"<<endl;
				cnt=min(cnt,puyo(i,j));
			}
		}
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int n, d;
int m[100];
vector<int> c[100];
int sum[100];

const int INF = 1000000000;

void print_table(){
  cout << "=======" << endl;
  for(int i=0;i<n;i++){
    cout << sum[i] << endl;
  }
  cout << "=======" << endl;
  cout << endl;
}

main(){
  while(cin >> n >> d && n && d){
    for(int i=0;i<n;i++){
      c[i].clear();
    }
    for(int i=0;i<n;i++){
      cin >> m[i];
      for(int j=0;j<m[i];j++){
	int input;
	cin >> input;
	c[i].push_back(input);
      }
    }
    fill(sum, sum+100, 0);
    for(int i=0;i<n;i++){
      for(int j=0;j<m[i];j++){
	sum[i] += c[i][j];
      }
    }
    bool f = true;
    while(f){
      f = false;
      for(int i=0;i<n;i++){
	if(m[i] <= 0) continue;
	sum[i] -= c[i][m[i]-1];
	int valM = -1;
	int valm = INF;
	for(int j=0;j<n;j++){
	  valM = max(valM, sum[j]);
	  valm = min(valm, sum[j]);
	}
	if(valM - valm <= d){
	  m[i]--;
	  f = true;
	  break;
	}
	sum[i] += c[i][m[i]-1];
      }
    }
    bool ans = true;
    for(int i=0;i<n;i++){
      if(m[i] > 0){
	ans = false;
	break;
      }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int main()
{
 int a,b,c,s=0,flag;
 scanf("%d %d %d",&a,&b,&c);
 int x=a-b,y=a-c,z=b-c;
 if(x<0)x*=-1;
 if(y<0)y*=-1;
 if(z<0)z*=-1;
 if(x<y && x<z){s+=x;flag =0;}
    else if(y<x && y<z){s+=y;flag=1;}
    else{s+=z;flag=2;}
if(flag==0){
    if(y<z){s+=y;}
    else{s+=z;}
}
if(flag==1){
    if(x<z){
        s+=x;
    }
    else{s+=z;}
}
if(flag==2){
    if(x<y){
        s+=x;
    }
    else{s+=y;}
}
 printf("%d",s);
return 0;
}

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


int main() {

	int n;
	cin >> n;

	int ans = 1;

	for (int i = 2; i <= n; i++) {

		int num = i;
		if (i*i > n)
		{
			break;
		}
		while (num * i <= n) {
			num *= i;
		}
		ans = max(ans, num);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

void solve(int a, int b, int x, int y, string s)
{
    if(a == x && b == y){
        cout << s << endl;
        return;
    }
    if((a == 5 && b <= 3) || (a <= 3 && b == 5) || a + b == 10)
        return;

    solve(a + 1, b, x, y, s + 'A');
    solve(a, b + 1, x, y, s + 'B');
}

int main()
{
    int x, y;
    cin >> x >> y;
    solve(0, 0, x, y, "");
}

Measured memory_bytes: 1204
use std::str::FromStr;
use std::fmt::Debug;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line: Vec<i32> = read_as_vec();
    let (a, b) = (line[0], line[1]);

    if b%a ==0{
        println!("{}", a+b);
    }else{
        println!("{}", b-a);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


#define INF 1e+9
#define MAX_V 2005

struct edge {
    int to;
    int cost;
};

// <最短距離, 頂点の番号>
using P = pair<int, int>;

int V;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    cin >> V;
    int x, y;
    cin >> x >> y;
    x--; y--;
    edge e3 = {y, 1};
    edge e4 = {x, 1};
    G[x].push_back(e3);
    G[y].push_back(e4);
    for (int i=0; i<V-1; ++i) {
        //有向グラフ
        edge e = {i+1, 1};
        edge e2 = {i, 1};
        G[i].push_back(e);
        G[i+1].push_back(e2);
    }
    vector<int> ans(V);
    rep(i, V){
      dijkstra(i);
      for(int j=i+1; j<V; j++){
        ans[d[j]]++;
      }
    }
    for (int i=1; i<V; ++i) {

            cout << ans[i] << endl;
    }
}


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

using namespace std;
using ll = unsigned long long;

ll res = 1;
int zero = 0;
ll last = 1;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n; cin >> n;
    vector<ll> v(n);
    
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
        if (v[i] == 0) {
            cout << 0;
            return 0;
        }
    }
    
    sort(v.begin(), v.end());
    if (v[n - 1] == 1000000000000000000LL) {
        cout << -1;
        return 0;
    }
    
    for (int j = 0; j < n; ++j)
    {
        last = res;
        res *= v[j];
        if (res < last || res < 0) {
            cout << -1;
            return 0;
        }
    if (res > 1000000000000000000LL || res < 0)
    {
        cout << -1;
        return 0;
    }
    }

    cout << res;
}

Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  ll a,b,c,d;
  cin>>a>>b;
  c=min(a,b);
  rep(i,c){
    if(a%i==0 && b%i==0)
      d=i;
  }
  ll ans=a*b/d;
  cout<<ans<<endl;
}


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

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, pii> node;
const int maxn = 2e5 + 10;
int n, par[maxn]; ll k, a[maxn], f[maxn];
vector <node> e;

int find(int x) {
  return par[x] == x ? x : par[x] = find(par[x]);
}

void unite(int x, int y) {
  par[find(x)] = find(y);
}

void solve(int l, int r) {
  if (l == r) return;
  ll val = 1ll << 60;
  int mid = l + r >> 1, pl = 0, pr = 0;
  for (int i = l; i <= mid; i++) {
    f[i] = a[i] - k * i;
    if (val > f[i]) val = f[i], pl = i;
  }
  val = 1ll << 60;
  for (int i = mid + 1; i <= r; i++) {
    f[i] = a[i] + k * i;
    if (val > f[i]) val = f[i], pr = i;
  }
  for (int i = l; i <= mid; i++) {
    e.push_back(node(f[i] + f[pr], pii(i, pr)));
  }
  for (int i = mid + 1; i <= r; i++) {
    e.push_back(node(f[pl] + f[i], pii(i, pl)));
  }
  solve(l, mid), solve(mid + 1, r);
}

int main() {
  scanf("%d %lld", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", a + i), par[i] = i;
  }
  solve(1, n), sort(e.begin(), e.end());
  ll ans = 0;
  for (node p : e) {
    int u = p.second.first, v = p.second.second;
    if (find(u) != find(v)) {
      ans += p.first, unite(u, v);
    }
  }
  printf("%lld", ans);
  return 0;
}

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

using namespace std;
using int64 = long long;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

int main() {
    int x;
    cin >> x;
    cout << (x>=30?"Yes":"No") << endl;
}


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

int main()
{

	int n, k, x;
	cin >> n >> k;
	vector<int> v(n + 1, 0);
	v[0] = 1;
	int d;
	for(int i = 0; i < k; i++)
	{
		cin >> d;
		for(int i = 0; i < d; i++)
		{
			cin >> x;
			v[x] = d;
		}
	}

	
	cout << count(v.begin(), v.end(), 0);
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

  int main(){
    int n;
    map<int,int> m;
    cin >> n;
    rep(i,n){
      int tmp;
      cin >> tmp;
      m[tmp]++;
    }
    int ans=0;
    int two=0;
    int one=0;
    int kind=0;
    for (auto q:m){
      kind++;
      //printf("num = %d cnt = %d\n",q.first,q.second);
      if (q.second%2==0) two++;
      else one++;
    }
    if (two%2==0) cout << kind << endl;
    else cout << kind-1 << endl;
  }


Measured memory_bytes: 4992
S = input()
flag = True
if S[0] != 'A':
    flag = False
if S.count('C') != 1 or 'C' not in S[2:-1]:
    flag = False
if S.replace('A', 'a').replace('C', 'c').islower() != True:
    flag = False
print('AC' if flag else 'WA')


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

int main() {
   int N,K;
  cin>>N>>K;
  vector<int>h(N);
  for(int i=0;i<N;i++){
    cin>>h.at(i);
  }
  int ans=0;
  for(int i=0;i<N;i++){
    if(h.at(i)>=K){
      ans++;
    }
  }
  cout<<ans<<endl;
}

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

int n;

int main() {
    
    cin >> n;
    vector<int> odd(1e5 + 1), even(1e5 + 1);
    for (int i = 0; i < n / 2; i++) {
        int o, e;
        cin >> o >> e;
        odd[o] += 1;
        even[e] += 1;
    }
    
    long max_odd = distance(odd.begin(), max_element(odd.begin(), odd.end()));
    long max_even = distance(even.begin(), max_element(even.begin(), even.end()));
    
//    oddとevenで最大のindexが違う場合
    if (max_odd != max_even) {
        cout << n - odd[max_odd] - even[max_even] << endl;
        return 0;
    } else {
        sort(odd.begin(), odd.end(), greater<int>());
        sort(even.begin(), even.end(), greater<int>());
        if(odd[0] - odd[1] > even[0] - even[1]) {
            cout << n - odd[0] - even[1] << endl;
        } else {
            cout << n - even[0] - odd[1] << endl;
        }
    }
}

Measured memory_bytes: 1024
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N = inp()
aa = inpl()
bb = inpl()

tmp1 = 0
tmp2 = 0
for i in range(N):
	a,b = aa[i],bb[i]
	if a < b:
		tmp1 += (b-a)//2
	else:
		tmp2 += a-b

if tmp2 <= tmp1:
	print('Yes')
else:
	print('No')


Measured memory_bytes: 5864
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from fractions import gcd
    n,m=map(int,input().split())
    s,t=[input() for _ in range(2)]
    gcd=gcd(n,m)
    lcm=n*m//gcd
    n//=gcd
    m//=gcd
    print(lcm if all(s[n*i]==t[m*i] for i in range(gcd)) else -1)
resolve()

Measured memory_bytes: 66284
#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;

class binomial_coefficients {
	long long MAX_VAL;
	vector<long long> fac, mmi;

public:

	binomial_coefficients(){
	}
	
	binomial_coefficients(long long num){
		init(num);
	}
	
	~binomial_coefficients(){
		
	}
	
	void init(long long num){
		MAX_VAL = num+1; 
		fac.resize(MAX_VAL);
		mmi.resize(MAX_VAL);
		
		factorial_mod();
		modular_multiplicatibe_inverse();
	}
	
	void factorial_mod(){
		 fac[0] = 1;
		for(long long i = 1; i < MAX_VAL; fac[i] %= MOD, i++)
			fac[i] = fac[i - 1] * (i % MOD);
	}
	
	long long power(long long x, long long n){
		long long ans = 1;
		for(;n;n >>= 1, x *= x, ans %= MOD, x %= MOD)
			if(n&1)ans*=x;
		return ans % MOD;
	}
	
	void exgcd(long long a, long long b, long long &x, long long &y){
		if(b == 0){
			x = 1;
			y = 0;
			return ;
		}
		exgcd(b, a % b, y, x);
		y -= a / b * x;
	}
	
	void modular_multiplicatibe_inverse(){
		long long x, y;  
		exgcd(fac[MAX_VAL - 1], MOD, x, y);
		mmi[MAX_VAL-1] = x;
		// mmi[MAX_VAL-1] = power(fac[MAX_VAL-1], MOD-2);
		for(long long i = MAX_VAL - 2; i >= 0; mmi[i]%=MOD, i--)
			mmi[i] = mmi[i + 1] * ((i + 1) % MOD);
	}
	
	long long combination(long long n, long long r){
		return n < r ? 0 :fac[n] * (mmi[r] * mmi[n-r] % MOD) % MOD;
	}
};

signed main(){
	cout<<fixed<<setprecision(10);
	
	string S;
	binomial_coefficients BC;
	int K;
	int ans = 0;
	
	cin>>K;
	
	cin>>S;
	
	
	BC.init(S.size()+K+1000);
	
	for(int i = 0; i <= K; i++){
		ans += BC.combination(S.size() - 1 + K - i, K - i) * BC.power(25, K - i) % MOD * BC.power(26, i) % MOD;
		ans %= MOD;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 35656
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

/*

*/

void solve(){
    int q;
    cin >> q;
    multiset<ll> ml, mr;

    //cout << ml.size() << " " << *mr.begin() << endl;

    ll m = INF;
    rep(i,q){

        int qv;
        cin >> qv;
        //cout << "qv:" << qv << endl;

        if(qv==1){

            ll a,b;
            cin >> a >> b;

            if(m==INF) m = b;
            else if(a<*(--(ml.end()))) m += b + abs(*(--(ml.end()))-a);
            else if(a>*((mr.begin()))) m += b + abs(a-*((mr.begin())));
            else m += b;

            
            if(ml.empty()&&mr.empty()){
                ml.insert(a);
                mr.insert(a);
            }
            else{
                auto it = ml.end();
                auto it2 = mr.begin();
                --it;
                ll mlmax = *it;
                ll mrmin = *it2;
                if(mlmax <= a && a <= mrmin){
                    ml.insert(a);
                    mr.insert(a);
                }
                else if(a<mlmax){
                    ml.erase(it);
                    mr.insert(mlmax);
                    ml.insert(a);
                    ml.insert(a);
                }
                else{
                    mr.erase(it2);
                    ml.insert(mrmin);
                    mr.insert(a);
                    mr.insert(a);
                }
            }

            //cout << *ml.begin() << " " << *mr.begin() << endl;
            
        }
        else{

            auto itr = ml.end();
            --itr;
            //cout << "<" << *itr << " " << m << ">" << endl;
            cout << *itr << " " << m <<  endl;

        }

    }
}

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

Measured memory_bytes: 19072
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;
  vector<ll> count(27);
  for(int i = 0;i < 26;i++)count[i] = 0;
  //cout << 'a' - 'a' << endl;
  for(int i = 0;i < s.size();i++){
    count[s[i] - 'a']++;
  }
  ll res = 0;
  res = s.size() * (s.size() - 1) / 2;
  for(int i = 0;i < 26;i++){
    res -= count[i] * (count[i] - 1) / 2;
    //cout << count[i] << " ";
  }
  //cout << endl;
  res++;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <set>
using namespace std;
int main(void){
    int N,c;
    set<int> A;
    cin >> N;
    for(int i=0; i<N;i++){
        cin >> c;
        A.insert(c);
    }
    if(A.size() != N){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

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

  int N; scanf("%d",&N);
  vi A(N); REP(i,N) scanf("%d",&A[i]);

  set<int> written;
  REP(i,N) {
    if (!written.count(A[i])) {
      written.insert(A[i]);
    }
    else {
      written.erase(A[i]);
    }
  }

  cout << written.size() << endl;
}

Measured memory_bytes: 5376
<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        ++$this->pointer;

        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int) $this->next();
    }

    public function nextDouble()
    {
        return (float) $this->next();
    }
}

$sc = new Scanner();
$n = $sc->nextInt();
$array = [];

for($i=0;$i<$n;$i++){
    $array[] = $sc->nextInt();
}

$maxes   = array_keys($array, max($array));
$key_max = $maxes[0]; //最初に出現した最大値のキー名を返す

rsort($array);
$maximum_value = $array[0];
$second_maximum_value = $array[1];

$array = [];
$array = array_fill(0, $n, $maximum_value);
$array[$key_max] = $second_maximum_value;

for($i=0;$i<$n;$i++){
    echo $array[$i].PHP_EOL;
}

Measured memory_bytes: 29384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mod 1000000007
#define null NULL
#define test cout<<"#"
#define maX 1000000000
 
vector<ll> ans(100001, LONG_LONG_MAX);
void solve(vector<ll> &v, ll n, ll k)
{
	ans[0] = 0;
	for(ll x = 1; x < n; x++)
	{	
		ans[x] = 1000000000000;
		for(ll y = 1; y <= k; y++)
		{
			if((x-y)>=0)
				ans[x] = min(ans[x], abs(v[x]-v[x-y]) + ans[x-y]);
		}
	}
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n, k;
	cin>>n>>k;
    vector<ll> v(n);
    for(ll x = 0; x < n; x++)
		cin>>v[x];
	solve(v, n, k);
	cout<<ans[n-1];
}

Measured memory_bytes: 1792