akhauriyash/Code-Regression huggingface dataset:
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------
int n;
const int MX = 1e5 + 7;
ll a[MX];
ll b[MX];

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    cin >> n;
    FOR(i,0,n-1) cin >> a[i];
    FOR(i,1,n-1) a[i] += a[i-1];
    FOR(i,0,n-1) b[i] = a[i];

    ll total = 0;
    ll cnt1 = 0;
    ll cnt2 = 0;
    // a[0] < 0
    FOR(i,0,n-1) {
        a[i] += total;
        if(i%2==0) {
            if(a[i] > 0) continue;
            else {
                cnt1 += 1LL - a[i];
                total += 1LL - a[i];
            }
        } else {
            if(a[i] < 0) continue;
            else {
                cnt1 += a[i] + 1LL;
                total -= a[i] + 1LL;
            }
        }
    }
    total = 0;
    FOR(i,0,n-1) {
        b[i] += total;
        if(i%2==1) {
            if(b[i] > 0) continue;
            else {
                cnt2 += 1LL - b[i];
                total += 1LL - b[i];
            }
        } else {
            if(b[i] < 0) continue;
            else {
                cnt2 += b[i] + 1LL;
                total -= b[i] + 1LL;
            }
        }
    }
    cout << min(cnt1, cnt2) << endl;
    return 0;
}


Measured memory_bytes: 5212
#include<bits/stdc++.h>
using namespace std;
int main(){ 
  long long n,a[100],b[100],c[100],e=0,f=1000;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    cin>>b[i];
  }
  for(int i=0;i<n-1;i++){
    cin>>c[i];
  }
  for(int i=0;i<n;i++){
    e=e+b[a[i]-1];
    if(a[i]==f+1)
      e=e+c[f-1];
    f=a[i];
  }
    
  cout<<e<<endl;
  return(0);
}

Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <cstdio>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <chrono>
#include <functional>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

namespace atcoder {
	void judge_outer(bool judge_exp, string ok = "Yes", string ng = "No")
	{
		if (judge_exp) {
			cout << ok << endl;
		}
		else {
			cout << ng << endl;
		}
	}

	int ncr(int left, int right)
	{
		right = min(left - right, right);
		int ans = 1;
		for (int i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000256;
	const int tenfive = 100100;
}

using namespace atcoder;

int main(void)
{
	string c;
	cin >> c;
	bool flag = true;
	if (c[0] == 'A') {
		for (char i = 'A'; i <= 'Z'; i++) {
			if (c[1] == i ||c[c.length()-1] == i) {
				flag = false;
			}
		}
		if (flag) {
			int counter = 0;
			for (int i = 2; i < c.length() - 1; i++) {
				if (c[i] == 'C') {
					counter++;
				}
			}
			if (counter != 1) {
				flag = false;
			}
		}
	}
	else {
		flag = false;
	}
	judge_outer(flag, "AC", "WA");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>

using namespace std;

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long


int main(){
    int n; cin >> n;
    vector<lint> a; a.push_back(0);
    rep(i, n){
        lint x; cin >> x; a.push_back(x);
    }
    a.push_back(0);
    
    lint c = 0;
    rep(i, n + 1) c += abs(a[i+1] - a[i]);

    repn(i, n){
        lint res;
        if((a[i] - a[i-1])*(a[i+1] - a[i]) > 0) res = c;
        else res = c - abs(a[i]-a[i-1]) - abs(a[i+1]-a[i]) + abs(a[i+1]-a[i-1]);
        cout << res << endl;
    }
}

Measured memory_bytes: 2292
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int mod = 1_000_000_007;
        int[][] a = new int[N][N];
        for (int i=0;i<N;i++) {
            for (int j=0;j<N;j++) {
                a[i][j] = Integer.parseInt(sc.next());
            }
        }

        long[] dp = new long[1<<N];
        dp[0] = 1;
            for (int j=0;j<(1<<N);j++) {
                int tmp = j;
                int tmp_2 = j;
                int i=0;
                for (int k=0;k<N;k++) {
                    if ((tmp_2&1)==1) i++;
                    tmp_2=(tmp_2>>1);
                }
                for (int k=0;k<N;k++) {
                    if ((tmp&1)==0) {
                        if (a[i][k]==1) {
                            dp[j+(1<<k)] = (dp[j+(1<<k)]+dp[j])%mod;
                        }
                    }
                    tmp=(tmp>>1);
                }
            }
        System.out.println(dp[(1<<N)-1]);
    }
}

Measured memory_bytes: 40532
from collections import deque
 
K = int(input())
 
count = 0
Q = deque([1,2,3,4,5,6,7,8,9])
while count != K:
  a = Q.popleft()
  b = a%10
  if b != 0:
    Q.append(a*10 + b - 1)
  Q.append(a*10 + b)
  if b != 9:
    Q.append(a*10 + b + 1)
  count += 1
  #print(Q)
print(a)

Measured memory_bytes: 73824
public class Main {
	public static void main(String[] args) {
		var sc = new java.util.Scanner(System.in);
		var n = sc.nextInt();
		var a = new int[n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
		}
		var kai = a[0];
		for(int i=1;i<n;i++) {
			kai^=a[i];
		}
		for(int i=0;i<n;i++) {
			kai^=a[i];
			System.out.print(kai);
			if(i!=n-1) {
				System.out.print(" ");
			}
			kai^=a[i];
		}
		System.out.println();

	}
}

Measured memory_bytes: 60260
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int a[N];
  cin >> a[0];
  int c = a[0];
  for(int i=1;i<N;i++){
    cin >> a[i];
    c = __gcd(c,a[i]);
  }
  cout << c << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x, i, j) cerr << #x << "------------" << "\n";cerr << "from " << i << " to " << j << "\n";for(ll k=i; k<=j; k++) cerr << x[k] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
