akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        String A = sc.next();
        String B = sc.next();
        String C = sc.next();
        if (A.charAt(A.length() - 1) == B.charAt(0) && B.charAt(B.length() - 1) == C.charAt(0)) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }

    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define fi            first
#define se            second
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
const int N = 1e5+10;
int main()
{
    _SAD()
    int n,k=0,cnt=0,ans=0;
    string s,ss;
    cin>>n>>s;
   // bool f=false;
    for(int i=0;i<SZ(s);i++)
    {
        //bool fl=false;
        if(s[i]=='.')
        {
            cnt++;
        }
    }
    ans=cnt;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='#')
        {
            cnt++;
        }
        else
        {
            cnt--;
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<nl;
    return 0;
}


Measured memory_bytes: 720
// INCLUDES
#include <bits/stdc++.h>
//DEFINES
#define pii pair<int, int>
#define c1 __builtin_popcount
#define F first
#define S second
#define all(s) begin(s),end(s)
#define MIN3POS(a, b, c) (a) =< (b) ? ((a) =< (c) ? 1 : 3) : ((b) =< (c) ? 2 : 3)
#define MAX3POS(a,b,c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2:3)
#define endl '\n'
#define ll long long
#define ui unsigned int
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define IOS   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//NAMESPACES
using namespace std;
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

void solve(){
int a,b,c,k;
cin>>a>>b>>c>>k;
for(int i=0;i<=k;i++) {
    int gg = i;
    int bb = k-i;
    if(c<<bb > b<<gg && (b<<gg) > a) {
        cout<<"Yes";
        return ;
    }
}
cout<<"No";
}
int32_t main()
{
IOS
int t=1;
// cin>>t;
while(t--) {
    solve();
}

return 0;
}
// Use emplace back in place of pushback
// Use tie function , for object destructuring

Measured memory_bytes: 3536
#include <stdio.h>

int main(void)
{
    long i,human,money,total = 0;
    scanf("%ld",&human);
    for(i = 0;i < human;i++){
        scanf("%ld",&money);
        total = total + money;
    }
    printf("%ld\n",total/human);
    return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define int long long
#define il inline 
#define rep(i, l, r) for(register int i = l; i <= r; ++ i)
using namespace std;
const int maxn = 200005, mod = 1000000007;
inline int read()
{
	register char cc = getchar(); register int cn(0), flus(1);
	while(cc < '0' || cc > '9') {if(cc == '-') flus = - flus; cc = getchar();}
	while(cc >= '0' && cc <= '9') {cn = cn * 10 + cc - '0'; cc = getchar();}
	return cn * flus;
}
il int Mul(int a, int b) { return 1ll * a * b % mod; }
il int Inc(int a, int b) { return (a += b) >= mod ? a - mod : a; }
il int Dec(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
il int qpow(int a, int b) { int r = 1; while(b) { if(b & 1) r = Mul(r, a); a = Mul(a, a), b >>= 1; } return r; }
int n, m;
double p[maxn], ans, sum[maxn];
signed main() {
	n = read(), m = read();
	rep(i, 1, n) p[i] = (1 + read()) / 2.0, sum[i ] = sum[i - 1] + p[i];
	rep(i, m, n) ans = max(ans, sum[i] - sum[i - m]);
	printf("%.10lf", ans);
	return 0;
}


Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.C
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (N, K) = Read2Longs();
            var h = new long[N];
            for (int i = 0; i < N; i++)
            {
                h[i] = ReadLong();
            }

            h = h.OrderBy(x => x).ToArray();

            var minDif = long.MaxValue;
            for (int i = 0; i + K - 1 < N; i++)
            {
                minDif = Math.Min(minDif, h[i + K - 1] - h[i]);
            }

            return minDif;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 36524
#include<iostream>
#include<math.h>



void solve_A() {
	int R;
	std::cin >> R;
	std::cout << 2 * acos(-1) * R << std::endl;
}

void solve_B() {
	int N, M;
	std::cin >> N >> M;
	//int A[1001];
	long long int sum = 0;
	for (int i = 0; i < M; i++) {
		int tmp;
		std::cin >> tmp;
		sum += tmp;
	}
	
	std::cout << (sum <= N ? N - sum : -1) << std::endl;

}

int main()
{
	//solve_A();
	solve_B();
    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,true):false;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,true):false;}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
 
int nextInt() { int x; scanf("%d", &x); return x;}
 
const int V = 200;
double dp[40000 + 10][V + 10];
int t[110];
int v[110];
int vh[40000 + 10];
 
