akhauriyash/Code-Regression huggingface dataset:
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let A = cin.getInt(), B = cin.getInt(), T = cin.getInt();
    let ans = 0;
    while (T >= A) {
        T -= A;
        ans += B;
    }
    console.log(ans);
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21956
n = int(input())
h = list(map(int,input().split()))
lim = h[0]
k = 0
for i in range(1,n-1):
  i = n - i
  if h[i] - h[i-1] < -1:
    k = -1
  elif h[i] - h[i-1] == -1:
    h[i-1] -= 1
if k == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 14396
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i,n) for(int i=0;i<n;i++)
#define unsigned long ul
using namespace std;

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int n;
       cin >> n;
    int max = 0;
    int count = 0;
    REP(i, n){
        int s;
        cin >> s;
        if(s>=max){
            max = s;
            count++;
        }
    }
    cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
//#define all(v) ((v).begin(),(v).end())
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
    int h,w;
    cin>>h>>w;
    vector<vector<char>> v(h,vector<char>(w));
    vector<int> tate,yoko;
    rep(i,0,h)rep(j,0,w){
        cin>>v[i][j];
        if(v[i][j]=='#'){
            tate.pb(i);
            yoko.pb(j);
        }
    }

    rep(i,0,h){
        rep(j,0,w){
            if(find(all(tate),i)!=tate.end()&&find(all(yoko),j)!=yoko.end()){
                cout<<v[i][j];
            }
        }
        if(find(all(tate),i)!=tate.end())cout<<endl;
    }


    
}


Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<random>
#include<bitset>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++) //0から
#define REP(i,n) for(int j=i;j<n;j++) //iから

typedef long long ll;



//英字ならture、数字ならfalse
bool isalpha(char s){
    if(('A'<=s&&s<='Z')||('a'<=s&&s<='z')){
        return 1;
    }else{
        return 0;
    }
}
//全ての文字が英字ならture、数字ならfalse
bool Isalpha(string s){
    ll n;
    bool tmp = true;
    rep(i,n){
        if(isalpha(s[i])){
            tmp = false;
        }
    }
    return tmp;
}




using Graph = vector<vector<ll>>;



//cout<<fixed<<setprecision(10);

ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

ll MIN(ll a, ll b){
    ll tmp;
    if(a<b){
        tmp = a;
    }
    else{
        tmp = b;
    }
    return tmp;
}

ll MAX(ll a, ll b){
    ll tmp;
    if(a<b){
        tmp = b;
    }
    else{
        tmp = a;
    }

    return tmp;
}

int main(){
    int x,n;
    cin>>x>>n;
    if(n==0){
        cout<<x<<endl;
        return 0;
    }
    vector<int> p(n);
    vector<bool> b(101,true);
    rep(i,n){
        cin>>p[i];
        b[p[i]] = false;
    }

    int l = abs(x+1), ans;
    for(int i = 0; i < 102; i++){
        if(b[i]){
            if(abs(x-i)<l){
                ans = i;
                l = abs(x-i);
            }
        }
    }

    cout<<ans<<endl;

    return 0;
}



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

#define mp make_pair
#define pb push_back
#define fill(a) memset(a,0,sizeof(a))