const ll mod = 1e9 + 7;
const ll inf = 1e11 + 5;
const int MaxN = 2e5 + 5;

int noOfDigits(int n){
	int ans = 0;
	while(n){
		ans++;
		n /= 10;
	}
	return ans;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	string s;
	cin >> s;
	int n = (int)s.length();
	int leftIdForRight[n], rightIdForLeft[n];
	stack<int> myStack;
	for(int i = 0; i < n; i++){
		if(s[i] == 'R'){
			myStack.push(i);
		}
		else{
			while(!myStack.empty()){
				leftIdForRight[myStack.top()] = i;
				myStack.pop();
			}
		}
	}

	for(int i = n - 1; i >= 0; i--){
		if(s[i] == 'L'){
			myStack.push(i);
		}
		else{
			while(!myStack.empty()){
				rightIdForLeft[myStack.top()] = i;
				myStack.pop();
			}
		}
	}

	vi ans(n);
	for(int i = 0; i < n; i++){
		if(s[i] == 'R'){
			int nextLeft = leftIdForRight[i];
			int stepsTaken = nextLeft - i;
			if(stepsTaken % 2 == 0){
				ans[nextLeft]++;
			}
			else{
				ans[nextLeft - 1]++;
			}
		}
		if(s[i] == 'L'){
			int nextRight = rightIdForLeft[i];
			int stepsTaken = nextRight - i;
			if(stepsTaken % 2 == 0){
				ans[nextRight]++;
			}
			else{
				ans[nextRight + 1]++;
			}
		}
	}
	for(int i = 0; i < n; i++){
		cout << ans[i] << " ";
	}
	cout << endl;
	return 0;
}			


Measured memory_bytes: 1872
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
 
int main() {
  ll n,k;
  cin >> n >> k;
  vl h;
  inputv(h,n);
  ll ans = INF;
  sort(h.begin(), h.end());
  rep(i,n-k+1){
    ans = min(ans, h[i+k-1] - h[i]);
  }
  cout << ans;
 return 0;
}

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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, w_cap;
    cin >> n >> w_cap;
    VI w(n), v(n);
    REP(i, n) cin >> w[i] >> v[i];
    VVL dp(n + 1, VL(w_cap + 10, 0));
    
    FOR(i, 1, n)FOR(j, 0, w_cap) {
        if(j - w[i - 1] < 0) dp[i][j] = dp[i - 1][j];
        else dp[i][j] = max(dp[i - 1][j - w[i - 1]] + v[i - 1], dp[i - 1][j]);
    }
    
    cout << dp[n][w_cap] << ln;
    return 0;
}


Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;

typedef tuple<ll,ll,ll> T;


ll i,j,k;


int main(){
    ll N;
    cin>>N;
    
    if(N<1200)cout<<"ABC";
    else if(N<2800)cout<<"ARC";
    else cout<<"AGC";
    cout<<endl;
}