int main2() {
  memset(dp,0,sizeof(dp));
  memset(vh,0,sizeof(vh));
 
  int N = nextInt();
  REP(i, N) t[i] = nextInt() * 2;
  REP(i, N) v[i] = nextInt() * 2;
  int T = 0;
  REP(i, N) T += t[i];
  {
    int p = 0;
    REP(i, N) {
      REP(_, t[i]) vh[p++] = v[i];
    }
  }
  REP(i, T + 1) REP(j, V + 1) dp[i][j] = -99999999;
  dp[0][0] = 0;
  for (int tt = 0; tt < T; tt++) {
    int VH = min(vh[tt], vh[tt+1]);
    for (int vv = 0; vv <= 200; vv++) {
      if (vv+1 <= VH) chmax(dp[tt + 1][vv+1], dp[tt][vv] + vv+0.5);
      if (vv   <= VH) chmax(dp[tt + 1][vv  ], dp[tt][vv] + vv    );
      if (vv-1 >= 0 && vv-1 <= VH) chmax(dp[tt + 1][vv-1], dp[tt][vv] + vv-0.5);
    }
  }
  double ans = dp[T][0] / 4.0;
  printf("%.10f\n", ans);
  return 0;
}
 
int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}

Measured memory_bytes: 66048
#include <bits/stdc++.h>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
#define pb push_back
#define fi first
#define se second
typedef long long LL;
typedef pair<int,int> PII;
const int N=100001;
const LL inf=1e18;
struct node{
	int id,ch[2];
}a[N*80];
int n,s,rt,tot,L[N],st[N];LL sum[N],dp[N],ans;
void pd(int t){
	if(!a[t].id)return;
	int&l=a[t].ch[0],&r=a[t].ch[1];
	if(!l)l=++tot;if(!r)r=++tot;
	a[l].id=a[r].id=a[t].id,a[t].id=0;
}
void Upd(int l,int r,int x,int y,int&t,int id){
	if(l>r)return;if(!t)t=++tot;
	if(l<=x&&y<=r){a[t].id=id;return;}
	pd(t);int m=(x+y)>>1;
	if(l<=m)Upd(l,r,x,m,a[t].ch[0],id);
	if(r>m)Upd(l,r,m+1,y,a[t].ch[1],id);
}
int Ask(int p,int x,int y,int t){
	if(!t)return 0;
	if(x==y)return a[t].id;
	pd(t);int m=(x+y)>>1;
	if(p<=m)return Ask(p,x,m,a[t].ch[0]);
	else return Ask(p,m+1,y,a[t].ch[1]);
}
LL Solve(int x,int y,int t){
	if(!t)return sum[n];
	if(a[t].id){
		int j=a[t].id;LL res=sum[n]-sum[j]+dp[j];
		if(sum[j]*2%s<x||sum[j]*2%s>y)res+=(sum[j]*2-y+s)%s;
		return res;
	}
	int m=(x+y)>>1;
	return min(Solve(x,m,a[t].ch[0]),Solve(m+1,y,a[t].ch[1]));
}
int main(){
	cin>>n>>s;
	ref(i,1,n){
		cin>>L[i]>>st[i];
		if(st[i]==1&&L[i]*2>s)return 0*puts("-1");
	}
	ref(i,1,n){
		sum[i]=sum[i-1]+L[i];
		int j=Ask(sum[i]*2%s,0,s-1,rt);
		dp[i]=sum[i]-sum[j];
		if(j)dp[i]+=dp[j]+(s+(sum[j]*2-sum[i]*2)%s)%s;
		if(st[i]==2)continue;
		int l=sum[i-1]*2%s,r=sum[i]*2%s;
		if(l<r)Upd(l+1,r-1,0,s-1,rt,i);
		else Upd(l+1,s-1,0,s-1,rt,i),Upd(0,r-1,0,s-1,rt,i);
	}
	ans=Solve(0,s-1,rt)+sum[n];
	cout<<ans<<endl;
}

Measured memory_bytes: 35072
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdint>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;
using std::lower_bound;
using std::upper_bound;
using std::find_if;
using std::copy;
using std::copy_if;

int main(){
    string s;
    cin >> s;
    int n=std::count(s.begin(),s.end(),'1');
    cout << n << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef vector<int>vi;
typedef pair<int,int>pi;
typedef vector<pi>vpi;
typedef vector<vi>vvi;
#define double long double
#define pow powl
#define sqrt sqrtl
#define cbrt cbrtl
#define floor floorl
#define ceil ceill
#define pb push_back
#define ep emplace_back
#define PB pop_back
#define pf push_front
#define ef emplace_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)-a.begin()
#define lb(a,b) lower_bound(all(a),b)-a.begin()
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) FOR(i,0,n-1) cin>>a[i]
#define in1(a,n) FOR(i,1,n) cin>>a[i]
#define ff first
#define ss second
#define out(a,n) FOR(i,0,n-1) cout<<a[i]<<" ";cout<<endl;
#define out1(a,n) FOR(i,1,n) cout<<a[i]<<" ";cout<<endl;
#define clr(a) a.clear()
#define pow2(a) (1LL<<a)
#define all(a) a.begin(),a.end()
#define all1(a) a.begin()+1,a.end()
#define rall(a) a.rbegin(),a.rend()
#define rall1(a) a.rbegin(),a.rend()
#define sz(a) ((int)a.size())
#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define NFOR(i,a,b) for(auto i=a;i>=b;i--)
const int mod=1e9+7;