typedef long long ll;
typedef long double ld;




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

    int n; cin>>n;

    int ans = 0;
    int q = 7;

    int x = n%2;
    if(x==0 || n%5==0)
    {
        cout<<-1<<"\n";
    }

    else
    {
        while(q%n)
        {
            q = q%n;
            ans++;
            q = (q%n)*10 + 7;
        }
        cout<<ans+1<<"\n";
    }
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int cnt=0;
    rep(i,s.size()){
        if(s[i]=='1'){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

int main(){
  string s,t,u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  if ( u == s){
    cout << a - 1 << " " << b << endl;
  } else {
    cout << a  << " " << b-1 << endl;
  }

  return 0;
}

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

namespace Maxflow{
const long long maxn=1111;
const long long maxm=666666;
const long long inf=10000000000000LL;

long long g[maxn],to[maxm],np[maxm],cp;
long long n,u,v,now,source,sink;
long long sum,cap[maxm],a[maxn];
long long d[maxn],p[maxn],cur[maxn],cnt[maxn];

void add_edge(long long x,long long y,long long z){
//    prlong longf("%d - %d: %d\n",x,y,z);
    cap[cp]=z;to[cp]=y;np[cp]=g[x];g[x]=cp++;cap[cp]=0;to[cp]=x;np[cp]=g[y];g[y]=cp++;
}

void init(){
    cp=2; memset(g,0,sizeof(g));
}
long long maxflow(){
    sum=0;
    for(u=1;u<=n;u++)cur[u]=g[u]; a[u=source]=inf; memset(d,0,sizeof(long long)*(n+1)); memset(cnt,0,sizeof(long long)*(n+1)); cnt[0]=n;
    while(d[source]<n)
    {
        for(now=cur[u];now;now=np[now])if(cap[now]&&d[v=to[now]]+1==d[u])break; cur[u]=now;
        if(now)
        {
            p[v]=now; a[v]=cap[now]; if(a[v]>a[u])a[v]=a[u];
            if((u=v)==sink)
            {
                do{cap[p[u]]-=a[sink]; cap[p[u]^1]+=a[sink]; u=to[p[u]^1];}while(u!=source);
                sum+=a[sink]; a[source]=inf;
            }
        }
        else
        {
            if(--cnt[d[u]]==0)break; d[u]=n; cur[u]=g[u];
            for(now=g[u];now;now=np[now]) if(cap[now] && d[u]>d[to[now]]+1) d[u]=d[to[now]]+1;
            cnt[d[u]]++;
            if(u!=source)u=to[p[u]^1];
        }
    }
//    prlong longf("maxflow\n");
    return sum;
}
}

int n;
int a[111];

long long tot;

int main() {
	scanf("%d", &n);
	tot = 0;
	for(long long i=1;i<=n;i++) {
		scanf("%d", &a[i]);
		tot += a[i];
		if (a[i]<0) tot += (-a[i]);
	}
	
	Maxflow::init();
	for(long long i=1;i<=n;i++)
		for(long long j=i*2;j<=n;j+=i)
			Maxflow::add_edge(j, i, Maxflow::inf);
	Maxflow::n = n+2;
	Maxflow::source = 0;
	Maxflow::sink = n+1;
	for(long long i=1;i<=n;i++) {
		if(a[i]>0) Maxflow::add_edge(0, i, a[i]);
		if(a[i]<0) Maxflow::add_edge(i, n+1, -a[i]);
	}
	long long flow = Maxflow::maxflow();
	printf("%lld\n", tot - flow);
	
	return 0;
}

Measured memory_bytes: 4352
#include <stdio.h>

int ii[2500],ji[2500],t=1;
void pop(void);

int main(void){
  const int inf=10000000;
  int h,w,i,j,g[55][55],ans=0;
  int iw[4]={1,0,-1,0},jw[4]={0,1,0,-1};
  char c;
  bool tu[55][55]={false},end=false;
  scanf("%d%d\n",&h,&w);
  ii[0]=1;
  ji[0]=1;
  for (i=0;i<h;i++){
    for (j=0;j<w;j++){
      scanf("%c",&c);
      if (c=='.'){
        ans++;
        tu[i+1][j+1]=true;
      }
    }
    scanf("\n");
  }
  for (i=0;i<h;i++){
    for (j=0;j<w;j++){
      g[i+1][j+1]=inf;
    }
  }
  g[1][1]=1;
  while (t){
    int ai,aj,ni,nj;
    ai=ii[0];
    aj=ji[0];
    pop();
    for (i=0;i<4;i++){
      ni=ai+iw[i];
      nj=aj+jw[i];
      if (tu[ni][nj]&&g[ni][nj]==inf){
        g[ni][nj]=g[ai][aj]+1;
        if (ni==h&&nj==w){
          end=true;
          break;
        }
        ii[t]=ni;
        ji[t]=nj;
        t++;
      }
    }
    if (end) break;
  }
  printf("%d\n",(end)? ans-g[h][w]:-1);
  return 0;
}

void pop(void){
  int i;
  t--;
  for (i=0;i<t;i++){
    ii[i]=ii[i+1];
    ji[i]=ji[i+1];
  }
  return;
}

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

N_1 = n - 1
ans = 0
i = 1
j = 1
while i <= N_1:
    while j <= N_1:
        if i * j <=  N_1:
            ans += 1
        else:
            j = N_1
        j = j + 1
    j = 1
    i = i + 1

print(ans)

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

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

  int ub= min(N+1, INT_MAX);
  int lb= K;
  double Dnumer;
  double Ddenom= 1.0*(double)N;
  double ans= 0.0;
  while(!(ub==1 && lb==1)){
    int Nlen= max(ub-lb, 0);
    Dnumer= (double)Nlen;

    ans+= Dnumer/ Ddenom;

    ub= min(N+1, lb);
    lb= (lb+1)/2;
    Ddenom*= 2.0;
  }

  cout << fixed;
  cout << setprecision(9) << ans << endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	string s;
	cin >> s;
	vector<long long int>by(s.size() + 1,1);
	for (int i = 1; i <= s.size(); i++) {
		by[i] = by[i - 1] * 10;
		by[i] %= 13;
	}
	reverse(s.begin(), s.end());
	vector<long long int>dp(13);
	dp[0] = 1;
	for (int i = 0; i < s.size(); i++) {
		vector<long long int>box(13);
		if (s[i] == '?') {
			for (int j = 0; j < 10; j++) {
				for (int k = 0; k < 13; k++) {
					box[(k + j * by[i]) % 13] += dp[k];
				}
			}
		}
		else {
			for (int k = 0; k < 13; k++) {
				box[(k + (s[i] - '0')*by[i]) % 13] += dp[k];
			}
		}
		for (auto &j : box)j %= MOD;
		dp = box;
	}
	cout << dp[5] << endl;
}


Measured memory_bytes: 1232
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <stack>
#include <map>
#include <iomanip>
using namespace std;

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

const int MAX = 510000;
const int MOD = 1000000007;

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

int divide(int a){
    int ans = 0 ;
    while (1)
    {
        if (a%2 == 0)
        {
            ans ++ ;
            a /= 2 ;
        }else
        {
            return ans ;
        }
        
        
    }
    
}


int main(){
    int n ;
    cin >> n ;
    int a ;
    int ans = 100 ;
    for (int i = 0; i < n; i++)
    {
        cin >> a ;
        ans = min(ans,divide(a)) ;
    }
        
    cout << ans << endl ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1e9+7;
const int INF=1001001001;
int64_t dp[3005][3005][5];
int main() {
  int R,C,K;
  cin>>R>>C>>K;
  vector<vector<int>>val(R,vector<int>(C));
  for(int i=0;i<K;i++){
    int r,c,v;
    cin>>r>>c>>v;
    r--;c--;
    val[r][c]=v;
  }
  for(int i=0;i<R;i++){
    for(int j=0;j<C;j++){
      for(int k=2;k>=0;k--){
        chmax(dp[i][j][k+1],dp[i][j][k]+val[i][j]);
      }
      for(int k=0;k<=3;k++){
        chmax(dp[i+1][j][0],dp[i][j][k]);
        chmax(dp[i][j+1][k],dp[i][j][k]);
      }
    }
  }
  int64_t MAX=0;
  for(int k=0;k<=3;k++){
    chmax(MAX,dp[R-1][C-1][k]);
  }
  cout<<MAX<<endl;
  return 0;  
}

Measured memory_bytes: 390504
#include <stdio.h>

int main(void) {
	char a, b;
	
	scanf("%c %c", &a, &b);
	
	if ((a == 'H' && b == 'H') || (a == 'D' && b == 'D')) {
		printf("H");
	} else {
		printf("D");
	}
	
	return 0;
}

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


int main()
{
	int A, B;
	cin >> A >> B;
	if (A <= 5)
		cout << 0 << endl;
	else if (A <= 12)
		cout << B / 2 << endl;
	else
		cout << B << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main() {
  uint32_t N = 0, Q = 0;
  std::string S;
  std::cin >> N >> Q >> S;

  std::vector<uint32_t> AC(N);
  uint32_t sum = 0;
  bool prevA = false;
  for (size_t i = 0; i < N; i++) {
    if (prevA && S[i] == 'C') sum++;
    prevA = (S[i] == 'A');
    AC[i] = sum;
  }

  for (size_t i = 0; i < Q; i++) {
    uint32_t l = 0, r = 0;
    std::cin >> l >> r;
    std::cout << AC[r - 1] - AC[l - 1] << std::endl;
  }

  return 0;
}

Measured memory_bytes: 1408
import java.util.*;
import java.awt.geom.*;

import static java.lang.Math.*;
public class Main {
	final Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main().init();
	}
	void init(){
		new AOJ1268();
	}
	class AOJ1268{
		AOJ1268(){
			while(sc.hasNext()){
				initEmpX = sc.nextInt();
				initEmpY = sc.nextInt();
				if((initEmpX|initEmpY)==0)	break;
				--initEmpX;
				--initEmpY;
				solve();
			}
		}
		int initEmpX,initEmpY;
		int[] target, vtd;
		final int MAX = Integer.parseInt("1000000000", 7);
		final int[] vx={0,1,0,-1}, vy={-1,0,1,0};
		final int[][] dic = {{0,0,0,0}, {0,0,1,2}, {0,3,0,4}, {0,5,6,0}};
		void solve(){
			target = new int[9];
			for(int i=0; i<9; i++){
				String in=sc.next();
				int c=0;
				if(in.equals("W"))		c=1;
				else if(in.equals("B"))	c=2;
				else if(in.equals("R"))	c=3;
				target[i] = c;
			}
			
			int lower = -1, upper = 31, mid = 0;
			while(lower+1 < upper){
				mid = (lower+upper) / 2;
				int[] init = {1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3};
				init[(initEmpX+initEmpY*3)*2] = 0;
				init[(initEmpX+initEmpY*3)*2+1] = 0;
				if( DFS(init, 0, mid, initEmpX, initEmpY, -1))	upper = mid;
				else	lower = mid;
			}
			System.out.println( upper>30? -1 : upper);
		}
		
		boolean DFS(int[] dice, int depth, int lim, int ex, int ey, int lpos){
			int diff=0;
			for(int i=0; i<9; ++i)if( dice[i*2] != target[i] )	diff += 1;
			if(diff == 0)	return true;
			
			if(depth+diff-1 > lim)	return false;
			
			int epos = ex+ey*3;
			for(int v=0; v<4; ++v){
				int xx = ex+vx[v], yy = ey+vy[v];
				if( !(0<=xx && xx<3 && 0<=yy && yy<3) )	continue;
				int pos = xx+yy*3;
				if(pos == lpos)	continue;
				
				int top = dice[pos*2], front = dice[pos*2+1],
					newTop = 0, newFront = 0;
				if(vx[v] != 0){
					newTop = 6-(top+front);
					newFront = front;
				}else{
					newTop = front;
					newFront = top;
				}
				
				dice[pos*2] = 0;
				dice[pos*2+1] = 0;
				dice[epos*2] = newTop;
				dice[epos*2+1] = newFront;
				
				if( DFS(dice, depth+1, lim, xx, yy, epos) )	return true;
				
				dice[pos*2] = top;
				dice[pos*2+1] = front;
				dice[epos*2] = 0;
				dice[epos*2+1] = 0;
			}
			return false;
		}
		int getHash(int[] dice){
			StringBuilder tmp = new StringBuilder();
			for(int i=0; i<18; i+=2)	tmp.append(dic[dice[i]][dice[i+1]]);
			return Integer.parseInt(tmp.toString(), 7);
		}
	}
}

Measured memory_bytes: 21904
NT_in = input()
NT = NT_in.split()
N = int(NT[0])
T = int(NT[1])
d = {}
for i in range(N):
	str_num = input()
	num = str_num.split()
	d[int(num[0])] = int(num[1])
for c, t in sorted(d.items(), key=lambda x: x[0]):
	if t <= T:
		print(c)
		break
else:
	print("TLE")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
ll MOD = 1e9 + 7;
int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    vector<ll>a(n);
    ll s = 0;
    rep(i, n ){
        cin >> a[i];
        s+= a[i];
    }
    rep(i, n) {
        s -= a[i];
        ans += ((s%MOD)*a[i])%MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4820
#include <cstdio>

const int N = 1e3 + 5;

int n,t,a,x,ans;
double mi = 2000000000;

double abs(double x)
{
	return x > 0 ? x : -x;
}

int main()
{
	scanf("%d%d%d",&n,&t,&a);
	for (int i = 1 ; i <= n ; i++)
	{
		scanf("%d",&x);
		double p = t - x * 0.006;
		if (mi > abs(p - a)) mi = abs(p - a),ans = i;
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 128
import numpy as np

S = input()
N = len(S)

w_num_arr = np.zeros(N)
b_num_arr = np.zeros(N)


if S[-1] == "W":
    w_num_arr[-1] = 1

for i in range(N-1-1, -1, -1):
    if S[i] == "W":
        w_num_arr[i] = w_num_arr[i+1] + 1
    else:
        w_num_arr[i] = w_num_arr[i+1]

ans = 0
for i in range(N):
    if S[i] == "B":
        ans += int(w_num_arr[i])

print(ans)


Measured memory_bytes: 14568
while True:
    n = int(input())
    if n == 0:
        break
    pointA, pointB = 0, 0
    for i in range(n):
        cardA, cardB = map(int, input().split())
        if cardA == cardB:
            pointA += cardA
            pointB += cardB
        elif cardA > cardB:
            pointA += cardA + cardB
        else:
            pointB += cardA + cardB
    print(pointA, pointB)      

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

using namespace std;

struct Node{
    int key;
    Node *parent;
    Node *left;
    Node *right;
};

Node *nil, *root;

void insert(int a){
    Node *x = root;
    Node *y = nil; //xの親
    Node *z = (Node*)malloc(sizeof(Node));
    z->key = a;
    z->left = nil;
    z->right = nil;

    //zの親に適切なNodeを指定する
    while(x != nil){
        y = x;
        //根の値より大きいかどうかで根の位置をずらしていく。小さければ左。
        if(z->key < x->key){
            x = x->left; 
        }else if(x->key < z->key){
            x = x->right;
        }
    }
    z->parent = y;

    if(y == nil){
        root = z;
    }else if(z->key < y->key){
        y->left = z;
    }else{
        y->right = z;
    }
}

vector<int> in;
void inorder(Node *n){
    if(n == nil)return;
    inorder(n->left);
    in.push_back(n->key);
    inorder(n->right);
}

vector<int> pre;
void preorder(Node *n){
    if(n == nil)return;
    pre.push_back(n->key);
    preorder(n->left);
    preorder(n->right);
}

void print(){
    inorder(root);
    for(int i = 0; i < in.size(); i++){
        cout << " " << in[i];
    }
    cout << endl;
    preorder(root);
    for(int i = 0; i < pre.size(); i++){
        cout << " " << pre[i];
    }
    cout << endl;
    pre.clear();
    in.clear();
}

int main(void){
    int n;
    cin >> n;
    while(n--){
        string command;
        cin >> command;
        if(command == "insert"){
            int a;
            cin >> a;
            insert(a);
        }else{
            print();
        }
    }
}


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

typedef long long int ll;
typedef vector<int> vi;			typedef vector<ll> vl;
typedef vector<vi> vvi; 		typedef vector<vl> vvl;
typedef pair<int, int> 	pii;	typedef pair<ll, ll> pll;
typedef vector<pii> vii; 		typedef vector<pll> vll;
typedef map<int,int> mii;
typedef vector<char> vc;
typedef vector<bool> vb;
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define rforne(i,n) for(int i=n;i>=1;i--)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
const ll INFL = 1e18;
const int INFI = 1e9;
#ifdef KARAN
	#include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}
ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; 
	while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
void graph(vvi &adj, int m) {int x, y; forn(i, m){cin>>x>>y; adj[--x].pb(--y); adj[y].pb(x);}}

void solve(){
	int h, w, k;
	cin>>h>>w>>k;
	vector<string> a(h);
	forn(i, h) cin>>a[i];

	int cntr = 0;
	forn(i, h) forn(j, w) if(a[i][j]=='#') cntr++;
	k = cntr - k;

	int ans = 0;
	
	forn(i, 1<<h) forn(j, 1<<w){
		int curr = 0;
		forn(i1, h) forn(j1, w)
			if(i&(1<<i1)||j&(1<<j1))
				if(a[i1][j1]=='#') curr++;
		if(curr==k) ans++;
	}

	cout<<ans<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef KARAN
		freopen("inp.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    	freopen("err.txt", "w", stderr);
	#endif
	int t=1;
	// cin>>t;
	while(t--)
		solve();
}

Measured memory_bytes: 3652
fn b() {
    input! {
        k: usize,
        s: Chars
    }

    if s.len() > k {
        println!("{}...", s.into_iter().take(k).collect::<String>());
    }
    else {
        println!("{}", s.into_iter().collect::<String>());
    }
}

use proconio::{input, marker::Chars};

fn main() {
    b();
}

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

int main() {
    int n, k, j;
    double p[200010];
    double sum = 0;
    double max = 0;
    int place = 0;
    double ans = 0;
    
    cin >> n >> k;
    rep(i, n){
        cin >> p[i];
    }
    
    rep(i, n-k){
        sum = sum + p[i+k] - p[i];
        if(max < sum){
            max = sum;
            place = i+1;
        }
    }
    
    for(j=place; j<place + k; j++){
        ans += ((p[j] + 1) * 0.5);
    }
    
    //cout << ans << endl;
    printf("%.10f", ans);
    
    return 0;
}




Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 1555,mo=1e9+7,inv2=(mo+1)/2;
int n,a[N],cnt;ll f[N],g[N],h[N];
ll power(ll a, ll n){
	ll res=1;
	while(n){
		if(n&1)res=1LL*res*a%mo;a=1LL*a*a%mo;n>>=1;
	}
	return res;
}
int solve(int l, int r, int d){
	int k=++cnt,mn=2e9;rep(i,l,r)mn=min(mn,a[i]);
	Vi ch;int tot=0;rep(i,l,r)tot+=(a[i]==mn);
	rep(i,l,r)if(a[i]>mn){
		int j;for(j=i;j<=r;j++)if(a[j]<=mn)break;
		ch.pb(solve(i,j-1,mn+1));i=j-1;
	}
	h[k]=mn-d+1;rep(i,0,SZ(ch)-1)h[k]+=h[ch[i]];
	g[k]=power(2,h[k]);
	int x=power(2,tot),y=2;
	rep(i,0,SZ(ch)-1)x=1LL*x*(f[ch[i]]+g[ch[i]]*2LL)%mo,y=1LL*y*g[ch[i]]%mo;
	f[k]=(x-y+mo)%mo;
//	printf("%d %d %d:%d %d %d\n",l,r,d,f[k],g[k],h[k]);
	return k;
}
int main() {
	read(n);rep(i,1,n)read(a[i]);int rt=solve(1,n,1);
	printf("%lld",(f[rt]+g[rt])%mo);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    ll n;
    while(cin >> n){
        set<ll> st;
        st.insert(1);
        for(ll i=2;i*i<=n;i++){
            if(n%i==0){
                st.insert(i);
                st.insert(n/i);
            }
        }
        st.erase(n);

        ll ansmax = st.size();
        ll ansmin = 0;

        vector<ll> ds;
        for(auto value : st) ds.push_back(value);

        for(int i=ds.size()-1;i>=0;i--){
            //cout << i << endl;
            if(ds[i]<0) continue;
            ansmin++;
            for(int j=i-1;j>=0;j--){
                if(ds[j] < 0) continue;
                if(ds[i]%ds[j] == 0){
                    ds[j] = -1;
                }
            }
        }

        //cout << ds << endl;
        cout << ansmin << " "<< ansmax << endl;
    }
}



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

int main() {
  int N;
  cin >> N;
  vector<int> height(N);

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

  int max = 0;
  int start = 0;

  while(start < N-1) {
    int length = 0;
    for(int i = start;i<N-1;i++) {
      if(height[i+1] <= height[i]) {
        length++;
      } else {
        break;
      }
    }

    if(length > max) {
      max = length;
    }

    start = start + length + 1;
  }

  cout << max << endl;

  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 1000000000000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<long long,long long> P;
typedef pair<long long,P> PP;
long long wa;
long long ans;
long long ha;
long long w,h;
long long p[100006];
vector<long long> qqsort;
long long q[100006];
long long ruiq[100006];
int main()
{
	cin>>w>>h;
	rep(i,w)
	{
		cin>>p[i];
		wa+=p[i];
	}
	rep(i,h)
	{
		cin>>q[i];
		ha+=q[i];
		qqsort.push_back(q[i]);
	}
	qqsort.push_back(INF);
	sort(all(qqsort));
	rep(i,h)
	{
		if(i==0)ruiq[i]=qqsort[0];
		else ruiq[i]=ruiq[i-1]+qqsort[i];
	}
	rep(i,w)
	{
		long long tt=(long long)(upper_bound(all(qqsort),p[i])-qqsort.begin());
		if(tt!=0)
		{
			ans+=ruiq[tt-1]+p[i]*(h-tt);
		}
		else ans+=p[i]*h;
	}
	ans+=wa;
	ans+=ha;
	cout<<ans<<endl;
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int N;
	cin >> N;

	vector<int> C(N-1), S(N-1), F(N-1);
	rep(i, N-1){
		cin >> C[i] >> S[i] >> F[i];
	}

	for(int i = 0; i < N; i++){
		ll t = 0;
		for(int j = i; j < N-1; j++){
			if(t <= S[j]){
				t = S[j] + C[j];
			}else{
				ll q = (t - S[j]) % F[j] == 0 ? (t - S[j]) / F[j] :  (t - S[j]) / F[j] + 1;
				t = S[j] + q * F[j] + C[j];
			}
		}

		cout << t << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int bits_diff(int n, int a, int b) {
    int diff = a^b;
    int c = 0;
    rep(i,0,n) if(diff&(1<<i)) ++c;
    return c;
}

vector<int> solve(int n, int a, int b) {
    assert(n>=1);
    b = b^a;
    vector<int> result(1<<n);
    int bdiff = bits_diff(n,0,b);
    assert(bdiff>=1);
    if(bdiff==1) {
        int below_mask = (b-1);
        int above_mask = ((1<<(n-1))-1)^below_mask;
        rep(i,0,(1<<n)) {
            int gray = i^(i/2);
            bool has_big = gray&(1<<(n-1));
            result[i] = (gray&below_mask)+((gray&above_mask)<<1);
            if(has_big) result[i] += b;
        }
    }
    else {
        assert(bdiff>=3);
        int first = -1, second = -1;
        rep(i,0,n) {
            if(first==-1 && ((b&(1<<i))>0)) first = 1<<i;
            else if(second==-1 && ((b&(1<<i))>0)) second = 1<<i;
        }
        int below_mask = (second-1);
        int above_mask = ((1<<n)-1)^((second<<1)-1);
        int bb = (b&below_mask)|((b&above_mask)>>1);
        auto first_part = solve(n-1,0,first);
        auto second_part = solve(n-1,first,bb);
        above_mask = ((1<<(n-1))-1)^below_mask;
        rep(i,0,1<<(n-1)) {
            int x = first_part[i];
            result[i] = (x&below_mask)+((x&above_mask)<<1);
        }
        rep(i,0,1<<(n-1)) {
            int x=  second_part[i];
            result[i+(1<<(n-1))] = (x&below_mask)+((x&above_mask)<<1)+second;
        }
    }
    for(int &x:result) x^=a;
    return result;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, a, b;
    cin >> n >> a >> b;
    if(bits_diff(n,a,b)%2==0) cout << "NO\n";
    else {
        cout << "YES\n";
        auto result = solve(n,a,b);
        {
            vector<bool> seen(1<<n);
            assert(result[0]==a && result[(1<<n)-1]==b);
            int last = -1;
            rep(i,0,1<<n) {
                int x = result[i];
                assert(!seen[x]);
                seen[x] = true;
                if(last!=-1) assert(bits_diff(n,x,last)==1);
                last =x;
            }
        }
        for(int x:result) {
            cout << x << " ";
        }
        cout << "\n";
    }
}


Measured memory_bytes: 1792
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#define eb(i,j) emplace_back((i),(j))
#include <bits/stdc++.h>
using namespace std;

//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;
const int mod = 1000000009;

int n,k,g,a,mx;

int gcdcore(int a, int b){
    if (!b) return a;
    return gcdcore(b,a%b);
}
int gcd(int a, int b){
    if(a<b) swap(a,b);
    return gcdcore(a,b);
}

int main(){
    I(n); I(k); I(g);
    mx = g;
    REP(i,n-1){
        I(a);
        mx = max(mx,a);
        g = gcd(a,g);
    }
    if(mx >= k && k%g==0){
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

const string YES = "Yes";
const string NO = "No";

void solve(long long H, long long N, std::vector<long long> A){
    int sum=0;
    REP(i,0,N) sum+=A[i];
    if(sum>=H) cout<<YES<<endl;
    else cout<<NO<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    long long H;
    scanf("%lld",&H);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(H, N, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine().trim();
        String[] arr = line.split(" ");
        int a = Integer.parseInt(arr[0]);
        int b = Integer.parseInt(arr[1]);
        int s = a * b;
        int l = a * 2 + b * 2;
        System.out.println(s + " " + l);
        br.close();
    }
     
}

Measured memory_bytes: 24088
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

ll dist(pi a, pi b){
	return abs(a.fi - b.fi) + abs(a.se - b.se);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vector<pi> p(n);
	rep(i, n) cin >> p[i].fi >> p[i].se;
	pi mn = p[0], mx = p[0];
	sort(all(p));
	ll ans = 0LL;
	repn(i, 1, n){
		ans = max(ans, dist(p[i], mn));
		ans = max(ans, dist(p[i], mx));
		if(p[i].se > mx.se && (p[i].fi - mx.fi) < (p[i].se - mx.se)) mx = p[i];
		if(p[i].se < mn.se && (p[i].fi - mn.fi) < (mn.se - p[i].se)) mn = p[i];
	}
	rep(i, n) swap(p[i].fi, p[i].se);
	sort(all(p));
	mn = p[0], mx = p[0];
	repn(i, 1, n){
		ans = max(ans, dist(p[i], mn));
		ans = max(ans, dist(p[i], mx));
		if(p[i].se > mx.se && (p[i].fi - mx.fi) < (p[i].se - mx.se)) mx = p[i];
		if(p[i].se < mn.se && (p[i].fi - mn.fi) < (mn.se - p[i].se)) mn = p[i];
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 4696
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    H = [int(x) for x in input().split()]

    m = H[0]
    ans = 1
    for i in range(1, N):
        if H[i] >= m:
            ans += 1
        m = max(m, H[i])

    print(ans)
    

if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

times = sum(b) - sum(a)
if times < 0:
    print("No")
    exit()

times_b = 0
for i in range(n):
    if b[i] < a[i]:
        times_b += a[i] - b[i]

common = 0
for i in range(n):
    if b[i] > a[i] and (b[i] - a[i]) % 2 == 1:
        common += 1

if times_b + common <= times:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 40816
public class Main {
    public static void main(String[] args) {

        java.util.Scanner sc = new java.util.Scanner(System.in);

        dice d1 = new dice();
        for (int i = 0; i < 6; i ++) { d1.number[i] = sc.nextInt(); }

        int q = sc.nextInt();
        for (int i = 0; i < q; i ++) { d1.getRight(sc.nextInt(), sc.nextInt()); }
    }
}

class dice {
    int number[]  = new int[6];

     public void getRight(int top, int front) {

         int right = - 1;
        if (top == number[3] && front == number[1] || top == number[1] && front == number[2]
            || top == number[2] && front == number[4] || top == number[4] && front == number[3]) { right = 0; }
        else if (top == number[3] && front == number[5] || top == number[5] && front == number[2]
            || top == number[2] && front == number[0] || top == number[0] && front == number[3]) { right = 1; }
        else if (top == number[4] && front == number[0] || top == number[0] && front == number[1]
            || top == number[1] && front == number[5] || top == number[5] && front == number[4]) { right = 2; }
        else if (top == number[0] && front == number[4] || top == number[4] && front == number[5]
            || top == number[5] && front == number[1] || top == number[1] && front == number[0]) { right = 3; }
        else if (top == number[2] && front == number[5] || top == number[5] && front == number[3]
            || top == number[3] && front == number[0] || top == number[0] && front == number[2]) { right = 4; }
        else if (top == number[1] && front == number[3] || top == number[3] && front == number[4]
            || top == number[4] && front == number[2] || top == number[2] && front == number[1]) { right = 5; }
        System.out.println(number[right]);
    }
}

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
int main(){
    int n;cin>>n;
    string s=to_string(n);
    int k=(int)s.size();
    int tmp=0;
    rep(i,k){
        tmp+=s[i]-48;
        //printf("si=%d\n",s[i]);
    }
    bool flag=false;
    if(n%tmp==0)flag=true;
    cout<<(flag?"Yes":"No")<<endl;
}

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

using namespace std;
#define rep(i, n) for (int64_t i = 0; i < n; i++)

const double PI = 3.14159265358979323846;


vector<vector<int64_t>> a;
int64_t n;

void make_a(vector<int64_t> a_l,  int64_t m)
{
	if (a_l.size() == n - 1)
	{
		for (int64_t i = a_l.back(); i <= m; i++)
		{
			a.push_back(vector<int64_t>(a_l));
			a.back().push_back(i);
		}
	}
	else
	{
		for (int64_t i = a_l.back(); i <= m; i++)
		{
			auto temp = vector<int64_t>(a_l);
			temp.push_back(i);
			make_a(temp, m);
		}
	}
	
}

int main()
{
	int64_t a, b, n, max_n;
	cin >> a >> b >> n;
	if (n >= b - 1)
	{
		max_n = b - 1;
	}
	else
	{
		max_n = n;
	}
	n = floor(a * max_n / b) - a * floor(max_n / b);
	cout << n << endl;
	return 0;
}

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

const string characters = "abcdefghijklmnopqrstuvwxyz.?! ";

string convert(const string &number) {
	if(number.size() & 1) return "NA";

	string res = "";
	for(unsigned i = 0; i < number.size(); i += 2) {
		if(!('1' <= number[i] && number[i] <= '6')) return "NA";
		if(!('1' <= number[i + 1] && number[i + 1] <= '5')) return "NA";


		const unsigned idx = (number[i] - '1') * 5 + (number[i + 1] - '1');

		if(idx >= characters.size()) return "NA";

		res += characters[idx];
	}

	return res;
}

int main() {
	string number;
	while(cin >> number) {
		cout << convert(number) << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1192
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
#define MAXN 200000
int n,m;
char s[MAXN+5];
vector<int> G[MAXN+5];
int del[MAXN+5],cnt;
void dfs(int x)
{
    int A=0,B=0;
    for(int i=0;i<G[x].size();i++)
    {
        int xnext=G[x][i];
        if(del[xnext])continue;
        if(s[xnext]=='A')A=1;
        else B=1;
    }
    if(!A||!B)
    {
        del[x]=1;
        for(int i=0;i<G[x].size();i++)
        {
            int xnext=G[x][i];
            if(!del[xnext])dfs(xnext);
        }
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    scanf("%s",s+1);
    for(int i=1;i<=m;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    for(int i=1;i<=n;i++)
    {
        if(del[i])continue;
        int A=0,B=0;
        for(int j=0;j<G[i].size();j++)
        {
            int xnext=G[i][j];
            if(s[xnext]=='A')A=1;
            else B=1;
        }
        if(!A||!B){del[i]=1;dfs(i);}
    }
    for(int i=1;i<=n;i++)if(del[i])cnt++;
    if(cnt==n)printf("No\n");
    else printf("Yes\n");
}


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

class DisjointSet{
	public:
		vector<int> rank, p;
	
	//constructor	
	DisjointSet() {}
	DisjointSet(int size){
		rank.resize(size, 0);
		p.resize(size, 0);
		for(int i=0; i<size; ++i) makeSet(i);
	}		
	
	
	void makeSet(int x){
		p[x]=x;
		rank[x]=0;	
	}
	
	bool same(int x, int y){
		return findSet(x)==findSet(y);
	}

	void unite(int x, int y){
		link(findSet(x), findSet(y));	
	}
	
	void link(int x, int y){
		if(rank[x]>rank[y]){
			p[y]=x;	
		}	
		else {
			p[x]=y;
			
			if(rank[x]==rank[y]) rank[y]++;
		}
	}
	
	int findSet(int x){
		if(x!=p[x]) p[x]=findSet(p[x]);
			
		return p[x];
	}	
};

int main(){
	int n;
	long q;
	scanf(" %d %ld", &n, &q);
	
	DisjointSet ds = DisjointSet(n);
	
	for(long i=0; i<q; ++i){
		int com, x, y;
		scanf(" %d %d %d", &com, &x, &y);
		
		if(com==0) ds.unite(x,y);	
		else if(com==1){
			if(ds.same(x,y)) printf("1\n");
			else printf("0\n");
		}
		
	}
}



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

typedef long long LL;

#define FOR(i, a, b) for (int i = (a), i##_END_ = (b); i <= i##_END_; i++)
#define DNF(i, a, b) for (int i = (a), i##_END_ = (b); i >= i##_END_; i--)

template <typename Tp> void in(Tp &x) {
	char ch = getchar(), f = 1; x = 0;
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') ch = getchar(), f = -1;
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= f;
}

template <typename Tp> void out(Tp x) {
	if (x > 9) out(x / 10);
	putchar(x % 10 + '0');
	return;
}

template <typename Tp> Tp Max(const Tp &x, const Tp &y) {return x > y ? x : y;}
template <typename Tp> Tp Min(const Tp &x, const Tp &y) {return x < y ? x : y;}
template <typename Tp> bool chkmax(Tp &x, Tp y) {return x >= y ? 0 : (x=y, 1);}
template <typename Tp> bool chkmin(Tp &x, Tp y) {return x <= y ? 0 : (x=y, 1);}

const int MAXN = 100010;

int n, m;
int p[MAXN], fa[MAXN];

int find(int x) {while (x != fa[x]) x = fa[x] = fa[fa[x]]; return x;}

int main()
{
	in(n); in(m);
	FOR(i, 1, n) in(p[i]);

	FOR(i, 1, n) fa[i] = i;
	
	FOR(i, 1, m) {
		int x, y; in(x); in(y); fa[find(x)] = find(y);
	}

	int ans = 0;
	FOR(i, 1, n) if (find(i) == find(p[i])) ans++;

	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 1024
import java.lang.reflect.Array;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String S = sc.next();
		Long K = sc.nextLong();
		if (S.length() < K) {
			for (int i = 0; i < S.length(); i++){
				if(S.charAt(i)!= '1'){
					System.out.println(S.charAt(i));
					return;
				}
			}
			System.out.println(1);			
		} else {
			for (int i = 0; i < K; i++){
				if(S.charAt(i)!= '1'){
					System.out.println(S.charAt(i));
					return;
				}
			}
			System.out.println(1);			
		}
	}	
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
const int INF=2E9;

int main(){
    char c;
    int H,W;
    bool COL[60][60]={false};
    
    cin >> H >> W;
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            cin >> c;
            if(c=='#'){
                COL[j][i]=true;
            }
        }
    }
    string ans="Yes";
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            if(COL[j][i]){
                if(COL[j-1][i] || COL[j+1][i] || COL[j][i-1] || COL[j][i+1]){
                }else ans="No";
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256