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

int h, w;
char ground[52][52];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int BFS(int i, int j){
    int isvisited[52][52] = {};
    bool B = false;
    bool W = false;
    queue<pair<int, int>> que;
    que.push(pair<int, int>(i, j));
    while(!que.empty()){
        pair<int, int> q = que.front(); que.pop();
        for(int k=0;k<4;k++){
            pair<int, int> next_q;
            next_q.first = q.first + dx[k];
            next_q.second = q.second + dy[k];
            if(0 <= next_q.first && next_q.first < h &&
            0 <= next_q.second && next_q.second < w &&
            isvisited[next_q.first][next_q.second] == 0){
                isvisited[next_q.first][next_q.second] = 1;
                if(ground[next_q.first][next_q.second] == 'B'){
                    B = true;
                }
                else if(ground[next_q.first][next_q.second] == 'W'){
                    W = true;
                }
                else{
                    que.push(next_q);
                }
            }
        }
    }
    if(B && !W){
        return 1;
    }
    else if(!B && W){
        return -1;
    }
    else{
        return 0;
    }
}

int main(){
    while(true){
        cin >> w >> h;
        if(h == 0 && w == 0) break;
        int B = 0;
        int W = 0;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin >> ground[i][j];
            }
        }
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(ground[i][j] == '.'){
                    int result = BFS(i, j);
                    if(result == 1){
                        B++;
                    }
                    if(result == -1){
                        W++;
                    }
                }
            }
        }
        cout << B << " " << W << "\n";
    }
    return 0;
}


