akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll D;
    cin >> D;
    vector<ll> vec(26);
    rep(i,26){
        cin >> vec[i];
    }
    vector<vector<ll> > happiness(D, vector<ll>(26));
    rep(i,D){
        rep(j,26){
            cin >> happiness[i][j];
        }
    }
    vector<ll> sad(26,0);
    rep(j,26){
        sad[j] += vec[j];
    }
    rep(i,D){
        ll sadistic_per_day = 0;
        rep(j,26){
            sadistic_per_day += sad[j];
        }
        ll minus_point = 0;
        ll t = 0;
        minus_point -= sadistic_per_day;
        ll max_point = minus_point;
        rep(j,26){
            if (max_point <= minus_point + sad[j] + happiness[i][j]){
                t = j + 1;
                max_point = minus_point + sad[j] + happiness[i][j];
            }
        }
        rep(j,26){
            sad[j] += vec[j];
        }
        sad[t - 1] = 0;
        cout << t << endl;
    }
}



Measured memory_bytes: 3728
def task(n, m, x, c, a):
    mx = [0] * m
    for i in range(0, n):
        for j in range(0, m):
            mx[j] += a[i][j]

    for j in range(0, m):
        if mx[j] < x:
            print(-1)
            return

    states = [0] * m

    best = 100000000
    for i in range(1, 2**n):
        price = 0

        for k in range(0, m):
            states[k] = 0

        for j in range(0, n):
            if ((i >> j) & 1):
                price += c[j]
                for k in range(0, m):
                    states[k] += a[j][k]

        if price < best:
            found = True
            for k in range(0, m):
                if states[k] < x:
                    found = False
                    break

            if found:
                best = price

    print(best)


n, m, x = map(int, input().split())
c = []
a = []
for i in range(0, n):
    values = list(map(int, input().split()))
    c.append(values[0])
    a.append(values[1:])

task(n, m, x, c, a)


Measured memory_bytes: 68508
X = int(input())
dp = [False] * (X + 1)
dp[0] = True
for x in range(X+1):
  if x - 100 >= 0 and dp[x-100] == True:
    dp[x] = True
  elif x - 101 >= 0 and dp[x-101] == True:
    dp[x] = True
  elif x - 102 >= 0 and dp[x-102] == True:
    dp[x] = True
  elif x - 103 >= 0 and dp[x-103] == True:
    dp[x] = True
  elif x - 104 >= 0 and dp[x-104] == True:
    dp[x] = True
  elif x - 105 >= 0 and dp[x-105] == True:
    dp[x] = True
  elif x % 100 == 0 or x % 101 == 0 or x % 102 == 0 or x % 103 == 0 or x % 104 == 0 or x % 105 == 0:
    dp[x] = True
print(1 if dp[-1] else 0)

Measured memory_bytes: 3828
#!/usr/bin/env python
# coding: utf-8

# In[2]:


import bisect


# In[ ]:


A, B, Q = map(int, input().split())


# In[ ]:


s = [0] * A
for i in range(A):
    s[i] = int(input())

t = [0] * B
for i in range(B):
    t[i] = int(input())
x = [0] * Q
for i in range(Q):
    x[i] = int(input())


# In[6]:


# A = 2
# B = 3
# Q = 4
# s = [100, 600]
# t = [400, 900, 1000]
# x = [150, 2000, 899, 799]


# In[13]:


def func(i, j):
    ans = []
    if i != 0 and j != 0:
        ans.append(max(y - s[i - 1], y - t[j - 1]))
    if i != len(s) and j != len(t):
        ans.append(max(s[i] - y, t[j] - y))
    if i != 0 and j != len(t):
        ans.append(2*(y-s[i-1]) + (t[j]-y))
        ans.append(2*(t[j]-y) + (y-s[i-1]))
    if i != len(s) and j != 0:
        ans.append(2*(y-t[j-1]) + (s[i]-y))
        ans.append(2*(s[i]-y) + (y-t[j-1]))
    return min(ans)


# In[15]:


ans = []
for y in x:
    i = bisect.bisect_left(s, y)
    j = bisect.bisect_left(t, y)
    ans.append(func(i, j))
print('\n'.join(map(str,ans)))


# In[ ]:





# In[ ]:





# In[ ]:





# In[ ]:





# In[ ]:






Measured memory_bytes: 99672
// Problem : C - Replacing Integer
// Contest : AtCoder Beginner Contest 161
// URL : https://atcoder.jp/contests/abc161/tasks/abc161_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll a, b;
	cin >> a >> b;
	cout << min(a % b, b - (a % b)) << endl;
	return 0;
}
 


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
int getrand(int l, int r) { // [l, r]
    static uint32_t y = time(NULL);
    y ^= (y << 13); y ^= (y >> 17);
    y ^= (y << 5);
    return y % (r - l + 1) + l;
}
string makeString(int len, string type = "qwertyuiopasdfghjklzxcvbnm") {
    string res = "";
    rep(i, 0, len) res += type[getrand(0, type.size() - 1)];
    return res;
}
/*---------------------------------------------------------------------------------------------------
????????????????????????????????? ??§?????§  
??????????????? ??§?????§ ???????´<_??? ?????? Welcome to My Coding Space!
???????????? ??? ?´_???`??????/??? ???i     
?????????????????????????????? ???  |???|     
????????? /?????? /??£??£??£??£/??????|  
??? ???_(__??????/???    ???/ .| .|????????????  
??? ????????????/????????????/??????u??????  
---------------------------------------------------------------------------------------------------*/



