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

#define ll long long
#define ar array

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> dp(3);
    for (int day = 0; day < n; day++) {
        vector<int> new_dp(3);
        vector<int> c(3);
        for (int i = 0; i < 3; i++) {
            cin >> c[i];
        }
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (i != j) {
                    new_dp[j] = max(new_dp[j], dp[i] + c[j]);
                }
            }
        }
        dp = new_dp;
    }
    cout << max({dp[0], dp[1], dp[2]}) << "\n";
}


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

int main(){
	long long d,g;
	cin>>d>>g;
	long long p[d],c[d];
	for(int i=0;i<d;i++)cin>>p[i]>>c[i];
	//long long p_sum[d];
	long long ans = 1e9;
	/*for(int i=0;i<d;i++){
		p_sum[i] = (i+1)*100*p[i] + c[i];
		per[i]  = p_sum[i] / p[i];
	}*/
	for(long i = 0; i < (1<<d); i++){
		long long num = 0,s = 0,rest_max = -1;
		for(long j = 0; j < d; j++){
			if((1&i>>j)==1){
				s += (j+1)*100*p[j] + c[j];
				num += p[j];
			}else{
				rest_max = j;
			}
		}
		if(s < g){
			long s1 = 100 * (rest_max + 1);
			int need = (g-s + s1 -1) / s1;
			if(need >= p[rest_max]){
				continue;
			}
			num += need;
		}
		ans = min (ans,num);
	}
	cout << ans <<endl;
}


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

using namespace std;

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

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

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

signed main(){
	cout<<fixed<<setprecision(10);
	
	int T;
	
	cin>>T;
	
	for(int _ = 0; _  < T; _++){
		int N;
		int sum = 0;
		int ans = 0;
		priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> Q1, Q2;
		vector<pair<int,int>> A, B;
		
		cin>>N;
		
		for(int i = 0; i < N; i++){
			int K, L, R;
			
			cin>>K>>L>>R;
			
			K--;
			
			ans += min(L, R);
			
			
			if(L > R) A.push_back({K,L - R});
			if(R > L) B.push_back({N - K - 2,R - L});
		}
		
		sort(A.begin(), A.end());
		sort(B.begin(), B.end());
		
		for(int i = 0; i < A.size(); i++){
			// cout<<"A "<<A[i].first<<" "<<A[i].second<<endl;
			if(Q1.size() <= A[i].first) {
				Q1.push({A[i].second, A[i].first});
				ans += A[i].second;
			} else {
				pair<int,int> p = Q1.top(); Q1.pop();
				
				ans -= p.first;
				
				if(p.first >= A[i].second) {
					Q1.push(p);
					ans += p.first;
				} else {
					Q1.push({A[i].second, A[i].first});
					ans += A[i].second;
				}
			}
		}
		
		for(int i = 0; i < B.size(); i++){
			// cout<<"B "<<B[i].first<<" "<<B[i].second<<endl;
			if(B[i].first <= -1) continue;
			if(Q2.size() <= B[i].first) {
				
					Q2.push({B[i].second, B[i].first});
				ans += B[i].second;
			} else {
				pair<int,int> p = Q2.top(); Q2.pop();
				
				ans -= p.first;
				
				if(p.first >= B[i].second) {
					Q2.push(p);
					ans += p.first;
				} else {
					Q2.push({B[i].second, B[i].first});
					ans += B[i].second;
				}
			}
		}
		
		cout<<ans<<endl;
	}
	
	
	
	return 0;
}

Measured memory_bytes: 11040
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


//naosu
long int gcd(long int a,long int b){
  long int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

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

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

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}


long int lcm(long int a,long int b){
  return a/gcd(a,b)*b;
}


long int f(long int n,long int c,long int d){
  long int cnt=n/c+n/d-n/lcm(c,d);
  return n-cnt;
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int n,k;
  scanf("%d%d",&n,&k);

  printf("%d\n",!!(n%k));

  return 0;
}

Measured memory_bytes: 1672
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


