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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

template<class T> struct edge{
	int to;
	T wt;
	edge(int to,const T& wt):to(to),wt(wt){}
};
template<class T> using weighted_graph=vector<vector<edge<T>>>;

template<class T>
vector<T> Dijkstra(const weighted_graph<T>& G,int s){
	const T INF=numeric_limits<T>::max();
	int n=G.size();
	vector<T> d(n,INF); d[s]=0;
	priority_queue<pair<T,int>> Q; Q.emplace(0,s);
	while(!Q.empty()){
		T d0=-Q.top().first;
		int u=Q.top().second; Q.pop();
		if(d0>d[u]) continue;
		for(const auto& e:G[u]){
			int v=e.to;
			if(d[v]>d[u]+e.wt) d[v]=d[u]+e.wt, Q.emplace(-d[v],v);
		}
	}
	return d;
}

int main(){
	int h,w; scanf("%d%d",&h,&w);
	char B[100][101];
	rep(i,h) scanf("%s",B[i]);

	weighted_graph<int> G(h*w+2);
	int s=h*w,t=h*w+1;
	rep(i,h) rep(j,w) {
		if(i<h-1) G[i*w+j].emplace_back((i+1)*w+j,B[i][j]==B[i+1][j]?0:1);
		if(j<w-1) G[i*w+j].emplace_back(i*w+(j+1),B[i][j]==B[i][j+1]?0:1);
	}
	G[s].emplace_back(0,B[0][0]=='.'?0:1);
	G[h*w-1].emplace_back(t,B[h-1][w-1]=='.'?0:1);

	printf("%d\n",(Dijkstra(G,s)[t]+1)/2);

	return 0;
}


Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
		public static void main(String[] args) {
				Scanner sc = new Scanner(System.in);
				int n = sc.nextInt();
				int m = sc.nextInt();
				int a[]=new int[n];
				int b[]=new int[n];
				int c[]=new int[m];
				int d[]=new int[m];
				int e[]=new int[m];
				int min[]=new int[n];
				int minIdx[]=new int[n];
				
				for(int i=0;i<n;i++){
					a[i]=sc.nextInt();
					b[i]=sc.nextInt();
				}
				for(int k=0;k<m;k++){
					c[k]=sc.nextInt();
					d[k]=sc.nextInt();
				}
				
				for(int i=0;i<n;i++){
					for(int k=0;k<m;k++){
						e[k]=Math.abs(a[i]-c[k])+Math.abs(b[i]-d[k]);
					}
					min[i]=e[0];
					for(int k=0;k<m;k++){
						if(min[i]>e[k]){
							min[i]=e[k];
							minIdx[i]=k;
						}
					}
				}
				for(int i=0;i<n;i++){
					System.out.println(minIdx[i]+1);
				}
		}		
	}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

struct Edge {
  int to, a, b;
  Edge(int to, int a, int b):to(to),a(a),b(b) {}
};

struct Data {
  int v, s;
  ll x;
  Data(int v, int s, ll x):v(v),s(s),x(x) {}
  bool operator<(const Data& a) const {
    return x > a.x;
  }
};

const int MAX_V = 50;
const int MAX_S = 50*50+5;
const ll INF = 1e18;

vc(Edge) g[MAX_V];
ll dp[MAX_V][MAX_S+5];