string T, P;
int NT, NP;
//--------------------------------------------------------------------------------------------------
void _main() {
    cin >> T >> P;
    NT = T.length(), NP = P.length();

    int p = 0;
    deque<int> qu;
    rep(i, 0, NT) {
        if (T[i] == P[p]) {
            p++;
            qu.push_back(i);
            if (p == NP) break;
        }
    }
    if (p != NP) {
        printf("no\n");
        return;
    }

    p = NP - 1;
    rrep(i, NT - 1, 0) {
        if (T[i] == P[p]) {
            int pre = qu.back(); qu.pop_back();
            if (pre != i) {
                printf("no\n");
                return;
            }
            p--;
            if (p < 0) break;
        }
    }
    if (0 <= p) {
        printf("no\n");
        return;
    }

    printf("yes\n");
}

Measured memory_bytes: 5816
#include <bits/stdc++.h>
#define _boost ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define fi first
#define se second
#define clz __builtin_clz
#define clzll __builtin_clzll
#define bp __builtin_popcount
#define _unique(x) sort((x).begin(),(x).end()),(x).erase(unique((x).begin(), (x).end()),(x.end()))
#define all(x) (x).begin(),(x).end()
#define _rand(i,j) uniform_int_distribution<int>(i, j)(rng___)
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;
template < typename _T, typename _T2> string to_string(pair<_T,_T2> x) {return "<"+to_string(x.fi)+", "+to_string(x.se)+">";}
template < typename _T> string to_string(vector<_T> vec) {string s="[ "; for(auto el:vec)s+=to_string(el)+", "; s[s.size()-1]=']';s[s.size()-2]=' '; return s;}
string to_string(string s) {return s;}
template < typename _T> string to_string(set<_T> vec) {string s="{ "; for(auto el:vec)s+=to_string(el)+", "; s[s.size()-1]='}';s[s.size()-2]=' '; return s;}
template < typename _T, typename _T2> string to_string(map<_T,_T2> vec) {string s="{ "; for(auto el:vec)s+="mp["+to_string(el.fi)+"]= "+to_string(el.se)+", "; s[s.size()-1]='}';s[s.size()-2]=' '; return s;}
template < typename _T > inline void _DBG(const char *s, _T x){cerr << s << " = " << to_string(x) << "\n";}
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a){while(*s != ',') cerr << *s++;cerr << " = " << to_string(x) << "\n";_DBG(s + 1, a...);}
#ifdef LOCAL
#define _print(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define _print(...) ;//cout<<2;//(__VA_ARGS__)
#endif
mt19937 rng___(chrono::steady_clock::now().time_since_epoch().count());


const LL MOD = 1e9+7;//998244353;
const LL LLINF = 1e18+7;
const int N=1e5+8;

struct SegmentTree /// (+, max)
{
    const static int MAX = 1 << 20;
    LL INF = LL(1e18) + 7;
    vector < LL > tree;
    SegmentTree()
    {
        tree.resize(2 * MAX, 0);
    }
    void update(int a, LL val)
    {
        a += MAX;
        tree[a]+=val;
        a/=2;
        while(a) tree[a] = max(tree[2*a],tree[2*a+1]), a /= 2;
    }
    LL query(int a, int b)
    {
        a += MAX, b += MAX;
        LL res = max(tree[a], tree[b]);
        while(a / 2 != b / 2)
        {
            if(a % 2 == 0) res = max(res, tree[a + 1]);
            if(b % 2 == 1) res = max(res, tree[b - 1]);
            a /= 2, b /= 2;
        }
        return res;
    }
};
SegmentTree tree;
int main()
{
    _boost;
    int n;
    cin>>n;
    vector<int> h(n),a(n);
    for(int i=0;i<n;i++)cin>>h[i];
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)
    {
        tree.update(h[i],tree.query(0,h[i])-tree.query(h[i],h[i])+a[i]);
    }
    cout<<tree.query(0,n);
}




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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using ll = long long;
using namespace std;

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

    int h, w; cin >> h >> w;
    char array[h][w]; REPI(i, h) REPJ(j, w) cin >> array[i][j];

    REPI(i, h){
        for(int k = 0; k < 2; k++){
            REPJ(j, w)
                cout << array[i][j];
        cout << '\n';
        }
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    final long M = 998244353L;
    int N = scanner.nextInt();
    int[] a = new int[N];
    int MAX_SUM = 0;
    for (int i = 0; i < N; i++) {
      a[i] = scanner.nextInt();
      MAX_SUM += a[i];
    }

    long[][] dp = new long[N + 1][MAX_SUM + 1];
    dp[0][0] = 1;
    for (int i = 1; i <= N; i++) {
      for (int j = 0; j <= MAX_SUM; j++) {
        dp[i][j] = dp[i - 1][j] * 2;
        dp[i][j] %= M;
        if (j >= a[i - 1]) {
          dp[i][j] += dp[i - 1][j - a[i - 1]];
          dp[i][j] %= M;
        }
      }
    }

    long cnt = 0;
    if (MAX_SUM % 2 == 0) {
      long[][] dp2 = new long[N + 1][MAX_SUM + 1];
      dp2[0][0] = 1;
      for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= MAX_SUM; j++) {
          dp2[i][j] = dp2[i - 1][j];
          if (j >= a[i - 1]) {
            dp2[i][j] += dp2[i - 1][j - a[i - 1]];
            dp2[i][j] %= M;
          }
        }
      }
      cnt = dp2[N][MAX_SUM / 2];
      cnt *= modpow(2, M - 2, M);
      cnt *= 6;
      cnt %= M;
    }

    long sum = modpow(3, N, M);
    sum += cnt;
    sum %= M;
    for (int i = (MAX_SUM + 1) / 2; i <= MAX_SUM; i++) {
      long d = dp[N][i] * 3 % M;
      sum -= d;
      if (sum < 0) sum += M;
    }
    System.out.println(sum);
  }

  private static long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
      if (n % 2 == 1) res = (res * a) % mod;
      a = (a * a) % mod;
      n >>= 1;
    }
    return res % mod;
  }
}


