akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359
/*
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
 
using namespace __gnu_pbds;
typedef tree<pii,null_type,less <pii>,rb_tree_tag,tree_order_statistics_node_update>ind_set;
*/
///*X.find_by_order("index")
///X.order_of_key("key")
 
 
 
#define deb(x) cerr<<#x<< " : " <<x<<"\n";
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------

int n,d;
int arr[100][100];
set<int> S;
void solve()
{
	rep(i,0,100005)S.insert(i*i);
	cin>>n>>d;
	rep(i,0,n)rep(j,0,d)cin>>arr[i][j];
	int ans=0;
	rep(i,0,n)rep(j,i+1,n)
	{
		int num=0;
		rep(k,0,d)num+=(arr[i][k]-arr[j][k])*(arr[i][k]-arr[j][k]);
		if (S.find(num)!=S.end())ans++;

	}cout<<ans<<"\n";
}

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
 
    #ifdef local
    ///freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    clock_t qwertyuiop = clock();
    #endif
 
 
    int t=1;
    ///cin>>t;
    
    rep(a,0,t)
    {
        ///cout<<"Case #"<<a+1<<": ";
        solve();
    }
    #ifdef local
	{qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}

Measured memory_bytes: 4992
//Walk on Multiplication Table
#include <iostream>
#define ll long long
#include <math.h>
using namespace std;
int main () {
	ll n, x;	cin >> n;
	for (int i = sqrt (n) + 1; i >= 1; i--) {
		if (n % i == 0) {
			x = i + n / i - 2;
			cout << x << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, cnt=0, ans=0;
  cin >> n;
  int h[n];
    for(int i=0; i<n; i++) cin >> h[i];
    for(int i=0; ans<n-i; i++){
      for(int j=i;j<n-1;j++){
        if(h[j]>=h[j+1]) cnt += 1;
        else break;
      }
      ans = max(ans, cnt);
      cnt = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
L=list(map(int,input().split()))
mx = sum(L)
mn = mx/(4*m)
L.sort(reverse = True)
count = 0
for i in range(n):
    if L[i]>=mn:
        count+=1
    if count ==m:
        print('Yes')
        sys.exit()
print('No')
sys.exit()



Measured memory_bytes: 61988
//ProblemA.cpp

#include <iostream>

static std::istream & ip = std::cin;
static std::ostream & op = std::cout;

#if OJ_MYPC
#include <ojio.h>
#endif

#ifndef OPENOJIO
#define OPENOJIO
#endif

#if 1 || DEFINE
/***************************************************************/
typedef unsigned long long u64;
typedef long long s64;

typedef unsigned uint;

#define ABS(x) ((x) > 0 ? (x) : -(x))

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define MIN3(x, y, z) MIN(x, MIN(y, z))
#define MAX3(x, y, z) MAX(x, MAX(y, z))

#define FillZero(arr) memset(arr, 0, sizeof(arr));

/***************************************************************/
#endif //1 || DEFINE

#include <string>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <utility>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>

//001
//op << setfill('0') << setw(3) << setiosflags(ios::right) << 1;

//op << fixed << setprecision(20);

using namespace std;

//ProblemA.cpp

int main(int argc, char* argv[])
{
	OPENOJIO;

	s64 a, b, c;
	ip >> a >> b >> c;

	s64 rst;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		rst = 0;
	}
	else {
		if (a >= b && a >= c) rst = b*c;
		else if (b >= a && b >= c) rst = a*c;
		else rst = a *b;
	}

	cout << rst << endl;

	return 0;
}
/***************************************************************/


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	n := make([]int, 0)
	for i:=0; ;i++{
		var num int
		fmt.Scan(&num)
		if num == 0 {
			break
		}
		n = append(n, num)
	}

	for i:=0; i<len(n); i++{
		fmt.Printf("Case %d: %d\n", i+1, n[i])
	}
}


Measured memory_bytes: 2424
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>
#include <map>
#include <climits>
#include <vector>
#include <set>
#include <string>
#include <numeric>

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define flood(arr, char, size) for (int i=0; i<size; i++) arr[i] = char
#define int long long
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<int, int>> vii;
const int N = 1e5 + 2;
const int INF = 1e9 + 5;
const int MOD = 1e9 + 7;

int32_t main() {
    FAST_IO;
    int n, m;
    cin >> n >> m;
    int heights[N];
    vi AdjList[N];
    for (int i = 1; i <= n; i++) cin >> heights[i];
    while (m--) {
        int u, v;
        cin >> u >> v;
        AdjList[u].push_back(v);
        AdjList[v].push_back(u);
    }
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        int h = heights[i];
        bool flag = true;
        if (AdjList[i].empty()) flag = true;
        else {
            for (int x: AdjList[i]) {
                if (heights[x] >= h) {
                    flag = false;
                    break;
                }
            }
        }
        if (flag) cnt++;
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 10288
n=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if A[i]!=A[j] and A[j]!=A[k] and A[i]!=A[k]:
                if A[i]<A[j]+A[k] and A[j]<A[i]+A[k] and A[k]<A[j]+A[i]:
                    ans+=1
print(ans)

Measured memory_bytes: 9188
#include<stdio.h>


#define MAX 100


int cnt[ MAX + 2 ] ;

int main( void )
{
	int N ,max ;
	scanf( "%d" ,&N ) ;

	int i ,p ;
	for( i = max = 0 ; i < N ; ++i )
	{
		scanf( "%d" ,&p ) ;

		++cnt[ p ] ;
		max = max < p ? p : max ;
	}

	for( i = max ; i > 0 ; --i )
	{
		cnt[ i ] += cnt[ i + 1 ] ;

		if( cnt[ i ] >= i )
		{
			printf( "%d\n" ,i ) ;

			return 0 ;
		}
	}
}


Measured memory_bytes: 2080
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
using namespace std;

const int Maxn = 6005;
int n, sza, szb;
char str[Maxn];
int a[Maxn], b[Maxn], pos[Maxn];
string dp[Maxn];

inline string Max(string a, string b) {
	if (a == "") return b;
	else if (b == "") return a;
	for (int i = 0; i < (int)min(a.size(), b.size()); ++ i)
		if (a[i] != b[i]) return a[i] > b[i] ? a : b;
	return a.size() > b.size() ? a : b;
}

int main() {
	scanf("%d\n%s", &n, str + 1);
	for (int i = 1; i <= (n << 1); ++ i)
		if (str[i] == 'a') a[++ sza] = i, pos[i] = sza;
		else b[++ szb] = i, pos[i] = szb;
	for (int i = n; i; -- i) {
		if (a[i] < b[i]) {
			int k = i;
			for (int j = b[i] - 1; j > a[i]; -- j)
				if (str[j] == 'a') {
					k = pos[j];
					break;
				}
			dp[i] = "ab"s + dp[k + 1];
		}
		else {
			int k = i;
			while (k < n && b[k + 1] < a[k]) ++ k;
			for (int j = b[i]; j <= (n << 1); ++ j)
				if (i <= pos[j] && pos[j] <= k) dp[i] += str[j];
			dp[i] += dp[k + 1];
		}
		dp[i] = Max(dp[i], dp[i + 1]);
	}
	string ans = "";
	for (int i = 1; i <= n; ++ i)
		ans = Max(ans, dp[i]);
	printf("%s\n", ans.c_str());
	return 0;
}

Measured memory_bytes: 9984
#include <iostream>
#include <vector>
// #include <algorithm>
// #include <set>
// #include <string>
// #include <cmath>
// #include <map>
// #include <iomanip>

#define MOD 1000000007

using namespace std;
// typedef unsigned long long ull;
typedef long long ll;

void p() {
    cout << "\n";
}
template<class Head, class... Body>
void p(Head head, Body... body) {
    cout << head << ",";
    p(body...);
}

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    for (const auto i : v) {
        os << i << " ";
    }
    os << "]";
    return os;
}

struct Edge {
    int from;
    int to;
    int cost;
};

int main(int argc, char const *argv[]) {
    int N, M;
    cin >> N >> M;

    vector<int> a(M);
    vector<Edge> E;
    for (int i = 0; i < M; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        E.push_back({a-1, b-1, -c});
    }

    vector<ll> dist(N, 0);
    vector<bool> visited(N, false);
    visited[0] = true;
    bool inf = false;
    for (int i = 0; i < N; ++i) {
        bool update = false;
        for (const auto& edge : E) {
            if (visited[edge.from] && (!visited[edge.to] || dist[edge.to] > dist[edge.from] + edge.cost)) {
                dist[edge.to] = dist[edge.from] + edge.cost;
                visited[edge.to] = true;
                update = true;
                if (i == N-1 && edge.to == N-1) {
                    inf = true;
                }
            }
        }
        // cout << i << " update:" << update << endl;
        // cout << visited << endl;
        // cout << dist << endl;
        if (!update) {
            break;
        }
    }

    if (inf) {
        cout << "inf" << endl;
    } else {
        cout << -dist[N-1] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
bool vis[200005];
ll tim[200005];
ll ind[2000005];
ll loop=0;
ll a[200005];
int main(){
	//freopen("in.txt","r",stdin);
	ll n,k;
	cin>>n>>k;
	for(ll i=1;i<=n;i++){
		cin>>a[i];
	}
	ll ans=1;
	vis[1]=true;
	tim[1] = 1;
	ind[1] = 1;
	for(int i=2;i<=k;i++){
		ans = a[ans];
		if(vis[ans]){
			loop=i-tim[ans];break;
		}else{
			vis[ans]=true;
			tim[ans]=i;
			ind[i]=ans;
		}
	}
	if(loop==0){
		cout<<a[ans]<<endl;
	}	
	else{
		k-=tim[ans];
		k%=loop;
		cout<<a[ind[k+tim[ans]]]<<endl;
	}
	//cout<<loop<<endl;
	return 0;
}

Measured memory_bytes: 7988
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int inf = 2e17;
const int mod = 1e9 + 7;

signed main() {
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    int left = A - D, right = A + D;
    int ok = D - C + 1, ng = C * 2 - 1;
    int base = D - C;
    for (int i = 1; i < N - 1; i++) {
        left -= D;
        right += D;
        ok += base;
        ng -= base;
    }
    if (left <= B && B <= right) {
        if (ng <= 0) {
            cout << "YES" << endl;
            return 0;
        }
        int ans = (B - left) % (ok + ng);
        cout << (ans < ok ? "YES" : "NO") << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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


vector<int> f(int x){
    vector<int> res;
    for(int i = 1; i * i <= x; i++){
        if (x % i == 0){
            res.push_back(i);
            res.push_back(x/i);
        }
    }
    return res;
}

int main(){
    int n;
    int m;
    cin >> n >> m;
    vector<int> res = f(m);
    int ans = 0;
    rep(i, res.size()){
        if (m / res[i] >= n){
            ans = max(ans, res[i]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n;string a,b;
int main(){
	cin>>n>>a>>b;
	rep(i,n)cout<<a[i]<<b[i];
	re 0;
}


Measured memory_bytes: 256
sa=gets.chomp.split("")
sb=gets.chomp.split("")
sc=gets.chomp.split("")
arr=[sa, sb, sc]
h = {"a"=>0, "b"=>1, "c"=>2}
i = 0
c = ''
while true
  t = arr[i]
  if t.empty?
    puts c.upcase
    exit
  end
  c = t.shift
  i = h[c]
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 1e5+5;
const ll mod =   1e9+7;

int main()
{  fast
int n;cin>>n;
int arr[n+1];int ans=0;
for(int i=1;i<=n;i++){
	cin>>arr[i];
	if(i%2&&arr[i]%2)
	ans++;
}
cout<<ans;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    int n; cin >> n;
    VI a(n);
    int sum = 0;
    FOR(i, 0, n) {
        cin >> a[i];
        sum += a[i];
        a[i] *= n;
    }

    int ans = -1, res = INF;
    FOR(i, 0, n) {
        if (chmin(res, abs(a[i] - sum))) {
            ans = i;
        }
    }
    print(ans);

    return 0;
}

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

using namespace std;

int main()
{
    int n;  cin >> n;
    vector <int> v(n), dp(n, 1e9 + 10);

    for (auto &x : v)
        cin >> x;

    dp[0] = 0;
    for (int i = 0; i < n; i++)
        for (int j : {i + 1, i + 2} )
            if (j < n)
                dp[j] = min(dp[j], dp[i] + abs(v[i] - v[j]));
    cout << dp[n-1] << "\n";
    
}

Measured memory_bytes: 1024
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
N, W = map(int, input().split())
value = []
weight = []
for _ in range(N):
    v, w = map(int, input().split())
    value.append(v)
    weight.append(w)

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

print(dp[N][W])



Measured memory_bytes: 41904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll k;
    string s;
    cin >> s >> k;
    map<string, bool> b;
    vector<string> c;
    rep(i, 0, s.size()){
        rep(j, 0, min(k, (ll)s.size()-i)){
            auto t = s.substr(i,j+1);
            if(!b[t]) c.push_back(t);
            b[t] = true;
        }
    }
    sort(c.begin(), c.end());
    cout << c[k-1] << endl;
    return 0;
}

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

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    int empty = 1;
    int count = 0;
    while (empty < b) {
        empty--;
        empty += a;
        count++;
    }
    cout << count << endl;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution
}


Measured memory_bytes: 256
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Data.List.Split (splitOn)

main :: IO ()
main = do
  n <- getl toInt
  when (n /= 0) $ do
    xs <- rgetl n $ (\[x,y] -> Point x y) . map toDbl . splitOn ","
    print $ solve xs
    main

solve :: [Point] -> Int
solve ps = length ps - length ups - length lps + 2
  where
    sps = sort ps
    ups = hch sps
    lps = (hch . reverse) sps

isConvex :: Point -> Point -> Point -> Bool
isConvex p0 p1 p2 = cross v0 v1 < 0.0
  where
    v0 = toVect p0 p1
    v1 = toVect p0 p2

ch :: [Point] -> [Point]
ch ps
  | length ps < 3 = ps
  | isConvex p0 p1 p2 = ps
  | otherwise = ch (p2:p0:rs)
  where
    (p2:p1:p0:rs) = ps
    
hch :: [Point] -> [Point]
hch ps = foldl f [] ps
  where
    f xs p = ch (p:xs)
    
toInt :: String -> Int
toInt s = read s

toDbl :: String -> Double
toDbl s = read s

getl :: (String -> a) -> IO a
getl f = f <$> getLine

rgetl :: Int -> (String -> a) -> IO [a]
rgetl n f = map f <$> replicateM n getLine

eps :: Double
eps = 1e-9
 
data Point = Point {xop :: Double, yop :: Double} deriving Show
data Vect = Vect {xov :: Double, yov :: Double} deriving Show

cross :: Vect -> Vect -> Double
cross v1 v2 = xov v1 * yov v2 - yov v1 * xov v2
 
toVect :: Point -> Point -> Vect
toVect p1 p2 = Vect (xop p2 - xop p1) (yop p2 - yop p1)

instance Eq Point where
  x == y = abs (xop x - xop y) < eps && abs (xop x - xop y) < eps

instance Ord Point where
  compare x y 
    | abs (xop x - xop y) < eps && abs (yop x - yop y) < eps = EQ
    | xop x < xop y = LT
    | xop x > xop y = GT
    | abs (xop x - xop y) < eps && yop x < yop y = LT
    | abs (xop x - xop y) < eps && yop x > yop y = GT

Measured memory_bytes: 4432
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int H;
    cin >> H;
    vector<long long int> memo(2*10000+1, -1);
    memo[0]=0;
    int N;
    cin >> N;
    for(int n=0; n<N; n++) {
        int A;
        long long int B;
        cin >> A >> B;
        
        for(int h=0; h+A<=2*max(H, A); h++) {
            if(memo[h]==-1) continue;
            if(memo[h+A]==-1) {
                memo[h+A] = memo[h]+B;
            } else {
                memo[h+A] = min(memo[h+A], memo[h]+B);
            }
        }
    }

    long long int ans=1e9;
    for(int h=H; h<2*10000+1; h++) {
        if(memo[h]==-1) continue;
        ans = min(ans, memo[h]);
    }
    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int i, o, t, j, l, s, z;
    cin >> i >> o >> t >> j >> l >> s >> z;
    long long int res = 0;
    if (i % 2 + l % 2 + j % 2 >= 2 && i > 0 && l > 0 && j > 0) {
        i--, l--, j--;
        res += 3;
    }
    res += i / 2 * 2;
    res += j / 2 * 2;
    res += l / 2 * 2;
    res += o;
    cout << res << endl;
}




Measured memory_bytes: 3636
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



int main(){

    int n;
    cin >> n;
    string a,b;
    cin >> a >> b;

    rep(i,0,n){
	cout << a[i] << b[i];
    }
    cout << endl;
    return  0;
}


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

int main(){
  int j,N,M;
  int max1=0,tmp,tmp2;
  cin >> N;
  vector <string> blue(N);
  for (int i=0;i<N;i++){
    cin >> blue.at(i);
  }
  cin >> M;
  vector <string> red(M);
  for (int i=0;i<M;i++){
    cin >> red.at(i);
  }
  sort(blue.begin(),blue.end());
  sort(red.begin(),red.end());
  for(int i=0;i<N;i++){
    tmp=1;
    for(int j=0;j<M;j++){
      if(blue.at(i)==red.at(j))
        tmp--;
    }
    if(i==N-1){
      max1=max(tmp,max1);
      break;
    }
    for(int k=i+1;k<N;k++){
      if(blue.at(i)==blue.at(k)){
        tmp++;
      }
      else{
        i=k-1;
        break;
      }
    }
    max1=max(max1,tmp);
  }
  cout << max1<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	double r;
	double S=0.0,L=0.0,pi=3.14159265359;
	scanf("%lf",&r);
	S=r*r*pi;
	L=2*r*pi;
	printf("%.6lf %.6lf\n",S,L);
	return 0;
}

Measured memory_bytes: 2684
/*--ILRS-- sr4saurabh  */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define popb pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=10000000+6;
#define M_PI           3.14159265358979323846
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   // #ifndef ONLINE_JUDGE
     //  freopen ("INPUT.txt" , "r" , stdin);
       //freopen ("OUTPUT.txt", "w" , stdout);
    //#endif


  ll x;
  cin>>x;
  ll arr1[1001];
  ll arr2[1001];
  arr1[0]=arr2[0]=0;
  for(int i=1;i<=1000;i++)
  {
    arr1[i]=pow(i,5);
    arr2[i]=arr1[i];
  } 

  for(int j=0;j<=1000;j++)
  {
    for(int k=0;k<=1000;k++)
    {

      if(arr1[j]-arr2[k]==x)
      {
        cout<<j<<" "<<k<<endl;
        return 0;
      }
      if(arr1[j]+arr2[k]==x)
      {
        cout<<j<<" -"<<k<<endl;
        return 0;
      }
    }
  }














return 0;
}

Measured memory_bytes: 4036
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		int max=0;
		for(int i=2;i<1001000;i++) {
			boolean flag = true;
			int sqrt = (int)Math.ceil(Math.sqrt(i));
			for(int j=0; j<max && primes[j]<=sqrt;j++){
				if(i%primes[j]==0){
					flag = false;
					break;
				}
			}
			if(flag){
				primes[max++] = i;
			}
		}
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String s;
		while ((s = br.readLine()) != null) {
			int data = Integer.parseInt(s);

			System.out.println(countPrime(data));
		}
	}
	
	private static int countPrime(int n){
		int i=0;
		
		while(primes[i]<=n)i++;
		
		return i;
	}
	
	static int[] primes = new int[80000];
}

Measured memory_bytes: 25576
import java.util.stream.*;
import java.util.*;

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

    public static void main(String[]$) {
        long n = scanner.nextInt(), k = scanner.nextInt();
        System.out.println(k == 0 ? n * n : LongStream.rangeClosed(k + 1, n).map(i -> (i - k) * (n / i) + Math.max(0, (n - n / i * i) - k + 1)).sum());
    }
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
char S[100];
ll i, j, k;

int main(){
    scanf("%s", S);
    if(S[5]=='0'&&S[6]<='4'){
        printf("Heisei");
    }else{
        printf("TBD");
    }

    return 0;
}

Measured memory_bytes: 256
#ifdef debug
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>
//#include "optimization.h"

using namespace std;

#define vec vector
#define ALL(x) (x).begin(), (x).end()

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

const int inf = 1e9;
const ll inf64 = 1e18;

int main() {

#ifdef debug
    freopen("input.txt", "r", stdin);
#endif

    string s;

    cin >> s;

    vec< int > have(26);

    for(char c : s) {
        have[c - 'a'] = 1;
    }

    for(int i = 0;i < 26;i++) {
        if(!have[i]) {
            cout << s << char(i + 'a') << "\n";
            return 0;
        }
    }

    for(int i = (int)s.size() - 1;i >= 0;i--) {
        for(char c = s[i] + 1;c <= 'z';c++) {
            if(!have[c - 'a']) {
                cout << s.substr(0, i) << c << "\n";
                return 0;
            }
        }
        have[s[i] - 'a'] = 0;
    }

    cout << "-1\n";

    return 0;
}



Measured memory_bytes: 256
N, X = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
d = 0
if A[0] > X:
    d = A[0] - X
    ans += d
for i in range(N-1):
    s = A[i]+A[i+1]-d
    if s > X:
        d = s - X
        ans += d
    else:
        d = 0
 
print(ans)

Measured memory_bytes: 14052
#include <stdio.h>

int main (void)
{
	//変数宣言
	int x,y,ans;//入力
	char str[8]; //標準入力読み取り用
	
	//標準入力読み込み
	fgets(str,8,stdin);
	sscanf(str,"%d %d",&x,&y);
	
  	ans = x+y;
	
	//出力
	if(ans >= 10)
	{
		puts("error");
	}else
	{
		printf("%d",ans);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

typedef struct List {
	struct List *next;
	int v;
} list;

int main()
{
	const int sup = 1 << 30, inf = -sup;
	int i, N, K, u, w, l[100001], r[100001];
	list *adj[100001] = {}, e[200001];
	scanf("%d", &N);
	for (i = 0; i < N - 1; i++) {
		scanf("%d %d", &u, &w);
		e[i*2].v = w;
		e[i*2+1].v = u;
		e[i*2].next = adj[u];
		e[i*2+1].next = adj[w];
		adj[u] = &(e[i*2]);
		adj[w] = &(e[i*2+1]);
	}
	scanf("%d", &K);
	for (i = 1; i <= N; i++) {
		l[i] = inf;
		r[i] = sup;
	}
	for (i = 1; i <= K; i++) {
		scanf("%d", &u);
		scanf("%d", &(l[u]));
		r[u] = l[u];
	}
	
	int par[100001] = {}, q[100001], head, tail;
	list *p;
	par[1] = 1;
	q[0] = 1;
	for (head = 0, tail = 1; head < tail; head++) {
		u = q[head];
		for (p = adj[u]; p != NULL; p = p->next) {
			w = p->v;
			if (par[w] == 0) {
				par[w] = u;
				q[tail++] = w;
			}
		}
	}
	for (head--; head > 0; head--) {
		u = q[head];
		if (l[u] == inf) continue;
		if (l[par[u]] == inf) {
			l[par[u]] = l[u] - 1;
			r[par[u]] = r[u] + 1;
		} else if ((l[par[u]] + l[u]) % 2 != 0) {
			l[par[u]] = (l[u] - 1 > l[par[u]])? l[u] - 1: l[par[u]];
			r[par[u]] = (r[u] + 1 < r[par[u]])? r[u] + 1: r[par[u]];
			if (l[par[u]] > r[par[u]]) break;
		} else break;
	}
	if (head > 0) {
		printf("No\n");
		fflush(stdout);
		return 0;
	}
	
	for (head++; head < tail; head++) {
		u = q[head];
		if (l[u] == inf) l[u] = l[par[u]] + 1;
		else if (l[par[u]] + 1 >= l[u] && l[par[u]] + 1 <= r[u]) l[u] = l[par[u]] + 1;
		else l[u] = l[par[u]] - 1;
	}
	printf("Yes\n");
	for (i = 1; i <= N; i++) printf("%d\n", l[i]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 7164
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define se second
#define fi first
#define mk make_pair
using namespace std;
int main(){
  set<int>s;
  int n,x;
  cin>>n>>x;
  int a[n];
  r(i,n)cin>>a[i];
  int p=__gcd(a[0],a[1]);
  for(int i=2;i<n;i++)p=__gcd(p,a[i]);
  sort(a,a+n);
  if(x%p==0&&a[n-1]>=x)cout<<"POSSIBLE"<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 640
def resolve():
    '''
    code here
    '''
    X = int(input())

    max_num = int(2 * (10 ** 9) ** (1/5))

    is_flag = False
    for i in range(-1*max_num, max_num):
        for j in range(-1*max_num, max_num):
            if i ** 5 - j ** 5 == X:
                print(i, j)
                is_flag = True
                break
        
        if is_flag:
            break





if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9444
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n, k;
	cin >> n >> k;
	
	vector<int> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	
	sort(a.begin(), a.end());
	
	ll ans = 0;
	for(int i = 0; i < k; ++i) {
		ans += (ll)a[i];
	}
	
	cout << ans << endl;
	
	return 0;
}


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

#include <bits/stdc++.h>
 
#if DEBUG
    #include "debug.h"
#else
    #define debug(args...)
#endif    

#define int long long

using namespace std;

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


#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int INF = 1e18;
const int mod = 1e9+7;

const int N = 2e5 + 10;
inline int add(int x,int y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline int mul(int x,int y){
  x = (1LL * x * y) % mod;
  return x;
}
clock_t time_p=clock();



int32_t main(){
  fast;

  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  
  string s;
  cin >> s;
  int k;
  cin >> k;
  int n = s.length();
  int ff = 1;
  for(int i = 0; i < n; i++)if(s[i] != s[0])ff = 0;
  if(ff) {
    cout << (k * n)/2 << "\n";
    return 0;
  }
  int cc = 0;
  int ans = 0;
  char prev = '.';
  for(int i = 0; i < n;i++) {
    if(s[i] != prev) {
      ans = ans + cc/2;
      prev = s[i];
      cc = 1;
    }
    else
      cc++;
  }
  // cout << ans << "\n";
  ans = ans * k;
  if(s[n-1]==s[0]) {
    int dd = 0;
    while(s[dd] == s[0] and dd < n)dd++;
    ans = ans - (dd/2) * k;
    ans = ans + (k - 1) * ((cc + dd)/2) + (cc/2) + (dd/2);
  }
  else {
    ans = ans + (cc/2) * k;
  }

  cout << ans;

    
  
  time_p=clock()-time_p;
  cerr<<"\nTime Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
  
  return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        GridDpContest solver = new GridDpContest();
        solver.solve(1, in, out);
        out.close();
    }

    static class GridDpContest {
        int r;
        int c;
        boolean[][] arr;
        int mod = (int) 1e9 + 7;
        int[][] memo;

        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            r = sc.nextInt();
            c = sc.nextInt();
            arr = new boolean[r][c];
            for (int i = 0; i < r; i++) {
                String tmp = sc.next();
                for (int j = 0; j < c; j++)
                    arr[i][j] = tmp.charAt(j) == '.';
            }
            memo = new int[r][c];
            for (int[] x : memo)
                Arrays.fill(x, -1);
            pw.println(dp(0, 0) % mod);
        }

        private int dp(int i, int j) {
            if (i >= r || j >= c || r < 0 || j < 0 || !arr[i][j])
                return 0;
            if (i == r - 1 && j == c - 1)
                return 1;
            if (memo[i][j] != -1)
                return memo[i][j];
            int right = dp(i, j + 1) % mod;
            int down = dp(i + 1, j) % mod;
            return memo[i][j] = (right + down) % mod;
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 32552
use proconio::{input, fastout};
use proconio::marker::Usize1;
use std::collections::HashMap;

#[derive(Debug)]
struct Edge {
    to: usize,
    cost: usize,
}
impl Edge {
    fn new (to: usize, cost: usize) -> Self {
        Self { to, cost }
    }
}

#[fastout]
fn main() {
    input! {
        n: usize,
        abc: [(Usize1, Usize1, usize); n-1],
        q: usize,
        k: Usize1,
        xy: [(Usize1, Usize1); q],
    }

    let mut tree = HashMap::new();

    for (a, b, c) in abc {
        tree.entry(a).or_insert_with(|| vec![]).push(Edge::new(b, c));
        tree.entry(b).or_insert_with(|| vec![]).push(Edge::new(a, c));
    }

    let mut dist = vec![0; n];
    dfs(&tree, &mut dist, k, None, 0);

    for (x, y) in xy {
        let ans = dist[x] + dist[y];

        println!("{}", ans);
    }

}

fn dfs(tree: &HashMap<usize,Vec<Edge>>, dist: &mut Vec<usize>, v: usize, p: Option<usize>, cost: usize) {
    dist[v] = cost;
    if let Some(edges) = tree.get(&v) {
        for edge in edges.iter() {
            if let Some(p) = p {
                if edge.to == p {
                    continue;
                }
            }
            dfs(tree, dist, edge.to, Some(v), cost + edge.cost);
        }
    }
}


Measured memory_bytes: 30640
N = int(input())

flag = False
if N % 4 % 7 == 0 or N % 7 % 4 == 0 or N % 11 == 0:
    flag = True
else:
    value = N // 7

    for l in range(1, value+1):
        if (N - 7 * l) % 4 == 0:
            flag = True
            break

if flag == True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
const ll mod=1000000007;
 
ll power(ll a, ll b) {
	ll r=1;
	for(ll i=0; i<b; i++) {
		r = (r*a)%mod;
	}
	return r;
}
 
int main(){
	ll n, r;
	scanf("%lld", &n);
	r=0;
	r += power(10,n);
	r -= 2*power(9,n);
	r += power(8,n);
	r %= mod;
	r = (r+mod)%mod;
	printf("%lld\n", r);
}

Measured memory_bytes: 3828
#include<stdio.h>
int main(void)
{
	int a,s,d[5],f[5],g,h,z,i,j;
	scanf("%d %d",&a,&s);
	while(a!=0&&s!=0){
		z=0;
		h=0;
		g=10;
		for(i=1;i<=4;i++){
			d[i]=a%g;
			f[i]=s%g;
			a=a/10;
			s=s/10;
		}
		for(i=1;i<=4;i++){
			if(d[i]==f[i]){
					h++;
			}
			for(j=1;j<=4;j++){
				if(i!=j&&d[i]==f[j]){
					z++;
				}
			}
		}
		printf("%d %d\n",h,z);
		scanf("%d %d",&a,&s);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N,K;
ll A[101010];
ll S[101010];
ll T[101010];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N) {
		cin>>A[i];
		S[i+1]=S[i]+A[i];
		T[i+1]=T[i]+max(0LL,A[i]);
	}
	ll ma=S[N];
	for(i=0;i+K<=N;i++) {
		ll left=T[i];
		ll right=T[N]-T[i+K];
		ll mid=max(0LL,S[i+K]-S[i]);
		ma=max(ma,left+right+mid);
	}
	
	
	cout<<ma<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 2560
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	n := readInt()
	k := readInt()
	m := make(map[int]int)
	for i := 0; i < n; i++ {
		a := readInt()
		m[a]++
	}
	b := make([]int, 0, n)
	for _, c := range m {
		b = append(b, c)
	}
	sort.Ints(b)
	var ans int
	for i := 0; i < len(b)-k; i++ {
		ans += b[i]
	}
	println(ans)
}

// -----------------------------------------------------------------------------


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

using namespace std;
#define INF 100001;

int main()
{
    int n;
    cin >> n;
    int h[n];
    for (int i = 0; i < n; ++i)
    {
        cin >> h[i];
    }
    int dp[n] = {};

    for (int i=n-2; i>=0; i--)
    {
        int a = dp[i+1] + abs(h[i] - h[i+1]);
        int b = INF;
        if (i+2<n)
        {
            b = dp[i+2] + abs(h[i] - h[i+2]);
        }

        dp[i] = min(a,b);
    }

    cout << dp[0] <<endl;
}

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

int main()
{
	long long int h, w;
	cin >> h >> w;
	long long int ans = min((w % 3 != 0) * h, (h % 3 != 0) * w);
	if(ans > 0){
		for(auto x = 1; x <= w - 1; ++x){
			long long int a = x * h;
			long long int b = (w - x) * (h / 2);
			long long int c = (w - x) * ((h + 1) / 2);
			ans = min(ans, max({ a, b, c }) - min({ a, b, c }));
		}
		for(auto y = 1; y <= h - 1; ++y){
			long long int a = y * w;
			long long int b = (h - y) * (w / 2);
			long long int c = (h - y) * ((w + 1) / 2);
			ans = min(ans, max({ a, b, c }) - min({ a, b, c }));
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define loop(i,n) for(int i=0;i<(n);i++)
#define cont(i,n) for(int i=1;i<=(n);i++)
#define circ(i,a,b) for(int i=(a);i<=(b);i++)
#define range(i,a,b,c) for(int i=(a);((c)>0?i<=(b):i>=(b));i+=(c))
#define foreach(it,v) for(__typeof((v).begin()) it=(v).begin(),_e_D_=(v).end();it!=_e_D_;it++)
#define y0 y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1 y1II11II11III11I1III11II111IIII1II1I1
#define pub push_back
#define pob pop_back
#define mak make_pair

typedef long long ll;
typedef long double lf;
const int Inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3fll;
/* Source code starts here */

const int jt=1000000007;
int r1,c1,r2,c2;

int ksmii(int a,int b){
	if(!b)return 1;
	int x=ksmii(a,b>>1);
	x=1ll*x*x%jt;
	if(b&1)x=1ll*x*a%jt;
	return x;
}

int C(int a,int b){
	int fz=1,fm=1;
	circ(i,a-b+1,a)fz=1ll*fz*i%jt;
	cont(i,b)fm=1ll*fm*i%jt;
	return 1ll*fz*ksmii(fm,jt-2)%jt;
}

int main(){
	scanf("%d%d%d%d",&r1,&c1,&r2,&c2);
	printf("%d\n",((C(r2+c2+2,r2+1)+C(r1+c1,r1))%jt-(C(r2+c1+1,c1)+C(r1+c2+1,r1))%jt+jt)%jt);
	return 0;
}

Measured memory_bytes: 3812
x,k,d = list(map(int, input().split()))
x = abs(x)
a,b = divmod(x, d)
a = min(a, k)
x -= a * d
#print('a=',a)
#print('x=',x)
#print('ka=',k-a)
x -= d * ((k-a) % 2)
print(abs(x))


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

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll n,b;
    cin >> n;
    
    vector<ll> a(n);
    vector<ll> c(n);
    
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        c[i] = i - a[i];
    }
    
    sort(c.begin(), c.end());
    if(n % 2 == 0) b = (c[n/2-1] + c[n/2]) / 2;
    else b = c[n/2];
    
    ll ans = 0;
    for(ll i = 0 ; i < n ; i++){
        ans += abs(c[i]-b);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3456