inline int add(int a,int b){return (a%mod + b%mod)%mod;}
inline int sub(int a ,int b){return (a%mod - b%mod + mod)%mod;}
inline int mul(int a,int b){a%=mod;b%=mod;return a*b%mod;}
inline int power(int a,int b,int MOD){a%=mod;int res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define trace(x) cout<<#x<<" :: "<<x<<endl;
#define trace2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define trace3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define trace4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}
signed main()
{
     SPEED;
     int n;
     cin>>n;
     int current=1;
     int res=0;
     for(int i=0;i<n;i++)
     {
          int x;
          cin>>x;
          if(current==x)
               current++;
          else
            ++res;
     }
     cout<<(res!=n ? res :-1)<<endl;
     time();
     return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int Dx[100005],Dy[100005];
int n;
int X[100005],Y[100005];
char dd;

double solve (double a)
{

	double mxx = -1e18;
	double mnx = 1e18;
	double mxy = -1e18;
	double mny = 1e18;
	for(int i = 1;i <= n;i++)
    {
		double x = X[i]+a*Dx[i];
		double y = Y[i]+a*Dy[i];
		mxx = max(mxx,x);
		mnx = min(mnx,x);
		mxy = max(mxy,y);
		mny = min(mny,y);
	}
	return (mxx-mnx)*(mxy-mny);
}

int main()
{
    scanf("%d",&n);
    for(int i = 1;i <= n;i++)
    {
        scanf("%d %d %c", &X[i], &Y[i], &dd);
        switch(dd)
        {
            case 'U' :
            {
                Dy[i] = 1;
                break;
            }
            case 'D' :
            {
                Dy[i] = -1;
                break;
            }
            case 'L' :
            {
                Dx[i] = -1;
                break;
            }
            case 'R' :
            {
                Dx[i] = 1;
                break;
            }
        }
    }
    double ans = 1e18;
    double l = 0;
    double r = 1e9;
    for(int t = 0;t < 200;t++)
    {
        double uu = (l*2+r)/3;
        double dd = (l+r*2)/3;
        double uv = solve(uu);
        double dv = solve(dd);
        ans = min(ans,min(uv,dv));
        if(dv < uv)
        {
            l = uu;
        }
        else
        {
            r = dd;
        }
    }
    printf("%.15f",ans);
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  ll n,k; cin >> n >> k;
  vector<ll> h(n);
  cin >> h[0];
  ll tmp = h[0];

  for (int i = 1; i < n; ++i) {
    cin >> h[i];
    // h[i] = abs(tmp - h[i]);
  }

  sorti(h);
  ll res = h.back() - h.front() + 1;


  for (int i = 0; i <= n - k; ++i) {
    ll tmp = h[i+k-1] - h[i];
    
    if (tmp < res) res = tmp;
  }

  cout << res << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)

int main(void){
  int a,b,ans=-1;
  cin>>a>>b;

  for(int i=1;i<max(a,b);i++){
    if(abs(a-i)==abs(b-i))ans=i;
  }
  if(ans==-1)cout<<"IMPOSSIBLE"<<endl;
  else cout<<ans<<endl;

  return 0;
}


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

int main(){
    int A,B, K;
    cin >> A >> B >> K;

    int count = 0;
    int i=101;
    while(count < K){
        i--;
        if(A%i == 0 && B%i == 0){count++;}
        
    }

    cout << i << endl;
    return 0;

}

Measured memory_bytes: 256
#!/usr/bin/env python
import sys 
input = sys.stdin.readline

n, k = map(int, input().split())
ans = 0 

for i in range(1, n+1):
    score = i 
    tmpans = 1/n 
    while score < k:
        score *= 2
        tmpans *= 1/2 
    ans += tmpans

print(ans)


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

int main() {
	string s;
	int str[4];
	cin >> s;
	int n = 4;
	int sum;
	string ans[4];
	for (int j = 0; j < n; j++) {
		str[j] = s[j] - '0';
	}
	for (int i = 1; i < (1 << (n)); i++) {
		sum = str[0];
		
		for (int j = 1; j < n; j++) {
			if (i & 1 << j) {
				sum += str[j];
				ans[j] = "+";
			}
			else {
				sum -= str[j];
				ans[j] = "-";

			}//cout << ans[j] << str[j] << " ";
			//cout << "a "<<sum<<"a"<<endl;
		}//cout << sum;
		if (sum == 7) {
			//cout << "aaaaaaaa";
			for (int k = 0; k < n; k++) {
				if (k == 0) {
					cout << str[k];
					k++;
				}
				cout << ans[k] << str[k];
			}cout << "=7" << endl;
			return 0;
		}

	}

	//cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a=n%10; 
	if(a==2 || a==4 || a==5 || a==7 || a==9)
		cout<<"hon";
	else if(a==0 || a==1 || a==6 || a==8)
		cout<<"pon";
	else
		cout<<"bon";
	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
  int x[4] = {0};
  int n;
  int p[4];
  int count = 0;
  scanf("%d", &n);
  p[0] = n / 1000;
  p[1] = (n - 1000 * p[0]) / 100;
  p[2] = (n - 1000 * p[0] - 100 * p[1]) / 10;
  p[3] = (n - 1000 * p[0] - 100 * p[1] - 10 * p[2]);
  for (int i = 0; i < 4; i++) {
    if (p[i] == 2) count++;
  }
  printf("%d", count);
}

Measured memory_bytes: 128
#pragma region template
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a) \
    REP(i, (a).size()) { cout << (a[i]) << (i == (a).size() - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
    string S;
    cin >> S;
    if (S[2] == S[3] and S[4] == S[5])
    {
        OUT("Yes");
    }
    else
    {
        OUT("No");
    }
}
#pragma endregion template

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

template<typename F>
static inline constexpr decltype(auto) fix(F&& f) noexcept {
  return [f = std::forward<F>(f)](auto&&... args) {
    return f(f, std::forward<decltype(args)>(args)...);
  };
}
template<typename T>
static inline T fin() { T t; cin >> t; return std::move(t); }

int main() {
  let N = fin<i64>();
  let D = fin<i64>();
  let X = [N, D]() {
    vector<vector<i64>> vec(N, vector<i64>(D));
    for(int i = 0;i < N;i++) {
      for(int j = 0;j < D;j++) {
        cin >> vec[i][j];
      }
    }
    return std::move(vec);
  }();
  
  let ans = [N, D, &X]() {
    i64 cnt = 0;
    for(int i = 0;i < N;i++) {
      for(int j = i + 1;j < N;j++) {
        cnt += [D](let& x, let& y) {
          i64 sum = 0;
          for(int i = 0;i < D;i++) {
            sum += (x[i] - y[i]) * (x[i] - y[i]);
          }
          return sum == i64(sqrt(sum)) * i64(sqrt(sum));
        }(X[i], X[j]);
      }
    }
    return cnt;
  }();
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

long func(int n, char s[]){
    int ii1, ii2, p;
    long sum_max;
    int RGB[3] = {0, 0, 0};
    for(ii1=0; ii1<n; ii1++){
        if(s[ii1] == 'R') RGB[0]++;
        if(s[ii1] == 'G') RGB[1]++;
        if(s[ii1] == 'B') RGB[2]++;
    }
    sum_max = RGB[0]*RGB[1]*RGB[2];
    for(ii1=0; ii1<n-2; ii1++){
        for(ii2=ii1+1; ii2<n-1; ii2++){
            p = 2*ii2 - ii1;
            if(n > p && (s[ii1] != s[ii2] && s[ii2] != s[p]
               && s[ii1] != s[p])){
                  sum_max--;
               }
        }
    }

    return sum_max;
}

int main(void){
    int n;
    long sum;
    scanf("%d", &n);
    char s[4001];
    scanf("%s", s);
    sum = func(n, s);
    printf("%ld\n", sum);

    return 0;
}


Measured memory_bytes: 2156
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int k;
void pr(vector<vector<int> > x){
	int n = x.size();
	cout << n << '\n';
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			int a = x[i][j] + 1;
			assert(a >= 1);
			assert(a <= k);
			cout << a << " ";
		}
		cout << '\n';
	}
}

int main(){
	cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> k;
	if(k == 1){
		pr({{0}});
		return 0;
	}
	for(int n = 2; ; n += 2){
		assert(n <= 500);
		if(n <= k && k <= 2*n){
			int extra = k - n;
			int color = 0;
			vector<vector<int> > f(n, vector<int> (n, 0));
			for(int i = 0; i < n; i++){
				int c1 = color;
				int c2 = color;
				if(extra){
					c2++;
					extra--;
				}
				for(int j = 0; j < n; j++){
					if(j & 1){
						f[j][(i+j) % n] = c1;
					} else {
						f[j][(i+j) % n] = c2;
					}
				}
				color = c2 + 1;
			}
			pr(f);
			return 0;
		}
	}
}


Measured memory_bytes: 3200
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>

using namespace std;

int main(){
    int n, t, maxn = 0;
    cin >> n >> t;
    int a[n], b[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    b[n-1] = a[n-1];
    for(int i = n-2; i >= 0; i--){
        b[i] = max(b[i+1], a[i]);
    }
    int cnt = 0;
    for(int i=0; i<n; i++){
        if(maxn < b[i]-a[i]){
            maxn = b[i] - a[i];
            cnt = 1;
        }else if(maxn == b[i] - a[i]){
            cnt ++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1024
#A=[int(i)for i in input().split()]
A=input()
#print(A)
lastnum=int(A[-1])
if lastnum == 3:
  print("bon")
elif lastnum == 0 or lastnum == 1 or lastnum == 6 or lastnum == 8:
  print("pon")
else:
  print("hon")

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

int main(){
	int a, b;
	int count = 0;
	cin >> a >> b;
	for(int i = a; i <= b; i++){
		if(i/10000 == i % 10 && (i /1000)%10 == (i /10)%10) count++;
	}
	cout << count;
	return 0;
}

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

int main(){
    
    int S;
    cin>>S;
    int h,m,s;
    h=S/3600;
    S=S-h*3600;
    m=S/60;
    S=S-m*60;
    s=S;
    cout<<h<<':'<<m<<':'<<s<<'\n';
    return 0;
}


Measured memory_bytes: 3112
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <set>
#include <map>

#define X first
#define Y second
#define MP make_pair
#define PB push_back

using namespace std;

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

const int N = 1e5 + 500;
const int M = 1e6 + 500;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int LOG = 20;
const int OFF = (1 << LOG);
const double EPS = 1e-9;
const double PI = 3.1415926535;

ll a, b, c, k, sm = 0;

int main(){
    cin >> a >> b >> c >> k;
    if(a >= b && a >=c){
        for(;k;k--) a *= 2LL;
    }
    else if(b >= c && b >=a){
        for(;k;k--) b *= 2LL;
    }
    else{
        for(;k;k--) c *= 2LL;
    }
    cout << a + b + c << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

X, K, D = list(map(int, input().split()))

p = X
_p = 0
k = 0

if abs(p) > K*D:
    print(abs(p)-K*D)
    sys.exit()

if p < 0:
    for i in range(K):
        _p = p
        p += D
        k += 1
        if p > 0:
            break
    if (K-k) % 2 == 0:
        print(abs(p))
    else:
        print(abs(_p))
elif p > 0:
    for i in range(K):
        _p = p
        p -= D
        k += 1
        if p < 0:
            break
    if (K-k) % 2 == 0:
        print(abs(p))
    else:
        print(abs(_p))
else:
    if K % 2 == 0:
        print(0)
    else:
        print(D)


Measured memory_bytes: 63176
#include <bits/stdc++.h>
using namespace std;
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;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if(a == 1) {
        a = 14;
    }
    if(b == 1) {
        b = 14;
    }
    if(a == b) {
        cout << "Draw\n";
    } else {
        cout << (a > b ? "Alice" : "Bob") << "\n";
    }
}

Measured memory_bytes: 3624
#include <stdio.h>
#define SIZE 100

int main(){

  int i,j,k;
  int n,array[SIZE],temp;

  //input
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&array[i]);
  }

  i=0;

  //sort
  for(i=1;i<n;i++){
    j=i;
    
    for(k=0;k<n;k++){
      if(k!=0) printf(" ");
      printf("%d",array[k]);
    }
    printf("\n");

    while((j > 0) && (array[j-1]>array[j])){
      temp = array[j-1];
      array[j-1] = array[j];
      array[j] = temp;

      j--;
    }
  }
  
  for(k=0;k<n;k++){
    if(k!=0) printf(" ");
    printf("%d",array[k]);
  }
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 604
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
      
      	int A = sc.nextInt(), B = sc.nextInt();
      	if (B % A == 0) {
        	System.out.println(A+B);
        } else {
        	System.out.println(B-A);
        }
    }
}

Measured memory_bytes: 22740
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


#define rep(i,r,l) for(int i = r; i < l; i++)
#define elif else if
#define ll long long

int nextint(void){int n;scanf("%d",&n);return n;}
void printint(int d){printf("%d\n",d);}


int main(void){ 

    
    int x;
    scanf("%d",&x);
    (x>=30)?puts("Yes"):puts("No");
    
    
    return 0;
}



Measured memory_bytes: 1664
#include "bits/stdc++.h"
using namespace std;

int main() {
	string A, B;
	cin >> A >> B;
	if(A.size() >B.size()){
		cout << "GREATER"<<endl;
		return 0;
	}
	else if (A.size() < B.size()) {
		cout << "LESS" << endl;
		return 0;
	}
	else {
		for (int i = 0;i<A.size();++i) {
			if (A[i] >B[i]) {
				cout << "GREATER" << endl;
				return 0;
			}
			else if(A[i]<B[i]){
				cout << "LESS" << endl;
				return 0;
			}
		}
	}
	cout << "EQUAL" << endl;
	return 0;
}

Measured memory_bytes: 3612
/* 
/*-----------------------------------------------*/
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long int ll;
typedef vector<ll> vll;
/*-----------------------------------------------*/
// #define DBGMODE
#ifdef DBGMODE
	#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
	#define debug(...)
#endif
/*-----------------------------------------------*/
ll add_mod (ll a, ll b, ll p) { ll res = a + b; if (res > p) res -= p; return res; }
ll sub_mod (ll a, ll b, ll p) { ll res = a - b; if (res < 0) res += p; return res; }
const ll MOD = 1e9 + 7;
int N;
ll dp[110][5][5][5];

ll solve () {
	memset(dp, 0, sizeof dp);
	for (int x = 0; x < 4; x++)
		for (int y = 0; y < 4; y++)
			for (int z = 0; z < 4; z++) {
				ll &val = dp[3][x][y][z];
				if 		(x == 0 && y == 2 && z == 1) val = 0;
				else if (x == 0 && y == 1 && z == 2) val = 0;
				else if (x == 2 && y == 0 && z == 1) val = 0;
				else val = 1;
			}

	for (int i = 4; i <= N; i++)
		for (int x = 0; x < 4; x++) 
			for (int y = 0; y < 4; y++) 
				for (int z = 0; z < 4; z++) {
					for (int j = 0; j < 4; j++) dp[i][y][z][j] = add_mod(dp[i][y][z][j], dp[i - 1][x][y][z], MOD);
					if ((x == 0 && y == 2) ||
						(x == 0 && z == 2) ||
						(y == 0 && z == 2) ||
						(y == 2 && z == 0)) dp[i][y][z][1] = 0;
					if (y == 0 && z == 1) 	dp[i][y][z][2] = 0;
				}
	ll ans = 0;
	for (int x = 0; x < 4; x++)
		for (int y = 0; y < 4; y++)
			for (int z = 0; z < 4; z++)
				ans = add_mod(ans, dp[N][x][y][z], MOD);
	return ans;
}
/*-----------------------------------------------*/
int main() {
	#ifdef DBGMODE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	scanf("%d", &N);
	printf("%lld\n", solve());
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define endl '\n'
#define Endl '\n'
#define fi first
#define ii pair<int,int>
#define iil pair<ll,ll>
#define iii pair<pair<int, int>, int >
#define iiil pair<pair<ll, ll>, ll >
#define se second
#define ld long double
#define mod 1000000007
#define popcount __builtin_popcountll
#define x0 zxcxzcsacasd
#define x1 ghfghujfgfg
#define y0 olkjhdnncvcv
#define y1 bhvgrewm345345435
using namespace std;
multiset<ll>ms[5];
void add(ll x, ll y){
    ms[1].insert(x + y);
    ms[2].insert(-x + y);
    ms[3].insert(-x - y);
    ms[4].insert(x - y);
}

ll query(ll x, ll y){
    if(ms[1].empty())return -1;
    ll ret = 0;
    ret = max(ret, *ms[1].rbegin() + (-x - y));
    ret = max(ret, *ms[2].rbegin() + (x - y));
    ret = max(ret, *ms[3].rbegin() + (x + y));
    ret = max(ret, *ms[4].rbegin() + (-x + y));
    return ret;
}
ll a[1<<20];
ll b[1<<20];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%lld%lld", &a[i], &b[i]);
		add(a[i], b[i]);
	}
	ll ans = 0;
	for(int i=0;i<n;i++){
		ans = max(ans, query(a[i], b[i]));
		add(a[i], b[i]);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 81764
import math
from collections import Counter
n=math.factorial(int(input()))
dp=[]
for i in range(2,1001):
  while n%i==0:
    n//=i
    dp.append(i)
c=list(Counter(dp).items())
ans=1
for j in range(len(c)):
  ans*=c[j][1]+1
print(ans%1000000007)

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

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

using namespace std;

int n;

int main(){
    cin >> n;
    int f = 0;
    for(int i = n; i > 0; i /= 10){
        f += i % 10;
    }
    cout << (n % f ? "No" : "Yes") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
int main(){
    double r,l,s;
    cin >> r;
    l = r*2*M_PI;
    s = r*r*M_PI;
    // cout << l << " " << s << endl;
    printf("%.6f %.6f\n", s, l);
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll a[5];
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		char n=s[0];
		if(n=='M'){
			a[0]++;
		}
		else if(n=='A'){
			a[1]++;
		}
		else if(n=='R'){
			a[2]++;
		}
		else if(n=='C'){
			a[3]++;
		}
		else if(n=='H'){
			a[4]++;
		}
	}
	ll ans=0;
	for(int i=0;i<5;i++){
		for(int j=i+1;j<5;j++){
			for(int k=j+1;k<5;k++){
				ans+=a[i]*a[k]*a[j];
			}
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

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

int main () {
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  for (int i=0; i<M; i++) {
    cin >> A.at(i);
    N = N - A.at(i);
  }
  if (N >= 0) cout << N << endl;
  else cout << -1 << endl;
  // for (int i=0; i<M; i++) cout << A.at(i);
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;

  long long H;
  cin >> H;
  long long plus = 1;
  long long ans = 1;
  while(H > 1){
    H /= 2;
    plus *= 2;
    ans += plus;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
def abc044_c():
    #値入力
    _, A = map(int, input().split())
    X = list(map(lambda x : int(x)-A,input().split()))
    #初期値
    d = {0:1}
    for x in X:
        for k,v in list(d.items()):
            d[k + x] = d.get(k + x,0) + v #差分の合計
    ans = d[0] - 1 #差分合計0で初期値を除く
    print(ans)

if __name__ == '__main__':
    abc044_c()

Measured memory_bytes: 9228
#include<string.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<math.h>
using namespace std;
#define MAX 100000
#define SENTINEL 2000000000

int L[MAX / 2 + 2], R[MAX / 2 + 2];
int cnt;

void merge(int A[], int n, int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	for (int i = 0; i < n1; i++) L[i] = A[left + i];
	for (int i = 0; i < n2; i++) R[i] = A[mid + i];
	L[n1] = R[n2] = SENTINEL;
	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
		cnt++;
		if (L[i] <= R[j]) {
			A[k] = L[i++];
		}
		else {
			A[k] = R[j++];
		}
	}
}

void mergeSort(int A[], int n, int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(A, n, left, mid);
		mergeSort(A, n, mid, right);
		merge(A, n, left, mid, right);
	}
}

int main() {
	int A[MAX], n, i;
	cnt = 0;

	cin >> n;
	n = 2 * n;
	for (i = 0; i < n; i++) cin >> A[i];

	mergeSort(A, n, 0, n);
	long long sum = 0;
	for (i = 0; i < n; i += 2) {
		sum += min(A[i], A[i + 1]);
	}
	cout << sum;
	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);
		int[] a = new int[3];
		for(int i = 0; i < 3; i++){
			a[i] = scanner.nextInt();
		}

		Arrays.sort(a);

		if(a[2] - a[0] == a[1]){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23636
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		String x = input.next();
      	String ans = "";
      	for (int i = 0; i < x.length(); i++){
        	if (x.charAt(i)==',') ans+=" ";
          	else ans+=x.substring(i,i+1);
        }
      	System.out.println(ans);
	}
}

Measured memory_bytes: 23508
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, K = map(int, input().split())
ans = 0

if K == 0:
    ans = N*N
else:
    for b in range(K+1, N+1):
        a = (N)//b*(b-K)+max(0, (N-N//b*b)-K+1)
        ans += a
print(ans)


Measured memory_bytes: 2940
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int a = in.nextInt();
		int b = in.nextInt();
		int plana = n * a;
		if( plana>=b )
		{
			System.out.println(b);
		}
		else if( plana<b )
		{
			System.out.println(plana);
		}
	}
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	int m = 0;
	int m2 = 0;
	int count = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	b = a;
	auto itr = max_element(a.begin(), a.end());
	m = *itr;
	a.erase(itr);
	m2 = *max_element(a.begin(), a.end());

	for (int i = 0; i < n; i++) {
		if (b[i] == m) cout << m2 << endl;
		else cout << m << endl;
	}

	return 0;
}

Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner s = new Scanner(System.in);
		int H = s.nextInt();
		int W = s.nextInt();

		String[] arrays = new String[H];

		for (int i = 0; i < H; i++) {
			arrays[i] = s.next();
		}
		
		for (int i = 0; i < H + 2; i++) {
			if (i == 0 || i == H + 1) {
				for (int j = 0; j < W + 2; j++) {
					System.out.print("#");
				}
			} else {
				System.out.print("#" + arrays[i - 1] + "#");

			}
			System.out.print("\n");
		}

	}

}


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

const int INF = 1001001001;

int main(){
    int n, m;
    cin >> n >> m;
    Graph G(n);
    rep(i,m){
        int a, b;
        cin >> a >> b;
        --a; --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    queue<int> q;
    vector<int> dist(n, INF);
    vector<int> pre(n, -1);
    dist[0] = 0;
    q.push(0);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        for(int nv : G[v]) {
            if(dist[nv] != INF) continue;
            dist[nv] = dist[v] + 1;
            pre[nv] = v;
            q.push(nv);
        }
    }
    cout << "Yes" << "\n";
    rep(i,n){
        if(i==0) continue;
        int ans = pre[i];
        ++ans;
        cout << ans << "\n";
    }
    return 0;
}

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

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

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    int ans = 0;

    for(int l = 0, r = 0; l < N; l++)
    {
        while(r < N && A[r] == 1)
        {
            r++;

            ans = max(ans, r - l);   
        }

        l = r;
        r++;
    }

    cout << ans + 1 << endl;

    return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
	int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

const double PI = acos(-1);
int a, b, x;

int main() {
	read(a), read(b), read(x);
	if (x >= a * a * b / 2.0) printf("%.10lf\n", atan((2 * a * a * b - 2 * x) * 1.0 / (a * a * a)) * 180.0 / PI);
	else printf("%.10lf\n", atan(a * b * b  * 1.0 / (2 * x)) * 180.0 / PI);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define p 1000000007

struct item{
    ll weight;
    ll value;
};

ll dp[100+1][100000+1];

ll value(ll i,ll w,vector<item> &v)
{
    if(i==1)
    {
        return dp[i][w]=(v[i].weight<=w?v[i].value:0);
    }
    else
    {
        if(dp[i][w]!=-1)
        {
            return dp[i][w]; 
        }
        
        ll option1=( (w-v.at(i).weight)>=0?(v.at(i).value+value(i-1,w-v.at(i).weight,v)):0);
        ll option2=0+value(i-1,w,v);
        
        return dp[i][w]=max(option1,option2);
    }
}

ll solve(ll n,ll w,vector<item> &v)
{
    memset(dp,-1,sizeof(dp));
    return value(n,w,v);
    
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll n,w;
    cin>>n>>w;
    
    vector<item> v(n+1);
    for(ll i=1;i<=n;i++)
    {
        cin>>v[i].weight>>v[i].value;
    }
    cout<<solve(n,w,v);
    return 0;
}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
static const long long INF = 1LL<<59;
static const long long MOD = (ll)1e9+7;

#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i, n) for(ll i=0;i<n;i++)
#define SZ(v) (ll)((v).size())
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse((v).begin(), (v).end())
#define FOLDL(src, dst, lambda) partial_sum((src).begin(), (src).end(), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum((src).begin(), (src).end(), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate((v).begin(), (v).end(), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}

void solve() {
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    ll dx = -(x1 - x2);
    ll dy = -(y1 - y2);
    out(x2 - dy, y2 + dx, x1 - dy, y1 + dx);
}

int main() {
    fast_io;
    solve();
    return 0;
}

Measured memory_bytes: 256
# if true 

# include <iostream>

int main()
{

    int K; std::cin >> K;

    if (K % 2 == 0)
        std::cout << K / 2 * K / 2;
    else
        std::cout << K / 2 * (K / 2 + 1);

    return 0;
}

# endif

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()



def main():
    n = I()
    ans = 0
    N = 10**7 + 1
    prime = [True] * N
    prime[1] = False
    n_yaku = [1] * N
    min_prime = [1] * N

    for i in range(2, N):
        if not prime[i]:
            continue
        n_yaku[i] = 2
        min_prime[i] = i
        num = i + i
        while num < N:
            min_prime[num] = i
            prime[num] = False
            num += i
    for i in range(2, N):
        if prime[i]:
            continue
        j = i
        cnt = 0
        while j % min_prime[i] == 0:
            # print('j: ', j)
            # print('prime: ', min_prime[i])
            j //= min_prime[i]
            cnt += 1
        n_yaku[i] = n_yaku[j] * (cnt + 1)
    ans = 0
    for i in range(1, n+1):
        ans += i * n_yaku[i]
    print(ans)


main()



Measured memory_bytes: 397016
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n; cin >> n;
	string s; cin >> s;
	int q; cin >> q;
	while (q--)
	{
		int k; cin >> k;
		ll ans = 0;
		ll tmp = 0;
		ll cntm = 0;
		ll cntc = 0;
		REP(i, k)
		{
			if (s[i] == 'M') cntm++;
			if (s[i] == 'C')
			{
				tmp += cntm;
				cntc++;
			}
		}
		REP(i, n)
		{
			if (s[i] == 'D') ans += tmp;
			if (s[i] == 'M')
			{
				cntm--;
				tmp -= cntc;
			}
			if (s[i] == 'C') cntc--;
			if (i + k < n)
			{
				if (s[i+k] == 'M') cntm++;
				if (s[i+k] == 'C')
				{
					tmp += cntm;
					cntc++;
				}
			}
		}
		assert(cntm == 0 && cntc == 0);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1948
N=int(input())
L=list(map(int,input().split()))
S=sorted(L)
ans=float("inf")
for i in range(S[0],S[-1]+1):
	tmp=0
	for j in range(N):
		tmp+=(S[j]-i)**2
	
	ans=min(ans,tmp)
print(ans)

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

int board[1000];
int dice[1000];

int main()
{
    int N, M;
    while(cin >> N >> M && N && M) { 
        for(int i = 0; i < N; i++) 
            cin >> board[i];

        for(int i = 0; i < M; i++)
            cin >> dice[i];

        int cnt = 0, idx = 0;
        while(true) {
            idx += dice[cnt++];
            idx += board[idx];
            if(idx >= N - 1)
                break;

        }
        
        cout << cnt << endl;
    }
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
#include<map>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////   
/////////////////////////
int main(){

   
   double x,y;
   cin>>x>>y;
   printf("%.10lf", x/y);
   NL;

    return 0;
}

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

int main() {
  int N;
  bool M=true;
  int Z=0;
  cin >> N;
  vector<int>vec(N);
  for (int X=0; X<N; X++){
    cin >> vec.at(X);
  }
  for (int Y=0; M==true; Y++){
    for (int X=0; X<N; X++){
      if (vec.at(X)%2==0){
        vec.at(X)/=2;
      }
      else{
        M=false;
        break;
      }
      if (X==N-1){
        Z+=1;
      }
    }
  }
  cout << Z << endl;
}


Measured memory_bytes: 3608