akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <set>
using namespace std;

using i32 = int;
using i64 = long long;

#define REP(i, stop) for (int i = 0; i < stop; ++i)
#define ALL(v) (v).begin(), (v).end()

template<typename T>
T read() {
  T a = 0;
  for(;;) {
    char c = getchar();
    if (c & 16) {
      a = a * 10 + c - 48;
    } else {
      return a;
    }
  }
}

i64 A[1000], B[1000], C[1000];
signed main() {
//  i32 x, y, z, k;
//  scanf("%d%d%d%d", &x, &y, &z, &k);
  i32 X = read<i32>(),
      Y = read<i32>(),
      Z = read<i32>(),
      K = read<i32>();
//  REP(i, x) scanf("%lld", &A[i]);
//  REP(i, y) scanf("%lld", &B[i]);
//  REP(i, z) scanf("%lld", &C[i]);
  REP(i, X) A[i] = -read<i64>();
  REP(i, Y) B[i] = -read<i64>();
  REP(i, Z) C[i] = -read<i64>();
  sort(A, A + X);
  sort(B, B + Y);
  sort(C, C + Z);
  using P = pair<i64, i64>;
  set<P> Q;
  Q.insert({A[0] + B[0] + C[0], 0});
  REP(_, K) {
    i64 p = -(*Q.begin()).first;
    i64 q = (*Q.begin()).second;
    printf("%lld\n", p);
    Q.erase(Q.begin());
    i32 u = q & 1023;
    i32 v = q >> 10 & 1023;
    i32 w = q >> 20 & 1023;
    i64 u1 = q + 1;
    i64 v1 = q + (1 << 10);
    i64 w1 = q + (1 << 20);
    if (u + 1 < X) Q.insert({A[u + 1] + B[v] + C[w], u1});
    if (v + 1 < Y) Q.insert({A[u] + B[v + 1] + C[w], v1});
    if (w + 1 < Z) Q.insert({A[u] + B[v] + C[w + 1], w1});
  }
}

Measured memory_bytes: 512
import sys
cs = { c : 0 for c in list("abcdefghijklmnopqrstuvwxyz")}
for c in list(sys.stdin.read()):
    c = c.lower()
    if c in cs.keys():
        cs[c] = cs[c] + 1
for (c,cnt) in sorted(list(cs.items())):
    print('{0} : {1}'.format(c,cnt))




Measured memory_bytes: 5576
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;

int t[10][10];
int m[10];

int dfs(int i, bool* visited) {
    if (m[i] > -1) return m[i];
    if (visited[i] == true) return -1;
    if (i == 1) return 0;
    int mn = INT_MAX;
    visited[i] = true;
    for (int j = 0; j < 10; j++) {
        int cur = dfs(j, visited);
        if (cur != -1) {
            mn = min(mn, cur + t[i][j]);
        }
    }
    visited[i] = false;
    return mn;
}