class UnionFind:
    def __init__(self,n):
        self.par = [i for i in range(n+1)]  # 親のノード番号
        self.rank = [0]*(n+1)

    def find(self,x):  # xの根のノード番号
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def same_check(self,x,y):  # x,yが同じグループか否か
        return self.find(x) == self.find(y)

    def unite(self,x,y):  # x,yの属するグループの併合
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            x,y = y,x
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
        self.par[y] = x



N,M = MI()
UF = UnionFind(N)
for _ in range(M):
    a,b = MI()
    if not UF.same_check(a,b):
        UF.unite(a,b)

A = UF.par
for i in range(1,N+1):
    A[i] = UF.find(A[i])

del A[0]

print(len(set(A))-1)


Measured memory_bytes: 81472
#include<bits/stdc++.h>
using namespace std;
 
int main() {
   int N,L;
  cin>>N>>L;
 
  if(L>0){
    cout<<N*(2*(L)+(N-1))/2-L<<endl;
  }else if(N<=abs(L)){
     cout<<N*(2*(L)+(N-1))/2-(L+N-1)<<endl;
  }else{
     cout<<N*(2*(L)+(N-1))/2<<endl;
  }
  
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  
  double s=0;
  double c=0;
  for(int i=0;i<n;i++){
    
      s+=a[i];
      c++;
    
  }


  s=round(s/c);

  int ans=0;
  for(int i=0;i<n;i++){
    ans+=(a[i]-s)*(a[i]-s);
  }
  cout<<ans<<endl;
}

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

