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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N;
VL a;
VL now(13);

signed main() {
    cin >> N;
    PQG pq;
    ll sum = 0;
    REP(i, N) {
        LCIN(s);
        if(s % 10) pq.emplace(s);
        sum += s;
    }
    while(!pq.empty()) {
        if(sum % 10) {
            cout << sum << "\n";
            return 0;
        }
        sum -= pq.top();
        pq.pop();
    }
    cout << 0 << "\n";
}

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

int main(){
    int i,j,a,b;
    while(true){
        cin >> a >> b;
        if(a+b==0){
            return 0;
        }
        for(i=0; i<a; i++){
            for(j=0; j<b; j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3084
# -*- coding: utf-8 -*-
"""
Created on Fri May  4 20:13:10 2018
ALDS1_10_A
@author: maezawa
"""

fib_arr = [None for _ in range(45)]
fib_arr[0] = 1
fib_arr[1] = 1

def fib(n):
    if fib_arr[n] != None:
        return fib_arr[n]
    fib_arr[n] = fib(n-1)+fib(n-2)
    return fib_arr[n]
    
n = int(input())
print(fib(n))


Measured memory_bytes: 5616
#include<stdio.h>

int main(){
int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a > b || a > c){
    if(a == b + c){
      printf("Yes");
    }
    else{
    printf("No");
  }
  }
  else if(b > a || b > c){
    if(b == a + c){
      printf("Yes");
    }
    else{
    printf("No");
  }
  }
  else if(c > a || c > a){
    if(c == a + b){
      printf("Yes");
    }
    else{
    printf("No");
  }
  }
  else{
    printf("No");
  }
  return 0;
}

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

int n, t; 

int main(){

	scanf("%d %d", &n,&t); int mx = 0;
	for (int i = 1, x; i <= n; i ++){
		scanf("%d", &x);
		mx = max(x, mx);
		int now = t / mx + 1;
		if((now-1)*mx + x <= t) now++;
		
		if(t<=0){printf("1\n");t=0;continue;}
		else printf("%d\n", now);		
		t -= x;
	}
	
    return 0;
}



Measured memory_bytes: 3216
class Node
  attr_accessor :id, :left, :right, :parent, :sibling
  def initialize(id,left=nil,right=nil)
    @id,@left,@right=id,left,right
    @sibling,@parent=nil,nil
  end

  def height
    return -1 if @id==-1
    return @left.height<@right.height ? @right.height+1 : @left.height+1
  end

  def depth(root)
    return 0 if @id==root.id
    return @parent.depth(root)+1
  end

  def type
    if @parent.id==-1
      return "root"
    elsif @left.id==-1 && @right.id==-1
      return "leaf"
    else
      return "internal node"
    end
  end


  def degree
    if @left.id>=0&&@right.id>=0
      return 2
    elsif @left.id==-1&&@right.id==-1
      return 0
    else
      return 1
    end
  end
end

n=gets.to_i
nodes=[]
(0..n-1).each do |i|
  id,l,r=gets.split.map(&:to_i)
  nodes[id]=Node.new(id,l,r)
end

nodes.each do |i|
  i.left=i.left==-1?Node.new(-1):nodes[i.left]
  i.right=i.right==-1?Node.new(-1):nodes[i.right]
  i.left.sibling,i.right.sibling=i.right,i.left
  i.left.parent=i.right.parent=i
end

root=nil
nodes.each do |i|
  if i.parent==nil
    root=i
    root.sibling,root.parent=Node.new(-1),Node.new(-1)
  end
end

(0..nodes.size-1).each do |i|
  c=nodes[i]
  puts "node #{i}: parent = #{c.parent.id}, sibling = #{c.sibling.id}, degree = #{c.degree}, depth = #{c.depth(root)}, height = #{c.height}, #{c.type}"
end

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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  bool no = false;
  if (a == b && a == c && b == c)
    no = true;
  if (a != b && a != c && b != c)
    no = true;
  
  if(no)
   cout << "No" << endl;
  else
    cout << "Yes" << endl;
}

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

using namespace std;

template <long long Mod> struct ModInt { /* {{{ */
  long long v;
  constexpr ModInt(const long long x = 0) {
    v = x % Mod;
    if (v < 0) {
      v += Mod;
    }
  }
  constexpr ModInt operator+(const ModInt rhs) const { return ModInt(*this) += rhs; }
  constexpr ModInt operator-(const ModInt rhs) const { return ModInt(*this) -= rhs; }
  constexpr ModInt operator*(const ModInt rhs) const { return ModInt(*this) *= rhs; }
  constexpr ModInt operator/(const ModInt rhs) const { return ModInt(*this) /= rhs; }
  const ModInt &operator+=(const ModInt rhs) {
    v += rhs.v;
    if (v >= Mod) {
      v -= Mod;
    }
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) {
    if (v < rhs.v) {
      v += Mod;
    }
    v -= rhs.v;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) {
    v = v * rhs.v % Mod;
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) {
    long long exp = Mod - 2;
    while (exp) {
      if (exp & 1) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp >>= 1;
    }
    return *this;
  }
  friend ostream &operator<<(ostream &s, ModInt<Mod> m) {
    s << m.v;
    return s;
  }
  friend istream &operator>>(istream &s, ModInt<Mod> m) {
    s >> m.v;
    return s;
  }
}; /* }}} */

const int mod = 1e9 + 7;
using modint = ModInt<mod>;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> X(N), Y(M);
  modint v, w;
  for (int i = 0; i < N; i++) {
    cin >> X[i];
    if (i > 0) v += (modint)(X[i] - X[i - 1]) * i * (N - i);
  }
  for (int i = 0; i < M; i++) {
    cin >> Y[i];
    if (i > 0) w += (modint)(Y[i] - Y[i - 1]) * i * (M - i);
  }
  cout << v * w << endl;

  return 0;
}
/* vim:set fdm=marker: */


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

int main(void){
    int n;
    cin >> n;
    for(int i=1; i<=n; i++){
        int x=i;
        if(x%3 == 0){
            cout << " " << i;
            continue;
        }
        do{
            if(x%10 == 3){
                cout << " " << i;
                break;
            }
            x /= 10;
        }while(x);
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

class UnionFind {
    int n;
    vector<int> uni;
    int forest_size;
public:
    explicit UnionFind(int n) : n(n), uni(static_cast<u32>(n), -1), forest_size(n) {};

    int root(int a){
        if (uni[a] < 0) return a;
        else return (uni[a] = root(uni[a]));
    }

    bool unite(int a, int b) {
        a = root(a);
        b = root(b);
        if(a == b) return false;
        if(uni[a] > uni[b]) swap(a, b);
        uni[a] += uni[b];
        uni[b] = a;
        forest_size--;
        return true;
    }
    int size(){ return forest_size; }
    int size(int i){ return -uni[root(i)]; }
    bool same(int a, int b) { return root(a) == root(b); }
};

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--; b--;
        uf.unite(a, b);
    }
    cout << uf.size()-1 << "\n";
    return 0;
}

Measured memory_bytes: 3788
#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.at(i);
  sort(a.begin(),a.end());
  int ans=a[N-1]-a[0];
  cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <tuple>
#include <cmath>
#include <map>
#include <climits>
#include <deque>
#include <numeric>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n,m) for(int i=n;i<m;i++)
int main()
{
    int N, K; cin >> N >> K;
    int cur = 1;
    while (N--) cur += min(cur, K);
    cout << cur << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		int q = sc.nextInt();
		for (;;) {
			if (q == 0)
				break;
			String s = sc.next();
			String ss[] = s.split("\\B");
			int[] ds = new int[8];
			for (int i = 0; i < ss.length; i++) {
				ds[i] = Integer.parseInt(ss[i], 16);
			}
			StringBuilder bs = new StringBuilder();
			for (int i = 0; i < 8; i++) {
				bs.append(d2b(ds[i]));
			}
			StringBuilder ans = new StringBuilder();
			if (bs.charAt(0) == '1')
				ans.append("-");
			int z = 0;
			for (int i = 1; i <= 24; i++) {
				int b = bs.charAt(i) - '0';
				z += b << (24 - i);
			}
			double[] fs = { 0.5, 0.25, 0.125, 0.0625, 0.03125, 0.015625,
					0.0078125 };
			double r = 0.0;
			for (int i = 0; i < 7; i++) {
				if (bs.charAt(25 + i) == '1') {
					r += fs[i];
				}
			}
			ans.append(z);
			ans.append(".");
			String[] rr = Double.toString(r).split("\\.");
			ans.append(rr[1]);
			System.out.println(ans.toString());
			q--;
		}
	}

	String d2b(int n) {
		StringBuilder sb = new StringBuilder();
		for (int i = 3; i >= 0; i--) {
			if (n - (1 << i) >= 0) {
				sb.append(1);
				n -= 1 << i;
			} else {
				sb.append(0);
			}
		}
		return sb.toString();
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 70544
use proconio::input;

// use std::cmp::*;
// use std::collections::*;
// use proconio::marker::Chars;

fn main() {
    input! {
        // s: String
        // n: isize
        mut abc: [i64;3]
    }
    abc.sort();
    if (abc[0] == 5 && abc[1] == 5 && abc[2] == 7) {
        println!("{}", "YES");
    } else {
        println!("{}", "NO");
    }
}


Measured memory_bytes: 2172
#include<iostream>
#include<algorithm>
using namespace std;
int N,Q;
long L,R;
long A[2<<17];
int q[2<<17];
long x[2<<17],s[2<<17],t[2<<17];
long calc(int id)
{
	long now=A[id];
	for(int i=0;i<Q;i++)
	{
		if(q[i]==1)
		{
			if(now>=x[i])
			{
				now=t[i]*(now+s[i]);
			}
		}
		else
		{
			if(now<=x[i])
			{
				now=(now-s[i])/t[i];
			}
		}
	}
	return now;
}
main()
{
	cin>>N>>Q>>L>>R;
	for(int i=0;i<N;i++)cin>>A[i];
	sort(A,A+N);
	for(int i=0;i<Q;i++)
	{
		cin>>q[i]>>x[i]>>s[i]>>t[i];
	}
	int l=-1,r=N;
	while(r-l>1)
	{
		int M=l+r>>1;
		if(calc(M)<L)l=M;
		else r=M;
	}
	int left=r;
	l=-1,r=N;
	while(r-l>1)
	{
		int M=l+r>>1;
		if(calc(M)>R)r=M;
		else l=M;
	}
	int right=l;
	cout<<right-left+1<<endl;
}



Measured memory_bytes: 9972
from collections import Counter
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=[0]*(n+1)
for i in range(n):
    b[i+1]=(a[i]+b[i])%m
ans=0
for i in Counter(b).values():
    ans+=i*(i-1)//2
print(ans)

Measured memory_bytes: 17340
//password1488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 2e5+228;

signed main(){
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
    ll n, on;
    cin >> n;
    on = n;
    ll r=0;
    for(ll i = 2;i*i<=n;i++){
        if(on%i) continue;
        ll c=0;
        while(on%i==0) ++c, on/=i;
        ll ww = 1 ,wk=0;
        while(wk+ww<=c) wk+=ww++;
        r+=ww-1;
    }
    if(on-1) r++;
    cout<<r;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
signed main() {
	 int N;
     cin>>N;
     int ans=0;

     vector<int>L(N);
     for(int i=0;i<N;i++){
         cin>>L[i];
     }
     sort(L.begin(), L.end());
     for(int i=0;i<N;i++){
         for(int j=i+1;j<N;j++){
             for(int k=j+1;k<N;k++){
                if(L[i]+L[j]>L[k]){
                    ans++;
                }
             }
         }
     }
     cout<<ans<<endl;
}

Measured memory_bytes: 3604
use std::io;

fn main() {
        let n = get_string().parse::<u64>().unwrap();
        let a = get_string().parse::<u64>().unwrap();

        println!("{}", n * n - a);
}

fn get_string() -> String {

        let mut line = String::new();
        io::stdin().read_line(&mut line).ok();
        line.trim().to_string()
}

Measured memory_bytes: 4352
#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 main(void){
    vector<string> ans;
    while(true){
        char S[256];
        fgets(S, 256, stdin);
        int lenS = strlen(S);
        if(S[0] == '.' && lenS == 2) break;
        bool ok = true;
        stack<char> st;
        st.push('A');
        rep(i, lenS){
            if(S[i] == ')'){
                char tp = st.top();
                st.pop();
                if(tp != '('){
                    ok = false;
                    break;
                }
            }
            else if(S[i] == ']'){
                char tp = st.top();
                st.pop();
                if(tp != '['){
                    ok = false;
                    break;
                }
            }
            else if(S[i] == '('){
                st.push(S[i]);
            }
            else if(S[i] == '['){
                st.push(S[i]);
            }
        }
        if(st.empty() || st.top() != 'A') ok = false;
        if(ok) ans.push_back("yes");
        else ans.push_back("no");
    }
    rep(i, ans.size()) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 3332
from fractions import gcd
n, X = map(int, input().split())
x = [X] + list(map(int, input().split()))
x.sort()
ans = []
for i in range(n):
    ans.append(x[i+1]-x[i])

d = ans[0]
for i in range(1, len(ans)):
    d = gcd(d, ans[i])
print(d)

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

using namespace std;

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

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define fi first
#define se second
#include <bits/stdc++.h>

using namespace std;

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

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define fi first
#define se second


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

    string s;
    cin >> s;

    int a[2];
    a[0] = a[1] = 0;

    for(int i = 0; i < sz(s); ++i)
    {
        int broj = s[i] - '0';
        ++a[broj];
    }

    cout << 2*min(a[0],a[1]) << '\n';
}


Measured memory_bytes: 3768
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<ctype.h>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<math.h>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<stdio.h>
#include<stdlib.h>
#include<streambuf>
#include<string.h>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
int main(void){
	int n;
	scanf("%d",&n);
	int sum=0;
	for (int i=1;;i++){
		sum+=i;
		if (sum>=n){
			printf("%d",i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
ans = 0
for i in range(len(a)):
    if i+1 == len(a):
        if a[i] == m:
            ans += 1
        break
    else:
        if a[i]<=m:
            m -= a[i]
            ans += 1
print(ans)


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

int main(){
  	int a;	
  	std::cin >> a;
 	if(a < 3200){
      std::cout << "red" << std::endl;
    }
  	else{
	  std::string s;
      std::cin >> s;
      std::cout << s << std::endl;
    }
  return 0;
}
  	

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    map<string,int> counter;

    for(int i=0 ; i<n ; i++)
    {
        string temp;
        cin>>temp;
        counter[temp]++;
    }

    cout<<"AC x "<<counter["AC"]<<endl;
    cout<<"WA x "<<counter["WA"]<<endl;
    cout<<"TLE x "<<counter["TLE"]<<endl;
    cout<<"RE x "<<counter["RE"]<<endl;

    return 0;
}


Measured memory_bytes: 3616
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p
 
H,W,A,B=map(int, input().split())
p=10**9+7
X=[1]  #階乗テーブル
for i in range(1,H+W-1):
  X+=[ (X[-1]*i) %p ]
Y=[1]*(H+W-1)  #階乗の逆元テーブル
Y[H+W-2]=power_func(X[H+W-2],p-2,p)
for i in range(H+W-3,-1,-1):
  Y[i]=Y[i+1]*(i+1) %p

ans=0
for i in range(B,W):
  ans+=X[H-A-1+i]*X[A+W-2-i]*Y[H-A-1]*Y[i]*Y[A-1]*Y[W-1-i]
 
print(ans%p)

Measured memory_bytes: 18988
#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 vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
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;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    string s;
    cin >> s;

    vll rgb(3, 0);
    rep(i, n) {
        if (s[i] == 'R') {
            rgb[0]++;
        } else if (s[i] == 'G') {
            rgb[1]++;
        } else {
            rgb[2]++;
        }
    }
    ll ans = rgb[0] * rgb[1] * rgb[2];
    for (int i = 1; 2*i + 1 <= n; i++) {
        rep(j, n - 2*i) {
            char a, b, c;
            a = s[j];
            b = s[j+i];
            c = s[j+2*i];
            if (a != b && b != c && c!= a) ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3656
/**
 * @author khokharnikunj8
 */

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

using namespace std;

class AServalVsMonster {
public:
    void solve(std::istream &in, std::ostream &out) {
        int h, a;
        in >> h >> a;
        if (h % a == 0) {
            out << h / a;
        } else {
            out << (h / a + 1);
        }

    }
};


int main() {
    AServalVsMonster solver;
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, int> P;


int masu[2010][2010] = {0};

int main()
{
    int h, w;
    cin >> h >> w;

    vector<int> yoko[h+1];
    vector<int> tate[w+1];
    rep(i, h) yoko[i+1].push_back(0);
    rep(j, w) tate[j+1].push_back(0);
    rep(i, h)rep(j, w){
        char tmp; cin >> tmp;
        if(tmp == '#') {
            masu[i+1][j+1] = 1;
            yoko[i+1].push_back(j+1);
            tate[j+1].push_back(i+1);
        } 
    }
    rep(i, h) yoko[i+1].push_back(w+1);
    rep(j, w) tate[j+1].push_back(h+1);

    // rep(i, h) {show(yoko[i+1]);cout << endl;}
    // cout << endl;
    // rep(j, w) {show(yoko[j+1]);cout << endl;}


    int max_ans = 0;
    rep(i, h)rep(j,w){
        int ans = 0;
        if (masu[i+1][j+1] == 1) continue;
        auto x_itr = lower_bound(yoko[i+1].begin(), yoko[i+1].end(), j+1);
        auto y_itr = lower_bound(tate[j+1].begin(), tate[j+1].end(), i+1);
//        cout << *x_itr <<" " << *y_itr << endl;
//        cout << *(x_itr-1) <<" " << *(y_itr-1) << endl;

        ans += *(x_itr) - *(x_itr-1) -1;
        ans += *(y_itr) - *(y_itr-1) -1;
        ans -= 1;
//        cout << i << j << ":" << ans << endl;
        max_ans = max(max_ans, ans);
    }
    cout << max_ans << endl;
}



Measured memory_bytes: 50048
#include<iostream>
#include<cmath>
#include<iomanip>
#include<array>
#include<string>
#include<vector>
using namespace std;
typedef int q;
typedef double w;
int main()
{
	string s;
	cin>>s;
	q x=0;
	for(q z=0;z<s[z];z++){
		if(s[z]=='+'){x++; continue;}
		else{x--; continue;}
		 
		
		}
	
	
	
	cout<<x;
	
	
	
	
	
	
	
	
	
	
	
	
return 0;}

Measured memory_bytes: 256
x, y = map(int, input().split())
g1 = [2]
g2 = [4, 6, 9, 11]
g3 = [1, 3, 5, 7, 8, 10, 12]
if x in g1 and y in g1:
  print("Yes")
elif x in g2 and y in g2:
  print("Yes")
elif x in g3 and y in g3:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
string s;
vector<char> v;
int main(){
	cin >> s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='B'){
			if(v.size()!=0){
				v.pop_back();
			}
		}else{
			v.push_back(s[i]);
		}
	}
	for(int i=0;i<v.size();i++){
		cout << v[i];
	}
}

Measured memory_bytes: 256
#065-D
#クラスカル法
import heapq
V=int(input())#Eは辺の数、Vは頂点の数
vlist=[]
eque=[]
for i in range(V):
    x,y=map(int,input().split())
    vlist.append([i,x,y])

vlist.sort(key=lambda x:x[1])
for i in range(V-1):
    heapq.heappush(eque,[vlist[i+1][1]-vlist[i][1],vlist[i][0],vlist[i+1][0]])

vlist.sort(key=lambda x:x[2])
for i in range(V-1):
    heapq.heappush(eque,[vlist[i+1][2]-vlist[i][2],vlist[i][0],vlist[i+1][0]])


#Union-Find木
par=[]
rank=[]
def init(a): #初期化
    for i in range(a):
        par.append(i)
        rank.append(0)
def find(x): #根を見つける
    if par[x]==x:
        return x
    else:
        par[x]=find(par[x])
    return par[x]
def unite(x,y): #併合
    x=find(x)
    y=find(y)
    if rank[x]==rank[y]:
        par[x]=y
    else:
        par[y]=x
        if rank[x]==rank[y]:
            rank[x]+=1
    return
def same(x,y): #同じ集合か判定
    return find(x)==find(y)

init(V) #同じ木に属しているかどうかはUFTで判断する、初めは全部孤立した木

res=0 #合計コスト
while len(eque)!=0:
    te=heapq.heappop(eque)
    cost,u,v=te[0],te[1],te[2]
    if same(u,v): #同じ木に属していたら閉路ができるのでcontinue
        continue
    res+=cost
    unite(u,v) #辺を追加したら同じ木にする

print(res)

Measured memory_bytes: 55668
#include <bits/stdc++.h>
#include <set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000

#define writeln(n) cout<<n<<endl

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

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

const int inf=100000000;

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

llong gcd(llong a, llong b) {
        return b != 0 ? gcd(b, a % b) : a;
}
//setprecision(10);

//二項係数
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

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

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    COMinit();
    int n,k; cin>>n>>k;
    cout<<n-k+1<<endl;
    for(int i=2; i<=k; i++)
    {
        llong ans=0;
        llong vv=COM(k-1,i-1);
        llong v=COM(n-k+1,i);
        ans=v*vv%MOD;
        cout<<ans<<endl;
    }
    return 0;
    }

Measured memory_bytes: 12160
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 1e5 + 10;

bool seen[N];

vector<int> inverse(vector<int> p);
vector<int> compose(vector<int> p, vector<int> q);
vector<int> power(vector<int> p, int x);

int main() {
	fast_cin();
	int n, k;
	cin >> n >> k;
	int t = k;
	while (t > 1 and t % 6 != 2) {
		--t;
	}
	int x = (t - 2) / 6;
	vector<int> p(n + 1), q(n + 1);
	for (int i = 1; i <= n; ++i) {
		cin >> p[i];
	}
	for (int i = 1; i <= n; ++i) {
		cin >> q[i];
	}
	if (t == 1) {
		for (int i = 1; i <= n; ++i) {
			cout << p[i] << ' ';
		}
		cout << endl;
		return 0;
	}
	vector<int> p_inv = inverse(p);
	vector<int> q_inv = inverse(q);
	vector<int> u = q;
	u = compose(u, p_inv);
	u = compose(u, q_inv);
	u = compose(u, p);
	vector<int> v = inverse(u);
	vector<int> p_t1 = compose(compose(power(u, x), q), power(v, x));
	vector<int> p_t2 = compose(compose(power(u, x), compose(q, p_inv)), power(v, x));
	while (t + 1 < k) {
		vector<int> temp = compose(p_t2, inverse(p_t1));
		p_t1 = p_t2;
		p_t2 = temp;
		++t;
	}
	vector<int> ans;
	if (t == k) {
		ans = p_t1;
	} else {
		ans = p_t2;
	}
	for (int i = 1; i <= n; ++i) {
		cout << ans[i] << ' ';
	}
	cout << endl;
}

vector<int> inverse(vector<int> p) {
	int n = p.size() - 1;
	vector<int> ans(n + 1);
	for (int i = 1; i <= n; ++i) {
		ans[p[i]] = i;
	}
	return ans;
}

vector<int> compose(vector<int> p, vector<int> q) {
	int n = p.size() - 1;
	vector<int> ans(n + 1);
	for (int i = 1; i <= n; ++i) {
		ans[i] = p[q[i]];
	}
	return ans;
}

vector<int> power(vector<int> p, int x) {
	memset(seen, 0, sizeof(seen));
	int n = p.size() - 1;
	vector<int> ans(n + 1);
	for (int i = 1; i <= n; ++i) {
		if (seen[i]) {
			continue;
		}
		vector<int> cycle;
		int u = p[i];
		while (!seen[u]) {
			seen[u] = true;
			cycle.pb(u);
			u = p[u];
		}
		int k = cycle.size();
		for (int j = 0; j < k; ++j) {
			ans[cycle[j]] = cycle[(j + x) % k];
		}
	}
	return ans;
}

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

int main()
{
	string s[3];
	
	while (cin >> s[0], s[0] != "0"){
		cin >> s[1] >> s[2];
		
		bool c = true;
		for (int i = 0; i < 3; i++){
			if (s[i] == "www"){
				cout << "w" << endl;
				c = false;
				break;
			}
			else if (s[i] == "bbb"){
				cout << "b" << endl;
				c = false;
				break;
			}
			else if (s[0][i] == 'w' && s[1][i] == 'w' && s[2][i] == 'w'){
				cout << "w" << endl;
				c = false;
				break;
			}
			else if (s[0][i] == 'b' && s[1][i] == 'b' && s[2][i] == 'b'){
				cout << "b" << endl;
				c = false;
				break;
			}
			else if (s[0][0] == 'w' && s[1][1] == 'w' && s[2][2] == 'w'){
				cout << "w" << endl;
				c = false;
				break;
			}
			else if (s[0][0] == 'b' && s[1][1] == 'b' && s[2][2] == 'b'){
				cout << "b" << endl;
				c = false;
				break;
			}
			else if (s[0][2] == 'w' && s[1][1] == 'w' && s[2][0] == 'w'){
				cout << "w" << endl;
				c = false;
				break;
			}
			else if (s[0][2] == 'b' && s[1][1] == 'b' && s[2][0] == 'b'){
				cout << "b" << endl;
				c = false;
				break;
			}
		}
		if (c){
			cout << "NA" << endl;
		}
	}
	
	return (0);
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
#define int long long

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

  string s,t; cin >> s >> t;
  vector< vector<int> > dp(3001,vector<int>(3001,0));
  for(int i = 0; i < s.size(); i++){
    for(int j = 0; j < t.size(); j++){
      if(s[i] == t[j]) dp[i+1][j+1] = dp[i][j] + 1;
      else dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
    }
  }

  string ans;
  int i = s.size(),j = t.size();
  while(ans.size() != dp[s.size()][t.size()]){
    if(dp[i-1][j] == dp[i][j]) i--;
    else if(dp[i][j-1] == dp[i][j]) j--;
    else {
      i--,j--;
      ans += s[i];
    }
  }
  reverse(ans.begin(),ans.end());
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 70784
N = int(input())
A, B = map(int, input().split())
P = input().split()

low = []
middle = []
high = []

for i in range(len(P)):
    P[i] = int(P[i])
    if P[i] <= A:
        low.append(P[i])
    elif P[i] <= B:
        middle.append(P[i])
    else:
        high.append(P[i])

atta = [len(low), len(middle), len(high)]

print(min(atta))


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

#define ld long double
using namespace std;

ld f(int N, int K, int i, vector<ld> &prob, vector<vector<ld> > &dp) {
    if (K > N or K < 0)
        return 0;

    if (dp[N][K] != -1) {
        return dp[N][K];
    }

    // prob of choosing tail at ith coin and making K heads from N-1 coins
    // plus prob of choosing head at ith coin and making K-1 heads from N-1 coins
    dp[N][K] = f(N - 1, K, i - 1, prob, dp) * (1 - prob[i])
               + f(N - 1, K - 1, i - 1, prob, dp) * prob[i];

    return dp[N][K];
}

int main() {
    int N;
    cin >> N;
    vector<ld> prob(N + 1, 0);
    vector<vector<ld> > dp(N + 1, vector<ld>(N + 1, -1));
    dp[0][0] = 1;
    ld res = 0;

    for (int i = 1; i <= N; i++)
        cin >> prob[i];

    for (int k = N / 2 + 1; k <= N; k++) {
        res += f(N, k, N, prob, dp);
    }

//    for (auto row:dp) {
//        for (auto i:row)
//            cout << i << "\t";
//        cout << endl;
//    }

    cout << fixed << setprecision(10) << res << endl;

    return 0;
}

Measured memory_bytes: 141312
# coding: utf-8

# https://atcoder.jp/contests/abc112


def main():
    N = int(input())

    x, y, h = [None] * N, [None] * N, [None] * N

    for i in range(N):
        x[i], y[i], h[i] = map(int, input().split())

    for cx in range(0, 101):
        for cy in range(0, 101):
            first = True
            notans = False
            for i in range(N):
                # print(cx, cy, i)
                if h[i] > 0:
                    H = h[i] + abs(x[i]-cx) + abs(y[i]-cy)
                    if first:
                        first = False
                        pre_H = H
                    else:
                        if H != pre_H:
                            break
            if H == pre_H:
                for i in range(N):
                    if h[i] == 0:
                        if H - abs(x[i]-cx) - abs(y[i]-cy) > 0:
                            notans = True
                            break

                if notans:
                    continue

                print(cx, cy, H)
                return None


main()
# print(main())


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
static const int maxn = 2e5 + 5;
int a[maxn],sum[maxn];
int main()
{
	int n;
	cin>>n;
	for(int i = 1;i <= n; ++i)
	{
		int x;
		cin>>x;
		a[i] = a[i - 1] + x;
		sum[i] = sum[i - 1] ^ x;
	}
	long long ans = 0;
	int l = 1;
	for(int r = 1;r <= n; ++r)
	{
		while((a[r] - a[l - 1]) != (sum[r] ^ sum[l - 1]))
		{
			l++;
		}
		ans += (r - l + 1);
		// printf("ans = %lld,r = %d,l = %d\n",ans,r,l);
	}
	printf("%lld\n",ans);
	return 0;
}

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int n;
int w[105];
int main() {
	std::cin >> n;

	for (int i = 0; i < n; ++i)
		std::cin >> w[i];

	int a, b;
	int ans = 99999999;
	for (int i = 1; i < n; ++i) {
		a = 0, b = 0;
		for (int j = 0; j < n; ++j)
			if (j > i)
				a += w[j];
			else
				b += w[j];
		ans = std::min(ans, std::abs(a - b));
	}

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


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

void input()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
    #endif
}
#define endl "\n"
#define ll long long int
#define vll vector<double>
#define pb push_back
#define pll pair<ll,ll>
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define tll tuple<ll,ll,ll>
#define mt make_tuple
#define INF LONG_LONG_MAX
#define mod 1000000007
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define cases ll t; cin>>t; while(t--)
#define array(a,n) vll a(n); rep(i,0,n) cin>>a[i];
#define sortall(a) sort(a.begin(),a.end())
#define printall(a) rep(i,0,a.size()) cout<<a[i]<<" "; cout<<endl;

// --------------- My Template End --------------- //


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

   	  ll n;
    cin>>n;
    cout<<n+n*n+n*n*n;
        
}





Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int f = sc.nextInt();

		double max = 0;
		int maxAll = 0;
		int maxSugar = 0;
		int sugarMax;
		int aMax;
		int bMax;
		int cMax;
		int cMax1;
		int cMax2;
		int dMax;
		int dMax1;
		int dMax2;
		double temp;

		aMax = f / a * 100;
		for (int i = 0; i <= aMax; i++) {
			bMax = (f - a * i * 100) / b * 100;
			for (int j = 0; j <= bMax; j++) {
				sugarMax = (a * i + b * j) * e;
				cMax1 = sugarMax / c;
				cMax2 = (f - a * i * 100 - b * j * 100) / c;
				if(cMax1 < cMax2) {
					cMax = cMax1;
				} else {
					cMax = cMax2;
				}
				for (int k = cMax; k >= 0; k--) {
					dMax1 = (sugarMax - k * c) / d;
					dMax2 = (f - a * i * 100 - b * j * 100 - c * k) / d;
					if(dMax1 < dMax2) {
						dMax = dMax1;
					} else {
						dMax = dMax2;
					}
					for (int l = dMax; l >= 0; l--) {
						if (!(i + j + k + l == 0)) {
							temp = (double) 100 * (c * k + d * l) / ((a * i + b * j) * 100 + (c * k + d * l));
							if (temp > e) {
								break;
							}
							if (temp > max) {
								max = temp;
								maxAll = (a * i + b * j) * 100 + c * k + d * l;
								maxSugar = c * k + d * l;
							}
							if (max == (double) 100 * e / (e + 100)) {
								System.out.print(maxAll);
								System.out.print(" ");
								System.out.print(maxSugar);
								return;
							}
						}
					}
				}
			}
		}
		if (max == 0) {
			maxAll = a * 100;
		}

		System.out.print(maxAll);
		System.out.print(" ");
		System.out.print(maxSugar);
	}
}


Measured memory_bytes: 21844
// Problem : D - Replacing
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize "trapv"//  WA to RE int!!
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORR(i,n) for(int i=n;i>=0;i--)
#define pb push_back
#define vlli vector<int>
#define slli set<int>
#define mlli map<int,int>
#define int long long int 
#define test int tt1234; cin>>tt1234;while(tt1234--)
#define endl "\n"
#define all(zz) zz.begin(),zz.end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define error(x) cerr << #x <<" is " << x << endl;
#define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fint fast;test
#define SI(a,n) int a[n];FOR(i,n) cin>>a[i];
#define input(a,n) int n;cin>>n; SI(a,n)
#define set(a,x) memset(a,x,sizeof(a))
#define L(x)	((x)<<1)
#define R(x)	(((x)<<1)+1)
#define ft first
#define se second
#define MOD 1000000007
using namespace std;

void solve(){
	mlli m;
	int n;
	cin>>n;
	int sum=0;
	FOR(i,n){
		int y;
		cin>>y;
		sum+=y;
		m[y]++;
	}	
	int q;
	cin>>q;
	while(q--){
		int a,b;
		cin>>a>>b;
		int total=m[a];
		sum-=(a*total);
		sum+=b*total;
		m[b]+=total;
		m[a]=0;
		cout<<sum<<endl;
	}
	return;	
}


int32_t main() {
    // fint{
    	fast;
    	solve();
    // }
    return 0;
}


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

int main(){
  int n,x;
  cin >> n >> x;
  int ans=1,b,now=0;
  for(int i=0;i<n;i++){
    cin >> b;
    now+=b;
    if(now<=x)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
    char x,y;
    cin >> x >> y;
    if((int)x < (int)y){
        cout << " < ";
    } else if((int)x > (int)y){
        cout << " > ";
    } else {
        cout << " = ";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

const int m = 10;

int main(){
  int n; cin >> n;
  vvi f(n,vi(m));
  rep(i, n) rep(j, m) cin >> f[i][j];
  vvi p(n,vi(m+1));
  rep(i, n) rep(j, m+1) cin >> p[i][j];

  int ans = -1e9;
  for (int bit = 1; bit < (1 << m); bit++) {
    vi c(n);
    rep(i, n) rep(j, m){
      //if(bit & (1 << j)) if(f[i][j] == 1) c[i]++;
      if(f[i][j] && (bit & (1 << j))) c[i]++;
    }
    //std::cout << c[0] << '\n';
    int sum = 0;
    rep(i, n) sum += p[i][c[i]];
    chmax(ans, sum);
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
int main(){
long long a,b;
char c;
scanf("%lld %c %lld",&a,&c,&b);
if (c=='+')
    cout <<a+b;
else if (c=='-')
    cout <<a-b;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <math.h>
#include <algorithm>
#include <deque>
#include <climits>
using namespace std;
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repb(i,r,l) for(int i=r;i>l;i--)
#define ll long long
#define ull unsigned long long
#define ve vector
#define umap unordered_map
#define iter iterator

const ll MxN = 1e12;
void solve() {
    ll n,m;
    cin>>n>>m;
    if(n*2<=m) {
        cout<<((n*2)+m)/4<<endl;
    } else {
        cout<<m/2<<endl;
    }
}

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


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

using namespace std;

int main(){
    int i=0,m=0,n=0,temp=0,total=0;
    while(cin>>m){
        cin>>n;
        if(m<n){
            total=0;
            for(i=n-1;i>=0;i--){
               temp=m*(int)pow(10,i);
               total = total+temp;
            }
            cout<<total<<endl;
        }else if(m>n){
            total=0;
            for(i=m-1;i>=0;i--){
               temp=n*(int)pow(10,i); 
               total = total + temp;
            }
            cout<<total<<endl;
        }else{
            total=0;
            for(i=m-1;i>=0;i--){
                temp=n*(int)pow(10,i); 
                total= total + temp;
            }
            cout<<total<<endl;  
        }
    }
    return 0;
}

Measured memory_bytes: 256
n, k = list(map(int, input().split()))
s = str(input())
prev = '1'
r = []
for i in range(n):
  if s[i] != prev:
    if s[i] == '0':
      f = i
    else:
      r.append((f, i))
  prev = s[i]
if s[-1] == '0':
  r.append((f, n))
if k >= len(r):
  print(n)
else:
  a = 0
  for i in range(len(r) - k + 1):
    if i == 0:
      begin = 0
    else:
      begin = r[i-1][1]
    if i == len(r) - k:
      end = n
    else:
      end = r[i+k][0]
    a = max(a, end - begin)
  print(a)

Measured memory_bytes: 9972
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    a = IR(n)
    d = defaultdict(int)
    b = a[::1]
    b.sort()
    for i, bi in enumerate(b):
        d[bi] = i
    ans = [0, 0]
    for i in range(n):
        ans[i & 1] += d[a[i]] & 1 != i & 1
    print(max(ans))
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 56540
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;

const long long INF = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 200000;

int main() {
	int N;
	long long K;
	cin >> N >> K;
	vector<long long> A(N), F(N);
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> F[i];
	sort(A.begin(), A.end());
	sort(F.begin(), F.end(), greater<long long>());

	long long lower = 0, upper = 0;
	rep(i, N) upper = max(upper, A[i]*F[i]);
	long long mid = (lower + upper) / 2;
	long long ans = INF;
	while(lower <= upper) {
		long long num = 0;
		long long max_af = 0;
		rep(i, N) {
			if (A[i]*F[i] > mid) {
				num += (A[i]*F[i] - mid) / F[i];
				if ((A[i]*F[i] - mid) % F[i] != 0) num++;
			}
		}
		if (num > K)
			lower = mid + 1;
		else {
			upper = mid - 1;
			ans = min(ans, mid);
		}
		mid = (lower + upper) / 2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3328