Measured memory_bytes: 3176
/**
 * Created by hiramekun at 20:58 on 2020-05-03.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    vl a(n);
    cin >> a;

    map<ll, ll> xmi, ymi;
    map<ll, ll> xpl, ypl;
    rep(i, n) {
        xmi[a[i] - i]++;
        ymi[-a[i] - i]++;
        ypl[-a[i] + i]++;
        xpl[a[i] + i]++;
    }
    ll ans = 0;
    each(e, xmi) {
        ll tmp = e.second * ymi[e.first];
        ans += tmp;
    }
    each(e, xpl) {
        ll tmp = e.second * ypl[e.first];
        ans += tmp;
    }
    cout << ans / 2 << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 73248
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll gcd(ll a,ll b)
{
    return b==0 ? a : gcd(b,a%b);
}
int main()
{
     ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      ll k,n;
      cin>>k>>n;
      ll a[n];
      for(int i=0;i<n;i++)
      {
          cin>>a[i];
      }
      ll maxi=a[0]+(k-a[n-1]);
      for(int i=1;i<n;i++)
      {
          if(maxi<a[i]-a[i-1])
            maxi=a[i]-a[i-1];
      }
      cout<<k-maxi<<"\n";


    return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int arr[101];
int main()
{
	int n,i,max=0,min=0x7fffffff;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
	    scanf("%d",&arr[i]);
	    if(max<arr[i])
		    max=arr[i];
		if(min>arr[i])
		    min=arr[i];
	}
	printf("%d",max-min);
	return 0;    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		
		String ns = s.nextLine();	
		
		String []aa = ns.split("\\s");
		
		int N = Integer.parseInt(aa[0]);
		
		int K = Integer.parseInt(aa[1]);
		
		int Q = Integer.parseInt(aa[2]);
		
		int p[] = new int[N];
		for(int i=0;i<N;i++) {
			p[i] = K-Q;
		}
		
		for(int i=0;i<Q;i++) {
			String str = s.nextLine();
			
			int n = Integer.parseInt(str);
			n = n-1;
			
			p[n] = p[n]+1;
			
//			for(int j=0;j<N;j++) {
//				if(n == (j+1)) {
//					continue;
//				} else {
//					p[j] = p[j]-1;
//				}
//				
//			}
		}
		
		for(int i=0;i<N;i++) {
			if(p[i]<=0) {
				System.out.println("No");
			} else {
				System.out.println("Yes");
			}
		}
		

	}

}

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

int main() {
  string S, T, U;
  int A, B;
  cin >> S >> T >> A >> B >> U;
  
  if (S == U){
    A--;
    cout << A << " " << B << endl;
  }
  else {
    B--;
    cout << A << " " << B << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll mod=1e9+7;
	ios::sync_with_stdio(false);cin.tie(0);
    ll h,w;cin>>h>>w;
    vector <vector<char>> vec(h,vector <char> (w));
    for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>vec[i][j];
		}
    }
    vector <vector <ll>> dp(h,vector<ll> (w,0));
    for(int i=0;i<w;i++){
		if(vec[0][i]=='.'){
			dp[0][i]=1;
		}else{
			break;
		}

    }
    for(int i=0;i<h;i++){
		if(vec[i][0]=='.'){
			dp[i][0]=1;
		}else{
			break;
		}
    }
    for(int i=1;i<h;i++){
		for(int j=1;j<w;j++){
			if(vec[i][j]=='.'){
				dp[i][j]=dp[i-1][j]+dp[i][j-1];
				dp[i][j]=(dp[i][j])%mod;
			}
		}
    }
    cout<<dp[h-1][w-1]<<endl;
    return 0;
}


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

using namespace std;

using pii = pair<int, int>;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    vector<pii> Ai(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        Ai[i] = pii(A[i], i);
    }
    sort(Ai.rbegin(), Ai.rend());
    int i_max = Ai[0].second;
    for (int i = 0; i < N; i++)
        cout << ((i == i_max) ? Ai[1].first : Ai[0].first) << endl;

    return 0;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll a,b;
	cin>>a>>b;
	ll total=0;
	ll count=0;
	if(b==1){
		cout<<"0"<<endl;
		return 0;
	}
	
	while(1){
		total+=a;
		count++;
		if(total>=b) break;
		total-=1;
	}
	
	cout<<count<<endl;
}

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

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

    char pt = s[0];
    int cnt = 0;
    for (int i=1; i<s.length(); i++) {
        if (s[i] == pt) {
            if (pt == '1') pt = '0';
            else pt = '1';
            cnt++;
        } else {
            pt = s[i];
        }
   
    }
    cout << cnt;

    return 0;
}


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

int main(){
  int H,W;
  cin>>H>>W;
  vector<string> vec(H);
  for(int i=0;i<H;i++){
    cin>>vec.at(i);
  }
  for(int i=0;i<W+2;i++){
    cout<<"#";
  }
  cout<<endl;
  for(int i=0;i<H;i++){
    cout<<"#"<<vec.at(i)<<"#"<<endl;
  }
  for(int i=0;i<W+2;i++){
    cout<<"#";
  }
}

Measured memory_bytes: 3584
#include <iostream>
#define ll long long
using namespace std;
ll a,c[1000][1000],p[10000],la[1000],day,id;
int main() {
    cin>>a;
    for(int i=0;i<a;i++){
        for(int j=0;j<a-1;j++){
            cin>>c[i][j];
            c[i][j]--;
        }
    }
    bool tor = 1;
    while(tor){
        day++;
        tor = 0;
        for(int i=0;i<a;i++){
            if(p[i] < a-1){
                id = c[i][p[i]] ;
                if(la[i] < day && la[id]<day && p[id]<a-1 && c[id][p[id]] == i){
                    la[id] = day;
                    la[i] = day;
                    p[i] ++;
                    p[id]++;
                    tor = 1;
                }
            }
        }
        
    }
    for(int i=0;i<a;i++){
        if(p[i] != a-1){
            cout<<-1;
            return 0;
        }
    }
    cout<<day-1;
}

Measured memory_bytes: 8064
import java.io.*;
import java.util.*;

public class Main {

    public static int Lucas(int N) {
        if (N == 0) {
            return 2;
        } else if (N == 1) {
            return 1;
        } else {
            return Lucas(N - 1) + Lucas(N - 2);
        }

    }

    public static void main(String[] args) {

        Scanner Input = new Scanner(System.in);
        int N = Input.nextInt()+1;
        long A[] = new long[N];
        A[0] = 2;
        A[1] = 1;
        for (int I = 2; I < A.length; I++) {
            A[I]=A[I-1]+A[I-2];
        }
        System.out.println(A[N-1]);
    }
}


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

struct X {
	long long A, B, C;
};
struct Y {
	long long D, E, F;
};

long long INF = 1000000000;

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

int main() {
	int N, M;
	cin >> N >> M;
	vector<X> VX(N);
	vector<Y> VY(M);
	vector<long long> H, W;
	for (int i = 0; i < N; i++) {
		cin >> VX[i].A >> VX[i].B >> VX[i].C;
		H.push_back(VX[i].A);
		H.push_back(VX[i].B);
		W.push_back(VX[i].C);
	}
	for (int i = 0; i < M; i++) {
		cin >> VY[i].D >> VY[i].E >> VY[i].F;
		swap(VY[i].D, VY[i].E);
		swap(VY[i].E, VY[i].F);
		W.push_back(VY[i].D);
		W.push_back(VY[i].E);
		H.push_back(VY[i].F);
	}
	H.push_back(INF + 1), H.push_back(-INF - 1);
	W.push_back(INF + 1), W.push_back(-INF - 1);
	sort(H.begin(), H.end());
	sort(W.begin(), W.end());
	H.erase(unique(H.begin(), H.end()), H.end());
	W.erase(unique(W.begin(), W.end()), W.end());
	for (int i = 0; i < N; i++) {
		VX[i].A = lower_bound(H.begin(), H.end(), VX[i].A) - H.begin();
		VX[i].B = lower_bound(H.begin(), H.end(), VX[i].B) - H.begin();
		VX[i].C = lower_bound(W.begin(), W.end(), VX[i].C) - W.begin();
	}
	for (int i = 0; i < M; i++) {
		VY[i].D = lower_bound(W.begin(), W.end(), VY[i].D) - W.begin();
		VY[i].E = lower_bound(W.begin(), W.end(), VY[i].E) - W.begin();
		VY[i].F = lower_bound(H.begin(), H.end(), VY[i].F) - H.begin();
	}
	vector<vector<vector<bool> > > V(H.size() - 1, vector<vector<bool> >(W.size() - 1, vector<bool>(4, true)));
	vector<vector<bool> > B(H.size() - 1, vector<bool>(W.size() - 1, false));
	for (int i = 0; i < N; i++) {
		for (int j = VX[i].A; j < VX[i].B; j++) {
			V[j][VX[i].C - 1][1] = V[j][VX[i].C][3] = false;
		}
	}
	for (int i = 0; i < M; i++) {
		for (int j = VY[i].D; j < VY[i].E; j++) {
			V[VY[i].F - 1][j][0] = V[VY[i].F][j][2] = false;
		}
	}
	/*
	for (int i = 0; i < H.size() - 1; i++) {
		for (int j = 0; j < W.size() - 1; j++) {
			cout << ' ' << (V[i][j][2] ? '.' : '#');
		}
		cout << endl;
		for (int j = 0; j < W.size() - 1; j++) {
			cout << (V[i][j][3] ? '.' : '#') << ' ';
		}
		cout << (V[i][W.size() - 2][1] ? '.' : '#') << endl;
	}
	*/
	for (int i = 0; i < H.size() - 1; i++) {
		V[i][0][3] = V[i][W.size() - 2][1] = false;
	}
	for (int i = 0; i < W.size() - 1; i++) {
		V[0][i][2] = V[H.size() - 2][i][0] = false;
	}
	int SX, SY;
	for (int i = 0; i < H.size() - 1; i++) {
		if (H[i] <= 0 && 0 < H[i + 1]) SX = i;
	}
	for (int i = 0; i < W.size() - 1; i++) {
		if (W[i] <= 0 && 0 < W[i + 1]) SY = i;
	}
	B[SX][SY] = true;
	queue<pair<int, int> > Q;
	Q.push({ SX, SY });
	while (!Q.empty()) {
		pair<int, int> PP = Q.front();
		Q.pop();
		for (int i = 0; i < 4; i++) {
			if (V[PP.first][PP.second][i]) {
				int NX = PP.first + dx[i], NY = PP.second + dy[i];
				if (!B[NX][NY]) {
					B[NX][NY] = true;
					Q.push({ NX, NY });
				}
			}
		}
	}
	if (B[0][0]) {
		cout << "INF" << endl;
		return 0;
	}
	long long COUNT = 0;
	for (int i = 0; i < H.size() - 1; i++) {
		for (int j = 0; j < W.size() - 1; j++) {
			if (B[i][j]) COUNT += (H[i + 1] - H[i]) * (W[j + 1] - W[j]);
		}
	}
	cout << COUNT << endl;
}