void gen() {exit(0);}
int main() {
    #ifdef DEBUG
    freopen("input", "r", stdin);
//    freopen("output", "w", stdout);
//    gen();
    #endif
    int h, w;
    scanf("%d %d", &h, &w);
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            scanf(" %d", &t[i][j]);
        }
    }
    fill(m, m + 10, -1);
    for (int i = 0; i < 10; i++) {
        bool visit[10];
        fill(visit, visit + 10, false);
        m[i] = dfs(i, visit);
    }
    int ans = 0;
    forn(i, 0, h) {
        forn(j, 0, w) {
            int x;
            scanf(" %d", &x);
            if (x != -1) {
                ans += m[x];
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    long long int a, b, k, i;
    scanf("%lld %lld %lld", &a, &b, &k);

    if( a+b <= k )
    {
        a = 0;
        b = 0;
    }
    else
    {
        if( a>k )
        {
            i = a - k;
            a = i;
        }
        else
        {
            i = k - a;
            a = 0;
            b = b - i;
        }
    }

    printf("%lld %lld",a,b);

    return 0;

}


Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cotu cout
#define itn int
const int INF = 1e9 + 7;

int main(){
    int a,b; cin>>a>>b;
    if((a<1 || a>9 ) || (b<1 || b>9)) cout<<-1;
    else cout<<a*b;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define mod 998244353
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}

int main() {
   fast();
  long long n;
  cin>>n;
  long long l=n;
  int ans=0;
  while(l){
    l=l/10;
    ans++;
  }
  for(long long i=2;i<=sqrt(n);i++){
    if(n%i==0){
      long long c=i;
      long long d=n/i;
      int f=0;
      int g=0;
      while(c){
        c=c/10;
        f++;
      }
      while(d){
        d=d/10;
        g++;
      }
      ans=min(ans,max(f,g));
    }
  }
  cout<<ans<<"\n";



}


Measured memory_bytes: 3600
long long M[10][1001];
main(i,j,k){
	M[0][0]=1;
	for(i=0;i<=100;i++)for(j=1000;j-i>=0;j--)for(k=9;k;k--)M[k][j]+=M[k-1][j-i];
	for(;scanf("%d%d",&i,&j),i|j;)printf("%lld\n",M[i][j]);
exit(0);}

Measured memory_bytes: 672
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;


#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;

int main(){
 

    int n,k;
    int ans=1;
    cin>>n>>k;

    REP(i,n){
        ans=min(ans+k,2*ans);
    }
    cout<<ans<<endl;



}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;

template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}

#define P (1'000'000'007)

int dp[3003][3003][4] = {0};

signed main() {
    int R, C, K;
    cin >> R >> C >> K;

    map<pair<int, int>, int> mv;

    rep(i, K) {
        int r, c, v;
        cin >> r >> c >> v;

        mv.emplace(make_pair(r, c), v);
    }

    dp[0][0][0] = 0;

    rep(i, R + 1) {
        rep(j, C + 1) {
            if (auto it = mv.find(make_pair(i, j + 1)); it != mv.end()) {
                chmax(dp[i][j + 1][0], dp[i][j][0]);
                chmax(dp[i][j + 1][1], max(dp[i][j][0] + it->second, dp[i][j][1]));
                chmax(dp[i][j + 1][2], max(dp[i][j][1] + it->second, dp[i][j][2]));
                chmax(dp[i][j + 1][3], max(dp[i][j][2] + it->second, dp[i][j][3]));
            } else {
                rep(k, 4) {
                    chmax(dp[i][j + 1][k], dp[i][j][k]);
                }
            }

            int m = 0;
            rep(k, 4) {
                m = max(m, dp[i][j][k]);
            }
            if (auto it = mv.find(make_pair(i + 1, j)); it != mv.end()) {
                dp[i + 1][j][1] = m + it->second;
            }
            dp[i + 1][j][0] = m;
        }
    }

    int ans = 0;
    rep(i, 4) {
        chmax(ans, dp[R][C][i]);
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 297144
#include <iostream>

using namespace std;
long long n, a, sum;
int main()
{
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a;
        sum ^= a;
    }
    if(sum == 0){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}


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

def sort(a, left, right):
    if left < right:
        mid = (left+right)/2
        pivot = a[mid]
        a[mid] = a[left]
        p = left
        for i in range(left+1, right+1):
            if a[i] < pivot:
                p = p+1
                p, i = i, p
        a[left] = a[p]
        a[p] = pivot
        sort(a, left, p-1)
        sort(a, p+1, right)

def search(a, target):
    lo = 0
    hi = n-1
    while lo <= hi:
        mid = (lo+hi)/2
        if target <= a[mid]:
            hi = mid-1
        if target >= a[mid]:
            lo = mid+1
    if lo == hi+2:
        return True
    else:
        return False

n = int(raw_input())
S = map(int, raw_input().split())
q = int(raw_input())
T = map(int, raw_input().split())
count = 0
sort(S, 0, n-1)
for i in range(q):
    if search(S, T[i]):
        count += 1
print count

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.141592653589793238462643383279;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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 main(void){
    int N,M,X; cin >> N >> M >> X;
    VI C(N); VVI A(N, VI(M,0));
    REP(i,N){
        cin >> C[i];
        REP(j,M) cin >> A[i][j];
    }

    int ans = INF;
    REP(i,1<<N){
        VI a(M,0);
        int tmp = 0;
        REP(j,N){
            if(!(i & (1<<j))) continue;
            REP(k,M){
                a[k] += A[j][k];
            }
            tmp += C[j];
        }
        bool flag = true;
        REP(j,M) if(a[j] < X){flag = false; break;}
        if(flag) chmin(ans, tmp);
    }

    cout << (ans < INF ? ans : -1) << en;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,w;
ll wei[101],val[101];
ll dp[101][100001];
ll fun(ll ind, ll wt){
    if(ind ==n)
    return 0;
    if(wt == w ) return 0;
    
    
    if(dp[ind][wt] != -1) return dp[ind][wt];
    
   ll maxi=0;
    
    if(wt+wei[ind] <= w){
       ll l= val[ind]+fun(ind+1 , wt+wei[ind]);
       ll r= fun(ind+1 , wt);
      return dp[ind][wt] = max(l,r);
    }
    else{
      return dp[ind][wt] = fun(ind+1 , wt);
    }
    //return dp[ind][wt]
}
int main() {
cin>>n>>w;
for(ll i=0;i<n;i++)
cin>>wei[i]>>val[i];
memset(dp , -1 , sizeof dp);
cout<<fun(0,0);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int s[110], sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> s[i];
    sum += s[i];
  }

  if (sum % 10 > 0) {
    cout << sum << endl;
  } else {
    int ans = 0;
    for (int i = 0; i < N; i++) {
      int tmp = sum - s[i];
      if (tmp % 10 == 0) continue;
      ans = max(ans, tmp);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        int[] a=cin.ArrayInt(2,0);
        int[] b=cin.ArrayInt(2,0);
        int ans=0;
        if(a[0]!=b[0])ans=1;
      Console.WriteLine(ans);
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
    public void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

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

  int a[500][500];
  rep (i, h) rep (j, w) cin >> a[i][j];

  vector<pair<pair<int, int>, pair<int, int>>> vp;
  rep (i, h) rep (j, w) {
    if (i == h - 1 && j == w - 1) continue;

    int y, x, ny, nx;

    if (i % 2 == 0) {
      ny = y = i;
      nx = x = j;
      if (++nx == w) {
        nx--;
        ny++;
      }
    } else {
      ny = y = i;
      nx = x = w - 1 - j;
      if (--nx == -1) {
        nx++;
        ny++;
      }
    }

    if (a[y][x] % 2) {
      a[y][x]--;
      a[ny][nx]++;
      vp.eb(mp(mp(y + 1, x + 1), mp(ny + 1, nx + 1)));
    }
  }

  cout << sz(vp) << endl;
  rep (i, sz(vp)) {
    cout << vp[i].F.F << ' ' << vp[i].F.S << ' ' << vp[i].S.F << ' ' << vp[i].S.S << endl;
  }
}


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

int main(){
    int a, b;
    cin >> a >> b;
    if(b*2 < a) cout << a-b*2 << endl;
    else cout << 0 << endl;
    return 0;
}

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

using namespace std;

const int RGB[8][3] = {
	{ 0   ,0   ,0   },
	{ 0   ,0   ,255 },
	{ 0   ,255 ,0   },
	{ 0   ,255 ,255 },
	{ 255 ,0   ,0   },
	{ 255 ,0   ,255 },
	{ 255 ,255 ,0   },
	{ 255 ,255 ,255 },
};

const string COLOR[8] = {
	"black",
	"blue",
	"lime",
	"aqua",
	"red",
	"fuchsia",
	"yellow",
	"white",
};

int main() {
	int len, d, j, minD, index;
	int rgb[3];
	string colorInfo, tmp;
	stringstream ss;

	while (cin >> colorInfo, colorInfo[0] == '#') {
		len = colorInfo.size() - 1;

		for (int i = 1, j = 0; i < len; i += 2) {
			ss.clear();
			ss.str("");

			ss << colorInfo[i] << colorInfo[i + 1];
			ss >> tmp;
			//cout << tmp << endl;
			rgb[j++] = strtol(tmp.c_str(), 0, 16);
		}

		minD = INT_MAX;
		for (j = 0; j < 8; j++) {
			d = pow(rgb[0] - RGB[j][0], 2) + pow(rgb[1] - RGB[j][1], 2) + pow(rgb[2] - RGB[j][2], 2);
			if (d < minD) {
				minD = d;
				index = j;
			}
		}

		cout << COLOR[index] << endl;

	}

	return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;

int main()
{
    long long n,minabs,nrminus,sum,x;
    scanf("%lld",&n);
    minabs=LLONG_MAX;
    nrminus=0;
    sum=0;
    while(n--)
    {
        scanf("%lld",&x);
        if(x<0)
            nrminus++;
        minabs=min(minabs,abs(x));
        sum+=abs(x);
    }
    printf("%lld",sum-2*(nrminus%2)*minabs);

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace B___Small_and_Large_Integers
{
    class Program
    {
        static void Main(string[] args)
        {
            var ABK = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var A = ABK[0];
            var B = ABK[1];
            var K = ABK[2];

            for (int i = A; i <= B; i++)
            {
                if (i < A + K || i > B - K)
                {
                    Console.WriteLine(i);
                }
            }

        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <cstring>

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

using namespace std;
typedef long long ll;



int main(){
    
    string s;
    
    cin>>s;
    
    ll count=0;
    
    for(int i=0;i<s.size();++i){
        count+=s[i]-'0';
        count=count%9;
    }
    
    if(count%9==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
    
   

}


Measured memory_bytes: 3744
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
for i in range(h):
    for j in range(w):
        cnt = 0
        if s[i][j] == "#":
            continue
        for k, l in zip([-1, -1, -1, 0, 1, 1, 1, 0], [-1, 0, 1, 1, 1, 0, -1, -1]):
            if 0 <= i+k < h and 0 <= j+l < w:
                if s[i + k][j + l] == "#":
                    cnt += 1
        s[i][j] = cnt
for i in s:
    for j in i:
        print(j, end="")
    print("")

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
 
#define INF 1234567890
#define ll long long

ll res = 0;
int N;

ll f(ll a, ll n) // a + 2a + ... + na
{
	return a * (n*(n+1)/2);
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	for(int i=1; i<=N; i++)
	{
		ll cnt = N/i;
		res += f(i, cnt);
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 3644
// from 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 mut 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")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    };
}
// macro_rules! debug { ($x: expr) => () }

#[allow(dead_code)]
fn show<T>(iter: T) -> String
where
    T: Iterator,
    T::Item: std::fmt::Display,
{
    let mut res = iter.fold(String::new(), |sum, e| sum + &format!("{} ", e));
    res.pop();
    res
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::btree_map::Entry::{Occupied, Vacant};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::mem::swap;

fn main() {
    use std::io::Write;
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    macro_rules! printf { ($($arg:tt)*) => (write!(out, $($arg)*).unwrap()); }
    macro_rules! printfln { () => (writeln!(out).unwrap()); ($($arg:tt)*) => (writeln!(out, $($arg)*).unwrap()); }

    input! {
        n: usize,
        xyh: [(i64, i64, i64); n],
    }
    for cx in 0..101 {
        for cy in 0..101 {
            // debug!((cx, cy));
            let hv: Vec<_> = xyh
                .iter()
                .filter(|&&(_, _, h)| h > 0)
                .map(|&(x, y, h)| h + (cy - y).abs() + (cx - x).abs())
                .collect();

            let ht = hv[0];
            let ex = 
                hv.iter().all(|&x| x == ht) && 
                xyh.iter()
                    .all(|&(x, y, h)| max(ht - (cx - x).abs() - (cy - y).abs(), 0) == h);
            if ex {
                printfln!("{} {} {}", cx, cy, ht);
                return;
            }
        }
    }
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 10000000

using namespace std;

#define MAXN 100001

int main(){
  int n,m;cin>>n>>m;
  vector<vector<int>>g(MAXN*3);
  rep(i, m){
    int u,v;cin>>u>>v; u--,v--;
    g[u].push_back(n+v);
    g[n+u].push_back(2*n+v);
    g[2*n+u].push_back(v);
  }
  int s,t;cin>>s>>t;s--,t--;

  vector<int>d(3*n);
  rep(i, 3*n)d[i]=INF;
  d[s]=0;

  queue<pi>q;
  q.push({0, s});
  while(q.size()){
    int now = q.front().second;
    int cost = q.front().first;
    q.pop();
    if(d[now]<cost)continue;

    for(auto c:g[now]){
      if(d[c]<=cost+1)continue;
      d[c]=cost+1;
      q.push({d[c], c});
    }
  }

  if(d[t]==INF)cout<<-1<<endl;
  else cout<<d[t]/3<<endl;

  return 0;
}

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

int main() {
  int a,h;
  cin >>a;
  int b;
  h=a;
  while(a>0){
    b+=a%10;
    a/=10;
  }
  if(h%b==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <typeinfo>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007
using namespace std;


int main(){
	int n,d,x;
	cin >> n >> d >> x;
	rep(i,n){
		int a;
		cin >> a;
		x += 1+(d-1)/a;
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int max(int a,int b){
    return a>b?a:b;
}
int main() {
    int a,b;
    scanf("%d%d",&a,&b);
    printf("%d\n",max(a+b,max(a-b,a*b)));
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		int ans = 0;
		for (int i = 1; i <= N; i++) {
			if (i % 2 == 0) {
				continue;
			}
			
			int count = 0;
			for (int j = 1; j <= i; j++) {
				if (i % j == 0) {
					count++;
				}
			}
			
			if (count == 8) {
				ans++;
			}
		}
		
		System.out.println(ans);
	}
	
}

Measured memory_bytes: 21460
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef pair<int,int> P;
int main() {
  int a, b, d;
  while(cin>>a>>b>>d, a) {
    vector<P> v;
    REP(i, b)
      if ((d+i*a)%b == 0)
        v.push_back(P(i, (d+i*a) / b));
    REP(i, a)
      if ((d+i*b)%a == 0)
        v.push_back(P((d+i*b) / a, i));
    
    for (int i = 0; i*a<=d ; i++)
      if ((d-i*a) % b == 0) {
        v.push_back(P(i, (d-i*a)/b));
      }
    P res = P(INF, INF);
    FOR(it, v) {
      if (res.first+res.second > it->first+it->second) {
        res = *it;
      } else if (res.first+res.second == it->first+it->second) {
        if (a*res.first+b*res.second > a*it->first+b*it->second)
          res = *it;
      }
    }
    cout << res.first << " " << res.second << endl;
  }
}

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

using namespace std;
int main()
{
  int arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k ;
  cin>>k;
  cout<<arr[k-1];
}


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

int main() {
  int cnt = 0, len;
  string s;
  cin >> s;
  len = s.size();
  for (int i = 0; i < len - 1; i++) {
    if ((s[i] == '0' && s[i + 1] == '1') || (s[i] == '1' && s[i + 1] == '0')) {
      cnt += 2;
      s.erase(i, 2);
      len = s.size();
      i -= 2;
    }
  }
  cout << cnt << endl;
}

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

int main()
{
    data_type n;
    cin>>n;
    vector<data_type>vc(n),dp(n,0);
    for(auto &i:vc)
        cin>>i;
    dp[n-2]=abs(vc[n-1]-vc[n-2]);
    for(int i=n-3; i>=0; i--)
        dp[i]=min(dp[i+1]+abs(vc[i]-vc[i+1]),dp[i+2]+abs(vc[i+2]-vc[i]));
    cout<<dp[0]<<endl;

    return 0;
}


Measured memory_bytes: 4776
import java.util.*;

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 l = a + b;
    int r = c + d;

    if(l > r) {
      System.out.println("Left");
    } else if(l < r) {
      System.out.println("Right");
    } else {
      System.out.println("Balanced");
    }
  }
}


Measured memory_bytes: 21844
// package agc.agc012;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt();
        int[] a = new int[3*n];
        for (int i = 0; i < 3*n ; i++) {
            a[i] = in.nextInt();
        }
        Arrays.sort(a);

        long total = 0;
        for (int i = n ; i < a.length ; i += 2) {
            total += a[i];
        }
        out.println(total);
        out.flush();
    }

    public static void debug(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }

    public static class InputReader {
        private static final int BUFFER_LENGTH = 1 << 12;
        private InputStream stream;
        private byte[] buf = new byte[BUFFER_LENGTH];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int next() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public char nextChar() {
            return (char) skipWhileSpace();
        }

        public String nextToken() {
            int c = skipWhileSpace();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char) c);
                c = next();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public long nextLong() {
            int c = skipWhileSpace();
            long sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = next();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public double nextDouble() {
            return Double.valueOf(nextToken());
        }

        int skipWhileSpace() {
            int c = next();
            while (isSpaceChar(c)) {
                c = next();
            }
            return c;
        }

        boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    }
}

Measured memory_bytes: 25244
#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define sd second
#define ll long long

using namespace std;

const int maxn = 3010;
const ll oo = 1e18;

int n,base;
ll p1[maxn*maxn],p2[maxn],C[maxn][maxn],f[maxn][maxn],pp[maxn];

ll sum(ll a, ll b) {
    return (a+b)%base;
}

ll sub(ll a, ll b) {
    return (a-b+base)%base;
}

ll mul(ll a, ll b) {
    return (a*b)%base;
}

ll pw(ll a, ll b) {
    if (b == 0) return 1ll;
    if (b == 1) return a;
    ll tg = pw(a,b/2);
    tg = mul(tg,tg);
    if (b%2) return mul(tg,a);
    else return tg;

}

void init() {
    for (int i=0;i<maxn;i++) {
        C[0][i]=1;
        for (int k=1;k<=i;k++) C[k][i] = sum(C[k-1][i-1],C[k][i-1]);
    }
    p2[0]=1; p1[0] = 1;
    for (int i=1;i<maxn;i++) p2[i] = (p2[i-1] * 2) % (base-1);
    for (int i=0;i<=n;i++) pp[i] = pw(2ll,p2[n-i]);
    for (int i=1;i<maxn*maxn;i++) p1[i] = (p1[i-1] * 2) % base;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
  //  freopen("in.txt","r",stdin);
    cin>>n>>base;
    init();
    f[0][0] = 1;
    for (int i=0;i<=n;i++) {
        for (int j=1;j<=i;j++) f[i][j] = sum(f[i-1][j-1], mul(f[i-1][j],1ll*j));
    }
    ll ans = 0;
    for (int i=0;i<=n;i++) {
       // cout<<dp[i]<<" "<<C[i][n]<<endl;
        ll dp =0;
        for (int j=0;j<=i;j++) {
            dp = sum(dp, mul(f[i][j], mul(p1[(n-i)*j] , pp[i])));
            if (j) dp = sum(dp,mul(mul(f[i][j],j), mul(p1[(n-i)*(j-1)] , pp[i])));
        }
        if (i%2==0) ans = sum(ans,mul(dp,C[i][n]));
        else ans = sub(ans,mul(dp,C[i][n]));
    }
    cout<<ans;
}


Measured memory_bytes: 211072
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    
    int A,B;
    cin >> A>>B;
    if(B%A==0) cout << A+B << endl;
    else cout << B-A << endl;
    
    return 0;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	a, b := sc.nextInt(), sc.nextInt()
	a1 := ""
	a2 := ""
	for i := 0; i < a; i++ {
		a2 += strconv.Itoa(b)
	}
	for i := 0; i < b; i++ {
		a1 += strconv.Itoa(a)
	}

	if a1 < a2 {
		fmt.Fprintln(wtr, a1)
	} else {
		fmt.Fprintln(wtr, a2)
	}
	wtr.Flush()
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<ll> &v) {
    std::for_each(v.begin(), v.end(), [](ll x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    string S;
    cin >> S;
    vector<ll> ans(S.length() + 1, 0LL);
    REP(i, S.length()) {
        if(S[i] == '<') {
            ans[i + 1] = ans[i] + 1;
        }
    }

    for(int i = S.length() - 1; i >= 0; i--) {
        if(S[i] == '>') {
            ans[i] = max(ans[i + 1] + 1, ans[i]);
        }
    }

    cout << accumulate(ans.begin(), ans.end(), 0LL) << endl;
    return 0;
}

Measured memory_bytes: 4740
#include<stdio.h>
#include<math.h>

struct Point{
  double x;
  double y;
};

void koch(int, struct Point, struct Point );


int main(){
  struct Point p1, p2;
  int n;

  scanf("%d", &n);

  p1.x =0;
    p1.y = 0;
  p2.x = 100;
  p2.y=0;

 printf("%.8f %.8f\n", p1.x, p1.y);
 
 koch(n, p1, p2);
 printf("%.8f %.8f\n", p2.x, p2.y);

 return 0;
}
void koch(int d, struct Point p1, struct Point p2){
  struct Point s, t, u;
  double k;

  if(d == 0) return;

  k = M_PI * 60.0 / 180.0;

  s.x = (2.0 * p1.x + 1.0 * p2.x) / 3.0;
  s.y = (2.0 * p1.y + 1.0 * p2.y) / 3.0;
  t.x = (1.0 * p1.x + 2.0 * p2.x) / 3.0;
  t.y = (1.0 * p1.y + 2.0 * p2.y) / 3.0;
  u.x = (t.x - s.x) * cos(k) - (t.y - s.y) * sin(k) + s.x;
  u.y = (t.x - s.x) * sin(k) + (t.y - s.y) * cos(k) + s.y;

  koch(d-1, p1, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(d-1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(d-1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(d-1, t, p2);
}



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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    int k;
    cin>>k>>a>>b;
    int f=0;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout<<"OK";
            f=1;
            break;
        }
    }
    if(f==0){
        cout<<"NG";
    } 
    return 0;
}

Measured memory_bytes: 3652
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto & in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t H,W,A,B;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> H>>W>>A>>B;
	if (H < B * 2 || W < A*2) {
		out << "No" << endl;
		return 0;
	}

	const char map[] = "01";
	for (int i = 0; i < H; i++)
	{
		int next = i < B ? 0 : 1;
		int j = 0;
		for (; j < A; j++)
		{
			out << map[next];
		}
		next ^= 1;
		for (; j < W; j++)
		{
			out << map[next];
		}
		out << "\n";
	}

	return 0;
}
#endif


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#include <stdio.h>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
//#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll> > mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;
const int dx[9] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
const int dy[9] = {0, -1, 1, 0, -1, 1, -1, 1, 0};
 
int N, K;
int bb[4010][4010];
int ww[4010][4010];
 
int bacc[4010][4010];
int wacc[4010][4010];
int bsum(int x1, int y1, int x2, int y2){
  return bacc[y2][x2] - bacc[y2][x1] - bacc[y1][x2] + bacc[y1][x1];
}
int wsum(int x1, int y1, int x2, int y2){
  return wacc[y2][x2] - wacc[y2][x1] - wacc[y1][x2] + wacc[y1][x1];
}
 
signed main()
{
  cin >> N >> K;
  int K2 = K * 2;
  REP(i,N) {
    int x, y;
    char c;
    cin >> x >> y >> c;
    x %= K2;
    y %= K2;
    if (c == 'B') {
      bb[y][x]++;
      bb[y+K2][x]++;
      bb[y][x+K2]++;
      bb[y+K2][x+K2]++;
    } else {
      ww[y][x]++;
      ww[y+K2][x]++;
      ww[y][x+K2]++;
      ww[y+K2][x+K2]++;
    }
  }

  REP(y,K2*2) REP(x,K2*2) {
    bacc[y+1][x+1] += bb[y][x] + bacc[y+1][x] + bacc[y][x+1] - bacc[y][x];
    wacc[y+1][x+1] += ww[y][x] + wacc[y+1][x] + wacc[y][x+1] - wacc[y][x];
  }

  int ans = 0;
  REP(y1,K2) REP(x1,K2) {
    int x2 = x1 + K, y2 = y1 + K;
    int sum = bsum(x1, y1, x2, y2) + bsum(x2, y2, x2+K, y2+K);
    sum += wsum(x2, y1, x2+K, y2) + wsum(x1, y2, x2, y2+K);
  
    ans = max(ans, sum);
  }

  cout << ans << endl;
}

Measured memory_bytes: 251264
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string x,y;
    cin>>x>>y;
    ll dp[x.size()+1][y.size()+1];
    memset(dp,0,sizeof(dp));
    for(ll i=1;i<=x.size();i++)
    {
     for(ll j=1;j<=y.size();j++)
     {
      if(x[i-1]==y[j-1])
        dp[i][j]=dp[i-1][j-1]+1;
      else 
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
     }
    }
   string ans="";
  ll i=x.size(),j=y.size();
  while(i>=1&&j>=1)
  {
    if(x[i-1]==y[j-1])
    {ans.insert(ans.begin(),x[i-1]);i--;j--;}
    else if (dp[i-1][j] > dp[i][j-1]) 
         i--; 
      else
         j--; 
   }
   cout<<ans;
    return 0;
}


Measured memory_bytes: 74028
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
ll ans = 0LL;
int i_index;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};
string board[64];

int main(){
    cin >> N >> M;
    vector<ll> x(M);
    rep(i, M) cin >> x[i];
    sort(x.begin(), x.end());
    vector<ll> dif;
    rep(i, M-1) dif.push_back(abs(x[i] - x[i+1]));
    sort(dif.begin(), dif.end());
    rep(i, dif.size() - (N - 1)) ans += dif[i];
    cout << ans << endl;
}

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

#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define fo(i, a, b, k) for(int i = a; i <= b; i += k)
#define _fo(i, a, b, k) for(int i = a; i >= b; i -= k)
#define foa(i, a) for (auto &i : a)
#define fod(i, a) for(int i = 1; i*i <= a; i++)
#define sz(a) ((int) a.size())
#define all(a) begin(a), end(a)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mk(x, y) make_pair(x, y)  
#define log2i(x) (31-__builtin_clz(x))
#define log2ll(x) (63-__builtin_clzll(x)) 
#define msz(x) __builtin_popcount(x) 
#define mszll(x) __builtin_popcountll(x) 
#define fom(i, a, b) for(int i = a; i < (1<<b); i++)
#define ifon(i, mask) if(mask&(1<<i))
#define ss(i, mask) while(i=(i-mask)&mask)
#define ifss(i, mask) if(i > (mask^i)) 

typedef int64_t ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int MAX = 1e5+1;
const int MOD = 1e9+7;
const ll INF = INT_MAX;
const ll _INF = INT_MIN;

int n;
int alp[26];
map<string, ll> cnt;
ll ans = 0;

string solve(string s) {
	int l = sz(s);
	string curr = "";
	
	fill(alp, alp+26, 0);
	fo(i, 0, l-1, 1) alp[s[i]-'a']++;
	fo(i, 0, 25, 1) 
		fo(j, 1, alp[i], 1) curr += (char)(97+i);
		
	return curr;
}

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin >> n;
	while(n--) {
		string s, curr;
		
		cin >> s;
		curr = solve(s);
		
		ans += cnt[curr];
		cnt[curr]++;
	}
	
	cout << ans;
}

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

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

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

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a) {if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(int a) {if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
void AorB(int a,string b,string c) {if(a){cout<<b<<endl;}else{cout<<c<<endl;}}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}


signed main(){start();
    int n,ans=0;
    cin>>n;
    Vi a(n);
    REP(i,0,n){
        cin>>a[i];
        a[i]--;
        if(a[i]<i) if(a[a[i]]==i) ans++;
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,count=0;
	cin>>n>>k;
	map<int,int> mp;
	for(int i=1;i<=k;i++ )
	{
		int d;
		cin>>d;
		for(int j=1;j<=d;j++)
		{
			int x;
			cin>>x;
			mp[x]++;
		}
	}
	for(int i=1;i<=n;i++)
	if(mp[i]==0)
	count++;
	cout<<count;
}

Measured memory_bytes: 3636
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const long long MOD = 1000000000 + 7;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = 1LL << 60;//numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>g;
vector<edge>ed;
vector<Pll>pv;
set<LL>st;
map<Pll, LL>ma;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
string str, ss;
bool f[200000];
LL n, m, s, t, h, w, k, q, p, ans, sum, cnt, a[210000], b[210000],
dp[210000][5];
int main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n)rep(j, 5)dp[i + 1][j] = INF / 2;
	//0偶奇偶0
	rep(i, n) {
		dp[i + 1][0] = dp[i][0] + a[i];
		LL n1 = (a[i] == 0 ? 2 : a[i] % 2), n2 = (a[i] % 2) ^ 1;
		dp[i + 1][1] = min({ dp[i + 1][1],dp[i][0] + n1,dp[i][1] + n1 });
		dp[i + 1][2] = min({ dp[i + 1][2],dp[i][0] + n2,dp[i][1] + n2,dp[i][2] + n2 });
		dp[i + 1][3] = min({ dp[i + 1][1],dp[i][0] + n1,dp[i][1] + n1
			,dp[i][2] + n1,dp[i][3] + n1 });
		dp[i + 1][4] = min({ dp[i + 1][4],dp[i][0] + a[i],dp[i][1] + a[i],dp[i][2] + a[i],dp[i][3] + a[i],dp[i][4] + a[i] });
	}
	cout << min({ dp[n][0],dp[n][1],dp[n][2],dp[n][3],dp[n][4] }) << endl;
	return 0;
}

Measured memory_bytes: 11776
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int a[m],sum=0;
	for(int i=0;i<m;++i){
		cin>>a[i];
		sum+=a[i];
	}
	if(sum>n){
		cout<<"-1";
		return 0;
	}
	else if(sum<=n){
		cout<<n-sum;
		return 0;
	}
}

Measured memory_bytes: 3672