int main()
{
  string s;cin>>s;
  for(int i=0;i<s.size();i++)
  {
    if((i+1)%2!=0 && s[i]=='L') {cout<<"No"; return 0;}
    else if((i+1)%2==0 && s[i]=='R') {cout<<"No"; return 0;}
  }
  cout<<"Yes";
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100

int main(){

  int i,j,b,v,k;
  int a[N];

  scanf("%d", &b);

  for(i = 0; i <= b-1; i++){
    scanf("%d", &a[i]);
  }
  printf("%d", a[0]);
  for(k = 1; k <= b-1; k++){
    printf(" %d", a[k]);
  }
    printf("\n");
  for(i = 1; i <= b-1; i++){
    v = a[i];
    j = i - 1;
    while(j >= 0 && a[j] > v){
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;
    printf("%d", a[0]);
    for(k = 1; k <= b-1; k++){
      printf(" %d", a[k]);
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2068
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,p,q,result;
  cin>>a>>b;
  p=a/b;
  if(a%b==0){
    cout<<p<<endl;
  }
  else{
      cout<<p+1<<endl;
  }


  return 0;
}


Measured memory_bytes: 256
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (n : k : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  hs <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  print . length . filter (k <=) $ hs

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    int a,b;
    cin >> a >> b;
    if(b%a==0){
        cout << a+b << endl;
    }else{
        cout << b-a << endl;
    }
}

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

using namespace std;

long long n, a[310], x = 0, y = 0, z = 0;
double memo[310][310][310];

double dp(int x, int y, int z) { //x -- > the number dishes has 1, y --> the number dishes has 2, z --> the number dishes has 3
	if(x == 0 && y == 0 && z == 0) {
		return 0;
	}
	if(memo[x][y][z] > -1.00) {
		return memo[x][y][z];
	}
	double cnst = (double)n/(double)(x+y+z);
	memo[x][y][z] = 0;
	if(x > 0) {
		memo[x][y][z] += (dp(x - 1, y ,z) + cnst) * (double)x / (double)(x + y + z);
	}
	if(y > 0) {
		memo[x][y][z] += (dp(x + 1, y - 1 ,z) + cnst) * (double)y / (double)(x + y + z);
	}
	if(z > 0) {
		memo[x][y][z] += (dp(x, y + 1, z - 1) + cnst) * (double)z / (double)(x + y + z);
	}
	return memo[x][y][z];
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	for(int i = 0; i < 310; i++) {
		for(int j = 0; j < 310; j++) {
			for(int k = 0; k < 310; k++) {
				memo[i][j][k] = -1.00;
			}
		}
	}
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		if(a[i] == 1) {
			x++;
		}
		else if(a[i] == 2) {
			y++;
		}
		else {
			z++;
		}
	}
	cout << fixed << setprecision(10) << dp(x, y, z) << endl;
}



Measured memory_bytes: 233088
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>

typedef long long ll;
const ll INF = 1e18 + 1;
const ll MOD = 1e9 + 7;

// print(x, y, z);
// print(va.begin(), va.end());
void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}
template<typename Iterator> void printVec(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << std::distance(begin, it) << "] " << *it << " ";
    if (std::distance(begin, it) % 20 == 19) { std::cout << std::endl; }
  }
  std::cout << std::endl;
}

template<typename T> T lminimum(const std::vector< T >& v) {return *std::min_element(v.begin(), v.end());}
template<typename T> T lmaximum(const std::vector< T >& v) {return *std::max_element(v.begin(), v.end());}
template<typename T> void lunique(std::vector< T >& v) {v.erase(std::unique(v.begin(), v.end()), v.end());}
template<typename T> void lsort(std::vector< T >& v) {std::sort(v.begin(), v.end());}
template<typename T> void lgreatersort(std::vector< T >& v) {std::sort(v.begin(), v.end(), std::greater<>());}
template<typename T> bool lnext_permutation(std::vector< T >& v) {return std::next_permutation(v.begin(), v.end());}

int main(int argc, char* argv[])
{
  // Speed Up
  // http://tatanaideyo.hatenablog.com/entry/2014/10/24/214714
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  std::string S;
  std::cin >> S;

  std::stack< char > st;
  for (ll i = 0; i < (ll)S.size(); ++i) {
    if (S[i] == 'S') {
      st.push(S[i]);
      continue;
    }

    // T
    if (!st.empty() && st.top() == 'S' && S[i] == 'T') {
      st.pop();
    } else {
      st.push(S[i]);
    }
  }

  print(st.size());
  return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include<string>
using namespace std;
int main(){
    string S;
    int N,K;
    cin>>N>>K;
    cin>>S;
    K=K-1;
    if(S[K]=='A')
    {
        S[K]='a';
    }
    else if(S[K]=='B')
    {
        S[K]='b';   
    }
    else if(S[K]=='C')
    {
        S[K]='c';
    }
    cout<<S<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()

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

ll Q,H,S,D,N;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> Q >> H >> S >> D;
    cin >> N;
    N*=4;

    ll res=0;
    if (D<2*S && D<4*H && D<8*Q){
        res+=N/8*D;
        N-=8*(N/8);
    }

    if (S<2*H && S<4*Q){
        res+=N/4*S;
        N-=4*(N/4);
    }

    if (H<2*Q){
        res+=N/2*H;
        N-=2*(N/2);
    }

    res+=N*Q;
    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define P pair<int, int>

using namespace std;
using ll = long long;

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

struct edge {int from, to, cost; };

void solve(){
    bool y = false;
    int n;
    scanf("%d", &n);
    char s[n];
    rep(i, n){
        scanf("%c", &s[i]);
        if(s[i] == 'Y') y = true;
    } 
    if(y){
        printf("Four\n");
    }else{
        printf("Three\n");
    }
}

int main(){
    solve();
    return 0;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll,int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const int N = 100005;

void solve(){
	vector<ll> v;
	function<void(ll, int)> gen = [&](ll cur, int len){
		if(len == 11)
			return ;
		v.pb(cur);
		if(cur == 0){
			for(int i = 1; i <= 9; i++)
				gen(i, len+1);
		}
		int d = cur % 10;
		for(int i = -1; i <= 1; i++){
			int nd = d + i;
			if(nd >= 0 and nd <= 9){
				gen(cur*10 + nd, len+1);
			}
		}
	};
	gen(0,0);
	sort(all(v));
	v.erase(unique(all(v)), v.end());
	int k;
	cin >> k;
	cout << v[k] << '\n';
}

int main(){
	fastio;
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 7268
#include <stdio.h>
#define INF 200000
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define MAX 100
int n;
int color[MAX];
int M[MAX][MAX];
int d[MAX];
int p[MAX];
int prim(){
        int u,Minv;
        int i,v;
        int sum=0;
        for(i=0; i<n; i++) {
                color[i]=WHITE;
                d[i]=INF;
                p[i]=-1;

        }
        d[0]=0;
        while(1) {
                Minv=INF;
                for(i=0; i<n; i++) {
                        if(color[i]!=BLACK &&d[i]<Minv) {
                                Minv=d[i];
                                u=i;
                        }
                }

                if(Minv==INF) {
                        break;
                }
                color[u]=BLACK;
                for(v=0; v<n; v++) {
                        if(color[v]!=BLACK && M[u][v]!=INF) {
                                if(M[u][v]<d[v]) {
                                        d[v]=M[u][v];
                                        p[v]=u;
                                        color[v]=GRAY;
                                }
                        }
                }
        }
        for(i=0; i<n; i++) {
                if(p[i]!=-1) {
                        sum+=M[i][p[i]];
                }
        }

        return sum;

}
int main(){
        int i,j;

        scanf ("%d",&n);
        for(i=0; i<n; i++) {
                for(j=0; j<n; j++) {
                        scanf("%d",&M[i][j]);
                        if(M[i][j]==-1) {
                                M[i][j]=INF;
                        }
                }
        }


        printf("%d\n",prim());

        return 0;
}

Measured memory_bytes: 636
n = int(input())
for i in range(n):
    a, b, c = map(int, input().split())
    if a*a + b*b == c*c:
        print('YES')
    elif a*a + c*c == b*b:
        print('YES')
    elif b*b + c*c == a*a:
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 5592
#include<bits/stdc++.h>
int n;
inline std::string calc(std::string s) {
	if(s.front() == 'a') {
		std::string ret;
		int i0 = 0,i1 = 0, max = 0;
		for(;i1 < s.size();) {
			for(;i0 < s.size() && s[i0] != 'a';++i0);
			for(;i1 < s.size() && s[i1] != 'b';++i1);
			if(i0 < s.size() && i0 >= max) max = i1, ret += "ab";
			++ i0, ++ i1;
		}
		return ret;
	} else {
		std::string max;
		for(int i = 0;i + i < s.size();++i) {
			std::string now; int ca = i, cb = i;
			for(auto c : s) if(--(c == 'a' ? ca : cb) < 0)
				now += c;
			if(now > max) max = now;
		}
		return max;
	}
}
int main() {
	std::cin >> n, n <<= 1; std::string str; char ch; int cnt = 0;
	std::vector<std::string> ans;
	while(std::cin >> ch) {
		str += ch; cnt += ch & 1 ? 1 : -1; -- n;
		if(cnt == 0) ans.push_back(calc(str)), str = "";
	}
	std::reverse(ans.begin(), ans.end()); std::string a;
	for(auto i : ans) {
		auto s = i + a;
		if(s > a) a = s;
	}
	std::cout << a << '\n';
}


Measured memory_bytes: 384
N, M = map(int, input().split())
MIN = 0
MAX = 110000
        
for i in range(M):
    L, R = map(int, input().split())
    MIN = max(MIN, L)
    MAX = min(MAX, R)
    #print(MIN, MAX)

ans = MAX-MIN+1 if MAX >= MIN else 0
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k;
  vector<int> vec(32);
  vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};
  cin >> k;
  
  cout << vec.at(k-1) << endl;
}
  
  

Measured memory_bytes: 256
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    string s;   
    cin>>s;
    int cnt=0;
    for(auto ch:s)
    {
        if(ch=='o')
            cnt++;
    }
    cnt+=(15-s.length());
    if(cnt>=8)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 15504
H,W,D = map(int,input().split())
A = [list(map(int,input().split())) for i in range(H)]
d = [[0,0,0] for _ in range(H*W+2)]
for h in range(H):
    for w in range(W):
        d[A[h][w]+1] = [h+1,w+1,0]
d = d[2:]
for i in range(H*W):
    if i < D:
        continue
    d[i][2] = d[i-D][2]+abs(d[i][0]-d[i-D][0])+abs(d[i][1]-d[i-D][1])
q = int(input())
for i in range(q):
    l,r = map(int,input().split())
    print(d[r-1][2]-d[l-1][2])

Measured memory_bytes: 20448
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	ctMultipleOf2 := 0
	ctMultipleOf4 := 0
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		if a%4 == 0 {
			ctMultipleOf4++
		} else if a%2 == 0 {
			ctMultipleOf2++
		}
	}

	ok := false
	if ctMultipleOf4*2+1 >= n {
		ok = true
	} else if n-ctMultipleOf4*2 <= ctMultipleOf2 {
		ok = true
	}

	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 5504
void solve();

int main() {
	solve();
	return 0;
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <limits.h>
#include <math.h>
#include <iomanip>
using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;

void solve() {
	int r; cin >> r;
	cout << 3 * r * r << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define all(m) m.begin(), m.end()
#define uid uniform_int_distribution
#define init(m, x) memset(m, x, sizeof(m));
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int G = 300000;
ll mx = 0, c = 0;
vec<ll> l[G];
ll us[G];

void dfs(int v){
    us[v] = 1;
    c++;
    for(int h : l[v]){
        if(!us[h]) dfs(h);
    }
}

int main() {
    fast;
    ll a, k; cin>>a>>k;
    for(int q=0; q<k; q++){
        ll x, y; cin>>x>>y; x--, y--;
        l[x].pb(y);
        l[y].pb(x);
    }
    init(us, 0);
    for(int q=0; q<a; q++){
        if(!us[q]){
            c = 0;
            dfs(q);
            mx = max(mx, c);
        }
    }
    cout<<mx;
}

Measured memory_bytes: 25532
#include<iostream>
#include<string>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;


int main(){
    string a;
    cin >> a;
    int num=0;
    num = count(a.cbegin(), a.cend(), 'o');
    if(15-a.size()+num>=8){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, p;
    cin >> a >> p;
    p += a * 3;
    cout << p / 2 << endl;
    return 0;
}


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

using ll = long long;

int main() {
    int N, A;
    cin >> N;
    vector<int> c(3, 0);
    ll ans = 1, MOD = 1000000007;
    rep(i, N) {
        cin >> A;
        int b = 0;
        rep(j, 3) {
            if (c[j] == A) b++;
        }
        ans = (ans * b) % MOD;
        rep(j, 3) {
            if (c[j] == A) {
                c[j]++;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

int n;
int a[N], cnt[N];

int32_t main()
{
	IOS;
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	int ans = 1;
	for(int i = 1; i <= n; i++)
	{
		if(a[i] == 0)
		{
			if(cnt[0] == 0)
				ans *= 3;
			else if(cnt[0] == 1)
				ans *= 2;
		}
		else
		{
			if(cnt[a[i] - 1] - cnt[a[i]] <= 0)
			{
				cout << 0;
				return 0;
			}
			ans *= (cnt[a[i] - 1] - cnt[a[i]]);
		}
		ans %= MOD;
		cnt[a[i]]++;
	}
	for(int i = 0; i < n; i++)
	{
		if(cnt[i] > 3)
		{
			cout << 0;
			return 0;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1792
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
int main() {
    ll n,l;
    string s[110];
    std::cin >> n>>l;
    for (int i = 0; i < n; i++) {
        std::cin >> s[i];
    }
    sort(s,s+n);
    for (int i = 0; i < n; i++) {
        std::cout << s[i];
    }
    std::cout << std::endl;
    
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 922337203685477580LL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

#define N 5010

//head

int k, q;
int d[N];
int nd[N];
ll sum, cnt0;
int n, x, m;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> k >> q;
  rep(i, k) cin >> d[i];
  while(q--) {
    cin >> n >> x >> m;
    x %= m;
    rep(i, k) nd[i] = d[i]%m;
    cnt0 = 0;
    rep(i, k) if(!nd[i]) cnt0++;
    sum = accumulate(nd, nd+k, 0LL);
    int u = (n-1)/k;
    sum *= u;
    cnt0 *= u;
    sum += x;
    rep(i, n-1-u*k) sum += nd[i];
    rep(i, n-1-u*k) if(!nd[i]) cnt0++;
    cout << n-1-sum/m-cnt0 << '\n';
  }
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 998244353;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}

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

int main(){
    ll n; cin >> n;
    vl d(n);
    vl v(n);
    rep(i,n){
        cin >> d[i];
        if(i==0){
            if(d[i]!=0){
                puts("0");
                return 0;
            }
        }
        v[d[i]]++;
    }
    ll ans = 1;
    bool flag = false;
    rep(i,n-1){
        if(i==0){
            if(v[i]!=1){
                puts("0");
                return 0;
            }
        }else{
            if(flag && v[i]!=0){
                puts("0");
                return 0;
            }
            if(v[i]==0){
                flag = true;
                continue;
            }
            ans *= modpow(v[i-1],v[i],mod);
            ans %= mod;
        }
    }
    cout << ans << endl;
}

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

value = [0] * N
weight = [0] * N

for i in range(N):
    value[i] = li[i][0]
    weight[i] = li[i][1]
    
dp = [[0] * (W+10) for _ in range(N+10)]

for i in range(N):
    for w in range(W+1):
        if w >= weight[i]:
            dp[i+1][w] = max(dp[i][w - weight[i]] + value[i], dp[i][w], dp[i+1][w - weight[i]] + value[i])
        else:
            dp[i+1][w] = dp[i][w]

print(dp[N][W])


Measured memory_bytes: 42608
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

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

int f(int x) {
    int res = 0;
    while (x%2 == 0) {
        x /= 2;
        res++;
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    vi a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) a[i] /= 2;
    int t = f(a[0]);
    rep(i, n) {
        if (t != f(a[i])) {
            cout << 0 << endl;
            return 0;
        }
        a[i] >>= t;
    }
    m >>= t;

    ll l = 1;
    rep(i, n) {
        l = lcm(l, a[i]);
        if (l > m) {
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans = (m+l)/(2*l);
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <random>
#include <cassert>
#include <numeric>
#define ll long long int
#define LL unsigned long long
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;



int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    bool flag = true;
    if(k%2==0){
        if(abs(a-b) > 1000000000000000000) {
            cout << "Unfair" << endl;
        }else{
            cout << a - b << endl;
        }
    }else{
        if(abs(a-b) > 1000000000000000000) {
            cout << "Unfair" << endl;
        }else{
            cout << b - a << endl;
        }
    }
}


Measured memory_bytes: 3688
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;
char s[201],t[201];
int sa,ta;
bool judge()
{
	int flag=0;
	for(int i=0;i<sa;i++)
	{
		if(s[i]!=t[i]) flag=1;
	}
	if(flag==0) return 1;
	else return 0;
}
void f()
{
	char a=s[0];
	for(int i=1;i<sa;i++)
	{
		s[i-1]=s[i];
	}
	s[sa-1]=a;
}
int main()
{
	cin>>s>>t;
	sa=strlen(s);
	ta=strlen(t);
	if(sa==ta)
	{
		if(judge()==1)
		{
			cout<<"Yes"<<endl;
		}
		else
		{
			int j=0;
			while(judge()==0&&j<=sa)
			{
				f();
				j++;
			}
			if(j==sa+1) cout<<"No"<<endl;
			else cout<<"Yes"<<endl;
		}
	}
	else
	{
		cout<<"No"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  double W,H,x,y;
  cin >> W >> H >> x >> y;
  double ans = W * H / 2;
    cout << ans <<endl;

  if((W == 2 * x) && (H == 2 * y)){
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }

}



Measured memory_bytes: 256
import java.util.*;

class Main{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int k = sc.nextInt();
	int[] d = new int[k];
	for(int i = 0; i < k; i++) {
		d[i] = sc.nextInt();
	}
	boolean flag = true;
	while(flag == true) {
		flag = false;
		for(int i = 0; i < k; i++) {
			if(String.valueOf(n).contains(String.valueOf(d[i]))) {
				flag = true;
				n++;
				break;
			}
		}
		if(flag == false) {
			System.out.println(n);
		}
	}
}
}

Measured memory_bytes: 38396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) solve();
}

void solve() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << c - min(a - b, c) << endl;
}


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

using namespace std;

#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second

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

ll modpow(ll a, ll b){

    ll ans=1;
    while(b){
        if(b&1){
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b=b/2;
    }
    return ans;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n;
    cin>>n;

    if(n&1) cout<<0<<endl;
    else {
        n = n/2;
        ll ans = 0;
        ll st = 5;
        while(n / st > 0) {
            ans += n/st;
            st=st*5;
        }

        cout<<ans<<endl;
    }


}


Measured memory_bytes: 256
N, M = map(int, input().split())
timeline = []
for i in range(M):
    P, Y = map(int, input().split())
    timeline.append((Y, P, i))
timeline.sort()
count = [0] * (N + 1)
number = [(0, 0)] * M
for y, p, i in timeline:
    count[p] += 1
    number[i] = (p, count[p])
for i in range(M):
    print('{:06}{:06}'.format(number[i][0], number[i][1]))


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

int main() {
  int N;
  cin >> N;
  int x = N % 10;
  if(x == 3) {
    cout << "bon" << endl;
  }
  else if( x == 0 || x == 1 || x == 6 || x == 8) {
    cout << "pon" << endl;
  }
  else {
    cout << "hon" << endl;
  }
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int N;

double nl = -1.0;

double dp[301][301][301];

double rec(int x, int y, int z){
    if(dp[x][y][z] != nl) return dp[x][y][z];
    double acc = 0.0;
    if(x > 0) acc += rec(x-1, y, z) * x;
    if(y > 0) acc += rec(x+1, y-1, z) * y;
    if(z > 0) acc += rec(x, y+1, z-1) * z;
    acc += N;
    acc = acc * 1.0/(x+y+z);
    return dp[x][y][z] = acc;
}

void init(){
    rep(i, 301) rep(j, 301) rep(k, 301) dp[i][j][k] = nl;
    dp[0][0][0] = 0.0;
}

int main(void){
    init();
    cin >> N;
    int cnt[4] = {};
    rep(i, N){
        int a; cin >> a;
        cnt[a]++;
    }
    double ans = rec(cnt[1], cnt[2], cnt[3]);
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 213376
import math
import fractions
import sys
import itertools
import numpy as np
from collections import Counter
import datetime
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(n,r))

# r=input1()
# print(2*math.pi*r)

n,m=input2()
A=input_array()

if n<sum(A):
	print(-1)
else:
	print(n-sum(A))















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

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

  string mon ;
  cin >> mon ;

  int sum = 0 ;
  for (int i = 1 ; i < mon.size() ; i++){
    if (mon.at(i-1) == mon.at(i)) sum++ ;
  }
  cout << n - sum << endl ;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#pragma GCC optimize "trapv"
#define pb push_back
#define fi first
#define se second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#include "debug.cpp"
#endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  int n; cin >> n;
  n--;
  if(n==0){
    cout << 0 << '\n';
  }else{
    
    int ans = 0;

    for(int k=1;k<=n;k++){
      ans = ans + n/k;
    }

    cout << ans << '\n';

  }


  return 0;
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define ll long long
    #define int long long
    #define pb push_back
    #define For(i,n) for(ll  i=0;i<n;i++)
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;clock_t clk = clock();
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define ld long double
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define fi first
    #define se second
    #define pii pair<ll,ll>
    #define endl "\n"
    #define sz(x) (int)(x).size()
    #define what_is(x) cerr << #x << " is " << x << endl;
    #define time cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';
    const double pi=3.14159265358979323846264;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
/*.....................................................................................................................*/

    ll mod =(ll)1e9+7;
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
    long long binpow(long long x, long long p) 
    {
        if (p == 0) return 1;
    	if (p == 2 || (p & 1)) return mult(x, binpow(x, p - 1));
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}

    // bool check(ll y){}
    ll binsearch(ll l,ll r)
    {
        // while(r-l>1)
        // {
        //     ll mid=(l+r)/2;
        //     if(check(mid))l=mid;
        //     else r=mid;
        // }
        return l;
    }
    const ll man=(ll)1e3+5;
    vector<ll>adj[man];
    bool vis[man][man];
    ll d[man],depth[man],par[man];
    void addedge(ll u,ll v){adj[u].pb(v);adj[v].pb(u);}
    ll dx[4]={1,-1,0,0};ll dy[4]={0,0,1,-1};
/*........................................................................................................................*/

signed main()/*Check flow...question galat mat padhna */
{
    fast;
    ll a=0,b=0;
    string s;
    cin>>s;
    for(auto c:s)
    {
        if(c=='0')a++;
        else b++;
    }
    cout<<2*min(a,b)<<endl;
}

Measured memory_bytes: 3804
N=int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))


result = sum(B)
before = -2

for a in A:
    if before+1 == a:
        result = result + C[a-2]
    before = a

print(result)

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

int main(){
  int64_t N;
  cin >> N;
  int r_N = sqrt(N);
  int ans = to_string(N).size() * 2;
  for(int i = 1; i <= r_N; i++){
    int digit_sum;
    if(N % i != 0) continue;
    int64_t a = i;
    int64_t b = N / i;
    digit_sum = max(to_string(a).size(),to_string(b).size());
    ans = min(ans,digit_sum);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n,m; cin >> n >> m;
    vstr a(n),b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];

    rep(i,n-m+1){
        rep(j,n-m+1){
            bool can=true;
            if(a[i][j]!=b[0][0]) continue;
            rep(k,m){
                rep(l,m){
                    if(a[i+k][j+l]!=b[k][l]) can=false;
                }
            }
            if(can){
                couty;
                return 0;
            }
        }
    }
    coutn;
}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, m; cin >> n >> m;
	vector<vector<int>> g(n);
	for (int i = 0; i < m; i++) {
		int u, v; cin >> u >> v;
		u--; v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	vector<int> d(n, -1);
	d[0] = 0;
	bool ok = false;
	function<void(int)> dfs = [&](int u) {
		for (auto v : g[u]) {
			if (d[v] != -1) {
				if (d[v] == d[u]) {
					ok = true;
				}
			} else {
				d[v] = 1 - d[u];
				dfs(v);
			}
		}
	};
	dfs(0);
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		cnt += d[i];
	}
	long long tot;
	if (ok) {
		tot = (long long)n * (n - 1) / 2;
	} else {
		tot = (long long)cnt * (n - cnt);
	}
	cout << tot - m << endl;
	return 0;
}


Measured memory_bytes: 10064
import java.io.FileNotFoundException;
import java.util.Scanner;

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

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int D = sc.nextInt();


		if(N%(2*D+1)==0){
			System.out.println(N/(2*D+1));
		} else {
			System.out.println(N/(2*D+1)+1);
		}

	}
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  vector<int> v(n); cin >> v;
  int x = 1001001001;
  int sum = 0;
  for(auto e:v){
    sum += e;
    if(e % 10 != 0)ChangeMin(x,e);
  }
  if(sum%10 == 0)sum = max(0,sum-x);
  cout << sum << endl;
}



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

int digit(int x)
{
	int digit = 1;
	while (x /= 10)
	{
		digit++;
	}
	return digit;
}

int main()
{
	vector<int> a(201, -1);
	vector<int> b(201, -1);
	int i = 0;
	while (1)
	{
		cin >> a[i] >> b[i];
		if (cin.eof())
		{
			break;
		}
		i++;
	}
	i = 0;
	while (a[i] >= 0)
	{
		cout << digit(a[i] + b[i]) << endl;
		i++;
	}
	return 0;
}


Measured memory_bytes: 3100