Measured memory_bytes: 575520
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<int(n);i++)
using namespace std;
int main(){
    int d,n;
    cin >> d >> n;
    int s=1;
    for(int i=0;i<d;i++) s*=100;
    if(n<=99) cout << n*s << endl;
    else cout << 101*s << endl;
     
    return 0;
}

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

using namespace std;

int n, a[110], b[110];

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
	}	
	for(int i = 1; i <= n; ++i) {
		scanf("%d", &b[i]);
	}
	int res = 0;
	for(int i = 1; i <= n; ++i) {
		int tmp = 0;
		for(int j = 1; j <= i; ++j) tmp += a[j];
		for(int j = i; j <= n; ++j) tmp += b[j];
		res = max(res, tmp);
	}
	printf("%d\n", res);
	return 0;
}

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

using namespace std;

typedef long long ll;

signed main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    int c = 0;
    int aaaa = 1e9;
    for(auto& x : a){
        cin >> x;
        if(x % 2){
            ++c;
            aaaa = min(aaaa, x);
        }
    }
    int sum = accumulate(a.begin(), a.end(), 0);
    if(c % 2 == 0){
        cout << sum / 2 << endl;
    }else{
        cout << (sum - aaaa) / 2 << endl;
    }
}




Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a){
    long long ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
int main(){
    int n;
    cin >> n;
    int k;
    cin >> k;
    int c;
    rep(i,n){
        int a;
        cin >> a;
        if(a==1)c=i+1;
    }
    n--;
    cout << (n+k-2)/(k-1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,h[100005],k,f[100005];
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>h[i];
	memset(f,0x3f,sizeof(f));
	f[1]=0;
	for(int i=2;i<=n;i++){
		for(int j=1;j<=min(i-1,k);j++)
			f[i]=min(f[i-j]+abs(h[i]-h[i-j]),f[i]);
	}
	cout<<f[n];
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    int n = 0;
    cin >> n;
    vector<ll> one(n);
    for (int i=0; i<n; i++) {
        cin >> one.at(i);
    }
    vector<ll> two(n);
    for (int i=0; i<n; i++) {
        cin >> two.at(i);
    }
    for (int i=1; i<n; i++) {
        one.at(i) += one.at(i-1);
        two.at(i) += two.at(i-1);
    }
    ll maxi = 0;
    for (int i=0; i<n; i++) {
        if (i == 0) {
            maxi = max(maxi, one.at(i) + two.at(n-1));
        }
        else {
            maxi = max(maxi, one.at(i) + two.at(n-1) - two.at(i-1));
        }
    }
    cout << maxi << endl;
    return 0;
}


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

#define int long long
const int INF = (1LL << 31) - 1;
const int sqrtN = 512;
struct SqrtDecomposition {
  int N, K;
  vector<int> data;
  vector<int> bucketMin;
  SqrtDecomposition(int n) : N(n) {
    K = (N + sqrtN - 1) / sqrtN;
    data.assign(K * sqrtN, INF);
    bucketMin.assign(K, INF);
  }
  void update(int x, int y) {
    int k = x / sqrtN;
    int minVal = data[x] = y;
    for(int i = k * sqrtN; i < (k + 1) * sqrtN; ++i) {
      minVal = min(minVal, data[i]);
    }
    bucketMin[k] = minVal;
  }
  // [x, y)
  int find(int x, int y) {
    int minVal = INF;
    for (int k = 0; k < K; ++k) {
      int l = k * sqrtN, r = (k + 1) * sqrtN;
      if (r <= x || y <= l)
        continue;
      if (x <= l && r <= y) {
        minVal = min(minVal, bucketMin[k]);
      } else {
        for (int i = max(x, l); i < min(y, r); ++i) {
          minVal = min(minVal, data[i]);
        }
      }
    }
    return minVal;
  }
};

signed main() {
  ios::sync_with_stdio(false);
  int N, Q; cin >> N >> Q;
  SqrtDecomposition decomp(N);
  while(Q--) {
    int c, x, y; cin >> c >> x >> y;
    if(c == 0) {
      decomp.update(x, y);
    }
    else {
      cout << decomp.find(x, y + 1) << endl;
    }
  }
}

Measured memory_bytes: 3616
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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 all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"


bool check(string s){
  string t=s;
  reverse(all(t));
  rep(i,s.size())if(s[i]!=t[i])return false;
  return true;
}
bool solve(){  
  string s;cin>>s;
  ll n=s.size();
  bool isOK=true;
  if(!check(s))isOK=false;

  string t=s.substr(0,(n-1)/2);
  if(!check(t))isOK=false;
  t=s.substr((n+3)/2-1,n/2);
  if(!check(t))isOK=false;
  if(isOK)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return false;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


Measured memory_bytes: 256
class uinon_find():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m = list(map(int,input().split()))

uf = uinon_find(n)
for i in range(m):
    a,b = list(map(int,input().split()))
    a-=1
    b-=1
    uf.union(a,b)
ans=0
for i in range(n):
    ans=max(ans,uf.size(i))
print(ans)

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

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

    if(n == 100)
        n++;

    int ans = 1;
    for(int i = 0; i < d; i++)
        ans *= 100;

    cout << n * ans << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
double n; long long a, b;
int main() {
	while (true) {
		cin >> n; a = 1.0 * n * 16; b = 1.0*n * (1<<25);
		if (a < 0) { break; }
		if (b % (1<<21) != 0 || n>=256) { cout << "NA" << endl; }
		else {
			for (int i = 11; i >= 4; i--) {
				cout << (a / (int)pow(2, i)) % 2;
			}
			cout << '.';
			for (int i = 3; i >= 0; i--) {
				cout << (a / (int)pow(2, i)) % 2;
			}
			cout << endl;
		}
	}
}

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

int di(int x1,int y1,int x2,int y2){
	return abs(x1-x2)+abs(y1-y2);
}

int main(){
	int n,a,b,c,d;
	cin >> n >> a >> b >> c >> d;
	a--,b--,c--,d--;
	int ans = 1e9;
	for(int i = 1 ; i <= n ; i++){
		ans = min(ans,di(a%i,a/i,b%i,b/i)+di(c%i,c/i,d%i,d/i));
	}
	cout << ans << endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 100005

ll N;
ll A[SIZE],TOP[SIZE];
ll POW[61];

int main(){

	POW[0] = 1;
	for(int i = 1; i <= 60; i++){

		POW[i] = POW[i-1]*2;
	}

	scanf("%lld",&N);

	ll all = 0;

	for(ll i = 0; i < N; i++){

		scanf("%lld",&A[i]);
		all ^= A[i];
	}

	ll ans = all;

	for(int i = 0; i < N; i++){

		A[i] &= ~all;
	}

	for(int i = 0; i <= 60; i++){

		TOP[i] = -1;
	}

	ll r = 0;

	for(int i = 60; i >= 0; i--){

		//r行目以降で、i桁目に1が立っている行を探す
		ll loc = r;
		for(;loc < N; loc++){
			if(A[loc] & POW[i]){

				swap(A[loc],A[r]);
				break;
			}
		}
		if(loc == N)continue; //1が立っている行なし

		TOP[r] = i; //確定r行目の、1が立っている桁はi

		for(int k = 0; k < N; k++){
			if(k == r)continue;
			if(A[k] & POW[i]){

				A[k] ^= A[r];
			}
		}
		r++;
	}

	ll X = 0;

	for(int i = 60; i >= 0; i--){

		ll work = X|POW[i];

		ll tmp = work;
		for(int k = 0; k < r; k++){
			if(tmp & POW[TOP[k]]){

				tmp ^= A[k];
			}
		}
		if((tmp & work) == 0){

			X = work;
		}
	}

	ans += 2*X;

	printf("%lld\n",ans);

	return 0;
}




Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
#define AB(A) for(A=0;A<100;A++)a[A]=0

int main() {
  int n = 0, tmp0 = 0, tmp1 = 0;
  int tmp2 = 0, tmp3, out1 = 0, out2 = 0;
  int a[100];
  scanf("%d", &n);
  while (n) {
    AB(tmp3);
    tmp0 = 0, out2 = 0;
    while (tmp0 < n) {
      tmp1 = 0, out1 = 0;
      while (tmp1 < n) {
        scanf("%d", &tmp2);
        a[tmp1] += tmp2;
        printf("%5d", tmp2);
        out1 += tmp2;
        tmp1++;
      }
      printf("%5d\n", out1);
      a[tmp1] += out1;
      tmp0++;
    }
    tmp0 = 0;
    while (tmp0 < n) {
      printf("%5d", a[tmp0]);
      tmp0++;
    }
    printf("%5d\n", a[tmp0]);
    scanf("%d", &n);
  }
  return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, k;
	cin>>n>>k;
	if(k > n * (n - 1)/ 2 - (n - 1)){
		cout<<-1<<endl;
		return 0;
	}
	else{
		cout<<n * (n - 1) / 2 - k<<endl;
		for(int i = 2; i <= n; ++i){
			cout<<1<<" "<<i<<endl;
		}
		int res = n - 1;
		for(int i = 2; i <= n; ++i){
			for(int j = i + 1; j <= n; ++j){
				if(res == (n * (n - 1) / 2 - k))return 0;
				cout<<i<<" "<<j<<endl;
				res++;
			}
		}
	}
	return 0;
}


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

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

    int p1 = (float)s/n;
    int p2 = (float)s/n + 1;

    int ans1=0, ans2=0;
    for(int i=0; i<n; ++i){
        ans1 += (a[i]-p1) * (a[i]-p1);
        ans2 += (a[i]-p2) * (a[i]-p2);
    }
    cout << min(ans1, ans2);

    return 0;
}


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

#define F first
#define S second
#define prev azaza
#define MP make_pair
#define PB push_back

using namespace std;
typedef long long ll;
typedef long double ld;

const int max_n = 200111, inf = 1000111222;

pair<int, int> m[max_n];


bool cmpx(int a, int b) {
    return m[a].F < m[b].F;
}

bool cmpy(int a, int b) {
    return m[a].S < m[b].S;
}

int ans[max_n];

void process(vector<int> v) {
    for (int a : v) {
        ans[a] = v.size();
    }
}

int main()
{
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    vector<int> st;
    for (int i = 0; i < n; ++i ){
        cin >> m[i].F >> m[i].S;
    }
    vector<int> v;
    for (int i = 0; i < n; ++i) {
        v.PB(i);
    }
    sort(v.begin(), v.end(), cmpx);
    st.PB(v[0]);
    for (int I = 1; I < n; ++I) {
        int i = v[I];
        if (m[i].S >= m[st.back()].S) {
            continue;
        }
        st.PB(i);
    }
    int cur = 0;
    vector<vector<int>> gr;
    sort(v.begin(), v.end(), cmpy);
    reverse(v.begin(), v.end());
    vector<int> curg;
    for (int i : v) {
        if (m[i].S < m[st[cur]].S) {
            gr.PB(curg);
            curg.clear();
            ++cur;
        }
        curg.PB(i);
    }
    gr.PB(curg);
    curg = gr[0];
    int mxr = -100;
    for (int i : curg) {
        mxr = max(mxr, m[i].F);
    }
    for (int i = 1; i < gr.size(); ++i) {
        int mn = inf;
        int mx = -inf;
        for (int j : gr[i]) {
            mn = min(mn, m[j].F);
            mx = max(mx, m[j].F);
        }
        if (mxr > mn) {
            mxr = max(mxr, mx);
            for (int j : gr[i]) {
                curg.push_back(j);
            }
        } else {
            process(curg);
            curg = gr[i];
            mxr = mx;
        }
    }
    process(curg);
    for (int i = 0;i < n; ++i) {
        cout << ans[i] << ' ';
    }
    return 0;
}




Measured memory_bytes: 13608
#include <iostream>
    #include <vector>
     
    int main(){
        int c[8]={0};

        int N,a,ex=0;
        std::cin>>N;
        for(int i=0;i<N;++i){
            std::cin>>a;
            if(a<3200) c[a/400]=1;
            else ex+=1;
        }
        int ans=0;
        for(int i=0;i<8;++i){
            ans+=c[i];
        }
        if(ans==0){
            ex-=1;
            ans=1;
        }
        std::cout<<ans<<" ";
        ans+=ex;
        std::cout<<ans<<std::endl;
    }
    

Measured memory_bytes: 256
from heapq import heappush, heappop
from collections import defaultdict

def small(N, A, B, C, D):
    if N == 1:
        return D
    elif N == 2:
        return min(2*D, D+A)
    elif N == 3:
        return min(3*D, D+B, 2*D+A)
    else:
        assert False

def solve(N, A, B, C, D):
    if N <= 3:
        return small(N, A, B, C, D)
    visited = set()
    #visited.add(N)
    dist = {}
    dist[N] = 0
    q = []
    heappush(q, (0, N))
    def update(d2, d, cost):
        nonlocal q
        nonlocal dist
        if not d2 in dist or dist[d2] > dist[d] + cost:
            dist[d2] = dist[d] + cost
            heappush(q, (dist[d2], d2))
            # if d2 == 0:
            #     print(f'{d}->{d2}, cost={cost}')
    while len(q) > 0:
        _prov_cost, d = heappop(q)
        if d in visited:
            continue
        else:
            visited.add(d)
        #dから行けるところ->2,3,5で割れるようにする方法
        mod2 = d % 2
        mod3 = d % 3
        mod5 = d % 5
        if mod2 == 0:
            update(d//2, d, A)
        if mod3 == 0:
            update(d//3, d, B)
        if mod5 == 0:
            update(d//5, d, C)
        #if mod2 * mod3 * mod5 != 0:  #2でも3でも5でも割れない場合、2か3か5で割りに行く
            
        #奇数なので、上下を足す。11->10->5->6より11->12->6のほうが安い
        #ただし、割りに行く値よりD重ねたほうがいい場合もある
        #11->10->5はD+Aと(11-5)*Dとコストが安い方
        update((d-1)//2, d, min(D+A, (d - (d-1)//2)*D))
        #11->12->6はD+Aと(12-5)*Dとコストが安い方
        update((d+1)//2, d, min(D+A, (d - (d+1)//2)*D))
        #3で割りに行く
        _d2 = (d-mod3)//3
        update(_d2, d, min(mod3*D+B, (d-_d2)*D))
        _d2 = (d+(3-mod3))//3
        update(_d2, d, min((3-mod3)*D+B, (d-_d2)*D))
        #5で割りに行く
        _d2 = (d-mod5)//5
        update(_d2, d, min(mod5*D+C, (d-_d2)*D))
        _d2 = (d+(5-mod5))//5
        update(_d2, d, min((5-mod5)*D+C, (d-_d2)*D))
        '''
        if d % 5 == 1:
            update((d-1)//3, D+C)
            update((d+4)//5, 4*D+C)
        elif d % 5 == 2:
            update((d-2)//3, 2*D+C)
            update((d+3)//5, 3*D+C)
        '''

        #print('q:', q)
        #print('q for nonvisited:', [x for x in q if not x[1] in visited])
        #print('dist:', dist)
    #print(dist)
    return dist[0]
            #heappush(q, (D, d+1))
            #heappush(q, (D, d-1))

    

    

def main():
    T = int(input())
    for _ in range(T):
        N, A, B, C, D = tuple(int(c) for c in input().split(' '))
        print(solve(N, A, B, C, D))

if __name__ == "__main__":
    main()

Measured memory_bytes: 16416
#include <stdio.h>

int main(){
    int x, y;
    
    while(1){
        scanf("%d %d", &x, &y);
        if(x == 0 && y == 0){
            break;
        }
        if(x < y){
            printf("%d %d\n",x ,y);
        }else{
            printf("%d %d\n",y ,x);
        }
    }
}


Measured memory_bytes: 2048
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 200005, inf = 1000000007 ;
using namespace std ;

int n, e, ter[N], nxt[N], lnk[N], v[N] ;
struct poi {
	int st, l, r ;
} f[N] ;

void add(int x, int y) {
	ter[++ e] = y, nxt[e] = lnk[x], lnk[x] = e ;
}

bool dfs(int p, int las) {
	f[p].st = 3 ;
	f[p].l = - inf, f[p].r = inf ;
	for (int i = lnk[p]; i; i = nxt[i]) if (ter[i] != las) {
		int u = ter[i] ;
		if (!dfs(u, p)) return false ;
		if (!(f[u].st & 2)) f[p].st &= 2 ;
		if (!(f[u].st & 1)) f[p].st &= 1 ;
		f[p].l = max(f[p].l, f[u].l - 1) ;
		f[p].r = min(f[p].r, f[u].r + 1) ;
	}
	if (!f[p].st || f[p].l > f[p].r) return false ;
	if (f[p].l == f[p].r) {
		if ((f[p].l & 1) && !(f[p].st & 1)) return false ;
		if (!(f[p].l & 1) && !(f[p].st & 2)) return false ;
	}
	if (v[p] != - 1) {
		if (v[p] < f[p].l || v[p] > f[p].r) return false ;
		if (v[p] & 1) f[p].st &= 1 ; else f[p].st &= 2 ;
		if (!f[p].st) return false ;
		f[p].l = f[p].r = v[p] ;
	}
	return true ;
}

void solve(int p, int las) {
	for (int i = lnk[p]; i; i = nxt[i]) if (ter[i] != las) {
		int u = ter[i] ;
		if (v[u] == - 1) {
			v[u] = v[p] - 1 ;
			if (v[u] < f[u].l || v[u] > f[u].r) v[u] = v[p] + 1 ;
		}
		solve(ter[i], p) ;
	}
}

int main() {
	scanf("%d", &n) ;
	int x, y ;
	rep(i, 1, n - 1) {
		scanf("%d%d", &x, &y) ;
		add(x, y), add(y, x) ;
	}
	int m ;
	scanf("%d", &m) ;
	rep(i, 1, n) v[i] = - 1 ;
	rep(i, 1, m) {
		scanf("%d%d", &x, &y) ;
		v[x] = y ;
	}
	if (!dfs(1, 0)) printf("No\n") ; else {
		if (v[1] == - 1) {
			v[1] = f[1].l ;
			if ((v[1] & 1) && !(f[1].st & 1)) ++ v[1] ; else
			if (!(v[1] & 1) && !(f[1].st & 2)) ++ v[1] ;
		}
		solve(1, 0) ;
		printf("Yes\n") ;
		rep(i, 1, n) {
			printf("%d\n", v[i]) ;
		}
	}
	return 0 ; 
}

Measured memory_bytes: 11776
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int X, Y;
    cin >> X >> Y;
    int y = -1, x = -1;
    if ((Y - 2*X) % 2 == 0) {
        y = (Y - 2*X)/2;
        if ((4*X - Y) % 2 == 0) {
            x = (4*X - Y)/2;
        }
    }
    if (x >= 0 && y >= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d;
    cin>>n>>d;

    int times=0;
    for(int i=0;i<n;i++)
    {
       int x,y;
       cin>>x>>y;

       if(pow(x,2)+pow(y,2)<=pow(d,2))
       {
           times++;
       }
    }
    cout<<times;
}


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

int main() {
  
  string a,s,c;
  cin >> a >> s >>c;
  
  char s2 = s.at(0);
  char a2 = 'A';
  char c2 = 'C';
  
  cout << a2 << s2 << c2 << endl;
  
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>

typedef long long ll;

using namespace std;


int main(){
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a, a + n);
    int ans = 0;
    for(int i = 0; i < k; i++){
        ans += a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <cassert>
#include <stack> 

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define BASE 15487469
#define PI acos(-1.0)
#define MAXLEN 29

typedef std::pair <int, int> pii;
typedef long long ll;
typedef std::vector <ll> vll;

using namespace std;

int main() {
	int n;
	cin >> n;
	if (n == 3) {
		cout << "2 5 63" << endl;
	} else if (n == 4) {
		cout << "2 4 3 9" << endl;
	} else if (n == 5) {
		cout << "2 4 3 9 12" << endl;
	} else if (n == 6) {
		cout << "2 4 3 9 12 24" << endl;
	} else if (n <= 30000 / 2) {
		cout << "2 4 3 9 ";
		if (((3 + n - 2) * (n - 4)) % 3 == 0) for (int i = 1; i <= n - 4; i++) cout << (i + 2) * 2 << " ";
		else {
			cout << "15 21 ";
			for (int i = 1; i <= n - 6; i++) cout << (i + 2) * 2 << " ";
		}
		cout << endl;
	} else {
		int left = n - 30000 / 2;
		if (left % 2 == 0) {
			for (int i = 1; i <= 30000 / 2; i++) cout << i * 2 << " ";
			for (int i = 1; left; i += 2, left--) {
				cout << i * 3 << " ";
			}
			cout << endl;
		} else {
			left += 1;
			for (int i = 1; i <= 30000 / 2 - 1; i++) cout << i * 2 << " ";
			for (int i = 1; left; i += 2, left--) {
				cout << i * 3 << " ";
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;



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

	int N, P;
	string S;
	cin >> N >> P >> S;
	int ans = 0;
	if(P == 2){
		rep(i,N){
			if(S[i] == '0' || S[i] == '2' || S[i] == '4' || S[i] == '6' || S[i] == '8') ans += i+1;
		}
	}
	else if(P == 5){
		rep(i,N){
			if(S[i] == '0' || S[i] == '5') ans += i+1;
		}
	}
	else{
		map<int, int> mp{};
		int num = 0, kai = 1;
		mp[0]++;
		for(int i=N-1;i>=0;i--){
			num += (S[i]-'0') * kai;
			num %= P;
			mp[num]++;
			kai = (kai * 10) % P;
		}
		for(auto p : mp){
			int n = p.second;
			ans += n * (n-1) / 2;
		}
	}
	cout << ans <<endl;
}

Measured memory_bytes: 1044
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		int n, m, c;
		n = sc.nextInt(); m = sc.nextInt(); c = sc.nextInt();
		int b[] = new int[m];
		for(int i = 0; i < m; ++i) b[i] = sc.nextInt();
		int a[][] = new int[n][m];
		for(int i = 0; i < n; ++i) {
			for(int j = 0; j < m; ++j) {
				a[i][j] = sc.nextInt();
			}
		}
		
		int ans = 0;
		for(int i = 0; i < n; ++i) {
			int sum = c;
			for(int j = 0; j < m; ++j) sum += a[i][j]*b[j];
			
			if(sum > 0) ++ans;
		}
		
		System.out.println(ans);
	}
}


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

using namespace std;

int arr[200000];

int main(){
    int n, x, y;

    cin >> n;

    for(int i=0; i<n-1; i++){
        cin >> arr[i];
    }

    map<int, int> map;

    for(int i=0; i<n-1; i++){
        if(i+2 > arr[i])
            map[arr[i]]++;
    }
    
    for(int i = 1; i<=n; i++){
        cout << map[i] << "\n";
    }

}

Measured memory_bytes: 13772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
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;
}

signed main()
{
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    vi A;
    char tmp = S[0];
    A.push_back(1);
    REP(i, S.size() - 1)
    {
        if (S[i + 1] == tmp)
            A[A.size() - 1]++;
        else
        {
            A.push_back(1);
            tmp = S[i + 1];
        }
    }
    if (A.size() == 1)
    {
        cout << N << endl;
        return 0;
    }
    int tmpp = 0;
    int ans = 0;
    int tmpf = 0;
    int tmpe = 0;
    if (S[0] == '1')
    {
        tmpp += A[0];
        tmpf = 0;
        FOR(i, 1, K * 2 + 1)
        {
            tmpe = i;
            if (tmpe >= A.size())
                break;
            tmpp += A[tmpe];
        }
        chmax(ans, tmpp);
        while (tmpe <= A.size())
        {
            tmpp -= A[tmpf];
            tmpf++;
            tmpp -= A[tmpf];
            tmpf++;

            tmpe++;
            if (tmpe == A.size())
                break;
            tmpp += A[tmpe];
            chmax(ans, tmpp);
            tmpe++;
            if (tmpe == A.size())
                break;
            tmpp += A[tmpe];
            chmax(ans, tmpp);
        }
    }
    if (S[0] == '0')
    {
        tmpp = 0;
        tmpf = -1;
        FOR(i, 0, K * 2)
        {
            tmpe = i;
            if (tmpe == A.size())
                break;
            tmpp += A[tmpe];
        }
        chmax(ans, tmpp);
        while (tmpe <= A.size())
        {
            if (tmpf > -1)
            {
                tmpp -= A[tmpf];
            }
            tmpf++;
            tmpp -= A[tmpf];
            tmpf++;

            tmpe++;
            if (tmpe == A.size())
                break;
            tmpp += A[tmpe];
            chmax(ans, tmpp);
            tmpe++;
            if (tmpe == A.size())
                break;
            tmpp += A[tmpe];
            chmax(ans, tmpp);
        }
    }
    cout << ans << endl;
    // system("pause");
}

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

using ll=long long;

int main() {
  int N,H,W; cin >>N >>H >>W;
  cout <<(N-H+1)*(N-W+1) <<endl;
  return 0;
}


Measured memory_bytes: 3604
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < 3; ++i) {
        if(s[i]==t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	s := scanString()
	n := len(s)

	s1 := s[:(n-1)/2]
	s2 := s[(n+3)/2-1:]

	f := true

	for i := 0; i < len(s); i++ {
		if s[i] != s[n-1-i] {
			f = false
		}
	}

	for i := 0; i < len(s1); i++ {
		if s1[i] != s1[len(s1)-1-i] {
			f = false
		}
	}

	for i := 0; i < len(s2); i++ {
		if s2[i] != s2[len(s2)-1-i] {
			f = false
		}
	}
	
	if f {
		fmt.Fprintln(wr, "Yes")
	} else {
		fmt.Fprintln(wr, "No")
	}
}


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

typedef vector <int> vi;
typedef pair< int , int > pii;
#define endl "\n"
#define sd(val) scanf("%d",&val)
#define ss(val) scanf("%s",&val)
#define sl(val) scanf("%lld",&val)
#define debug(val) printf("check%d\n",val)
#define all(v) v.begin(),v.end()
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
#define MOD 1000000007
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);



int main()
{
	FIO;
	int k;
	cin >> k;
	string s;
	cin >> s;
	if (s.length() > k) {
		for (int i = 0; i < k; i++) {
			cout << s[i] ;
		}
		cout << "...";
	}
	else {
		cout << s << "\n";
	}
	return 0;
}

Measured memory_bytes: 3608
/*input
60522 114575 7559
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<ll,ll>
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const int maxn=1e6+5;
const int maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
ll inv(ll u){
    return mypow(u,MOD-2);
}
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n,m,k;
    cin>>n>>m>>k;
    ll ans=0;
    ll cur=1;
    REP(i,k+1){
        ans+=mult(m,mult(cur,mypow(m-1,n-i-1)));
        ans%=MOD;
        cur=mult(cur,n-i-1);
        cur=mult(cur,inv(i+1));
        //cout<<cur<<' ';
       // cout<<mult(m,mult(n-i,mypow(m-1,n-i-1)))<<'\n';
    }
    cout<<ans;
}


Measured memory_bytes: 3632
#include<stdio.h>
#define IIOOO "%c"
#define OOOO "%d%d"
#define OIIIIO "\n"
#define IIIIO &
#define OOIO (
#define OOIIO (!
#define OO (){
#define IIOIO )
#define IOOOO )&
#define OIIIO );
#define OIOO ){
#define OIOOO +
#define OIO ,
#define IOOIO 0
#define IIOO 1
#define OOO ;
#define IOIOO ;++
#define OIIOO <
#define IIIOO =
#define OOOOO ?'.':'#');
#define IIO H
#define IOO W
#define OOOIO for
#define IIIO i
#define IOIIO if
#define O int
#define OIIO j
#define IO main
#define OOIOO printf
#define OIOIO return
#define IOOO scanf
#define IOIO while
#define IIIIIO }
O IO OO
O IIO OIO IOO OOO
O IIIO OOO
O OIIO OOO
IOIO OOIO IIOO OIOO
IOOO OOIO OOOO OIO IIIIO IIO OIO IIIIO IOO OIIIO
IOIIO OOIIO IIO IIOIO OIOIO IOOIO OOO
OOOIO OOIO IIIO IIIOO IOOIO OOO IIIO OIIOO IIO IOIOO IIIO OIOO
OOOIO OOIO OIIO IIIOO IOOIO OOO OIIO OIIOO IOO IOIOO OIIO OIOO
OOIOO OOIO IIOOO OIO OOIO IIIO OIOOO OIIO IOOOO IIOO OOOOO
IIIIIO
OOIOO OOIO OIIIIO OIIIO
IIIIIO
OOIOO OOIO OIIIIO OIIIO
IIIIIO
OIOIO IOOIO OOO
IIIIIO



Measured memory_bytes: 2044
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

vector<pair<ll, ll>>factor(ll n){
    vector<pair<ll, ll>> prime;
    ll sq = sqrt(n) + 1;
    for(ll i = 2; i <= sq; i++){
        sq = sqrt(n) + 1;
        if(n%i == 0){
            prime.push_back(make_pair(i, 0));
            while(n%i == 0){
                n/=i;
                prime[prime.size()-1].second++;
            }
        }
    }
    if(n != 1){
        prime.push_back(make_pair(n, 1));
    }
    return prime;
}
int main(){
    ll n, p;
    cin >> n >> p;

    vector<pair<ll, ll>> fac = factor(p);
    ll ans = 1;
    rep(i, fac.size()){
        ans *= pow(fac[i].first,(fac[i].second/n));
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  ll H, W; cin >> H >> W;
  
  ll ans = 1e10;
  rep(tmp,(1<<3)) {
    bitset<3> s(tmp);
    vl area(3);
    ll Hs = H, Ws = W;

    if (s.test(0)) {
      area[0] = (H/3 + s[1]) * W;
      Hs -= H/3 + s[1];
    } else {
      area[0] = (W/3 + s[1]) * H;
      Ws -= W/3 + s[1];
    }

    if (s.test(2)) {
      area[1] = (Hs/2) * Ws;
    } else {
      area[1] = (Ws/2) * Hs;
    }

    area[2] = H*W - area[0] - area[1];

    sort(all(area));
    ans = min(ans, area[2]-area[0]);
  }

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


Measured memory_bytes: 256