Measured memory_bytes: 256
class UnionFindTree:
    """Disjoint-Set Data Structure
       Union-Find Tree
       
       used in SRM505 div.2 900
    """
    def __init__(self, n):
        self.par = list(range(n)) # parent
        self.rank = [0] * n # depth of tree

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y: return

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

class Kruskal:
    """ Kruskal's algorithm: find minimum spanning tree
        Complexity: O(E log(V))
        used in GRL2A(AOJ)
    """

    def __init__(self, V, E, start=0, INF=10**9):
        """ V: the number of vertexes
            E: adjacency list (undirected graph)
        """
        self.kruskal(V, E)

    def kruskal(self, V, E):
        edges = []
        for v1 in range(V):
            for v2, cost in E[v1]:
                if v1 < v2: edges.append((cost, v1, v2))
        edges.sort()
        self.mincost = 0
        self.minSpanningTree = []
        uf = UnionFindTree(V)
        for cost, v1, v2 in edges:
            if uf.same(v1, v2) == False:
                self.mincost += cost
                uf.unite(v1, v2)
                self.minSpanningTree.append((v1, v2, cost))

    def minCost(self):
        return self.mincost

    def getMinSpanningTree(self):
        return sorted(self.minSpanningTree)
    
V, E = map(int, input().split())
edge = [[] for _ in range(V)]
for _ in range(E):
    s, t, w = map(int, input().split())
    edge[s].append((t, w))
    edge[t].append((s, w))

msp = Kruskal(V, edge)
print(msp.minCost())

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

int main() {
  int N, K;
  cin >> N >> K;
  
  vector<int> H(N);
  for (int i = 0; i < N; i++) cin >> H.at(i);
  
  sort(H.begin(), H.end());
  
  int64_t sum = 0;
  for (int i = 0; i < N - K; i++) sum += H.at(i);
  
  cout << sum << endl;
}

Measured memory_bytes: 1024
if __name__ == "__main__":
    n = int(raw_input())

    s = []
    h = []
    c = []
    d = []

    i = 0
    while i < n:
        v = raw_input().split()
        if v[0] == "S":
            s.append(int(v[1]))
        elif v[0] == "H":
            h.append(int(v[1]))
        elif v[0] == "C":
            c.append(int(v[1]))
        elif v[0] == "D":
            d.append(int(v[1]))
        i += 1

    i = 1
    while i <= 13:
       if i not in s:
           print "S {0}".format(i)
       i += 1

    i = 1
    while i <= 13:
       if i not in h:
           print "H {0}".format(i)
       i += 1

    i = 1
    while i <= 13:
       if i not in c:
           print "C {0}".format(i)
       i += 1

    i = 1
    while i <= 13:
       if i not in d:
           print "D {0}".format(i)
       i += 1

Measured memory_bytes: 4272
from collections import Counter

def get_prime_factors(x):
    out = []
    if x < 1:
        return out
    while not x%2:
        out.append(2)
        x //= 2
    i = 3
    while i*i <= x:
        if not x%i:
            out.append(i)
            x //= i
        else:
            i += 2
    if x != 1:
        out.append(x)
    return out


def main():
    n = int(input())
    primes = Counter(get_prime_factors(n))
    ans = 0
    for k, v in primes.items():
        num = 1
        while v >= num:
            v -= num
            num += 1
            ans += 1
    print(ans)
    


if __name__ == "__main__":
    main()

Measured memory_bytes: 9464
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(void){
int n,i;
int ans=0;
cin>>n;
vector<int>a(n);
for(i=0;i<n;i++)cin>>a[i];
for(i=0;i<n-2;i++){
if((a[i]<a[i+1]&&a[i+1]<a[i+2])||(a[i]>a[i+1]&&a[i+1]>a[i+2]))ans++;
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i,0,n-1) cin >> a[i];
    int tot = 0;
    rep(i,0,n-1) tot += a[i];

    SORT(a);
    REV(a);
    string ans;
    if(a[m-1]*4*m >= tot) ans = "Yes";
    else ans = "No";

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  int a,b;
  cin >> a >> s;
  b=a/2;
  int i;
  int flag;
  flag=0;
    if(a%2!=0){
      flag=1;
    }else{
      for(i=0;i<b;i++){
        if(s[i]!=s[b+i]){
          flag=1;
        }
      }
    }
  if(flag==0){
    cout << "Yes";
  }else{
    cout << "No";
  }
  return(0);
}

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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}

// end of Template

int r,g;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>r>>g;
    cout<<(2*g)-r<<newl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