Measured memory_bytes: 638292
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 998244353;
int INF = 2e18;

signed main() {
    int N;
    cin >> N;
    vector<int> D(N), count(N, 0);
    int maxValue = 0;
    for (int i = 0; i < N; i++) {
        cin >> D[i];
        count[D[i]]++;
        maxValue = max(maxValue, D[i]);
    }
    if (D[0] != 0 || count[0] != 1) {
        cout << 0 << endl;
        return 0;
    }
    int ans = 1;
    for (int i = 1; i <= maxValue; i++) {
        if (count[i - 1] == 0) ans = 0;
        for (int j = 0; j < count[i]; j++) {
            ans = ans * count[i - 1] % mod;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
h, w = map(int, input().split())
A = [None] * h
for i in range(h):
  A[i] = input()

while ('.' * w in A):
  A.remove('.' * w)

B = [''.join(col) for col in zip(*A)]

while ('.' * len(A) in B):
  B.remove('.' * len(A))


A = [''.join(col) for col in zip(*B)]

for a in A:
  print(''.join(a))


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

using namespace std;

#define db(x) cout << (x) << '\n';
#define all(x) x.begin(),x.end()
#define UNIQUE(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
#define LB(v,x) lower_bound(all(v),x)
#define UB(v,x) upper_bound(all(v),x)
#define endl "\n"
#define F first
#define S second
#define PB push_back
#define int long long
#define trick int m = (l+r)>>1,lc=n<<1,rc=lc|1

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;

int dy[]={0,1,1,1,0,-1,-1,-1};
int dx[]={-1,-1,0,1,1,1,0,-1};
const int maxn = 1e5;
const int OO = 1e18;
const int mod = 1e9 + 7;
const double PI = acos(-1);

void maxself(int &a,int b)
{a=max(a,b);}
void minself(int &a,int b)
{a=min(a,b);}

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

//	freopen("name.in","r",stdin);
//	freopen("name.out","w",stdout);
	int a,b;
	cin >> a >> b;
	for(int i=0;i<=1250;i++)
	{
		int xb = i*0.1;
		int xa = i*0.08;
		if(xa == a and xb == b)
		{
			cout << i;
			return 0;
		}
	}
	cout << -1;
	return 0;
}



Measured memory_bytes: 256
require 'time'

def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def factorial(n)(n < 2)? 1 : (2..n).inject(:*) end

def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def yn(f) return (f)? "Yes": "No" end

def ynb(f) return (f)? "YES": "NO" end

def ap(a) a.each{|u| p u} end

def bit(n) n.to_s(2).split("").map(&:to_i) end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

n = inp[0]#k,f = inp
v = inpf
(n-1).times do
  v.sort!
  a = v.shift
  b = v.shift
  v.push((a+b)/2)
end
p v[0]
#puts ()? "Yes" : "No"
#puts ()? "YES" : "NO"
#puts ()? "yes" : "no"

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int a,b; cin >> a >> b;
  int ans = a-2*b;

  if(ans<0) ans = 0;

  cout << ans << endl;

  return 0;
}


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

int main() {
  ll h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];

  auto is_range = [&](int x, int y) {
    return (0 <= x) && (x < h) && (0 <= y) && (y < w);
  };

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

  vector<vector<int>> d(h, vector<int>(w, -1));

  queue<P> q;
  rep(i, h) rep(j, w) {
    if (s[i][j] == '#') {
      q.push(P(i, j));
      d[i][j] = 0;
    }
  }

  while (!q.empty()) {
    int cx = q.front().first, cy = q.front().second;
    q.pop();
    rep(i, 4) {
      int nx = cx + dx[i], ny = cy + dy[i];
      if (is_range(nx, ny) && d[nx][ny] == -1) {
        d[nx][ny] = d[cx][cy] + 1;
        q.push(P(nx, ny));
      }
    }
  }

  int ans = 0;
  rep(i, h) rep(j, w) ans = max(ans, d[i][j]);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 17228
#include <iostream>
using namespace std;
 
bool match(string s, string t, int j){
	for (int i=0; i<t.length(); i++){
		if (s[j+i]!='?' and s[j+i]!=t[i]) {
				return false;
		}
	}
	return true;
}
 
 
int main() {
	string s, t;
	cin>> s>>t;
	bool matched = false;
	int point = -1;
	for (int i=s.length()-t.length(); i>=0; i--){
		if (match (s, t, i)) {
			matched = true;
			point = i;
			break;
		}
	}
	if (matched==true){
		for (int j=point; j<t.length()+point; j++) s[j]=t[j-point];
			for (int j=0; j<s.length(); j++) if (s[j]=='?') s[j]='a';
			cout << s;
			return 0;
	}
	else cout << "UNRESTORABLE\n";
}


Measured memory_bytes: 3124
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
//#include <unordered_map>
//#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()

//typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18; // segment tree size
const ll MOD = 998244353;
const int INF = 0x3f3f3f3f; // memset(dp, 0x3f, sizeof(dp)), 2*INF < INT_MAX
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10; // double EPS

ll mul_inv(ll a, ll b = MOD) {
	ll t1 = a, t2 = b, t3;
	ll v1 = 1, v2 = 0, v3;
	while (t2 != 1) {
		ll x = t1 / t2;
		t3 = t1 - x*t2;
		v3 = v1 - x*v2;
		t1 = t2, t2 = t3;
		v1 = v2, v2 = v3;
	}
	return (v2 + b) % b;
}
ll F[300050];
ll Finv[300050];
ll Co(ll a, ll b) {
	ll rv = F[a] * Finv[b] % MOD;
	return rv * Finv[a - b] % MOD;
}
int main() {
	ll N, A, B, K, i;
	scanf("%lld %lld %lld %lld", &N, &A, &B, &K);

	F[0] = 1;
	for (i = 1; i <= 300000; i++) F[i] = F[i - 1] * i % MOD;
	for (i = 0; i <= 300000; i++) Finv[i] = mul_inv(F[i]);

	ll ans = 0;
	for (i = 0; i <= N; i++) {
		ll c = K - A * i;
		if (c < 0 || c % B) continue;
		ll v = c / B;
		if (v < 0 || v > N) continue;

		ll a = Co(N, i) * Co(N, v) % MOD;
		ans = (ans + a) % MOD;
	}
	return !printf("%lld\n", ans);
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

void dfs(vector<vector<ll>> &p, vector<ll> &oyaa,ll &ans,ll now,ll oyan, vector<ll> &ansoyaa,ll nnow,ll node,ll &nownode) {
    if (nownode <= node)return;
    if (oyaa[now] != -1 && nownode > node) {
        oyaa[now] = oyan;
        ans = now;
        nownode = node;
        for (int i = 0; i < oyaa.size(); i++) {
            ansoyaa[i] = oyaa[i];
        }
        oyaa[now] = -1;
        return;
    }
    oyaa[now] = oyan;
    for (int i = 0; i < p[now].size(); i++) {
        dfs(p, oyaa, ans, p[now][i], now,ansoyaa,nnow,node+1,nownode);
    }
    oyaa[now] = -1;
    return;
}

int main() {
    ll n,a,b;
    cin >> n >> a >> b;
    a = a - b;
    vector<ll> z(n);
    for (int i = 0; i < n; i++) {
        cin >> z[i];
    }
    ll ok = 1000000000;
    ll ng = 0;
    while(abs(ok-ng)>1){
        ll mid = (ok + ng) / 2;
        vector<ll> zz(n);
        for (int i = 0; i < n; i++) {
            zz[i]= z[i];
            zz[i] -= b * mid;
            ll za = 0;
            zz[i] = max(zz[i], za);
        }
        ll ans = 0;
        for (int i = 0; i < n; i++) {
            ans += (zz[i] + a - 1) / a;
        }
        if (ans <= mid)ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}

Measured memory_bytes: 1792
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
Ai= [input().split() for l in range(N)]
count=0
for i in range(N):
    tot=0
    for j in range(M):
        tot+=int(Ai[i][j])*B[j]
    if tot+C>0:
        count+=1  
print(count)

Measured memory_bytes: 9232
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, M, C;
	cin >> N >> M >> C;
	int a[30],b[30];
	int count = 0;
	for (int i = 0; i < M; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < N; i++) {
		int sum = 0;
		for (int j = 0; j < M; j++) {
			cin >> a[j];
			sum += a[j] * b[j];
		}
		sum += C;
		if (sum > 0) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

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

#define mp(x,y) make_pair(x,y)
const int MAXN=2e5+5;

int n,r1,r2,ecnt;
int ans[MAXN],siz[MAXN],ban[MAXN*4];
int head[MAXN],cnt;
struct node{
    int v,id,nxt;
}E[MAXN*4];

void addedge(int u,int v,int id){
    E[++cnt]=(node){v,id,head[u]};
    head[u]=cnt;
}

void dfs(int u,int fa=0){
    for(int i=head[u];i;i=E[i].nxt){
        int v=E[i].v;
        if(v==fa) continue;
        dfs(v,u);
        siz[u]++;
    }
}

void sol(int u){
    for(int &i=head[u];i;i=E[i].nxt){
        int v=E[i].v,id=E[i].id;
        if(ban[id]) continue;
        ban[id]=1;
        if(v==u-n) ans[v]=-1;
        else if(v==u+n) ans[u]=1;
        sol(v);
    }
}

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int x;
        scanf("%d",&x);
        if(x==-1) r1=i;
        else{
            addedge(x,i,++ecnt);
            addedge(i,x,ecnt);
        }
    }
    for(int i=1;i<=n;i++){
        int x;
        scanf("%d",&x);
        if(x==-1) r2=i+n;
        else{
            addedge(x+n,i+n,++ecnt);
            addedge(i+n,x+n,ecnt);
        }
    }
    dfs(r1);
    dfs(r2);
    for(int i=1;i<=n;i++){
        if((siz[i]&1)!=(siz[i+n]&1)) return puts("IMPOSSIBLE"),0;
        if(!(siz[i]&1)){
            addedge(i,i+n,++ecnt);
            addedge(i+n,i,ecnt);
        }
    }
    addedge(r1,2*n+1,++ecnt),addedge(2*n+1,r1,ecnt);
    addedge(r2,2*n+1,++ecnt),addedge(2*n+1,r2,ecnt);
    sol(2*n+1);
    puts("POSSIBLE");
    for(int i=1;i<=n;i++)
        printf("%d ",ans[i]);
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

vector<pair<int,int>> factorize(int n) {
    vector<pair<int,int>> factors;
    
    int c = 0;
    while (n % 2 == 0) {
        n /= 2;
        c++;
    }
    if (c != 0)
        factors.push_back(make_pair(2, c));

    for (int p = 3; p <= n; p += 2) {
        int c = 0;
        while (n % p == 0) {
            n /= p;
            c++;
        }
        if (c != 0)
            factors.push_back(make_pair(p, c));
    }
    if (factors.size() == 0 && n >= 2)
        factors.push_back(make_pair(n, 1));
    
    return factors;
}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N; cin >>N;
    int ans = 0;

    for (int i = 2*2*2*3+1; i <=N; i+=2) {
        vector<pair<int,int>> factors = factorize(i);
        int n_divisor = 1;
        for (auto factor: factors)
            n_divisor *= (factor.second+1);
        if (n_divisor == 8)
            ans++;
    }

    cout << ans << endl;
}


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

int n;
vector<int>L(5);
int ans=1<<30;
vector<int>l(10);
vector<int>R(10);

void cal(void){
  vector<int>check(11,0);
  for(int i=0;i<n;i++){
    check.at(R.at(i))++;
  }
  if(check.at(1)==0||check.at(2)==0||check.at(3)==0){
    return;
  }
  int mp=0;
  for(int i=1;i<=3;i++){
    int len=0;
    mp-=10;
    for(int j=0;j<n;j++){
      if(R.at(j)==i){
        len+=l.at(j);
        mp+=10;
      }
    }
    mp+=abs(len-L.at(i));
  }
  ans =min(mp,ans);
}
      

void dfs(int d){
  if(d==n){
    cal();
    return ;
  }
  R.at(d)=1;dfs(d+1);
  R.at(d)=2;dfs(d+1);
  R.at(d)=3;dfs(d+1);
  R.at(d)=4;dfs(d+1);
}

int main() {
  cin>>n;
  cin >>L.at(1)>>L.at(2)>>L.at(3);
  for(int i=0;i<n;i++){
    cin >>l.at(i);
  }
  dfs(0);
  cout <<ans;
}

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

typedef long long LL;
using namespace std;
const int mod = 1e9 + 7, maxn = 2e5 + 10;
#define pb push_back

int read()
{
	int x = 0, f = 1; char c = getchar();
	while(!isdigit(c)) { if(c == '-') f = 0; c = getchar(); }
	while(isdigit(c)) { x = (x << 3) + (x << 1) + (c ^ 48); c = getchar(); }
	return f ? x : -x;
}

int fix, top, sta[maxn], xz[maxn], f[maxn], vis[maxn], fac[maxn], ifac[maxn], inv[maxn], zj[maxn];
vector<int> vec, G[maxn], E[maxn];

void dfs(int u, int fa)
{
	vis[u] = 1; if(!fix) sta[++top] = u;
	vec.pb(u);
	for(int i = 0; i < G[u].size(); ++i)
	{
		int v = G[u][i]; if(v == fa) continue;
		if(vis[v]) 
		{
			int tmp = top; top = 0;
			while(tmp)
			{
				zj[++top] = sta[tmp];
				if(sta[tmp] == v) break;
				tmp--;
			}
			swap(zj, sta);
			fix = 1;
		}
		else dfs(v, u), f[v] = u;
	}
	if(sta[top] == u && !fix) --top;
}

void Dfs(int u, int fa)
{
	f[u] = fa;
	for(auto v : G[u]) if(v != fa) Dfs(v, u);
}

inline int C(int N, int M) { return (LL)fac[N] * ifac[M] % mod * ifac[N - M] % mod; }

int dfs1(int u)
{
	xz[u] = 1; int sum = 0, ans = 1;
	for(auto v : E[u])
	{
		ans = (LL)ans * dfs1(v) % mod * C(sum + xz[v], xz[v]) % mod;
		xz[u] += xz[v]; sum += xz[v];
	}
	return ans;
}

int main()
{
	int n = read();

	inv[0] = inv[1] = ifac[0] = ifac[1] = fac[0] = fac[1] = 1;
	for(int i = 2; i <= 2 * n + 5; ++i)
	{
		fac[i] = (LL)fac[i - 1] * i % mod;
		inv[i] = (LL)(mod - mod / i) * inv[mod % i] % mod;
		ifac[i] = (LL)ifac[i - 1] * inv[i] % mod;
	}

	for(int i = 1; i <= 2 * n; ++i)
	{
		int x = read(), y = read() + n;
		//cout << x << ' ' << y << endl;
		G[x].pb(y); G[y].pb(x);
	}
	for(int i = 1; i <= 2 * n; ++i) if(!G[i].size()) { puts("0"); return 0; };

	int Ans = 1, xhb = 0;
	for(int i = 1; i <= 2 * n; ++i) if(!vis[i])
	{
		top = 0; fix = 0; vec.clear(); int now = 0;
		dfs(i, 0);

		for(int j = 1; j <= top; ++j)
			for(auto k : G[sta[j]]) if(k != sta[(j - 1) == 0 ? top : j - 1] && k != sta[j == top ? 1 : j + 1])
				Dfs(k, sta[j]);
		if(top) { f[sta[1]] = sta[top]; }

		for(auto j : vec) E[j].clear(), xz[j] = 0;
		for(auto j : vec) if(f[j])
			for(auto k : G[j])
				if(k < f[j]) E[j].pb(k), xz[k] = 1;//, cout << k << ' ' << j << endl;
		int sum = 0, ans = 1;
		for(auto j : vec) if(!xz[j]) 
			ans = (LL)ans * dfs1(j) % mod * C(sum + xz[j], xz[j]) % mod, sum += xz[j];
		(now += ans) %= mod;

		if(top)
		{
			f[sta[top]] = sta[1];
			for(int j = top - 1; j >= 1; --j) f[sta[j]] = sta[j + 1];
			for(auto j : vec) E[j].clear(), xz[j] = 0;
			for(auto j : vec) if(f[j])
				for(auto k : G[j])
					if(k < f[j]) E[j].pb(k), xz[k] = 1;
			sum = 0, ans = 1;
			for(auto j : vec) if(!xz[j]) ans = (LL)ans * dfs1(j) % mod * C(sum + xz[j], xz[j]) % mod, sum += xz[j];
			(now += ans) %= mod;
		}

		Ans = (LL)Ans * now % mod * C(xhb + vec.size(), xhb) % mod;
		xhb += vec.size();
	}
	cout << Ans << endl;

	return 0;
}

Measured memory_bytes: 28280
#include <iostream>
#include <algorithm>


#define FOR(i,a,b) for(long long int i =(a); i <(b);i++)
#define REP(i,N)   FOR(i,0,N)
#define debug(x)   cout << #x << " = " << x << endl;

using namespace std;

int main(void){

    string str;
    cin >> str;

    int indA = str.find('A');

    reverse(str.begin(),str.end());

    int indZ = str.size() - str.find('Z');

    cout << indZ - indA << endl;

    
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int main() {
  int time,hour,min,sec,damy;

  scanf("%d", &time);

  hour = time / 3600;
  damy = time % 3600;
  min = damy / 60;
  sec = damy % 60;

  printf("%d:%d:%d\n", hour, min, sec);

  return 0;
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
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;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    int k,n;
    cin >> k >> n;
    int a[n];
    rep(i,n) cin >> a[i];

    int x = 0;
    int y = n-1;
    int ans = a[y]-a[x];

    for(int i=1;i<n-1;i++){
        ans = min(ans,k-a[i]+a[i-1]-x);
        ans = min(ans,a[i]-x+k-a[i+1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

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; }

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/
ll cnt[10][10] = {};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin>>N;
    rep1(i,N+1){
        string S = to_string(i);
        int t = S[0] - '0';
        int b = S[(int)S.size() - 1] - '0';
        cnt[t][b]++;
    }
    ll ans = 0;
    rep1(i,10)rep1(j,10){
        //if(i > j)continue;
        ans += cnt[i][j] * cnt[j][i];
    }
    /*
    rep1(i,10)rep1(j,10){
        if(cnt[i][j])cerr<<i<<", "<<j<<": "<<cnt[i][j]<<endl;
    }*/
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
using namespace std;
using ll = long long;

const int MAX = 1000000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

int main()
{

  //cout << fixed << setprecision(10);
  
  string s; cin >> s;
  int ans=700;
  rep(i,s.size()){
    if (s[i]=='o'){ans+=100;}
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#define BUFFER_SIZE 1024

int bfs(int sx,int sy);
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

struct queue {
    int buffer[BUFFER_SIZE];
    int head;
    int tail;
};

void init(struct queue *q)
{
    q->head = 0;
    q->tail = -1;
}

void enqueue(struct queue *q, int x)
{
    if (q->head == q->tail) {
        fprintf(stderr, "queue is full\n");
        exit(1);
    }

    q->buffer[q->head] = x;
    q->head = (q->head + 1) % BUFFER_SIZE;
}

int dequeue(struct queue *q)
{
    int t = (q->tail + 1) % BUFFER_SIZE;
    if (q->head == t) {
        fprintf(stderr, "queue is empty\n");
        exit(1);
    }

    q->tail = t;
    return q->buffer[q->tail];
}


int map_d[32][32];
int map_a[32][32];
int map_b[32][32];
int w,h;

bool isOK(int sx,int sy,int nx,int ny){

  if(ny<0 || nx<0)return false;
  if(sx==nx){
    if(sy<ny){
      if(map_a[sx][sy]==0)return true;
    }
    else if(sy>ny){
      if(map_a[sx][ny]==0)return true;
    }
  }
  else{
    if(sx<nx){
      if(map_b[sx][sy]==0)return true;
    }
    else{
      if(map_b[nx][sy]==0)return true;
    }
  }
  return false;
}
//---->x
//|
//|
//y
int main(){

 
  for(;;){
    
    for(int i=0;i<32;i++){
      for(int j=0;j<32;j++){
	map_d[i][j]=100000;
	map_a[i][j]=1;
	map_b[i][j]=1;
      }
    }
    map_d[0][0]=0;
     

    scanf("%d %d",&w,&h);
    if(w==0)return 0;
    //??\???
    for(int i=0;i<h-1;i++){
      for(int j=0;j<w-1;j++){scanf("%d",&map_a[i][j]);}
      for(int j=0;j<w;j++){scanf("%d",&map_b[i][j]);}
    }
    for(int j=0;j<w-1;j++){scanf("%d",&map_a[h-1][j]);}

    bfs(0,0);

    if(map_d[h-1][w-1]==100000)
      printf("0\n");
    else
      printf("%d\n",map_d[h-1][w-1]+1);
    

  }

}


int bfs(int sx,int sy){
  struct queue q;
  
  init(&q);
  enqueue(&q,sx);
  enqueue(&q,sy);

  
  while (q.head != (q.tail + 1) % BUFFER_SIZE) {

    int x,y;
    
    x=dequeue(&q);
    y=dequeue(&q);
    if(x==w-1 && y == h-1)return 0;
      
    for(int i=0;i<4;i++){
      int nx = x+dx[i],ny=y+dy[i];
      if(!isOK(x,y,nx,ny) || map_d[nx][ny]!=100000){continue;}
      if(map_d[nx][ny]>map_d[x][y]+1)map_d[nx][ny]=map_d[x][y]+1;
      enqueue(&q,nx);
      enqueue(&q,ny);
    }
  }

}

Measured memory_bytes: 1208
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <cassert>
#include <stack> 

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define PI acos(-1.0)
#define MAXLEN 29

typedef std::pair <int, int> pii;
typedef long long ll;
typedef std::vector <ll> vll;

using namespace std;

int n;
ll a[10000];
ll b[10000];
ll x, y;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	for (int i = 0; i < n; i++) {
		if (a[i] > b[i]) x += a[i] - b[i];
		else y += (b[i] - a[i]) / 2;
	}
	if (x > y) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	int N;

	cin >> N;

	cout << (N%2 ==0?N:N*2) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
	FastIO
	lld n, i;
	cin >> n;
	string s;
	cin >> s;
	lld c = 0;
	for(i = 1; i < n; i+=1)
	{
		if (s[i]!=s[i-1])
		{
			c+=1;
		}
	}
			c+=1;
	cout <<c;
	return 0;
}

Measured memory_bytes: 512
import sys

input = sys.stdin.readline

a = [list(map(int, input().split())) for _ in range(3)]
marked = [[False, False, False] for _ in range(3)]

Q = int(input())
for i in range(Q):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                marked[j][k] = True
                
for i in range(3):
    if marked[i][0] == marked[i][1] == marked[i][2] == True:
        print("Yes")
        exit()
    if marked[0][i] == marked[1][i] == marked[2][i] == True:
        print("Yes")
        exit()
if marked[0][0] == marked[1][1] == marked[2][2] == True:
    print("Yes")
    exit()
if marked[0][2] == marked[1][1] == marked[2][0] == True:
    print("Yes")
    exit()
print("No")


Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
antena = []
for _ in range(5):
	antena.append(int(input()))
k = int(input())
for i in range(5):
	for j in range(i,5):
		if antena[j] - antena[i] > k:
			print(':(')
			exit()
print('Yay!')

Measured memory_bytes: 38256
import java.util.*;
import java.io.*;

public class Main{
	static class FastReader {

        BufferedReader br;
        StringTokenizer st;

        private FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

	 int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
	}

	int[] nextIntArrayOne(int n) {
				int[] a = new int[n+1];
				for (int i = 1; i < n+1; i++)
					a[i] = nextInt();
				return a;
	}

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

	public static void main(String[] args) {
		FastReader s =new FastReader();
		
		StringBuilder str = new StringBuilder();
		
			int n = s.nextInt();
			if(n >= 30) {
				str.append("Yes\n");
			}else {
				str.append("No\n");
			}
			
		
		System.out.println(str);
	}

	

}



Measured memory_bytes: 32760
#include <iostream>

using namespace std;

const long long MOD = 1e9 + 7;

int main(){
	long long N, K;
	cin >> N >> K;

	long long ans = 0;
	for (long long k = K; k <= N + 1; k++){
		long long temp = (2 * N - k + 1) * k / 2 - k * (k - 1) / 2;
		// cerr << k << " " << temp << endl;
		ans += temp + 1;
		ans %= MOD;
	}

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


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

using namespace std;

int main()
{
   int P, Q, R;
   int sum = 0;

   cin >> P >> Q >> R;

   if (P > Q) {
       if (P > R) {
           sum = Q + R;
       } else {
           sum = P + Q;
       }
   } else {
       if (Q > R) {
           sum = P + R;
       } else {
           sum = P + Q;
       }
   }
   cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int N = sc.nextInt();
        int X = sc.nextInt();
        int T = sc.nextInt();

        int A;
        int B;
        int C;
      
        A=N/X;
        B=N%X;
        if(B==0){
        	C=A*T;
        } else {
        	C=(A+1)*T;
        }
      
      
        // 出力
        System.out.println(C);
    }
}

Measured memory_bytes: 35604
import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from decimal import Decimal


def main():
    x, n = map(int, input().split())
    p = list(map(int, input().split()))
    cand = []
    for i in range(102):
        cand.append(i)
    for i in range(len(cand)):
        for j in range(n):
            if cand[i] == p[j]:
                cand[i] = 100000
    mini = 100
    for i, c in enumerate(cand):
        if mini > abs(c-x):
            ans = i
            mini = abs(c-x)

    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  while(1) {
    int n;
    cin >> n;
    if(n == 0) break;

    int limit = 24*3600;
    int data[limit];
    for(int i = 0; i < limit; i++) {
      data[i] = 0;
    }

    for(int i = 0; i < n; i++) {
      int h, m, s;
      int ss, gs;
      scanf("%d:%d:%d", &h, &m, &s);
      ss = h*3600 + m*60 +s;
      scanf("%d:%d:%d", &h, &m, &s);
      gs = h*3600 + m*60 +s;
      for(int j = ss; j < gs; j++) {
	data[j]++;
      }
    }

    int max = -1;
    for(int i = 0; i < limit; i++) {
      if(data[i] > max) max = data[i];
    }

    cout << max << endl;
  }
  return 0;
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
#include <limits>
#include <math.h>
#include <cmath>
#include <cctype>
#include <cstdio>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll> ;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vvll = vector<vector<long long >>;
#define PI  3.1415926535
#define rep(i, k, n) for(ll i = k; i < n; i++)

int main(){
  ll n, k;
  cin >> n >> k;
  
  vll okashi (n+1, 0);
  
  rep(i, 0, k){
    ll d; cin >> d;
    rep(j, 0, d){
      ll a; cin >> a;
      okashi[a]++;
    }
  }
  
  ll ans = 0;
  rep(i, 1, n+1){
    if(okashi[i] == 0){ans++;}
  }
  
  cout << ans << endl;
}






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

namespace ConsoleApp4
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			var q = from a in Console.ReadLine().Split(' ')
					select long.Parse(a);
			var aList = q.ToList();

			// X(i) + X(i+1) = 2A(i)
			// X(1) + X(2) = 2A(1), X(3) + X(4) = 2A(3), X(5) + X(6) = 2A(5), ...

			// A(0) + ... + A(N-1) = X(0) + ... X(N-1) = S
			// X(0) = S - ((X(1) + X(2)) + (X(3) + X(4)) + ... (X(N-2) + X(N-1)))
			// X(0) = S - (2A(1) + 2A(3) + ... 2A(N-2))
			// X(0) = S - 2(A(1) + A(3) + ... A(N-2))

			var xList = new List<long>(n);
			long x1 = aList.Sum();
			for (int i = 1; i < n - 1; i++)
			{
				if ((i % 2) == 1)
				{
					x1 -= (2 * aList[i]);
				}
			}
			xList.Add(x1);

			// X(i+1) = 2A(i) - X(i)
			for (int i = 0; i < n - 1; i++)
			{
				xList.Add(2 * aList[i] - xList[i]);
				Console.Write(xList[i] + " ");
			}
			Console.WriteLine(xList.Last());
		}
	}
}


Measured memory_bytes: 32340