akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  bool all_even = true;
  REP(i,0,n) {
    ll a;
    cin >> a;
    if(a % 2) {
      all_even = false;
    }
  }
  cout << (all_even ? "second" : "first") << endl;

  return 0;
}


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

int main(){
    string s,t;
    int count=0;
    cin >> s >> t;
    for(int i=1;i<=3;i++){
        if(s.substr(i-1,1)==t.substr(i-1,1)){

            count++;
        }
    }

    cout << count;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr_inv(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define rep(i,n) repr(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
#define PI 3.1415926535
using namespace std;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
void swap(long long *x, long long *y)
{
	long long temp=*x;
	*x=*y;
	*y=temp;
}
long long GCD(long long m, long long n)
{
	long long temp;

	if(m<n) swap(&m, &n);

	while(n!=0){
		temp=m%n; m=n; n=temp;
	}
	return m;
}
long long LCM(long long a, long long b)
{
	long long gcd=GCD(a, b);

	return (a/gcd)*b;
}
int main(void)
{
	int n;

	long long ans;

	cin>>n;

	vector<long long> t(n);

	rep(i, n) cin>>t[i];

	if(n>=2){
		ans=LCM(t[0], t[1]);

		repr(i, 2, n){
			ans=LCM(ans, t[i]);
		}
		cout<<ans<<endl;
	}else{
		cout<<t[0]<<endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int p,q,H,W;
	while(1){
		scanf ("%d %d",&H,&W);
		if (H == 0 && W == 0) break;
		for (p = 0; p < H; p++){
			for (q = 0; q < W; q++){
				printf ("#");
			}
			printf ("\n");
		}
		printf ("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};
int dyy[]={0,-1,0,1};
int dxx[]={-1,0,1,0};

/*#define int ll*/
signed main(){
    int n;
    cin>>n;
    string s[55];
    int a[55][55];
    memset(a,0,sizeof(a));
    rep(i,0,n){
        cin>>s[i];
        
        rep(j,0,s[i].size()){
            a[i][s[i][j]-'a']++;
        }
    }
    rep(i,0,26){
        int ans=111;
        rep(j,0,n){
            ans=min(ans,a[j][i]);
        }
        if(ans>0){
            rep(h,0,ans){
        cout<<char(i+'a');
            }
        }
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
template<typename T> ll min(ll a, const T&& b) { return a < b ? a : b; }
template<typename T> ll min(const T&& a, ll b) { return a < b ? a : b; }
template<typename T> ll max(ll a, const T&& b) { return a > b ? a : b; }
template<typename T> ll max(const T&& a, ll b) { return a > b ? a : b; }
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n, k; cin >> n >> k;
  cout << n - k + 1 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<iomanip>

using namespace std;

void D() {
	int N;
	cin >> N;
	int K;
	cin >> K;
	vector<int> ps(N);

	for (int i = 0; i < N; i++) {
		cin >> ps[i];
	}

	vector<int> max(N-K +1);

	int subsum = 0;
	for (int i = 0; i < K; i++) {
		subsum += ps[i];
	}
	max[0] = subsum;
	for (int j = 1; j + K < N + 1; j++) {
		int head = ps[j - 1];
		int tail = ps[j + K - 1];
		max[j] = max[j - 1] + tail - head;
		
	}

	auto iter = max_element(max.begin(), max.end());
	size_t index = distance(max.begin(), iter);

	double ans = (K + max[index]);
	ans /= 2;
	cout << ans << endl;
}

void A() {
	string S, T;
	cin >> S >> T;

	int A, B;
	cin >> A >> B;

	string U;
	cin >> U;
	if (U == S) {
		cout << (A - 1) << " " <<  B << endl;
	}
	else {
		cout << A << " " <<  (B - 1) << endl;
	}
}

void B() {
	string S;
	cin >> S;
	string X;
	for (int i = 0; i < S.length(); i++) {
		X += "x";
	}

	cout << X << endl;
}

void E() {
	int N, K;
	cin >> N >> K;
	vector<vector<int>> lists(3, vector<int>(100));
	lists[0][0] = 1;
	lists[1][0] = 0;
	lists[2][0] = 0;

	int D = log10(N) + 1;
	for (int i = 1; i < D; i++) {
		lists[0][i] = 9 + lists[0][i - 1];
		lists[1][i] = 9 * lists[0][i - 1];
		lists[2][i] = 9 * lists[1][i - 1];
	}
	int ans = 0;
	for (int j = D - 1; j >= 0; j--) {
	}
}
int main() {
	B();
}

Measured memory_bytes: 256
#include<iostream>

int main(){
  std::string str;
  getline(std::cin, str);

  for(int i = 0; i < str.size(); i++){
    if('a' <= str[i] && str[i] <= 'z'){
      str[i] = toupper(str[i]);
    }else if('A' <= str[i] && str[i] <= 'Z'){
      str[i] = tolower(str[i]);
    }
  }
  std::cout << str << std::endl;
  
  return 0;
}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(),(x).end()
template <typename T>
std::ostream& operator<<(std::ostream&s,const vector<T>&xs){
    s<<'[';for(size_t i=0;i<xs.size();++i){if(i)s<<' ';s<<xs[i];}return s<<']';
}

vll permmult(const vll& P, const vll& Q){
    ll n=P.size();
    vll PQ(n);
    for(ll i=0;i<n;++i)PQ[i]=Q[P[i]];
    return PQ;
}

vll permpow(vll P, ll k){
    ll n=P.size();
    vll result(n);
    iota(all(result),0);
    for(;k;k/=2){
        if(k%2)result=permmult(result,P);
        P=permmult(P,P);
    }
    return result;
}

vll permpow2(const vll& P, ll k) {
    ll n=P.size();
    vll Q(n);
    vll done(n);
    vll cycle;
    for(ll i=0;i<n;++i)if(!done[i]){
        done[i]=true;
        cycle.clear();
        cycle.push_back(i);
        for(ll j=P[i];j!=i;j=P[j]){
            cycle.push_back(j);
            done[j]=true;
        }
        ll m=cycle.size();
        for(ll j=0;j<m;++j)Q[P[cycle[j]]] = cycle[(j+k+1)%m];
    }
    return Q;
}

vll perminv(const vll& P) {
    ll n=P.size();
    vll Q(n);
    for(ll i=0;i<n;++i)Q[P[i]]=i;
    return Q;
}

int main() {
    ios::sync_with_stdio(false);

    if (0) {
        //vll perm{0,1, 3,2,  5,6,4,  10,7,8,9};
        vll perm{4,1,2,0,3};
        for(ll i=1;i<10;++i){
            cout<<"i="<<i<<", "<<permpow(perm,i)<<" "<<permpow2(perm,i)<<'\n';
        }
        return 0;
    }

    ll N;cin>>N;
    vll xs(N);for(ll&x:xs)cin>>x;
    ll M,K;cin>>M>>K;
    vll P(N-1);iota(all(P),0);
    for(int i=0,a;i<M&&cin>>a;++i)swap(P[a-2],P[a-1]);
    //P=permpow2(P,K);
    P=permpow(P,K);
    //P=perminv(P);
    vll ds(N-1);
    for(ll i=1;i<N;++i)ds[i-1]=xs[i]-xs[i-1];
    cout<<xs[0]<<".0\n";
    for(ll x=xs[0],i=0;i+1<N;++i){
        x+=ds[P[i]];
        cout<<x<<".0\n";
    }
}


Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[]) {
	int count,mymin,mymax,temp;
	mymin = 1000;
	mymax = 0;
	std::cin >> count;
	for (size_t i = 0; i < count; i++) {
		std::cin >> temp;
		mymin = min(mymin,temp);
		mymax = max(mymax,temp);
	}
	std::cout << mymax-mymin << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 300
#define M 7
ll c[N+1], b[N+1], d[N+1];
int p[M] = {2, 3, 5, 7, 11, 13, 17};
int pr[N];
bool isPrime(int x){
	if(pr[x]==1) return true;
	if(pr[x]==-1) return false;
	pr[x] = -1;
	if(x<2) return false;
	for(int i = 2; i*i<=x; i++) if(x%i==0) return false;
	pr[x] = 1;
	return true;
}
int dfs(int ix){
	if(ix<7){
		int res = dfs(ix+1);
		int x = p[ix];
		while(x<=N){
			b[x] = 1;
			res = max(res, dfs(ix+1));
			x *= p[ix];
		}
		x = p[ix];
		while(x<=N){
			b[x] = 0;
			x *= p[ix];
		}
		return res;
	}
	memcpy(d, b, sizeof(b));
	for(int i = 2; i <= N; i++){
		if(!d[i]) continue;
		for(int j = i+1; j <= N/i; j++){
			if(!d[j]) continue;
			if(__gcd(i, j)==1) d[i*j] = 1;
		}
	}
	int res = 0;
	rep(i, N) res += c[i+1]*d[i+1];
	/*if(d[16]==1&&d[7]==1&&d[25]==1&&d[32]==0&&d[49]==0&&d[125]==0&&d[9]==0){
		cerr<<"RES: "<<res<<endl;
		rep(i, N) if(b[i+1]) cerr<<i+1<<" "; cerr<<endl;
		rep(i, N) if(d[i+1]) cerr<<i+1<<" "; cerr<<endl;
		//rep(i, N) cerr<<b[i+1]<<" "; cerr<<endl;
		//rep(i, N) cerr<<d[i+1]<<" "; cerr<<endl;
	}*/
	for(int i = p[M-1]+2; i <= N; i++){
		if(isPrime(i)){
			int s = 0;
			for(int j = 1; i*j <= N; j++){
				s += c[i*j]*d[j];
			}
			if(s>0) res += s;
		}
	}

	return res;
}
int main(){
	int n;
	cin>>n;
	rep(i, n){
		int a, x;
		cin>>a>>x;
		c[a] = x;
	}
	b[1] = 1;
	cout<<dfs(0)<<endl;
	return 0;
}

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

int main(){
  int height;
  int width;
  while(true){
    cin >> height >> width;
    if(height == 0 && width == 0)
      break;
    for (int i = 0; i < height; i++){
      for (int j = 0; j < width; j++){
        cout << "#";
      }
      cout << "\n";
    }
    cout << "\n";
  }
  return 0;
}




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

template <typename T>
class LazySegmentTree {
	const int n;
	const T id;
	vector<T> data, data2;
	int size(int n) {
		int res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	T sub(int l, int r, int node, int lb, int ub) {
		if (ub <= l || r <= lb) return id;
		if (l <= lb && ub <= r) {
			return data[node] + data2[node] * (ub - lb);
		}
		return data2[node] * (min(r, ub) - max(l, lb))
			+ sub(l, r, node * 2, lb, (lb + ub) / 2)
			+ sub(l, r, node * 2 + 1, (lb + ub) / 2, ub);
	}
	void suc(int l, int r, int node, int lb, int ub, T val) {
		if (ub <= l || r <= lb) return;
		if (l <= lb && ub <= r) {
			data2[node] += val;
			return;
		}
		data[node] += val * (min(r, ub) - max(l, lb));
		suc(l, r, node * 2, lb, (lb + ub) / 2, val);
		suc(l, r, node * 2 + 1, (lb + ub) / 2, ub, val);
	}
public:
	LazySegmentTree(int n_) :
		n(size(n_)), id(0), data(n * 2, id), data2(n * 2, id) {}
	void add(int l, int r, T val) {
		suc(l, r + 1, 1, 0, n, val);
	}
	T getSum(int l, int r) {
		return sub(l, r + 1, 1, 0, n);
	}
};

int main()
{
	cin.sync_with_stdio(false);
	int n, q;
	cin >> n >> q;
	LazySegmentTree<ll> lst(n);
	for (int i = 0, type, s, t, x; i < q; i++) {
		cin >> type >> s >> t; s--; t--;
		if (type) {
			printf("%lld\n", lst.getSum(s, t));
		}
		else {
			cin >> x;
			lst.add(s, t, x);
		}
	}
	return 0;
}

Measured memory_bytes: 7060
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define mp            make_pair
#define PI            3.14159265
#define M             1000000007
#define MM            998244353
#define fr            first
#define sc            second
#define all(v)        (v).begin(),(v).end()
#define rall(v)       (v).rbegin(),v.rend()
#define vc            vector
#define vi            vector<int>
#define pii           pair<int,int>
#define psi           pair<string,int>
#define pis           pair<int,string>
#define mii           map<int,int>
#define msi           map<string,int>

int solve(){
    int n; cin>>n;
    int m=n/100,y=n%100;
    if(m<=12&&y<=12&&m>=1&&y>=1) cout<<"AMBIGUOUS";
    else if(m<=12&&(y>12||y==0)&&m>=1) cout<<"MMYY";
    else if((m>12||m==0)&&y<=12&&y>=1) cout<<"YYMM";
    else cout<<"NA";
}

signed main() {
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	long[] Ai = new long[N+1];
    	for (int i = 0; i < Ai.length; i++) {
    		Ai[i] = sc.nextLong();
    	}
    	long tmp = 0L;
    	long hunt = 0L;
    	for (int i = 0; i < N; i++) {
    		long B = sc.nextLong();
    		long Btmp = B + tmp;
    		if (Ai[i] <= B + tmp) {
    			if (Ai[i] <= tmp) {
    				tmp = B;
    			} else {
    				tmp = Btmp - Ai[i];
    			}
    			hunt += Ai[i];
    		} else {
    			tmp = 0L;
    			hunt += Btmp;
    		}
    	}
    	if (Ai[N] <= tmp) {
    		hunt += Ai[N];
    	} else {
    		hunt += tmp;
    	}
    	System.out.println(hunt);
    }
}

Measured memory_bytes: 80960
#include<stdio.h>

int main(void){
    int n[6];
    for(int i=0;i<6;i++){
        scanf("%d",&n[i]);
    }
    //for(int i=0;i<4;i++){
        if(n[4]-n[0]>n[5]){
            printf(":(");
            return 0;
        }
    //}
    printf("Yay!");
    return 0;
}

Measured memory_bytes: 128
from collections import defaultdict
from itertools import accumulate

n, v = map(int, input().split())
programs = defaultdict(list)
for _ in range(n):
    s, t, c = map(int, input().split())
    programs[c].append((s, t))

imos = [0] * (10 ** 5 + 2)
for c, p in programs.items():
    p.sort()
    ps, pt = p[0]
    for s, t in p[1:]:
        if pt == s:
            pt = t
        else:
            imos[ps - 1] += 1
            imos[pt] -= 1
            ps, pt = s, t
    imos[ps - 1] += 1
    imos[pt] -= 1

print(max(accumulate(imos)))


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001;

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

int H,W,N;
char fld[55][55];

int D[50][50][50][50];

void bfs(int sy,int sx){
    fill_n(*D[sy][sx],2500,INF);
    D[sy][sx][sy][sx]=0;
    queue<pint>que;
    que.push(pint(sy,sx));
    while(que.size()){
        int y,x;
        tie(y,x)=que.front();
        que.pop();
        rep(i,4){
            int ny=y+dy[i],nx=x+dx[i];
            if(ny<0||ny>=H||nx<0||nx>=W||fld[ny][nx]=='#'||D[sy][sx][ny][nx]!=INF)continue;
            D[sy][sx][ny][nx]=D[sy][sx][y][x]+1;
            que.push(pint(ny,nx));
        }
    }
}

int r[50][50],n[50][50],f[50][50];

vint ev[50][50];

int dp[1111][2];

int calc(vint vec,int r,int n,int f){
    fill_n(*dp,1111*2,INF);
    dp[0][0]=0;
    rep(i,vec.size()){
        int t=min(dp[i][0]+n,dp[i][1]+vec[i]*r);
        dp[i+1][0]=t+f;
        dp[i+1][1]=t-r*vec[i];
    }
    return dp[vec.size()][0];
}

signed main(){
    cin>>H>>W>>N;
    rep(i,H)cin>>fld[i];
    rep(i,H)rep(j,W)if(fld[i][j]=='.')bfs(i,j);


    rep(i,H)rep(j,W)cin>>r[i][j];
    rep(i,H)rep(j,W)cin>>n[i][j];
    rep(i,H)rep(j,W)cin>>f[i][j];

    int y,x;cin>>y>>x;
    ev[y][x].pb(0);
    int t=0;
    rep(i,N-1){
        int yy,xx;
        cin>>yy>>xx;
        while(y!=yy||x!=xx){
            int d=-1;
            rep(i,4){
                int ny=y+dy[i],nx=x+dx[i];
                if(ny<0||ny>=H||nx<0||nx>=W||fld[ny][nx]=='#')continue;
                if(D[y][x][yy][xx]==D[ny][nx][yy][xx]+1)d=i;
            }

            y+=dy[d];x+=dx[d];t++;
            ev[y][x].pb(t);
        }
    }

    int ans=0;
    rep(i,H)rep(j,W)ans+=calc(ev[i][j],r[i][j],n[i][j],f[i][j]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 38356
import itertools
n,x = map(int,input().split())
L = [int(i) for i in input().split()]
cnt = 0
tmp = [0]
Sum = list(itertools.accumulate(L))
Sum = tmp + Sum

for i in range(len(Sum)):
    if Sum[i] > x:
        break
    else:
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int bo[1001];
int main()
{
	int a;
    scanf("%d9",&a);
    bo[1]=1;
    for(int i=2;i<=a;i++){
		for(int j=(i*i);j<=a;j=i*j){
			bo[j]=1;
		}
	}
	for(int i=a;i>=1;i--)
		if(bo[i]) { printf("%d",i); break;}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int r, D, x0;
  cin >> r >> D >> x0;
  for(int i=0;i<10;i++) {
    x0 = r*x0-D;
    cout << x0 << " ";
  }
  cout << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n,m;
vector<int>G[100];
int D[100][100];
main()
{
	while(cin>>n>>m,n)
	{
		for(int i=0;i<n;i++)G[i].clear();
		for(int i=0;i<n;i++)for(int j=0;j<n;j++)if(i!=j)D[i][j]=1e9;
		for(int i=0;i<m;i++)
		{
			int a,b,c;cin>>a>>b>>c;a--,b--;
			G[a].push_back(b);
			G[b].push_back(a);
			D[a][b]=D[b][a]=c;
		}
		for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++)
			D[i][j]=min(D[i][j],D[i][k]+D[k][j]);
		int ans=D[0][n-1];
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<G[i].size();j++)
			{
				for(int k=0;k<G[i].size();k++)
				{
					if(j==k)continue;
					ans=min(ans,D[0][G[i][j]]+D[G[i][k]][n-1]);
				}
			}
		}
		cout<<ans<<endl;
	}
}



Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans


void solve() {
}

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

    string S;
    cin >> S;
    int ans = 0, cnt = 0;
    for (auto& c : S) {
        if (c == 'R')
            cnt++;
        else
            cnt = 0;
        chmax(ans, cnt);
    }
    cout << ans << endl;

    solve();
    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int a,b;
  
  cin >> a >> b;
  
  if (a+b==15) cout << '+' << endl;
  else if (a*b==15) cout << '*' << endl;
  else cout << 'x' << endl;
  
  return 0;
}

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

using namespace std;

void scan(u_int64_t b, u_int64_t &ans){
    u_int64_t bit;

    bit = 1;
    ans = 0;
    for(int i = 0;i < 64;i++){
        if(i == 0){
            if(b != 0){
                if((b-1)/2%2 == 0){
                    ans = ans | bit;
                }
            }
        }
        else if(b/bit%2 == 1 && b%2 == 0){
            ans = ans | bit;
        }

        bit = bit << 1;
    }

    return;
}

int main(void){
    u_int64_t a, b;
    cin >> a >> b;

    u_int64_t ans_b, ans_a;

    scan(b, ans_b);
    scan(a-1, ans_a);

    cout << (ans_b ^ ans_a) << endl;

    return 0;
}

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

namespace std
{
    class Program
    {
        static void Main(string[] args)
        {
            
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = int.Parse(input[2]);

            if ((a == b) && (b == c) && (a == c))
            {
                Console.WriteLine("1");
            }
            else if ((a != b) && (b != c) && (a != c))
            {
                Console.WriteLine("3");
            }
            else
            {
                Console.WriteLine("2");
            }
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
using namespace std;
const int N = 100;
const int INF = 1001001000;
int main(){
    int n;
    int x[N];
    
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }
    
    int min = INF;
    for(int i = 1; i <= 100; i++){
        int sum = 0;
        for(int j = 0; j < n; j++){
            sum += (x[j] - i)*(x[j] - i);
        }
        if(sum < min) min = sum;
    }
    
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
import random
d=int(input())
c=list(map(int,input().split()))
num=[0]*26
ans=[]
numans=0
s=[]
for i in range(1,d+1):
    num1=1
    num2=-(10**100)
    num3=[0]*26
    for j in range(26):
        num3[j]=-1*((i-num[j])*c[j])
    s.append(list(map(int,input().split())))
    for j in range(26):
        num5=s[i-1][j]-num3[j]
        if num5>num2:
            num1=j+1
            num2=num5
    ans.append(num1)
    numans+=num2+s[i-1][num1-1]
    num[num1-1]=i
def sco(n1,n2,n3):
    n0=0
    n01=[0]*26
    old=ans[n1]
    ans[n1]=n2
    for k in range(n3):
        n0+=s[k][ans[k]-1]
        n01[ans[k]-1]=k+1
        for l in range(26):
            n0-=(k+1-n01[l])*c[l]
    return n0
for i in range(1540):
    num6=random.randint(1,26)
    num7=random.randint(1,365)
    num100=sco(num7-1,num6,d)
    if num100>numans:
        ans[num7-1]=num6
for i in range(d):
    print(ans[i])


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

#define endl "\n"
#define si(a) scanf("%d ",&a);
#define si2(a,b) scanf("%d %d ",&a,&b);
#define si3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sll(a) scanf("%lld ",&a);
#define sll2(a,b) scanf("%lld%lld",&a,&b)
#define sll3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define sf(a) scanf("%f ",&a);
#define sd(a) scanf("%lf ",&a);
#define sc(a) scanf("%c ",&a);
#define ss(a) scanf("%s ",a);
#define sf2(a,b) scanf("%f %f ",&a,&b);
#define sd2(a,b) scanf("%lf %lf ",&a,&b);
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<n;i++)
#define forq(i,q,n) for(int i=q;i<n;i++)
#define form(i,n) for(int i=n;i>=0;i--)
#define forp(i,q,n) for(int i=q;i>=n;i--)
#define fi first
#define se second
#define INF 1000000010
#define MOD 1000000007
#define MAXN
#define LL long long int


using namespace std;

string a, b, c;

void init(){
	cin >> a >> b >> c;
	if(a[a.size() - 1] == b[0] and b[b.size() - 1] == c[0])
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}
}

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

Measured memory_bytes: 256
def gcd(a,b):
  while b:a,b=b,a%b
  return a
n,x=map(int,input().split())
a=[abs(i-x)for i in list(map(int,input().split()))]
x=a[0]
for i in a[1:]:x=gcd(x,i)
print(x)

Measured memory_bytes: 14252
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        int[] nmr = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int n = nmr[0];
        int m = nmr[1];
        int r = nmr[2];
        int[][] map = Enumerable.Repeat(0, n).Select(_ => Enumerable.Repeat(int.MaxValue / 2, n).ToArray()).ToArray();
        int[] rs = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();
        for (int i = 0; i < m; i++)
        {
            int[] abc = Console.ReadLine().Split().Select(int.Parse).ToArray();
            map[abc[0] - 1][abc[1] - 1] = abc[2];
            map[abc[1] - 1][abc[0] - 1] = abc[2];
        }
        bool flag = true;
        while (flag)
        {
            flag = false;
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    for (int k = 0; k < n; k++)
                    {
                        if (map[i][j] > map[i][k] + map[k][j])
                        {
                            map[i][j] = map[i][k] + map[k][j];
                            flag = true;
                        }
                    }
                }
            }
        }

        long min = long.MaxValue;
        do
        {
            long res = 0;
            for (int i = 1; i < rs.Length; i++)
            {
                res += map[rs[i] - 1][rs[i - 1] - 1];
            }
            min = Min(min, res);
        } while (NextPermutation(rs));
        Console.WriteLine(min);
    }
    private static bool NextPermutation(int[] numList)
    {
        var largestIndex = -1;
        for (var i = numList.Length - 2; i >= 0; i--)
        {
            if (numList[i] < numList[i + 1])
            {
                largestIndex = i;
                break;
            }
        }

        if (largestIndex < 0) return false;

        var largestIndex2 = -1;
        for (var i = numList.Length - 1; i >= 0; i--)
        {
            if (numList[largestIndex] < numList[i])
            {
                largestIndex2 = i;
                break;
            }
        }

        var tmp = numList[largestIndex];
        numList[largestIndex] = numList[largestIndex2];
        numList[largestIndex2] = tmp;

        for (int i = largestIndex + 1, j = numList.Length - 1; i < j; i++, j--)
        {
            tmp = numList[i];
            numList[i] = numList[j];
            numList[j] = tmp;
        }

        return true;
    }
}


Measured memory_bytes: 13644
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

// BEGIN NO SAD
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// END NO SAD

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

void solve() {
  int n;
  cin >> n;
  cout << fixed << setprecision(12) << ((n+1)/2) / (double)n << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

uint64_t dp[100'000][13];
const uint64_t R = 1'000'000'007L;

int main()
{
    string s;
    cin >> s;

    for (int i = 0; i < s.size(); i++)
    {
        for (int j = 0; j < 13; j++)
        {
            dp[i][j] = 0;
        }
        for (int j = 0; j < 13; j++)
        {
            if (i == 0)
            {
                if (s[i] == '?')
                {
                    dp[i][j] = j < 10 ? 1 : 0;
                }
                else
                {
                    int k = s[i] - '0';
                    dp[i][j] = j == k ? 1 : 0;
                }
                continue;
            }
            if (s[i] == '?')
            {
                for (int k = 0; k < 10; k++)
                {
                    dp[i][(j * 10 + k) % 13] += dp[i - 1][j];
                    dp[i][(j * 10 + k) % 13] %= R;
                }
            }
            else
            {
                int k = s[i] - '0';
                dp[i][(j * 10 + k) % 13] = dp[i - 1][j];
            }
        }
    }

    cout << dp[s.size() - 1][5] << endl;
    return 0;
}

Measured memory_bytes: 10752
s=input()
a=97
if s=="zyxwvutsrqponmlkjihgfedcba":
    print("-1")
elif len(s)!=26:
    for i in range(26):
        if chr(a+i) not in s:
            print(s+chr(a+i))
            exit()
else:
    for i in range(26):
        for j in range(i+1):
            if s[-(i+1)]<s[-(j+1)]:
                print(s[:-(i+1)]+s[-(j+1)])
                exit()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    if(n % k == 0) cout << 0 << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 256
N, L = map(int, input().split())
Apples = [L + i - 1 for i in range(1, N + 1)]

ALL_TASTE = sum(Apples)
min_diff = float('inf')
ans = 0
for apple in Apples:
    taste = ALL_TASTE - apple
    if min_diff > abs(ALL_TASTE - taste):
        min_diff = abs(ALL_TASTE - taste)
        ans = taste

print(ans)


Measured memory_bytes: 3060
import math
def main():
    i = int(input())
    j = list(map(int, input().split()))
    res = 1

    if 0 in j:
        print(0)
        return

    for jj in j:
        res *= jj
        if math.pow(10, 18) < res:
            print(-1)
            return

    print(res)


if __name__ == "__main__":
    main()

Measured memory_bytes: 22660
k, a, b = map(int, input().split())
biscuit = 1
tmp = 1

if b <= a or k < a or (b - a) / 2 < 1:
    print(k + 1)
    exit()
else:
    biscuit += (a - 1)
    k -= (a - 1)

print((b - a) * (k // 2) + biscuit + (k%2==1 &1))


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  vector<int> dp(2);
  dp[1] = 1;
  for (char c : s) {
    vector<int> ndp(2);
    ndp[0] = min(dp[0] + (c - '0'), dp[1] + 10 - (c - '0'));
    if (c < '9') {
      ndp[1] = min(dp[0] + (c - '0') + 1, dp[1] + 10 - (c - '0') - 1);
    } else {
      ndp[1] = dp[1];
    }
    swap(dp, ndp);
  }
  cout << dp[0] << '\n';
}


Measured memory_bytes: 1948
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;
typedef vector<vector<ll>> matrix;

vector<int> edges[1000005];
int deg[1000005];
ll val[1000005];
ll ret[1000005];
bool done[1000005];

void solve() {
  int n;
  cin >> n;
  for(int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    edges[a].push_back(b);
    edges[b].push_back(a);
    deg[a]++;
    deg[b]++;
  }
  for(int i = 0; i < n; i++) cin >> val[i];
  sort(val, val+n);
  queue<int> q;
  for(int i = 0; i < n; i++) {
    if(deg[i] == 1) {
      q.push(i);
    }
  }
  int idx = 0;
  while(!q.empty()) {
    int curr = q.front();
    q.pop();
    done[curr] = true;
    ret[curr] = val[idx++];
    for(int out: edges[curr]) {
      if(!done[out]) {
        if(--deg[out] == 1) {
          q.push(out);
        }
      }
    }
  }
  assert(idx == n);
  ll ans = 0;
  for(int i = 0; i < n; i++) {
    for(int out: edges[i]) {
      if(out > i) {
        ans += min(ret[i], ret[out]);
      }
    }
  }
  cout << ans << "\n";
  for(int i = 0; i < n; i++) {
    cout << ret[i];
    if(i == n-1) cout << "\n";
    else cout << " ";
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
  solve();
}


Measured memory_bytes: 28416
import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int Q = scan.nextInt();
		int a, b, p, x;

		HashMap<Integer, Set<Integer>> map = new HashMap<>();
		for (int i = 0; i < N - 1; i++) {
			a = scan.nextInt();
			b = scan.nextInt();
			if (!map.containsKey(a)) {
				Set set = new HashSet<>();
				map.put(a, set);
			}
			map.get(a).add(b);

			if (!map.containsKey(b)) {
				Set set = new HashSet<>();
				map.put(b, set);
			}
			map.get(b).add(a);
		}
		int[] score = new int[N];
		for (int i = 0; i < Q; i++) {
			p = scan.nextInt();
			x = scan.nextInt();
			score[p - 1] += x;
		}

		ArrayDeque<Integer> que = new ArrayDeque();
		que.offer(1);
		boolean[] visited = new boolean[N];

		while (!que.isEmpty()) {
			int tgt = que.poll();
			Set<Integer> tgtSet = map.get(tgt);
			visited[tgt - 1] = true;
			for (Integer next : tgtSet) {
				if (!visited[next - 1]) {
					score[next - 1] += score[tgt - 1];
					que.offer(next);
				}
			}
		}

		// 結果の出力
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < N; i++) {
			sb.append(score[i]).append(" ");
		}
		System.out.println(sb);
	}
}

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

    //long long
    using ll = long long;

    // pair<int, int>
    using PII = pair<int, int>;

    //最大値、mod
    const int MOD = 1000000007;
    const int INF = 1000000000;
    const long long LINF = 1e18;

    //出力系
    #define print(x) cout << x << endl
    #define prints(x) cout << fixed << setprecision(10) << x << endl
    #define printc(x) cout << setw(2) << setfill('0') << x << endl;
    #define yes cout << "Yes" << endl
    #define YES cout << "YES" << endl
    #define no cout << "No" << endl
    #define NO cout << "NO" << endl
    
    // begin() end()
    #define all(x) (x).begin(),(x).end()

    //for
    #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

    //最大公約数 
    unsigned gcd(unsigned a, unsigned b) {
      if(a < b) return gcd(b, a);
      unsigned r;
      while ((r=a%b)) {
        a = b;
        b = r;
      }
      return b;
    }

    // 最小公倍数
    unsigned lcm(unsigned a, unsigned b){
        return a / gcd(a, b) * b; 
    }

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

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









int main(){
  ll N, A, B;
  cin >> N >> A >> B;
  ll ans = (N /(A + B)) * A + min(N % (A + B) , A);
  print(ans);
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] V = new int[N], C = new int[N];
        int max = 0;

        for (int i = 0; i < N; i ++) {
            V[i] = scanner.nextInt();
        }

        for (int i = 0; i < N; i ++) {
            C[i] = scanner.nextInt();
        }

        for (int i = 0; i < N; i ++) {
            if (V[i] - C[i] > 0) max += V[i] - C[i];
        }

        System.out.println(max);

    }
}


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

int main() {
  int n,k,sum = 0;
  int ans = 0; cin >> n >> k;
  string s; cin >> s;
  vector<int> a;
  int count = 1;
  if(s[0] == '0') a.push_back(0);
  for(int i=0;i<n-1;i++){
    if(s[i] == s[i+1]) count++;
    else {
      a.push_back(count);
      count = 1;
    }
  }
  a.push_back(count);
  if(s[n-1] == '0') a.push_back(0);
  if(a.size() == 1) {
    cout << a[0] << endl;
    return 0;
  }
  if(k*2+1 >= a.size()) {
    cout << n << endl;
    return 0;
  }
  for(int i=0;i<k*2+1;i++) sum += a[i];
  ans = sum;
  int l = 0; int r = 2*k+1;
  for(int i=0;i<(a.size()-k*2-1)/2;i++) {
    sum -= a[l]; l++;
    sum -= a[l]; l++;
    sum += a[r]; r++;
    sum += a[r]; r++;
    ans = max(sum,ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1020
'use strict';
(function(stdin) {
	var line  = stdin.toString();
	var result = (function(data) {
		return data
			.map(function(v) {
				return createTable(v[0],v[1]);
			}).join('\n');

		function createTable(rownum,colnum) {
			var table = [];
			var pattern_table = [];
			pattern_table[0] = ['#','.'];
			pattern_table[1] = ['.','#'];
			for (var row = 0; row < rownum; row++) {
						 table.push(
						 	createLine(colnum,pattern_table[row & 1]));
			}
			table.push('');
			return table.join('\n');
		}

		function createLine(colnum,pattern) {
			var line = '';
			for (var col = 0; col < colnum; col++) {
				line += pattern[col & 1];
			}
			return line;
		}

	}(
		line.split('\n0 0')[0]
		.split('\n')
		.map(function(v) {return v.split(' ').map(Number);})
	));
	console.log(result);

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 10728
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#define INF (INT_MAX / 2)
#define MAX_N 300000
using namespace std;

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

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

  int count[MAX_N + 1];
  fill(count, count + (MAX_N + 1), 0);
  for(int i = 0; i < n; i++){
    ++count[a[i]];
  }
  set< int > s;
  int m = 0;
  for(int i = 0; i <= MAX_N; i++){
    if(count[i] > 0){
      ++m;
      s.insert(i);
    }
  }
  if(m <= k){
    cout << 0 << endl;
    return 0;
  }

  int ss = (int)s.size();
  long long b[ss];
  int l = 0;
  for(auto itr = s.begin(); itr != s.end(); itr++){
    b[l++] = count[*itr];
  }
  sort(b, b + ss);
  long long sum = 0;
  for(int i = 0; i < m - k; i++){
    sum += b[i];
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 13184
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    int n;
    cin >> n;
    vector<int>pn(n);
    for(int i = 0; i < n; i++){
        cin >> pn.at(i);
    }
    int cnt = 0;
    for(int i = 1; i < n - 1; i++){
        if((pn.at(i) - pn.at(i - 1)) * (pn.at(i) - pn.at(i + 1)) < 0){
            cnt++;
        }
    }
    cout << cnt << endl;
    solve();
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#define rep(i, j, n) for (int i = (j); i < (n); ++i)
#define rrep(i, j, n) for (int i = (n)-1; i >= (j); --i)
using namespace std;
using ll = long long;
constexpr int INF = 1 << 30;

int main()
{
  ll n;
  cin >> n;
  vector<ll> a(n);

  ll s = 0;
  rep(i, 0, n)
  {
    cin >> a[i];
    s += a[i];
  }

  if (s % (n * (n + 1) / 2))
  {
    cout << "NO" << endl;
    return 0;
  }
  ll op_cnt = s / (n * (n + 1) / 2);

  bool ok = true;
  ll cnt = 0;
  rep(i, 0, n)
  {
    ll d = a[(i + 1) % n] - a[i];
    // d == x - (op_cnt - x) * (n - 1)
    // d == x + x * (n - 1) - op_cnt * (n - 1)
    // (d + op_cnt * (n - 1)) / n == x
    ll e = d + op_cnt * (n - 1);
    if (e % n == 0 && 0 <= e / n && e / n <= op_cnt)
      cnt += op_cnt - e / n;
    else
      ok = false;
  }
  ok &= cnt == op_cnt;

  cout << (ok ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N,M;
	cin >> N >> M;
	vector<ll> p[N],ch_num(N,0),path(N,0); 
	FOR(i,0,M){
		ll x,y;
		cin >> x >> y;
		x--;y--;
		p[x].push_back(y);
		ch_num[y]++;
	}
	queue<ll> Q;
	FOR(i,0,N){
		if(ch_num[i]==0){
			Q.push(i);
		}
	}
	while(not Q.empty()){
		ll nowv = Q.front();
		Q.pop();
		for(auto x:p[nowv]){
			path[x] = max(path[x],path[nowv]+1);
			ch_num[x]--;
			if(ch_num[x]==0){
				Q.push(x);
			}
		}
	}
	ll ans = 0;
	FOR(i,0,N)ans = max(ans,path[i]);
	cout << ans << endl;
}

Measured memory_bytes: 7296
A=[]
for i in range(3):
    A.append(list(map(int,input().split())))

N=int(input())
b=[0 for i in range(N)]
for i in range(N):
    b[i]=int(input())


for i in range(3):
    if(A[i][0] in b and A[i][1] in b and A[i][2] in b):
        print('Yes')
        exit()
    if(A[0][i] in b and A[1][i] in b and A[2][i] in b):
        print('Yes')
        exit()
if(A[0][0] in b and A[1][1] in b and A[2][2] in b):
    print('Yes')
    exit()
if(A[0][2] in b and A[1][1] in b and A[2][0] in b):
    print('Yes')
    exit()

print('No')


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

int main() {
    string s; cin >> s;
    string res = "";
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'B') {
            res = res.substr(0, res.length() - 1);
        } else {
            res += s[i];
        }
    }
    cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    long long a, b, c;
    cin >> a >> b >> c;
    if(a % 2 == 1 && b % 2 == 1 && c % 2 == 1){
        cout << min(a * b, min(a * c, b * c)) << endl;
    }
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
import math 
a = [int(input())for i in range(5)]
rest = []
t = 0
for i in a:
  if i%10 == 0 :
    t+=i
  else:
    rest.append(i)
if rest == [] :
  print(t)
else :
  f = sorted(rest, key=lambda x:str(x)[-1] ,reverse=True)
  c = [math.ceil(i/10)*10for i in f[:-1]]
  t += sum(c)+f[-1]
  print(t)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

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

using namespace std;


vector<int>p[200005];
bool f[200005];
int main() {

	int n;
	int m;
	
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		p[a].push_back(b);
		p[b].push_back(a);
		if (a == n)f[b] = 1;
		if (b == n)f[a] = 1;
	}
	for (int i = 0; i < p[1].size(); i++) {
		
			if (f[p[1][i]] ) {
				cout << "POSSIBLE" << endl; return 0;
			}
			
	}
	cout << "IMPOSSIBLE" << endl;

	return 0;
	
}


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

int route(vector<vector<int>> &graph, vector<int> arl, int pos){
    int num = 0;
    arl[pos]++;
    bool check = true;
    for(int i=1; i<arl.size(); i++){
        if(arl[i] == 0){
            check = false;
            break;
        }
    }
    if(check){
        return 1;
    }
    for(int i=0; i<graph[pos].size(); i++){
        if(arl[graph[pos][i]] == 0){
            num += route(graph,arl,graph[pos][i]);
        }
    }
    return num;
}

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> graph(n+1);
    for(int i=0; i<m; i++){
        int a,b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    vector<int> arl(n+1,0);
    cout << route(graph, arl, 1) << endl;
}

Measured memory_bytes: 256