using namespace std;
int main(){
  int a,b,k;
  cin>>a>>b;
  if(abs(a-b)%2==0){
    if(a<b){
    cout<<abs(a-b)/2+a;
  }else if(a>b){
    cout<<abs(b-a)/2+b;
  }else if(a==b){
    cout<<0;
  }
  }else{
      cout<<"IMPOSSIBLE";
    }
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;

std::string solve(int64_t n, int64_t k, std::string s) {
  s[k - 1] = std::tolower(s[k - 1]);
  return s;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t n;
  std::cin >> n;
  int64_t k;
  std::cin >> k;
  std::string s;
  std::cin >> s;
  auto const res = solve(n, k, s);
  std::cout << res << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

int main()
{
	int n,k;
	ll ans=0;
	
	cin>>n>>k;
	for(int b=1;b<n+1;b++)
	{
		ans += (n/b)*max(0,b-k) + max(0,(n%b)-k+1);
	}

	if(k==0)
	{
		ans -= n;
	}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define st first
#define nd second


using ll = long long;
using namespace std;
using pii = pair<int, int>;

char c[10];
int main(){
	scanf("%s", c+1);
	printf((c[3] == c[4] && c[5] == c[6]) ? "Yes" : "No");

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POSSIBLE(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Possible(i) cout<<(i?"Possible":"Impossible")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=998244353;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
ll GCD(ll A,ll B){
  return (B==0)?(A):(GCD(B,A%B));
}
ll LCM(ll A,ll B){
  return A/GCD(A,B)*B;
}
//
int N,K;
vector<int> V[2000];
int num[2000];
int m;
void DFS(int n,int ran){
	if(ran-1==K/2){
		if(K%2){
			m=max(m,(int)V[n].size()-1);
		}
		return;
	}
	FOR(i,0,V[n].size()){
		if(num[V[n][i]]==INF){
			num[V[n][i]]=ran;
			DFS(V[n][i],ran+1);
		}
	}
}
int main(){
	cin>>N>>K;
	if(K==1){
		cout<<N-2<<endl;
		return 0;
	}
	FOR(i,0,N-1){
		int A,B;
		cin>>A>>B;
		A--;B--;
		V[A].PB(B);
		V[B].PB(A);
	}
	int ans=INF;
	FOR(i,0,N){
		if(V[i].size()==1){
			continue;
		}
		fill(num,num+N,INF);
		m=0;
		if(K%2){
			FOR(j,0,V[i].size()){
				fill(num,num+N,INF);
				num[i]=0;
				num[V[i][j]]=0;
				DFS(i,1);
				DFS(V[i][j],1);
				sort(num,num+N);
				ans=min(ans,N-(int)(upper_bound(num,num+N,(K-1)/2)-num));
			}
		}else{
			num[i]=0;
			DFS(i,1);
			sort(num,num+N);
			ans=min(ans,N-(int)(upper_bound(num,num+N,K/2)-num));
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,m;
  while(cin>>n>>m,n||m){
    string pd[n],sa[n],da[n];
    for(int i=0;i<n;i++) cin>>pd[i]>>sa[i]>>da[i];
    string so[m],de[m],me[m];
    for(int i=0;i<m;i++) cin>>so[i]>>de[i]>>me[i];
    vector<int> ans;
    for(int i=0;i<m;i++){
      bool f=0;
      for(int j=n-1;j>=0;j--){
	bool ff=1;
	for(int k=0;k<8;k++){
	  ff&=sa[j][k]=='?'||sa[j][k]==so[i][k];
	  ff&=da[j][k]=='?'||da[j][k]==de[i][k];
	}
	if(ff){
	  f=pd[j]=="permit";
	  break;
	}
      }
      if(f) ans.push_back(i);
    }
    cout<<ans.size()<<endl;
    for(int i=0;i<(int)ans.size();i++)
      cout<<so[ans[i]]<<" "<<de[ans[i]]<<" "<<me[ans[i]]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3404
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20)
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1e9+7;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
//llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cout<<setprecision(20);
	double n,m,d;cin>>n>>m>>d;
	if(d==0){cout<<(m-1)/n<<endl;}
	else{cout<<2*(m-1)*(n-d)/(n*n)<<endl;}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
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;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
const int MAX = 111;
int dp[MAX][MAX]={};

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

  int h,w;
  cin>>h>>w;

  vector<string> st(h);
  for(int i=0;i<h;i++) cin>>st[i];

  const int INF = 1e9;
  dp[0][0]=(st[0][0]=='#');
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(i==0 and j==0) continue;
      dp[i][j]=INF;
      if(i) chmin(dp[i][j],dp[i-1][j]+(st[i-1][j]=='.' and st[i][j]=='#'));
      if(j) chmin(dp[i][j],dp[i][j-1]+(st[i][j-1]=='.' and st[i][j]=='#'));
    }
  }

  cout<<dp[h-1][w-1]<<newl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    string s;
    cin>>s;
    map<char,int> hoge;
    for(auto a:s){
        if(hoge.count(a)){
            hoge.at(a)++;
        }else{
            hoge[a]=1;
        }
    }
    
    string ans="Yes";
    for(auto a:s){
        if(hoge.at(a)%2!=0){
            ans="No";
            break;
        }
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
string S;
string C = "AGCT";

void solve() {
	cin >> S;
	N = sz(S);
	int res = 0;
	rep(i, 0, N) {
		rep(j, i, N) {
			bool ok = true;
			rep(k, i, j + 1) {
				bool found = false;
				rep(q, 0, 4) {
					found |= (C[q] == S[k]);
				}
				ok &= found;
			}
			if(ok) MAX(res, j - i + 1);
		}
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

int main() {
	long long n, k;
	cin >> n >> k;

	long long ans = 0;

	if (n / k)
	{
		n %= k;
	}

	if (n < abs(n - k))	cout << n << endl;
	else cout << abs(n - k) << endl;

	return 0;
}

Measured memory_bytes: 3624
# -*- coding: utf-8 -*-

H,W,A,B = map(int, input().split())
mod = (10 ** 9 + 7)

# 予め組み合わせ計算に必要な階乗と逆元のテーブルを作っておく
factorial = [0] * (H+W)
factorial[0] = 1
factorial[1] = 1
inverse = [0] * (H+W)
inverse[0] = 1
inverse[1] = 1
for i in range(2,H+W):
    factorial[i] = factorial[i-1] * i % mod
    # フェルマーの小定理から(x! ** mod-2 % mod == x! ** -1 % mod)
    # powに第三引数入れると冪乗のmod付計算を高速にやってくれる
    inverse[i] = pow(factorial[i], mod-2, mod)
    
# 組み合わせの数だけ返してくれる関数(自作)
def nCr(n, r):
    # 10C7 = 10C3
    r = min(r, n-r)
    # 分子の計算
    numerator = factorial[n]
    # 分母の計算
    denominator = inverse[r] * inverse[n-r] % mod
    return numerator * denominator % mod

h = H - A
w = B + 1
ans = 0
# マスを右上に1つずつずらして、必ず通る場所でパターンを足し合わせていく
while h > 0 and w <= W:
    ans = (ans + nCr(h+w-2, h-1) * nCr(H-h+W-w, H-h)) % mod
    h -= 1
    w += 1

print(ans)

Measured memory_bytes: 18764
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: u8,
        s: String
    }
    let a = 'A' as u8;
    let ans = s
        .as_bytes()
        .into_iter()
        .map(|si| (a + (si - a + n) % 26) as char)
        .collect::<String>();
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    ll ans=0,n;
    cin>>n;
    for(int i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0) ans+=i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3592
// Problem : E - Divisible Substring
// Contest : AtCoder Beginner Contest 158
// URL : https://atcoder.jp/contests/abc158/tasks/abc158_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#define DEBUG(...) cerr << #__VA_ARGS__ << ": ", debug(__VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator << (ostream &os, const vector<T> &v) {os << "["; for (int i=0; i<(int)v.size(); i++) {if (i) os << ", "; os << v[i];} return os << "]";}
void debug() {cerr << "\n";} template<typename T, typename... Args> void debug(T x, Args... args) {cerr << x << "; "; debug(args...);}

int mod[10000] = {};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    int n, p;
    string s;
    cin >> n >> p >> s;
    
    long long ret = 0;
    if (p == 2 || p == 5) {
        for (int i=0; i<n; i++)
            if ((s[i] - '0') % p == 0)
                ret += i + 1;
    } else {
        int cur = 0, power = 1;
        for (int i=n-1; i>=0; i--) {
            cur = (cur + power * (s[i] - '0')) % p;
            power = (power * 10) % p;
            ret += mod[cur] + (cur == 0);
            mod[cur]++;
        }
    }
    
    cout << ret << "\n";

    return 0;
}


Measured memory_bytes: 720
#include <stdio.h>
#include <string.h>

typedef struct card {
  int value;
  char mark;
} card;

void swap_card(card *a, card *b) {
  int temp_value;
  char temp_mark;
  temp_value = a->value;
  temp_mark = a->mark;
  a->value = b->value;
  a->mark = b->mark;
  b->value = temp_value;
  b->mark = temp_mark;
}

void bubble_sort(int N, card *c) {
  int i,j;
  for(i = 0;i < N;i++)
    for(j = N-1; j > i; j--)
      if(c[j].value < c[j-1].value)
	swap_card(c+j-1, c+j);
}

void selection_sort(int N, card *a) {
  int i,j,mini;
  for(i = 0; i < N-1; i++) {
    mini = i;
    for(j = i+1; j < N; j++)
      if(a[mini].value > a[j].value)
	mini = j;
    if(i != mini) 
      swap_card(a+i, a+mini);
  }
}

int check_sort(int N, card *a, card *b, int p) {
  int i,j;
  i = 0; j = 0;
  while(1) {
    while(i < N && a[i].value != p) i++;
    while(j < N && b[j].value != p) j++;
    if(i == N || j == N) break;
    if(a[i].mark != b[j].mark) return 1;
    i++;j++;
  }

  return 0;
}

int main() {
  int N,i,j,t;
  char c;
  char stability[2][11] = {"Stable", "Not stable"};
  scanf("%d", &N);
  card a[N],a1[N],a2[N];
  memset(a, 0, sizeof(a));
  for(i = 0; i < N; i++) {
    scanf(" %c ", &c);
    a[i].mark = c;
    scanf("%d", &t);
    a[i].value = t;
  }

  memcpy(a1, a, sizeof(a));
  memcpy(a2, a, sizeof(a));

  bubble_sort(N, a1);
  selection_sort(N, a2);
  
  for(i = 0; i < N-1; i++) printf("%c%d ", a1[i].mark, a1[i].value);
  t = 0; j = 0;
  while(t == 0 && j < 9) {
    t += check_sort(N, a, a1, j);
    j++;
  }
  printf("%c%d\n%s\n", a1[i].mark, a1[i].value, stability[t]);
    for(i = 0; i < N-1; i++) printf("%c%d ", a2[i].mark, a2[i].value);
  t = 0; j = 0;
  while(t == 0 && j < 9) {
    t += check_sort(N, a, a2, j);
    j++;
  }
  printf("%c%d\n%s\n", a2[i].mark, a2[i].value, stability[t]); 
  
  return 0;
}

Measured memory_bytes: 616
#include <stdio.h>
using namespace std;
void trace(int A[], int N) {
	int i;
	for (i = 0; i < N; i++){
		if (i > 0)	printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
}
void insertSort(int A[], int N) {
	int j, i, v;
	for (i = 1; i < N; i++) {
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		trace(A, N);
	}
}
int main() {
	int N, i, j;
	int A[100];
	scanf("%d", &N);
	for (i = 0; i < N; i++)
		scanf("%d", &A[i]);
	trace(A, N);
	insertSort(A, N);
	return 0;
}

Measured memory_bytes: 2724
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    bool flag[212345] = {false}, ans = false;
    ll a[212345], b[212345];
    rep(i,m){
        cin >> a[i] >> b[i];
        if(a[i]==1)
            flag[b[i]] = true;
            if(b[i]==1)
                flag[a[i]] = true;
    }
    rep(i,m){
        if(a[i]==n&&flag[b[i]]==true)
            ans = true;
        if (b[i]==n&&flag[a[i]]==true)
            ans = true;
    }
    if(ans)
        cout << "POSSIBLE" << endl;
        else
            cout << "IMPOSSIBLE" << endl;
        return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <numeric>
#include <queue>
#include <cstring>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef long long ll;
typedef vector<ll> vll;
const int inf=1000000005;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
int dp[1005][1005];
string s1,s2;
int main(int argc,char const* argv[])
{
  cin >> s1 >> s2;
  int n1=int(s1.size());
  int n2=int(s2.size());
  memset(dp,inf,sizeof(dp));
  for(int i=0;i<=n1;i++)
    {
      dp[i][0]=i;
    }
  for(int j=0;j<=n2;j++)
    {
      dp[0][j]=j;
    }
  for(int i=1;i<=n1;i++)
    {
      for(int j=1;j<=n2;j++)
	{
	  dp[i][j]=min(dp[i][j],dp[i-1][j]+1);
	  dp[i][j]=min(dp[i][j],dp[i][j-1]+1);
	  if(s1[i-1]==s2[j-1])
	    {
	      dp[i][j]=min(dp[i][j],dp[i-1][j-1]);
	    }
	  else
	    {
	      dp[i][j]=min(dp[i][j],dp[i-1][j-1]+1);
	    }
	}
    }
  cout << dp[n1][n2] << endl;
  return 0;
}



Measured memory_bytes: 7156
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<vector<int>> F(N, vector<int>(10,0));
    vector<vector<int>> P(N, vector<int>(11,0));
    REP(i, N){
        REP(j, 10){
            cin >> F[i][j];
        }
    }
    REP(i, N){
        REP(j, 11){
            cin >> P[i][j];
        }
    }
    ll ans = -INF;
    Rep(i, 1, 1<<10){
        ll t = 0;
        bool flag = false;
        REP(j, N){
            ll p = 0;
            REP(k, 10){
                if(i&(1<<k) && F[j][k]){
                    p++;
                    flag = true;
                }
            }
            t += P[j][p];
        }
        if(flag) ans = max(ans, t);
    }
    pr(ans);
}

Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int width = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int aw = a + width;
		int bw = b + width;
		if((a<=b&&b<=aw)||(b<=a&&a<=bw)){
			System.out.println(0);
		}else if(bw<a){
			System.out.println(a-bw);
		}else if(b>aw){
			System.out.println(b-aw);
		}
	}
}

Measured memory_bytes: 21204
N = int(input())
T = list(map(int, input().split()))
M = int(input())
P = [0] * M
X = [0] * M
for i in range(M):
    P[i], X[i] = map(int, input().split())
    print(sum(T) - T[P[i]-1] + X[i])
    

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

int main(void)
{
    char s;
    int ans = 0;
    for (int i = 0; i < 3; i++)
    {
        cin >> s;
        if (s == '1')
        {
            ans++;
        }
    }
    cout << ans << endl;

    return (0);
}

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

int main() {
    
    int K;
    string S;
    cin >> K >> S; 

    int S_len = S.size();
    
    
    if (S_len <= K) {
        cout << S << endl;
    }
    
    else {cout << S.substr(0,K) << "..." << endl;
         }
    
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,double> ii;
const int N=2e6+20;
const double inf=2e15;
int n,inq[N];
double x[N],y[N],r[N],sx,sy,tx,ty;
vector<ii> e[N];
double dis(int i,int j)
{
	double D=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
	return max((double)0,D-(r[i]+r[j]));
}
queue<int> q;
double d[N];
void SPFA(int s,int t)
{
	for(int i=s;i<=t;i++)
		d[i]=inf,inq[i]=0;
	q.push(s);
	d[s]=0,inq[s]=1;
	while(!q.empty())
	{
		int u=q.front();
		q.pop(),inq[u]=0;
		for(int i=0;i<e[u].size();i++)
		{
			int v=e[u][i].first;
			double w=e[u][i].second;
			if(d[v]>d[u]+w)
			{
				d[v]=d[u]+w;
				if(!inq[v])
					q.push(v),inq[v]=1;
			}
		}
	}
	printf("%.10lf\n",d[t]);
}
int main()
{	
	while(cin>>x[0]>>y[0]>>tx>>ty)
	{
		cin>>n;
		for(int i=1;i<=n;i++)
			scanf("%lf%lf%lf",&x[i],&y[i],&r[i]);
		n++;
		x[n]=tx,y[n]=ty;
		for(int i=0;i<=n;i++)
			e[i].clear();
		for(int i=0;i<=n;i++)
		{	
			for(int j=0;j<=n;j++)
			{
				if(i==j)	continue;
				e[i].push_back(ii(j,dis(i,j)));
			}
		}
		SPFA(0,n);
	}
    return 0;
}

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

inline int qr()
{
    int s=0,f=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=(s<<3)+(s<<1)+(ch^48);ch=getchar();}
    return s*f;
}

int main()
{
    int a,b;
    cin>>a>>b;
    for(int i=1;i<=100000;i++)
    {
    	double k=double(i);
    	double bb=k*0.1,aa=k*0.08;
    	if(int(aa)==a&&int(bb)==b)
    	{
    		cout<<i<<endl;
    		return 0;
		}
	}
	cout<<"-1"<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define _GLIBCXX_DEBUG

using _loop_ll = long long;
#define REP(i,n) for(_loop_ll (i)=0; (i)<(_loop_ll)(n); (i)++)
#define FOR(i,a,b) for(_loop_ll (i)=(_loop_ll)(a); (i)<(_loop_ll)(b); (i)++)
#define FORR(i,a,b) for(_loop_ll (i)=(_loop_ll)(b)-1; (i)>=(_loop_ll)(a); (i)--)
 
#define ALL(v) (v).begin(),(v).end()
 
#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;

constexpr long long int MOD = 1000000007;

int factorial(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n;
    cin >> n;
    string ps = "";
    string qs = "";
    REP(i, n){
        char c;
        cin >> c;
        ps += c;
    }
    REP(i, n){
        char c;
        cin >> c;
        qs += c;
    }

    int p = atoi(ps.c_str());
    int q = atoi(qs.c_str());
    
    vi nums(n);
    REP(i, n) nums[i] = i + 1;
    // DEBUG_VEC(nums);
    vi perm;
    do {
        string s = "";
        REP(i, n){
            s += to_string(nums[i]);
        }
        perm.emplace_back(atoi(s.c_str()));
    } while (next_permutation(nums.begin(), nums.end()));

    sort(ALL(perm));
    // DEBUG_VEC(perm);
    // DEBUG(p);
    // DEBUG(q);

    ll a, b;
    ll i = 0;
    REP(i, factorial(n)){
        if(perm[i] == p) a = i;
        if(perm[i] == q) b = i;
    }   

    cout << abs(a - b) << endl;


    return 0;
};


Measured memory_bytes: 640
import math

def factorize(n):
    d = {}
    temp = int(math.sqrt(n))+1
    for i in range(2, temp):
        while n%i== 0:
            n //= i
            if i in d:
                d[i] += 1
            else:
                d[i] = 1
    if d == {}:
        d[n] = 1
    else:
        if n in d:
            d[n] += 1
        elif n != 1:
            d[n] =1
    return d

n = int(input())

if n == 1:
    print(1)
    exit()

mod = 10**9+7
D = {}
for i in range(2, n+1):
    d = factorize(i)
    for k, v in d.items():
        if k not in D:
            D[k] = v
        else:
            D[k] += v
ans = 1
for v in D.values():
    ans *= (v+1)
    ans %= mod
print(ans)

Measured memory_bytes: 41964
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

const long long mod = 1e9 + 7;

int main(){
	int n;
	cin >> n;
	
	long long A = 1;
	for(int i  = 0; i < n; i++){
		A *= 10;
		A %= mod;
	}
	
	long long B = 1;
	for(int i  = 0; i < n; i++){
		B *= 9;
		B %= mod;
	}
	
	long long C = 1;
	for(int i  = 0; i < n; i++){
		C *= 8;
		C %= mod;
	}
	
	long long ans;
	
	ans = A + mod - B;
	ans %= mod;
	
	ans = ans + mod - B;
	ans %= mod;
	
	ans += C;
	ans %= mod;
	
	cout << ans << endl;
	
	return 0;
}
 


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
#define itn int
bool dbg = false;
int N, M;
int S[101010];
V p;
void solve() {
    bool flag = false;
    bool FAIL = false;
    p.pb(N);
    int MAX = N;
    int NOW = N;
    while (true) {
        int t = NOW;

        for (int i = NOW - M; i < MAX; i++) {
            if (i <= 0) {
                flag = true;
                p.pb(0);
                break;
            }
            if (S[i] == 0) {
                NOW = i;
                p.pb(i);
                break;
            }
        }
        //cout << NOW << endl;
        if (flag) {
            break;
        }
        if (t == NOW) {
            FAIL = true;
            break;
        }
        MAX = t - M;
    }
    if (FAIL) {
        cout << -1 << endl;
        return;
    }
    V ans;
    FOR(i, 0, (int)p.size() - 1) {
        ans.pb(p[i] - p[i + 1]);
    }
    reverse(all(ans));
    FOR(i, 0, (int)ans.size()) {
        cout << ans[i] << " ";
    }
    cout << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    FORR(i, 0, N) {
        char c;
        cin >> c;
        if (c == '1')
            S[i] = 1;
    }
    solve();
    return 0;
}


Measured memory_bytes: 2548