int main() {
  int n, m, s;
  cin >> n >> m >> s;
  REP(i, m) {
    int u,v,a,b;
    cin >> u >> v >> a >> b;
    --u; --v;
    g[u].emplace_back(v,a,b);
    g[v].emplace_back(u,a,b);
  }
  vi c(n), d(n);
  REP(i, n) cin >> c[i] >> d[i];
  REP(i, n) REP(j, MAX_S+5) dp[i][j] = INF;
  chmin(s, MAX_S);

  priority_queue<Data> q;
  auto push = [&](int v, int s, ll x) {
    if (s < 0) return;
    if (dp[v][s] <= x) return;
    dp[v][s] = x;
    q.emplace(v,s,x);
  };

  push(0,s,0);
  while (!q.empty()) {
    Data dt = q.top(); q.pop();
    int v = dt.v, s = dt.s;
    ll x = dt.x;
    if (dp[v][s] != x) continue;
    {
      int ns = min(s+c[v], MAX_S);
      push(v,ns,x+d[v]);
    }
    for (Edge e : g[v]) {
      push(e.to, s-e.a, x+e.b);
    }
  }
  FOR(i, 1, n) {
    ll ans = INF;
    REP(j, MAX_S+5) {
      chmin(ans, dp[i][j]);
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 6100
#include "bits/stdc++.h"
#include <cmath>

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;
ll x, y;
ll calc(bool pushf, bool pushl){
    ll btn = 0;
    ll X = x;
    ll Y = y;
    if(pushf){
        X = -X;
        btn++;
    }
    if(pushl){
        Y = -Y;
        btn++;
    }

    if(X <= Y){
        btn += Y - X;
        return btn;
    }else{
        return 2000000000;
    }
}
int main() {
    cin >> x >> y;
    ll min_p = min(calc(true, true), min(calc(true, false), min(calc(false, true), calc(false, false))));
    cout << min_p << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s = in.next();
        StringBuilder sb = new StringBuilder(s.length());
        for (int i = 0; i < s.length(); i++){
            if (s.charAt(i) == 'B'){
                if (sb.length() > 0){
                    sb.replace(sb.length()-1, sb.length(), "");
                }
            }
            else{
                if (s.charAt(i) == '1') sb.append("1");
                else if (s.charAt(i) == '0') sb.append("0");
            }
        }
        System.out.println(sb.toString());
    }
}

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

int n, m, k;

vector<int> v;

void init(int n) {
  for (int i = 0; i <= n; ++i) {
    v.push_back(i);
  }
}

int root(int x) {
  if (v[x] == x) return x;
  return v[x] = root(v[x]);
}

bool same(int a, int b) {
  if (root(a) > root(b)) swap(a, b);
  int ar = root(a);
  int br = root(b);

  if (ar > n && ar != br) {
    return 1;
  }

  v[ar] = br;
  return 0;
}

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

  init(n + m);

  for (int i = 1; i <= k; ++i) {
    int a, b, c;
    cin >> a >> b >> c;

    if (a == 2) {
      c += n;
    }

    if (same(b, c)) {
      cout << i << endl;
      return 0;
    }
  }

  cout << 0 << endl;
}

Measured memory_bytes: 3936
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define INF 0x7fffffff
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
typedef tree<int,null_type,std::less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
using namespace std;
/*
ordered_set X;
X.insert(1);
cout<<*X.find_by_order(1)<<endl; Kth largest element
cout<<X.order_of_key(-5)<<endl;  number of elemets less than K
*/


int main(){
    //freopen(".txt", "w", stdout
    //IO;
    ll n;
    cin>>n;
    ll A[n];
    for(int i = 0; i < n; i++){
        cin>>A[i];
    }
    for(int i = 0; i < n; i++){
        ll a;
        cin>>a;
        A[i] = A[i] - a;
    }
    sort(A,A+n);
    reverse(A,A+n);
    ll ans = 0;
    for(int i = 0; i < n; i++){
        if(A[i] <= 0)
            break;
        ans += A[i];
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
import itertools
import math

N = int(input())

xy = [tuple(map(int, input().split())) for _ in range(N)]

roots = list(itertools.permutations(range(N)))

ans = 0
for root in roots:
    #for i,j in enumerate(root, root[1:]):
    for d in range(1,N):
        i,j = root[d-1], root[d]
        ans += math.sqrt( (xy[i][0] - xy[j][0])**2 + (xy[i][1] - xy[j][1])**2 )

print(ans / math.factorial(N))

Measured memory_bytes: 7972
#include<stdio.h>
 
void spin_w(int x[]){
  int sai1[6],i;
 
  for(i=0;i<6;i++){
    sai1[i]=x[i];
  }
 
  sai1[0]=x[2];
  sai1[2]=x[5];
  sai1[3]=x[0];
  sai1[5]=x[3];
 
  for(i=0;i<6;i++){
    x[i]=sai1[i];
  }
 
}
 
void spin_side(int x[]){
int sai1[6],i;
 
for(i=0;i<6;i++){
  sai1[i]=x[i];
 }
 
sai1[1]=x[2];
sai1[2]=x[4];
sai1[3]=x[1];
sai1[4]=x[3];
 
for(i=0;i<6;i++){
  x[i]=sai1[i];
 }
}
 
 
void spin_s(int x[]){
    int sai1[6],i;
     
  for(i=0;i<6;i++){
    sai1[i]=x[i];
  }
  sai1[0]=x[4];
  sai1[1]=x[0];
  sai1[4]=x[5];
    sai1[5]=x[1];
     
  for(i=0;i<6;i++){
    x[i]=sai1[i];
  }
}
 
int conf(int x[],int y[]){
     
    int i,count=0,count2=0,a=0,sai1[6],sai2[6];
     
    for(i=0;i<6;i++){
        sai1[i]=x[i];
        sai2[i]=y[i];
    }
     
    for(i=0;i<6;i++){
    if(sai1[i]==sai2[i]){
      count++;
    }
    }
     
  if(count!=6){
        for(i=0;i<=3;i++){
            spin_w(sai1);
            count2++;
        if(sai1[0]==sai2[0])break;
        }
        if(count2==4){
            for(i=0;i<=3;i++){
            spin_s(sai1);
        if(sai1[0]==sai2[0])break;
            }
        }
             
    for(i=0;i<=3;i++){
      spin_side(sai1);
      if(sai1[1]==sai2[1] && sai1[2]==sai2[2] && sai1[3]==sai2[3] && sai1[4]==sai2[4])break;
        }
  }
 
  count=0;
 
 
  for(i=0;i<6;i++){
    if(sai1[i]==sai2[i]){
      count++;
        }
    }
    if(count==6){
        return 1;
    }else{
        return 0;
    }
}
 
int main(){
  int i,j,k,l,sai1[6],sai2[6],sai_c[105][6],n,a=0;
     
    scanf("%d",&n);
    for(i=0;i<n;i++){
        for(j=0;j<6;j++){
            scanf("%d",&sai_c[i][j]);
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<6;j++){
            sai1[j]=sai_c[i][j];
        }
        for(k=i+1;k<n;k++){
            for(l=0;l<6;l++){
                sai2[l]=sai_c[k][l];
            }
                if(conf(sai1,sai2)==1){
            a++;
            }
        }
    }
  if(a==0){
      printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int N;

vector<string> ans;

void func(int x, int c, string cur) {
	if (x == 0) {
		ans.push_back(cur);
		return;
	}
	
	REP(i, c + 1) {
		string nex = cur;
		nex += i + 'a';
		func(x - 1, max(c, i + 1), nex);
	}
}

int main() {
	cin >> N;
	
	func(N, 0, "");
	
	for (string &cur : ans) cout << cur << endl;
	return 0;
}


Measured memory_bytes: 7796
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    
           int N,k;
           cin >>N>>k;

    vector<int> vec(N);
    for (int i = 0; i < vec.size(); i++) {
        cin>> vec.at(i);
    }
      sort(vec.begin(), vec.end()); 
  int sum=0;
   for(int i=0;i<k;i++) sum +=vec[i];
  
  cout<<sum<<endl;
}

Measured memory_bytes: 3624
#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;
  cin >> N;
  vector<int> A(N, 0);
  ll a;
  for (int i = 0; i < N; i++) {
    cin >> a;
    A[i] = a;
  }
  sort(A.begin(), A.end());

  string ans = "YES";
  ll tmp = A[0];
  for (int i = 1; i < N; i++) {
    if (A[i] == tmp) {
      ans = "NO";
      break;
    } else {
      tmp = A[i];
    }
  }

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


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

using namespace std;

int main(){
    int n;
    bool flag=false;
    cin>>n;
    if(n>0 && n<10){
        cout<<"Yes"<<endl;
        return 0;
    }else{
        for(int i=2; i<10; i++){
            flag=false;
            if(n/i<10 && n%i==0){
                flag=true;
                break;
            }
        }
    }
    if(flag){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
class SWAG():
    def __init__(self,unit,f,data):
        self.unit=unit
        self.f=f
        self.fold_r=[unit]
        self.fold_l=[unit]
        self.data_r=[]
        self.data_l=[]
        sep=len(data)//2
        for t in data[sep:]:
            self.append(t)
        for t in data[sep-1::-1]:
            self.appendleft(t)
    def append(self,x):
        self.fold_r.append(self.f(self.fold_r[-1],x))
        self.data_r.append(x)
    def appendleft(self,x):
        self.fold_l.append(self.f(self.fold_l[-1],x))
        self.data_l.append(x)
    def pop(self):
        if not self.data_r:
            self.__init__(self.unit,self.f,self.data_l[::-1])
        self.fold_r.pop()
        return self.data_r.pop()
    def popleft(self):
        if not self.data_l:
            self.__init__(self.unit,self.f,self.data_r)
        self.fold_l.pop()
        return self.data_l.pop()
    def fold_all(self):
        return self.f(self.fold_r[-1],self.fold_l[-1])
n,k,*p=map(int,open(0).read().split())
c=[0]
for a,b in zip(p,p[1:]):c+=c[-1]+(a<b),
*c,f=[b-a==k-1for a,b in zip(c,c[k-1:])]
x=not f
s_min=SWAG(10**18,min,p[:k-1])
s_max=SWAG(0,max,p[1:k])
for i,(a,b,c)in enumerate(zip(p,p[k:],c)):
    f|=c
    s_min.append(p[i+k-1])
    s_max.append(b)
    if not c and(a!=s_min.fold_all()or b!=s_max.fold_all()):x+=1
    s_min.popleft()
    s_max.popleft()
print(x+f)

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

long long s[1000000];
int ans = 0,n;

int slove1(int x){
	for(int i = x + 1;i <= n;i++){
		if(s[i] >= s[i - 1]) continue;
		else return i;
	}
	return n + 1; 
}

int slove2(int x){
    for(int i = x + 1;i <= n;i++){
	   if(s[i] <= s[i - 1] ) continue;
	   else return i;
	}
	return n + 1;
}

int main(){
	scanf("%d",&n);
	for(int i = 1;i <= n;i++) scanf("%lld",&s[i]);
	if(n == 1){
		printf("1");
		return 0;
	}
    for(int i = 2;i <= n;i++){
		if(s[i] == s[i - 1]){
			if(i == n) ans++;
			else continue;
		}
		if(s[i] > s[i - 1]) {
			int m = slove1(i);
			i = m;
			if(m == n)ans++;
			ans++;
			continue;
		}
		if(s[i] < s[i - 1]){
			int m = slove2(i);
			i = m;
			if(m == n) ans++;
			ans++;
			continue;
		}
	}
	printf("%d",ans);
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using LL = long long;
using ULL = unsigned long long;

void solve() {
	long long a, b, c; cin >> a >> b >> c;
	if (a % 2 == 0) { cout << 0 << endl; return; }
	if (b % 2 == 0) { cout << 0 << endl; return; }
	if (c % 2 == 0) { cout << 0 << endl; return; }

	if (a < b) swap(a, b);
	if (b < c) swap(b, c);
	if (a < b) swap(a, b);
	cout << b * c << endl;
}

int main() {

	solve();

	return 0;
}


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

int a,b;

int main(){
    cin>>a>>b;
    int c = a*b;
    if(c%2 == 0){
        cout << "Even" << endl;
    }
    else {
        cout << "Odd" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	vi c(4,0);
	for(int i=0;i<3;i++)
	{
		int x,y; cin>>x>>y; x--; y--;
		c[x]++; c[y]++;
	}
	sort(c.begin(),c.end());
	if(c[0]==1&&c[1]==1&&c[2]==2&&c[3]==2){cout<<"YES\n";}
	else cout<<"NO\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n; cin>>n;
    double x[n];
    string u[n];
    double ans=0;
    for(int i=0;i<n;i++) cin>>x[i]>>u[i];
    for(int i=0;i<n;i++){
        if(u[i]=="JPY") ans+=x[i];
        else ans+=x[i]*380000;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i, j, k;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int[] x = new int[n];
		int[] y = new int[n];
		int[] h = new int[n];
		int ii = 0;
		for(i = 0; i < n; i++) {
			x[i] = parseInt(sc.next());  
			y[i] = parseInt(sc.next());  
			h[i] = parseInt(sc.next());  
			if(h[i]>0) ii = i;
		}
		sc.close();
		int hh0;
		int max=0;
		int mx = 0;
		int my = 0;
LABEL:	for (int cx = 0; cx <= 100; cx++) {
			for (int cy = 0; cy <= 100; cy++) {
				boolean f = true; 
				hh0 = abs(x[ii]-cx) + abs(y[ii]-cy) + h[ii];
				for (i=0; i < n; i++) {
					if(h[i]>0) {
						if(hh0 != abs(x[i]-cx) + abs(y[i]-cy) + h[i]) {
							f = false;
							break;
						}
					} else {
						if(hh0 - abs(x[i]-cx) - abs(y[i]-cy) > 0) {
							f = false;
							break;
						}
					}
				}
				if(f) {
					max = hh0;
					mx = cx;
					my = cy;
//					out.printf("%d %d %d%n", mx, my, max);
					break LABEL;
				}
			}
		}
		StringBuilder sb = new StringBuilder();
		sb.append(mx).append(" ").append(my).append(" ").append(max);
		out.println(sb.toString());
	}
}


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

using namespace std;



string s;

int n;

bool pal(int st, int dr)
{
    for(int i = st, j = dr; i < j; i ++, j --)
    {
        if(s[i] != s[j])
            return 0;
    }

    return 1;
}

int main()
{
    cin >> s;
    n = s.size();
    s = " " + s;

    int rez = pal(1, n);
    rez += pal(1, (n - 1) / 2);
    rez += pal((n + 3) / 2, n);

    cout << (rez == 3 ? "Yes\n" : "No\n");

    return 0;
}


Measured memory_bytes: 256
/******************************************
*******************************************
*******************************************
	PREPARED BY - SOMESH AWASTHI 
	CHANDIGARH UNIVERSITY
*******************************************
*******************************************
*******************************************/

#include<bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(long long i=a;i<b;i++)
#define io ios::sync_with_stdio(false);cin.tie(NULL);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
long int mod=1000000007;

int main()
{
	io
	#ifdef SOMU
		clock_t startTime = clock();
		freopen("input.txt","r",stdin);
	#endif

	int n;
	cin >> n;
	int mat[n][3], dp[n][3] = {0};
	fr(i, 0, n) {
		fr(j, 0, 3) {
			cin >> mat[i][j];
			dp[i][j] = mat[i][j];
		}
	}
	fr(i, 1, n) {
		dp[i][0] += max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] += max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] += max(dp[i - 1][1], dp[i - 1][0]);
	}
	cout<<max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]});

	#ifdef SOMU
		cout << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;
	#endif
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<math.h>
using namespace std;

int main() {
	int B, R;
	string b[100], r[100];
	cin >> B;
	for (int i = 0; i < B; i++) {
		cin >> b[i];

	}
	cin >> R;
	for (int i = 0; i < R; i++) {
		cin >> r[i];
	}
	int ans = 0;
	for (int i = 0; i < B; i++) {
		int count = 1;
		for (int j = i + 1; j < B; j++) {
			if (b[i].compare(b[j]) == 0) {
				count++;
			}
		}
		for (int j = 0; j < R; j++){
			if (b[i].compare(r[j]) == 0) {
				count--;
			}
		}
		ans = max(count, ans);

	}
	cout << max(ans,0);

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int> 

const int N = 2e5 + 10;

//range min assign and point update query
struct ST
{
    int seg[4*N];
    
    void build(int node,int ss,int se,int n)
    {
        if(ss == se)
        {
            seg[node] = n;
            return;
        }
        
        int mid = (ss + se)/2;
        build(node*2+1,ss,mid,n);
        build(node*2+2,mid+1,se,n);
        seg[node] = n;
    }
    
    void update(int node,int ss,int se,int l,int r,int val)
    {
        if(ss > r || se < l) return;
        
        if(l <= ss && se <= r) 
        {
            seg[node] = min(seg[node],val);
            return;
        }
        
        int mid = (ss + se)/2;
        
        update(node*2+1,ss,mid,l,r,val);
        update(node*2+2,mid+1,se,l,r,val);
       
        if(node != 0) seg[node] = min(seg[node],seg[(node-1)/2]);
    }
    
    int query(int node,int ss,int se,int id)
    {
        if(node != 0) seg[node] = min(seg[node],seg[(node-1)/2]);
       
        if(ss == se) return seg[node];
        
        int mid = (ss + se)/2;
        
        if(id <= mid) return query(node*2+1,ss,mid,id);
        else return query(node*2+2,mid+1,se,id);
    }
};

ST bottom,righ;

void solve()
{
    int n,q;
    cin >> n >> q;
    
    bottom.build(0,0,n-1,n-1);
    righ.build(0,0,n-1,n-1);
    
    int res = (n-2)*(n-2);
    
    int t,x;
    
    while(q--)
    {
        cin >> t >> x; x--;
        
        if(t == 1)
        {
            int lev = bottom.query(0,0,n-1,x);
            res-=lev;
            if(lev > 0) res++; 
            
            bottom.update(0,0,n-1,x,x,1);
            righ.update(0,0,n-1,0,lev,x);
        }
        else
        {
            int lev = righ.query(0,0,n-1,x);
            res-=lev;
            if(lev > 0) res++;
            righ.update(0,0,n-1,x,x,1);
            bottom.update(0,0,n-1,0,lev,x);
        }
    }
    
    cout << res; 
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 11832
def calc(a,b,c):
    res = 0
    if not a == b:
        res+=1
    if not a == c:
        res+=1
    if not b == c:
        res+=1
    if res > 1:
        return res - 1
    else:
        return res
        
N = int(input())
A = input()
B = input()
C = input()
ans = 0
for i in range(N):
    ans+=calc(A[i],B[i],C[i])
print(ans)

Measured memory_bytes: 3064
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int a, t, Max = -1;   
char c[110]; 
int main() 
{
    scanf("%d%s",&a, c);
    for(int i = 0 ; i < a ; ++ i)
	{
        if(c[i] == 'I') 
		{      
            t ++;
        }
        else t --;             
        Max = max(Max,t);       
    }
    if(Max == -1) Max = 0;     
    printf("%d",Max);          
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++)
static const int MAX = 100;
main(){
  int N, C[101], P[201][3], S[201];
  
  cin >> N;
  rep(i, N) S[i] = 0;
  rep(i, N) rep(j, 3) cin >> P[i][j];
  rep(j, 3){
    rep(i, MAX+1)  C[i] = 0;
    rep(i, N) C[P[i][j]]++;
    rep(i, N) if ( C[P[i][j]] == 1 ) S[i] += P[i][j];
  }
  rep(i, N) cout << S[i] << endl;
}

Measured memory_bytes: 1164
N = int(input())

ans = ''
isOdd = False
while N != 0 :
    if N % 2 == 1 :
        ans += '1'
    else :
        ans += '0'
    if isOdd :
        N += 1
    N //= 2
    isOdd = not isOdd

if ans == '' :
    print('0')
else :
    print(ans[::-1])

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

int query(int u, int v) {
	cout << "? " << u+1 << " " << v+1 << endl;
	int ret; cin >> ret;
	return ret;
}
void solve() {
	int n, s, t; cin >> n >> s >> t; s--; t--;
	int d = query(s, t);
	vector<P> v;
	rep(i, n) {
		if (i == s || i == t)continue;
		int d1 = query(s, i);
		int d2 = query(i,t);
		if (d1 + d2 == d) {
			v.push_back({ d1,i });
		}
	}
	sort(v.begin(), v.end());
	vector<int> ans; ans.push_back(s);
	if (v.size() == 0) {
		cout << "! " << s << " " << t << endl; return;
	}
	ans.push_back(v[0].second);
	int cur = 0;
	for (int i = 1; i < v.size(); i++) {
		int dist = query(v[cur].second, v[i].second);
		if (v[i].first - v[cur].first == dist) {
			ans.push_back(v[i].second); cur = i;
		}
	}
	ans.push_back(t);
	cout << "!";
	rep(i, ans.size()) {
		cout << " " << ans[i]+1;
	}
	cout << endl;
}

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

	//cout << fixed << setprecision(10);
	//init();
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 4644
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define Swap(a,b) {int temp=a;a=b;b=temp;}
typedef long long ll;
typedef unsigned long long ull;

int a[110],b[110];
int main(){
    int n,flag=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d%d",&a[i],&b[i]);
        if(i>=2&&a[i]==b[i]&&a[i-1]==b[i-1]&&a[i-2]==b[i-2]) flag=1;
    }
    if(flag) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;


signed main(){
  int n;
  cin >> n;
  
  vector< map<int,int> > d(1001000, map<int,int> {});
  
  for(int i=1;i<=1000000;i+=2){
    int ii = i;
    if( i==1 ) ii = 2;
    if( d[ii].size() == 0 ){
      int j = ii + ii;
      while( j<d.size() ){
        d[j][ii] = 1;
        j += ii;
      }
    }
  }
  
  int c = 1;
  
  for(int i=2;i<n;i++){
    if( d[i].size() > 0 ){
      auto it = d[i].lower_bound(0);
      //cout << it->first <<endl;
      int m = 1;
      while( it != d[i].end() ){
        int k1v = it->first;
        int k1n = 0;
        int v1 = i;
        while( v1 >= k1v && v1 % k1v == 0 ){
          k1n ++;
          v1 /= k1v;
        }
        m *= ( k1n + 1 );
        ++it;
      }
      c += m;
    } else {
      c+= 2;
    }
  }
  
  cout << c << endl;
  return 0;
}



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

bool color[100500];

int main(void)
{
    string S;
    cin >> S;
    
    for(int i = 0; i < S.size(); i++)
    {
        if(S[i] == '1')
            color[i] = true;
        else
            color[i] = false;
    }
    
    int res = 0;
    for(int i = 0; i < S.size() - 1 ; i++)
    {
        if(color[i] == color[i+1])
        {
            color[i+1] = !color[i+1];
            res++;
        }
    }
    cout << res << endl;
    return 0; 
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int m = max({a, b, c});
  if ((a + b + c)%2 == 3 * m%2){
    int ans = (3 * m - a - b - c) / 2;
    cout << ans << endl;
  } else{
    int ans = (3 * (m + 1) - a - b - c) / 2;
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            int r = Integer.parseInt(br.readLine());
            int g = Integer.parseInt(br.readLine());
            int x = g * 2 - r;
            System.out.println(x);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 22996
N, T = map(int, input().split())
c_list = []
t_list = []
for i in range(N):
    c, t = map(int, input().split())
    c_list.append(c)
    t_list.append(t)

select_list = []
for i in range(N):
    if t_list[i] > T:
        pass
    else:
        select_list.append(c_list[i])

if len(select_list) == 0:
    print("TLE")
else:
    print(min(select_list))


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

using namespace std;

#define long long long
#define INF ((long) 2e18)
#define MOD ((long) (1e9 + 7))
#define umap unordered_map

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

    long t = 1;
    //cin >> t;

    while (t--) {
        long n, a, b;
        cin >> n >> a >> b;

        long ans = n / (a + b);
        long aux = ans * (a + b);
        long r = n - aux;
        ans *= a;
        ans += min(a, r);
        printf("%lld\n", ans);
    }
}


Measured memory_bytes: 3728
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <iterator>
#include <cmath>
#include <deque>
#include <stack>
#include <functional>
#include <queue>

signed main()
{
    {
        if (fopen("input.txt", "r")) {
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
        }
        std::ios_base::sync_with_stdio(false);
        std::cin.tie(NULL);
        std::cout.tie(NULL);
    }

    int h1, m1, h2, m2, k;
    std::cin >> h1 >> m1 >> h2 >> m2 >> k;
    int t1 = h1 * 60 + m1;
    int t2 = h2 * 60 + m2;
    if (t2 < t1)
        t2 += 24 * 60;
    int delta = t2 - t1;
    int ans = std::max(delta - k, 0);
    std::cout << ans;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
int main(){
    int n;cin>>n;
    int a[2][n];
    rep(i,2){
        rep(j,n)cin>>a[i][j];
    }
    int m1 =0,m2=0;
    int ans =0;
    bool f= true;
    rep(i,n){
        int sum =0;
        rep(j,n){
            if(j<i)sum+=a[0][j];
            if(j==i){
                sum+=a[0][j];
                sum+=a[1][j];
            }
            if(j>i)sum+=a[1][j];
        }
        ans=max(ans,sum);
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
n=int(input())
S=input()
s=list(S)

p=[]
#print(s)
for i in range(n-1):
  if s[i]==s[i+1]:
    p.append(i)
p.sort(reverse=True)
l=len(p)

for i in range(l):
    #print(p[i])
    s.pop(p[i])

print(len(s))


Measured memory_bytes: 7880
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  int A, B, C;
  cin >> A>> B >> C;
  if (A == B) cout << C << endl;
  else if (B == C) cout << A << endl;
  else cout << B << endl;

  return 0;
}


Measured memory_bytes: 3552
#include<iostream>
#include <bits/stdc++.h>
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define mp(x,y) make_pair(x,y)
#define endl '\n'
#define ll long long

const ll oo = 0x3f3f3f3f3f3f3f3;
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n, x; cin >> n >> x;
    ll sum = n;
    ll cant_of_lenX = (n % x == 0)?((n - x)/x) * 2 - 1 : ((n - x)/x) * 2;
    sum += (cant_of_lenX * x);
    while (true){

        if(n % x == 0) break;
        else {
            ll r = x;
            x = n % x;
            n = r;
        }
        cant_of_lenX = (n % x == 0)?((n)/x) * 2 - 1 : ((n)/x) * 2;
        sum += (cant_of_lenX * x);
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// long long mod = 1e9 + 7;
// string a, b, c;
// int dp(int i, int j, int k){
// 	if(k == c.length()){
// 		return 1;
// 	}
// 	long long ans = 0;
// 	if(i < a.length()){
// 		if(a[i] == c[k]){
// 			cout << "a " <<  ans << " "<< i << " " << j << " " << k <<endl;
// 			ans = (ans%mod + dp(i+1, j, k+1)%mod)%mod;
// 		}
// 		ans = (ans%mod + dp(i+1, j, k)%mod)%mod;
// 	}
// 	if(j < b.length()){
// 		if(b[j] == c[k]){
// 			cout << "b " <<  ans << " "<< i << " " << j << " " << k <<endl;
// 			ans = (ans%mod + dp(i, j+1, k+1)%mod)%mod;

// 		}
// 		ans = (ans%mod + dp(i, j+1, k)%mod)%mod;

// 	}
// 	if(i < a.length() and j < b.length()){
// 		cout << "c " <<  ans << " "<< i << " " << j << " " << k <<endl;
// 		ans = (ans%mod + dp(i+1, j+1, k)%mod)%mod;
// 	}
// 	return ans;

// }
// multiset <char> s;
// void show(int a[26]){
// 	for(int i = 0 ; i < 26; i++){
// 		cout << a[i] << " ";
// 	}
// 	cout << endl;
// }
// string minWindow(string s, string t){
// 	string ministring="";
// 	int len = 10000001;
// 	int hmapS[2600] = {0};
// 	int hmapT[2600] = {0};

// 	for(int i = 0; i < t.length(); i++){
// 		char temp = t[i];
// 		hmapT[temp]++;
// 	}

	

// 	return ministring;

// }
int main(){
	// map <int, int> m;
	// m[0] = 1;
	// cout << m[0];
	int n;
	cin >> n;
	long long a[100001];
	for(int i = 0 ; i < n; i++){
		cin >> a[i];
	}
	sort(a, a + n);
	if(n > 3){
		if(a[n-1] == 0){
			cout << "Yes";
		}
		else{
			if(n%3 != 0){
				cout << "No";
			}
			else{
				map <int, int> m;
				set<int> s1;
				for(int i=0; i < n; i++){
					s1.insert(a[i]);
					m[a[i]]++;
				}
				int count = s1.size();
				if(count != 3){
					if(count > 3){
						cout << "No";
					}
					else{
						int num[3];
						int j = 0;
						for(auto i:m){
							num[j] = i.first;
							j++;
						}
						if((m[num[0]]*2 == m[num[1]])){
							int s = num[0];
							int f = num[1];
							if((f^f) == (s) and (f^s) == (f)){
								cout <<"Yes";
							}
							else{
								cout << "No";
							}
						}
						else if(m[num[0]]*2 == m[num[1]]){
							int f = num[0];
							int s = num[1];
							if((f^f) == (s) and (f^s) == (f)){
								cout <<"Yes";
							}
							else{
								cout << "No";
							}
						}
						else{
							cout << "No";
						}
					}
				}
				else{
					int num[3];
					int j = 0;
					for(auto i:m){
						num[j] = i.first;
						j++;
					}
					if(m[num[0]] == m[num[1]] and m[num[1]] == m[num[2]]){
						if((num[0]^num[1]) == (num[2]) and (num[0]^num[2]) == (num[1]) and (num[2]^num[1]) == (num[0])){
							cout <<"Yes";
						}
						else{
							cout << "No";
						}
					}
					else{
						cout << "No";
					}


				}
			}
		}
	}
	else{
		if((a[0]^a[1]) == (a[2]) and (a[0]^a[2]) == (a[1]) and (a[2]^a[1]) == (a[0])){
			cout <<"Yes";
		}
		else{
			cout << "No";
		}
	}


	return 0;
}

Measured memory_bytes: 8064
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
 
        int ans = 1;
        int tmp = 0;
        for (int i = 1; i <= N; ++i) {
            int num = i;
            int cnt = 0;
            while (true) {
                if (num % 2 == 0) {
                    cnt++;
                    num /= 2;
                }
                else {
                    break;
                }
            }
            if (cnt > tmp) {
                tmp = cnt;
                ans = i;
            }
        }
 
        System.out.println(ans);
	}
}

Measured memory_bytes: 35788
#include <stdio.h>
#define MAX 500001
#define SENTINEL 1000000001

void merge_sort(int[], int, int);
void merge(int[], int, int, int);
int count = 0;

int main(){

    int n, S[MAX], i;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &S[i]);
    }

    merge_sort(S, 0, n);
    for (i = 0; i < n - 1; i++) {
        printf("%d ", S[i]);
    }
    printf("%d\n", S[n - 1]);
    printf("%d\n", count);

    return 0;
}

void merge_sort(int s[], int left, int right){
    if(left + 1 < right) {      // ２つかどうか判定
        int mid = (left + right) / 2;
        merge_sort(s, left, mid);
        merge_sort(s, mid, right);
        merge(s, left, mid, right);
    }
}

void merge(int s[], int left, int mid, int right){
    int i, k;
    int n1 = mid - left + 1;
    int n2 = right - mid + 1;
    int L[n1], R[n2];
    for(i = 0; i < (n1 - 1); i++){
        L[i] = s[left + i];
    }

    for(i = 0; i < (n2 - 1); i++){
        R[i] = s[mid + i];
    }

    L[n1 - 1] = SENTINEL;
    R[n2 - 1] = SENTINEL;

    i = 0;
    int j = 0;

    for(k = left; k < right; k++){
        if(L[i] <= R[j]){
            s[k] = L[i];
            i++;
        }
        else {
            s[k] = R[j];
            j++;
        }
            count++;
    }
}

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

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

int W, H, N, X[100], Y[100], A[100];

int main(){
    cin >> W >> H >> N;
    for(int i=0;i<N;i++)    cin >> X[i] >> Y[i] >> A[i];

    int WH[100][100];
    memset(WH, 0, sizeof(WH));

    for(int i=0;i<N;i++){
        if(A[i] == 1){
            for(int y=0;y<H;y++){
                for(int x=0;x<X[i];x++) WH[y][x] = 1;
            }
        } else if(A[i] == 2){
            for(int y=0;y<H;y++){
                for(int x=X[i];x<W;x++) WH[y][x] = 1;
            }
        } else if(A[i] == 3){
            for(int y=0;y<Y[i];y++){
                for(int x=0;x<W;x++) WH[y][x] = 1;
            }
        } else {
            for(int y=Y[i];y<H;y++){
                for(int x=0;x<W;x++) WH[y][x] = 1;
            }
        }
    }

    int ans = 0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(WH[i][j] == 0)   ans++;
        }
    }

    cout << ans << endl;
}


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

ll dp[100005][105];

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


    int n, W;
    cin>>n>>W;

    vector<int> weights(n), values(n);

    for(int i = 0; i<n; i++){
        cin>>weights[i];
        cin>>values[i];
    }


    for(int w = 1; w<=W; w++){
        for(int i = 0; i<n; i++){
            dp[w][i] = dp[w][i-1];

            if(w >= weights[i])
                dp[w][i] = max(dp[w][i], dp[w-weights[i]][i-1] + values[i]);
        }
    }

    cout<<dp[W][n-1];


    return 0;
}



Measured memory_bytes: 85580
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s; cin >> s;
  string ans;
  for(int i = 0; i < s.size(); i++){
    char moji = s.at(i);
    if(moji == 'B' and ans.size() != 0){
      ans.erase(ans.size() - 1,1);
    }
    else if(moji != 'B'){
      ans.push_back(moji);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3588
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int i;
  long long int sum=0;
  cin>>i;
 // int i=1;
  while(i!=0)
  {
    if((i%3!=0)&&(i%5!=0))
    {
      sum+=i;
    }
    i--;
  }
  cout<<sum;
  return 0;
}


Measured memory_bytes: 3560
import sys
a, b, c, d = map(int, input().split())
target = b - a + 1

def gcd(x,y):
  while y!=0:
    x,y=y,x%y
  return x
def lcm(x, y):
    return (x * y) // gcd(x, y)

b_num = b//c + b//d -b//lcm(c,d)
a_num = (a-1)//c + (a-1)//d - (a-1)//lcm(c,d)
print(target - (b_num - a_num))

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

int main(){
  int K; cin >> K;
  long long x=0;
  for(int i=0; i<=1000000; i++){
    x=x*10+7;
    if(x%K==0){
      cout << i+1 << endl;
      return 0;
    }else{
      x=x%K;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <stack>
#include <queue>
using namespace std;
int main(void){
    int h,w;
    cin>>h>>w;
    char a[60][60];
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<h;i++){
        a[i][0]='.';
        a[i][w+1]='.';
    }
    for(int i=0;i<w;i++){
        a[0][i]='.';
        a[h+1][i]='.';
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(a[i][j]=='#')cout<<a[i][j];
            else{
                int t=0;
                for(int k=-1;k<=1;k++){
                    for(int l=-1;l<=1;l++){
                        if(a[i+k][j+l]=='#')t++;
                    }
                }
                cout<<t;
            }
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int64_t N, M;

bool check(int64_t k) {
  int64_t s = N, c = M;
  c -= k * 2;
  s += c / 2;
  s -= k;
  return (s >= 0 && c >= 0);
}
int main() {
  cin >> N >> M;
  int64_t low = 0, high = 1LL<<60;
  while(low + 1 < high) {
    int64_t mid = (low + high) / 2;
    if(check(mid)) {
      low = mid;
    }else {
      high = mid;
    }
  }
  cout << low << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    LL n;
    cin >> n;

    vector<LL> a(n);
    
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    LL ans = 0;

    for(int i = 0; i < n; i++){
        ans += a[i] - 1;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
int gcd(int a,int b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}
int main() {
    int n,ans = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int l,r;
        cin >> l >> r;
        ans += (r-l+1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : Hello5.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
 ll n,a,b;
 cin>>n>>a>>b;
 ll c=a+b;
ll ans=a*(n/c);
ans+=min(a,n%c);
cout<<ans<<endl;
	  return 0;
	}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int plen,cnum,width,cspace;
    while(1){
        cin>>plen;
        if(plen==0)
            break;
        cin>>cnum>>width>>cspace;
        string str;
        getline(cin,str);
        vector<string> lines;
        while(getline(cin,str)&&str!="?"){
            // width¶¸ÂÅÊ¯é
            if(str==""){
                string s;
                for(int i = 0; i < width; i++)
                    s+='.';
                lines.push_back(s);
                continue;
            }
            for(int k = 0; k < (str.size()/width)+(str.size()%width==0?0:1); k++){
                // ÅIsÈçA.Åâ®
                if(k+1==(str.size()/width)+(str.size()%width==0?0:1)){
                    string s=str.substr(k*width);
                    for(int i = s.size(); i < width; i++)
                        s+='.';
                    lines.push_back(s);
                }
                else
                    lines.push_back(str.substr(k*width,width));
            }
        }
        const int onePageLine=plen*cnum;
        for(int i = 0; i < (lines.size()/onePageLine)+(lines.size()%onePageLine==0?0:1); i++){
            vector<string> page(plen,"");
            bool isDotOnly=true;
            for(int j = 0; j < cnum; j++){
                for(int k = 0; k < plen; k++){
                    // àµlinesÌI[ÜÅ«½çA½àÇÁµÈ¢
                    if(i*onePageLine+j*plen+k<lines.size())
                        page[k]+=lines[i*onePageLine+j*plen+k];
                    else{
                        for(int l = 0; l < width; l++)
                            page[k]+='.';
                    }
                    if(j!=cnum-1){
                        for(int l = 0; l < cspace; l++)
                            page[k]+='.';
                    }
                }
            }
            // .µ©È¢y[WÍóµÈ¢
            for(int j = 0; j < page.size(); j++){
                for(int k = 0; k < page[j].size(); k++){
                    if(page[j][k]!='.')
                        isDotOnly=false;
                }
            }
            if(!isDotOnly){
                // print
                for(int j = 0; j < page.size(); j++)
                    cout<<page[j]<<endl;
                cout<<"#"<<endl;
            }
        }
        cout<<'?'<<endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<ll,int> P;



int main() {
	int n;
	int d[101]={};
	cin>>n;
	for(int i=1;i<n+1;++i)cin>>d[i];
	sort(d,d+n+1);
	int t=0;
	for(int i=1;i<n+1;++i){
		if(d[i]>d[i-1])t++;
	}

	cout<<t<<endl;
	return 0;
}


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

        if(s[0]=='R'&&s[1]=='R'&&s[2]=='R')
        cout<<3<<endl;
        else if(s[0]=='R'&&s[1]=='R'||s[1]=='R'&&s[2]=='R')
        cout<<2<<endl;
        else if(s[0]=='R'||s[1]=='R'||s[2]=='R')
        cout<<1<<endl;
        else
        cout<<0<<endl;

}

Measured memory_bytes: 3620