akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi atan(1.0)*4
#define pb(x) push_back(x)
#define in(x) insert(x)
#define fl(x,y) for(ll i=x;i<y;i++)
#define all(cont) cont.begin(),cont.end()
#define sz size()
bool isprm(ll a){for(ll i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
int main()
{
    ll a,b,t,n,k,p,q,r,sum,ct=0,flag=0;
    string s,s1,s2,s3;
    set<ll>st;
    map<ll,ll>mp;
      cin>>k>>n;
      vector<ll>v,vv;
       fl(0,n)
       {
           cin>>r; mp[r]++;
       }
       ll mn=7647374365232;
           for(ll j=-1000;j<=1000;j++)
           {
               if(mp[j]==0)
               {
                   p=abs(k-j);
                   if(mn>p)
                   {
                       mn=p;
                       q=j;
                   }
               }
           }

       cout<<q<<endl;
    return 0;
}







Measured memory_bytes: 3764
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

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


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace __gnu_pbds;
using namespace std;
 
typedef
tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 2e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int t[N], a[N], b[N];
ll sumb, suma;
vector < int > vl;
ll f[N];
int cnt[N];

void upd (int x) {
	int i = lower_bound(every(vl), x) - vl.begin();
	for (;i <= vl.size(); i |= i + 1) {
		cnt[i] ++;
		f[i] += x;
	}
}

ll get_cnt (int r) {	
	int res = 0;
	while (r >= 0) {
		res += cnt[r];
		r = (r & (r + 1)) - 1;
	}
	return res;
}

ll get_sum (int r) {
	ll res = 0;
	while (r >= 0) {
		res += f[r];
		r = (r & (r + 1)) - 1;
	}
	return res;
}

pair <ll,ll> g(ll x) {
	int pos = lower_bound(every(vl), x) - vl.begin() - 1;
	ll res = 0;

	res += get_cnt(pos) * x - get_sum(pos);
	res += suma - (get_cnt(vl.size()) - get_cnt(pos)) * x - get_sum(pos);
	return mp(res + sumb, x);
}

void query () {
	int l = -1e9, r = 1e9;
	while (r - l > 20) {
		int md = (l + r) / 2;
		if (g(md) < g(md+ 1)) r= md + 1;
		else l = md;
	}
	pair < ll, ll > ans = mp(INF, INF);
	for (int i = l; i <= r; i ++)
		ans = min(ans, g(i));
	cout << ans.S << ' ' << ans.F << '\n';
}

void add (int a, int b) {
	sumb += b;
	suma += a;
	upd (a);
}

int main () {
	SpeedForce;

	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> t[i];
		if (t[i] == 1) cin >> a[i] >> b[i];
		vl.pb(a[i]);
	}
	sort(every(vl));
	vl.resize(unique(every(vl)) - vl.begin());

	for (int i = 1; i <= n; i ++) {
		if (t[i] == 1) add(a[i], b[i]);
		else query();
	}

	return Accepted;
}

// B...a

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

int a, b, c, d, e, k;

int main() {
    cin >> a >> b >> c >> d >> e >> k;
    if (e - a > k) {
        cout << ":(" << endl;
    } else {
        cout << "Yay!" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
int main()
{
    char i, s[100], l;
    scanf("%s",s);
    l = strlen(s);
    for(i=0;i<l;i++)
    {
        if((i+1)%2!=0)
        {
            if(s[i]!='R' && s[i]!='U' && s[i]!='D')
            {
                printf("No");
                return 0;
            }
        }
        else
        {
            if(s[i]!='L' && s[i]!='U' && s[i]!='D')
            {
                printf("No");
                return 0;
            }
        }
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
    long long int n,i,j,c=0,max=0;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<n;i++)
    {
        if(max<=a[i])
        {
            max=a[i];
            c++;
        }
    }

    cout<<c<<endl;
    return 0;

}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int n,k;cin>>n>>k;
    vector<P> es(n-1);
    vector<vector<int>> g(n);
    for(int i=0;i<n-1;i++){
        int a,b;cin>>a>>b;a--;b--;
        es[i]=P(a,b);
        g[a].push_back(b);
        g[b].push_back(a);
    }
    if(k%2==0){
        int res=INF;
        for(int i=0;i<n;i++){
            // node_i is the center
            int cnt=0;
            vector<int> d(n,INF);
            queue<int> q;
            q.push(i);
            d[i]=0;
            while(!q.empty()){
                int v=q.front();q.pop();
                for(int j=0;j<(int)g[v].size();j++){
                    int next=g[v][j];
                    if(d[next]!=INF) continue;
                    d[next] = d[v]+1;
                    q.push(next);
                    if(d[next]>k/2) cnt++;
                }
            }
            res=min(res,cnt);
        }
        cout<<res<<endl;
    }
    else{
        int res=INF;
        for(int i=0;i<n-1;i++){
            // edge_i is the center
            int cnt=0;
            vector<int> d(n,INF);
            queue<int> q;
            int a=es[i].first,b=es[i].second;
            q.push(a);q.push(b);
            d[a]=d[b]=0;
            while(!q.empty()){
                int v=q.front();q.pop();
                for(int j=0;j<(int)g[v].size();j++){
                    int next=g[v][j];
                    if(d[next]!=INF) continue;
                    d[next] = d[v]+1;
                    q.push(next);
                    if(d[next]>(k-1)/2) cnt++;
                }
            }
            res=min(res,cnt);
        }
        cout<<res<<endl;
    }
}


Measured memory_bytes: 384
#include <iostream>

int main(){
	int n, m, l;
	int matrixA[100][100];
	int matrixB[100][100];
	long int matrixC[100][100] = {};
	std::cin >> n >> m >> l;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			std::cin >> matrixA[i][j];
		}
	}
	for (int i = 0; i < m; i++)
	{
		for (int j = 0; j < l; j++)
		{
			std::cin >> matrixB[i][j];
		}
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < l; j++)
		{
			for (int k = 0; k < m; k++)
			{
				matrixC[i][j] += matrixA[i][k] * matrixB[k][j];
			}
		}
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < l; j++)
		{
			std::cout << matrixC[i][j];
			if (j == l - 1){
				std::cout << std::endl;
			}
			else{
				std::cout << " ";
			}
		}
	}
	return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
  
  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i, 3) {
    if(s[i]==t[i]) ++ans;
  }
  
  cout << ans << endl;
    
    return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    ll ans=100000000000000;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    rep(i,101){
        ll res=0;
        rep(j,n){
            res+=((a[j]-i)*(a[j]-i));
        }
        ans=min(ans,res);
    }
    rep(i,101){
        ll res=0;
        rep(j,n){
            res+=((a[j]+i)*(a[j]+i));
        }
        ans=min(ans,res);
    }
    cout << ans << "\n";
    return 0;
}   

Measured memory_bytes: 3668
#include<iostream>
#include<queue>
#include<vector>
#include<string>
#define ll long long
using namespace std;
int main() {
	int l, n; cin >> l >> n;
	string str; cin >> str;
	vector<int>datax,datao;
	datax.push_back(0);
	for (int i = 0; i < l; ++i) 
		if (str[i] == 'x') datax.push_back(i + 1);
	datax.push_back(l + 1);
	for (int i = 0; i < datax.size() - 1; ++i) 
		datao.push_back(datax[i + 1] - datax[i]-1);
	ll sum = l, add = 0;
	for (int i = 0; i < datao.size(); ++i) 
		if (datao[i] >= 2) add += 3 * (datao[i] - 1);
	for (int i = 1; i <= n; ++i) {
		sum += add;
		add *= 2;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  int A,B,C,D,L,R;
  
  cin >> A >> B >> C >> D;
  
  L = A + B;
  
  R = C + D;
  
  if (L == R) {
    cout << "Balanced" << endl;
  }
  
  if (L > R) {
    cout << "Left" << endl;
  }
  
  if (L < R) {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
def f(s, t):
    n = len(t)
    r = set()
    i = 0
    while True:
        i = s.find(t, i)
        if i == -1:
            break
        cand = s[i: (i+n)+1]
        if len(cand) == n + 1:
            r.add(cand)
        i += 1
    return sorted(r)

class Counter:
    def __init__(self, K):
        self._cnt = 0
        self.cur_c = ''
        self.K = K

    @property
    def cnt(self):
        return self._cnt

    @cnt.setter
    def cnt(self, i):
        self._cnt = i
        if self._cnt == K:
            raise ValueError

if __name__ == '__main__':
    s = input()
    K = int(input())

    l = sorted(set(s))



    ctr = Counter(K)
    try:
        for c1 in l:
            ctr.cur_c = c1
            ctr.cnt += 1
            for c2 in f(s, c1):
                ctr.cur_c = c2
                ctr.cnt += 1
                for c3 in f(s, c2):
                    ctr.cur_c = c3
                    ctr.cnt += 1
                    for c4 in f(s, c3):
                        ctr.cur_c = c4
                        ctr.cnt += 1
                        for c5 in f(s, c4):
                            ctr.cur_c = c5
                            ctr.cnt += 1
    except ValueError:
        print(ctr.cur_c)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int MX=100100;
int n,i,it,l[MX],u[MX],k[MX],w[MX];
long long m,s,le,ri,h,b[MX],c[MX];
bool cmpc(int i, int j) { return c[i]>c[j]; }
long long solve(long long h) {
  long long res=0,z=h%m,cur=0;
  ++it;
  for (i=0; i<h/m; i++) {
    w[k[i]]=it;
    res+=c[k[i]];
  }
  long long nxt=(i>=n)?0:c[k[i]];
  if (z) {
    for (i=0; i<n; i++) if (w[i]!=it)
      cur=max(cur,(z<=b[i])?l[i]*z:(b[i]*l[i]+(z-b[i])*u[i]));
    else
      cur=max(cur,((z<=b[i])?l[i]*z:(b[i]*l[i]+(z-b[i])*u[i]))-c[i]+nxt);
  }
  return res+cur;
}
int main() {
  scanf("%d%lld",&n,&m);
  for (i=0; i<n; i++) {
    scanf("%lld%d%d",&b[i],&l[i],&u[i]);
    s+=b[i]*l[i];
    c[i]=(m-b[i])*u[i]+b[i]*l[i];
    ri+=b[i];
    k[i]=i;
  }
  if (s==0) { puts("0"); return 0; }
  sort(k,k+n,cmpc);
  while (le<ri) {
    h=(le+ri)/2;
    long long lll=solve(h);
    if (lll>=s) ri=h; else le=h+1;
  }
  printf("%lld\n",ri);
  return 0;
}


Measured memory_bytes: 3328
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define For(i,j,k) for(int i=j;i<=k;i++)
#define Dow(i,j,k) for(int i=j;i>=k;i--)
#define LL long long
using namespace std;

inline int read() {
	int x = 0,f = 1;
	char ch = getchar();
	while(ch<'0'||ch>'9') { if(ch=='-') f = -1; ch = getchar(); }
	while(ch>='0'&&ch<='9') { x = x *10+ch-48 ; ch = getchar(); }
	return x * f ;
}

const int N = 311;
int n,m,ans;
int a[N][N],cnt[N],vis[N];

int main() {
	n = read(); m = read();
	For(i, 1, n) 
	  For(j, 1, m) a[i][j]=read();
	For(i, 1, m) vis[i] = 1; 
	ans = n;
	For(T, 1, m) {
		memset(cnt,0,sizeof cnt);
		For(i, 1, n) 
		  For(j, 1, m) 
		    if(vis[a[i][j]]) {
		    	++cnt[a[i][j]];
		    	break;
			}
		int Mx = 0,id = 0;
		For(i, 1, m) 
			if( cnt[i] > Mx ) Mx = cnt[i],id = i;
		ans = min(Mx,ans);
		vis[id] = 0;
	} 
	printf("%d\n",ans); 
	return 0;
}


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

int main() {
  ll N, T;
  cin >> N >> T;
  vector<ll> t(N);

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

  ll ans = 0;
  for(ll i = 0; i < N - 1; i++) {
    if(t[i+1] - t[i] >= T) {
      ans += T;
    }else {
      ans += t[i+1] - t[i];
    }
  }
  ans += T;
  cout << ans << endl;
}


Measured memory_bytes: 1792
from itertools import accumulate
from operator import add

N, Q = map(int, input().split())
S = input()
idx_list = [1 if S[i:i + 2] == 'AC' else 0 for i in range(len(S) - 1)]
idx_list_cumsum = [0] + list(accumulate(idx_list, add))

for _ in range(Q):
  l, r = map(int, input().split())
  print(idx_list_cumsum[r - 1] - idx_list_cumsum[l - 1])


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


int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];

    sort(d.begin(), d.end());

    cout << d[n / 2] - d[n / 2 - 1];
}


Measured memory_bytes: 640
import numpy as np

N, K = map(int, input().split(' '))
H = list(map(int, input().split(' ')))

minimum_cost = np.zeros(N, dtype=int)
H = np.array(H)

for i in range(1, N):
    start = max(0, i-K)
    minimum_cost[i] = min(minimum_cost[start:i]
                          + np.abs(H[i] - H[start:i]))

print(minimum_cost[-1])


Measured memory_bytes: 22828
using namespace std;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(ll i=0;i<n;i++)
#define Rip(i,n) for(ll i=1;i<n;i++)
#define all(V) V.begin(),V.end()
#define ll long long
#define ld long double
#define MOD 998244353
#define mod MOD
#define sec setprecision
constexpr double eps = 1e-9;
constexpr double PI = 3.141592653589793238462643383279;
ll gcd(ll a, ll b) {
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
int ketasuu(ll h) {
	if (h < 0)return(-(ketasuu(-h)));
	else if (h < 10)return(1);
	else return(1 + ketasuu(h / 10));
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
vector<ll> soinnsuubunnkai(ll n) {
	vector<ll>a;
	while (n % 2 == 0) {
		a.push_back(2);
		n /= 2;
	}
	ll f = 3;
	while (f * f <= n) {
		if (n % f == 0) {
			a.push_back(f);
			n /= f;
		}
		else f += 2;
	}
	if (n != 1)
		a.push_back(n);
	return(a);
}
// 二項係数計算
long long com(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
ll pow(ll a, ll b) {
	a = a % mod;
	if (b == 0)return(1);
	else if (b % 2 == 0)return(pow((a * a) % mod, b / 2));
	else return(a * (pow(a, b - 1)));
}
void solve() {
	char s[4];
	cin >> s;
	sort(s,s+4);
	if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3])cout << "Yes" << endl;
	else cout << "No" << endl;
}
int main() {
	solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) < (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[8] = { //移動
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL

struct Edge {
	int from, to;
	ll w;
};
typedef vector<vector<Edge>> Graph;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}

ll gettugibaisu(ll from, ll k) {

	ll ret = ((from + k - 1) / k) * k;

	return ret;
}

ll getmaebaisu(ll to, ll k) {

	ll ret = (to / k) * k;

	return ret;
}
class Loli {
	char str[601];
	int hash[601], pw[601];
	int mod = 1000000007, base = 1007;
	int len;
public:
	Loli() {};
	
	void setstr(char *str2, int n) {
		strcpy(str,str2);
		len = n;
		hash[0] = 0;
		pw[0] = 1;
		rep(i, 1, len + 1) {
			pw[i] = ((ll)pw[i - 1] * base) % mod;
			hash[i] = ((ll)hash[i - 1] * base + (int)str[i - 1]) % mod;
		}
	}

	inline int gethash(int l, int r) {//半開
		return  (hash[r] - (ll)hash[l] * pw[r - l] % mod + mod) % mod;
	}
};


signed main(void) {

	int n;
	cin >> n;
	int l = 2 * n - 1;
	char s[601][601];
	Loli lsh[601], lsv[601];

	REP(i, n) {
		char st[301];
		scanf("%s",st);
		strcpy(s[i], st);
		strcpy(s[i] + n, st);
		if (i != n - 1)
			strcpy(s[i + n], s[i]);
	}
	REP(i, l) {
		lsh[i].setstr(s[i], l);
	}
	REP(i, l) {
		char buf[600];
		REP(j, l) {
			buf[j] = s[j][i];
		}
		lsv[i].setstr(buf, l);
	}

	int cou = 0;
	REP(x, l - n + 1) {
		REP(y, l - n + 1) {
			bool f = true;
			REP(i, n) {
				if (lsh[y + i].gethash(x + 1 + i, x + n) != lsv[x + i].gethash(y + 1 + i, y + n)) {
					f = false;
					break;
				}
			}
				cou+=f;
		}
	}

	printf("%d\n",cou);
	return 0;
}



Measured memory_bytes: 6912
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
int main(){
    vector<int> A = {1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    int x, y;
    cin >> x >> y;
    cout << (A[x-1] == A[y-1] ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
<?php

class Operator
{
    private $operations;
    private $operations_count;

    public function doOperations()
    {
        fscanf(STDIN, '%d', $this->operations_count);
        $this->linked_list = new \SplDoublyLinkedList();
        for (;$this->operations_count > 0;$this->operations_count -= 1) {
            $operation = explode(' ', trim(fgets(STDIN)));
            if ($operation[0] === 'insert') {
                $this->linked_list->unshift($operation[1]);
            } elseif ($operation[0] === 'deleteFirst') {
                $this->linked_list->shift();
            } elseif ($operation[0] === 'deleteLast') {
                $this->linked_list->pop();
            } elseif ($operation[0] === 'delete') {
                foreach ($this->linked_list as $key => $element) {
                    if ($element === $operation[1]) {
                        $this->linked_list->offsetUnset($key);
                        break;
                    }
                }
            }
        }
    }

    public function getAnswer()
    {
        $keys_operated = array();

        while (count($this->linked_list) > 0) {
            $keys_operated[] = $this->linked_list->shift();
        }
        echo implode(' ', $keys_operated), PHP_EOL;
    }
}

$operator = new Operator();
$operator->doOperations();
$operator->getAnswer();



Measured memory_bytes: 136156
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let k = read_as_vec::<u32>()[0];
    let line = read_as_vec::<u32>();
    let (a, b) = (line[0], line[1]);

    for i in a..=b{
        if i%k == 0{
            println!("OK");
            return;
        }
    }
    println!("NG");
}


Measured memory_bytes: 2120
import sys
n,m = map(int,input().split())
s = []
c = []
for i in range(m):
    ts,tc = map(int,input().split()) 
    s.append(ts)
    c.append(tc)
ans = [0]*n
c_ans = [0]*n
for i in range(m):
    if s[i] == 1 and c[i] == 0 and n !=1:
        print(-1)
        sys.exit()
        

for i in range(m):
    if c_ans[s[i]-1] == 1:
        if ans[s[i]-1] != c[i]:
            print(-1)
            sys.exit()
    else:
        c_ans[s[i]-1] = 1
        ans[s[i]-1] = c[i]
ans = list(map(str,ans))
# print("".join(ans))
ans2 = "".join(ans)
ans2 = int(ans2)
# print(ans)
# print(len(str(ans)))
# print(ans)
if len(str(ans2)) != n:
    ans[0] = "1"
#  print(-1)
#     sys.exit()
print("".join(ans))

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

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

int w, h, xs, ys, xg, yg, G[MAX+2][MAX+2];

bool dfs(int x, int y, int color){
	if(color == 0 || G[x][y] != color) return false;
	if(x==xg&&y==yg) return true;
	G[x][y] = 0;
	for(int r=0; r<4; r++){
		if(dfs(x+dx[r], y+dy[r], color)) return true;
	}
	return false;
}

int main(void)
{
	int n, c, d, bx, by;
	while(cin>>w>>h, w&&h){
		for(int x=0; x<w+2; x++){
			for(int y=0; y<h+2; y++){
				G[x][y] = 0;
			}
		}
		cin >> xs >> ys >> xg >> yg >> n;
		for(int i=0; i<n; i++){
			cin >> c >> d >> bx >> by;
			for(int i=0; i<4; i++){
				for(int j=0; j<2; j++){
					if(d==0) G[bx+i][by+j] = c; 
					else G[bx+j][by+i] = c;
				}
			}
		}
		if(dfs(xs, ys, G[xs][ys])) cout << "OK" << endl;
		else cout << "NG" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
	int N;
	cin >> N;

	vector<int> v(N * 3);

	for (int i = N * 3 - 1; i >= 0; i--)
		cin >> v[i];

	sort(v.begin(), v.end(), std::greater<int>());

	long long sum = 0;
	for (int i = 0; i < N; i++) {
		sum += v[i * 2 + 1];
	}

	cout << sum << endl;

	return 0;
}



Measured memory_bytes: 1408
def resolve():
    n = int(input())
    prev = None

    arr = map(int, input().split(" "))

    for a in arr:
        if prev is not None:
            if a - prev > 0:
                a -= 1
            elif a - prev < 0:
                print("No")
                return
        else:
            a -= 1

        prev = max(a, 1)

    print("Yes")

resolve()

Measured memory_bytes: 60268
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<int> p,q;
    for(int i=0;i<n;i++){
        int v;
        cin >> v;
        p.push_back(v);
    }
    for(int i=0;i<n;i++){
        int v;
        cin >> v;
        q.push_back(v);
    }

    vector<int> r;
    for(int i=0;i<n;i++){
        r.push_back(i+1);
    }

    int a,b,counter=0;
    do{
        counter++;
        if(r==p) a=counter;
        if(r==q) b=counter;

    }while(next_permutation(r.begin(),r.end()));

    cout << abs(b-a) << endl;
}

Measured memory_bytes: 3596
{-# LANGUAGE ScopedTypeVariables #-}
import Data.List
import Control.Monad

modif::Int->String
modif i = let n =  length (show i) in (take (6-n) (repeat '0'))++(show i)

sort_sort::[(Int,Int)]->[(Int,Int)]
sort_sort = (map (\ ((i,p),n) -> (p,n)) ).
            (sortBy (\ ((i1,_),_) -> \ ((i2,_),_) -> compare i1 i2)).
            concat.
            (map ((\ l -> zip l [1..]).map (\(i,(p,_))->(i,p)))).
            (map (sortBy (\ (_,(_,y1)) -> \ (_,(_,y2)) -> compare y1 y2))).
            (groupBy (\ (_,(p1,_)) -> \ (_,(p2,_)) -> p1 == p2)).
            (sortBy (\ (_,(p1,_)) -> \ (_,(p2,_)) -> compare p1 p2)).
            (zip [(1::Int) ..])



sort_sort2::[(Int,Int)]->[(Int,Int)]
sort_sort2 =  (map (\ ((i,p),n) -> (p,n)) ).
              (sortBy (\ ((i1,_),_) -> \ ((i2,_),_) -> compare i1 i2)).
              concat.
              (map ((\ l -> zip l [1..]).map (\(i,(p,_))->(i,p)))).
              (groupBy (\ (_,(p1,_)) -> \ (_,(p2,_)) -> p1 == p2)).
              (sortBy (\ (_,(p1,_)) -> \ (_,(p2,_)) -> compare p1 p2)).
              (sortBy (\ (_,(_,y1)) -> \ (_,(_,y2)) -> compare y1 y2)).
              (zip [(1::Int) ..])

sort_sort3::[(Int,Int)]->[(Int,Int)]
sort_sort3 =  (map (\(i,(p,n)) -> (p,n))).
              (sortBy (\ (i1,_) -> \ (i2,_) -> compare i1 i2)).
              (\ ((i,(p,y)):rest) -> ((i,(p,1)):(numbering p 1 rest))).
              (sortBy (\ (_,x1) -> \ (_,x2) -> compare x1 x2)).
              (zip [(1::Int) ..])

numbering::Int->Int->[(a,(Int,Int))]->[(a,(Int,Int))]
numbering prev_pref prev_num []     = []
numbering prev_pref prev_num ((a,(p,y)):xs) = if p == prev_pref then (a,(p,prev_num+1)):(numbering prev_pref (prev_num+1) xs)
                                                         else (a,(p,1)):(numbering p 1 xs)
solver::[(Int,Int)]->[String]
solver = (map (\(p,n) -> (modif p)++(modif n))).sort_sort3

main::IO()
main=do
  nmc<-getLine
  let n:m:[]=map read (words nmc)
  dat<-forM [1..m] (\_-> do
                    py<-getLine
                    let p:y:[]= map read (words py)
                    return (p,y))
  forM_ (solver dat) (\ str -> do
                                putStr str
                                putStr "\n")


Measured memory_bytes: 150908
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
#include<random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const int MOD=1e9+7;

int main(){

  int x, ans = 0;
  cin >> x;
  ans += x / 500 * 1000;
  x %= 500;
  ans += x / 5 * 5;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    //--<for debugging>
    #define whatis(x) cout << #x << " is " << x<<" ";
    #define whatisl(x) cout << #x << " is " << x<<"\n";
    #define parr(array,end)for(ll loop=0;loop<end;loop++)cout<<array[loop]<<" ";cout<<"\n";
    #define lline cout<<"\n";
    #define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"\n";}
    #define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"___";}
        
    void err(istream_iterator<string> it) {}
    template<typename T, typename... Args>
    void err(istream_iterator<string> it, T a, Args... args) {
        cout << *it << " = " << a <<" , ";
        err(++it, args...);
    }
    //--</for debugging> 
    #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
    #define testcase ll tt; cin >> tt; while(tt--)
    #define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
    #define pb push_back 
    #define vars ll h,i,j,k,d,l,p,q,r,x,y,a,b,c,v,var,n,m,z,s,ans,ind1,ind2,flag,limit1,limit2,limit3,mod;string str;
    #define vll vector<ll>
    #define pll pair<ll,ll>
    #define sll set<ll>
    #define pint pair<int,int>
    const ll INF=1e9+7;
    const ll MOD=1e9+7;
    const string yes="YES\n";
    const string no="NO\n";
    int main()
    {
        boost vars
        //freopen("input.txt","r",stdin);
        //freopen("output.txt","w",stdout);
        s=0;
        cin>>n;
        ll arr[n];
        for(i=0;i<n;i++)cin>>arr[i];
        v=arr[0];
        for(i=1;i<n;i++)
        {
            if(arr[i]<v)s+=v-arr[i];
            v=max(v,arr[i]);
        }
        cout<<s;
    }

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 1<<18 , mo = 998244353;

inline lint powa(lint a,lint t)
{
	lint b=1;
	while(t){if(t&1)b=b*a%mo;a=a*a%mo,t>>=1;}
	return b;
}

inline lint inva(lint a){return powa(a,mo-2);}

const int inv2 = inva(2);

inline void fwtxor(lint a[],int nn,int dir)
{
	for(int i=1;i<nn;i<<=1)
		for(int j=0;j<nn;j+=i+i)
			for(int k=0;k<i;k++)
			{
				lint x=a[j+k],y=a[j+k+i];
				a[j+k]=(x+y)%mo,a[j+k+i]=(x-y+mo)%mo;
				if(dir<0)a[j+k]=a[j+k]*inv2%mo,a[j+k+i]=a[j+k+i]*inv2%mo;
			}
}

int n,nn;
lint gai[_]={0},sgai=0;
lint f[_],g[_],h[_]={0};

int main()
{
	n=ty(),nn=1<<n;
	for(int i=0;i<nn;i++)gai[i]=ty(),sgai=(sgai+gai[i])%mo;
	for(int i=0,x=inva(sgai);i<nn;i++)gai[i]=gai[i]*x%mo;

	f[0]=(gai[0]-1+mo)%mo;
	for(int i=1;i<nn;i++)f[i]=gai[i];
	h[0]=(powa(2,n)-1+mo)%mo;
	for(int i=1;i<nn;i++)h[i]=mo-1;

	fwtxor(f,nn,1),fwtxor(h,nn,1);
	for(int i=0;i<nn;i++)g[i]=h[i]*inva(f[i])%mo;
	fwtxor(g,nn,-1);

	for(int i=0;i<nn;i++)printf("%lld\n",(g[i]-g[0]+mo)%mo);

	return 0;
}


Measured memory_bytes: 11008
#include<bits/stdc++.h>
using namespace std;
#define INF 2000000000
#define N 2000
#define pb push_back
typedef long long LL;
int n;
vector<LL> a, b, h;

void printlog() {
    while (h.size() > 1) {
        if (h[0] == 0) b.pb(0), h.erase(h.begin());
        if (h[h.size() - 1] == 0) b.pb(h.size() - 1), h.erase(h.begin() + h.size() - 1);
        for(int i = 1; i < h.size() - 1; i++) {
            if (h[i]) continue;
            if ((h[i - 1] == 1 && h[i + 1] == 1) || (h[i - 1] == 0 && h[i + 1] == 0)) {
                b.pb(i);
                h.erase(h.begin() + i, h.begin() + i + 2);
                break;
            }
        }
    }
    cout << b.size() << endl;
    for(int i = 0; i < b.size(); i++) cout << b[i] + 1 << endl;
}

int main() {
    cin >> n;
    for(int i = 0; i < n; i++) {
        LL tmp; cin >> tmp; 
        a.pb(tmp), h.pb(0);
    }
    bool all_neg = 1;
    for(int i = 0; i < n; i++) all_neg &= (a[i] < 0);
    if (all_neg) {
        int pos = 0; LL ans = a[0];
        for(int i = 1; i < n; i++) 
            if (a[i] > ans) ans = a[i], pos = i;
        cout << ans << endl, h[pos] = 1;
    } else {
        LL x = 0, y = 0;
        for(int i = 1; i < n; i += 2) if (a[i] >= 0) x += a[i];
        for(int i = 0; i < n; i += 2) if (a[i] >= 0) y += a[i];
        cout << max(x, y) << endl;
        if (x > y) { for(int i = 1; i < n; i += 2) if (a[i] >= 0) h[i] = 1; }
        else { for(int i = 0; i < n; i += 2) if (a[i] >= 0) h[i] = 1; }
    }
    printlog();
}

Measured memory_bytes: 256
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

x = [a,b,c,d,e]
if n % min(x) == 0:
  print(n//min(x) + 4)
else:
  print(n//min(x) + 5)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int N; cin >> N;
    vector<int> A(N+1); for (auto &a : A) cin >> a;
    vector<int> B(N); for (auto &b : B) cin >> b;
    Int ans = 0;
    for (int i = 0; i < N; i++) {
        int s = min(A[i], B[i]);
        A[i] -= s;
        B[i] -= s;
        int t = min(A[i+1], B[i]);
        A[i+1] -= t;
        ans += s + t;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
//#include <unordered_map>
#include <string>
//typedef long long LL;
//typedef long double LD;
using namespace std;

//#define MOD 1000000007

int main() {
    string s;
    cin >> s;
    for(int i=0; i<s.size(); i++){
        s[i]='x';
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int w, h, i, j, maze[65][65], W[65][65], a, min;
    while (1) {
        scanf("%d %d", &w, &h);
        if (w==0 && h==0) break;
        
        for (i=1; i<=2*w+1; i++) maze[1][i]=100000;
        for (i=1; i<=2*w+1; i++) maze[2*h+1][i]=100000;
        for (i=1; i<=2*h+1; i++) maze[i][1]=100000;
        for (i=1; i<=2*h+1; i++) maze[i][2*w+1]=100000;
        
        for (i=2; i<=2*h; i++) {
            for (j=2; j<=2*w; j++) {
                if (i%2==1 && j%2==1) maze[i][j]=100000;
                else maze[i][j]=0;
            }
        }
        
        for (i=1; i<=2*h-1; i++) {
            if (i%2==1) {
                for (j=1; j<=w-1; j++) {
                    scanf("%d", &W[i][j]);
                    maze[i+1][2*j+1]=100000*W[i][j];
                }
            }
            else {
                for (j=1; j<=w; j++) {
                    scanf("%d", &W[i][j]);
                    maze[i+1][2*j]=100000*W[i][j];
                }
            }
        }
        maze[2][2]=1;
        
        a=1;
        while (a==1) {
            a=0;
            for (i=2; i<=2*h; i++) {
                for (j=2; j<=2*w; j++) {
                    min=100000;
                    if (maze[i-1][j]<min && maze[i-1][j]!=0) min=maze[i-1][j];
                    if (maze[i][j-1]<min && maze[i][j-1]!=0) min=maze[i][j-1];
                    if (maze[i][j+1]<min && maze[i][j+1]!=0) min=maze[i][j+1];
                    if (maze[i+1][j]<min && maze[i+1][j]!=0) min=maze[i+1][j];
                    if (min!=100000 && (maze[i][j]==0 && maze[i][j]!=100000)) {
                        maze[i][j]=min+1;
                        a=1;
                    }
                }
            }
        }

        printf("%d\n", (maze[2*h][2*w]+1)/2);
    }
    return 0;
}


Measured memory_bytes: 2080
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(void){

    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    int x[N];
    int y[M];

    for(int i = 0; i < N; i++){
        cin >> x[i];
    }
    for(int j = 0; j < M; j++){
        cin >> y[j];
    }

    bool isExistX = false;
    bool isExistY = false;
    int cx = 0;
    int cy = 0;
    for(int k = X + 1; k <= Y; k++){
        for(int i = 0; i < N; i++){
            if(x[i] >= k){
                cx = 0;
                isExistX = false;
                continue;
            }else{
                cx++;
                if(cx == N){
                    isExistX = true;
                }
            }
        }

        for(int i = 0; i < M; i++){
            if(y[i] < k){
                cy = 0;
                isExistY = false;
                continue;
            }else{
                cy++;
                if(cy == M){
                    isExistY = true;
                }
            }
        }

        if(isExistX && isExistY){
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 256
#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 G = vector<vector<int>>;
    
int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    for(ll i=k; i<n; i++){
        if(a[i-k]<a[i]) cout << "Yes";
        else cout << "No";
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 4828
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};

int main(){
  int n; cin>>n;
  set<int> s;
  rep(i,n){
    int x; cin>>x;
    s.insert(x);
  }
  int q; cin>>q;
  vector<int> t(n); rep(i,q) cin>>t[i];
  ll cnt=0;
  rep(i,q){
    if(s.count(t[i])) cnt++;
  }
  cout<<cnt<<endl;
}



Measured memory_bytes: 7760
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

char str[105];

int main(int argc, char* argv[])
{
    scanf("%s", str);
    int n=strlen(str);
    int i;
    for(i=0; i<n; i++) {
        if(i%2==0) {
            if(str[i]=='L') {
                printf("No\n"); return 0;
            }
        }
        else {
            if(str[i]=='R') {
                printf("No\n"); return 0;
            }
        }
    }
    printf("Yes\n");

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#pragma warning(disable:4996)

int main() {

	int cnt[4] = { 0, };
	
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		fflush(stdin);
		char ch[5] = { 0, };
		scanf("%s", ch);
		if (strcmp(ch, "AC")==0)
			cnt[0]++;
		else if (strcmp(ch, "WA")==0)
			cnt[1]++;
		else if (strcmp(ch, "TLE")==0)
			cnt[2]++;
		else if (strcmp(ch, "RE")==0)
			cnt[3]++;
	}
	printf("AC x %d\n", cnt[0]);
	printf("WA x %d\n", cnt[1]);
	printf("TLE x %d\n", cnt[2]);
	printf("RE x %d\n", cnt[3]);
	

	return 0;
}

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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int N;
VI2 A;
VI2 memo;

LL dp(int i, int j) {
    if(memo[i][j] != -1)     return memo[i][j];
    if(i == 1 && j == N - 1) return A[1][N-1];
    if(i >= 2 || j >= N)     return -1;

    if(i == 0) {
        if(j == N - 1) {
            LL next = dp(i+1, j);
            return (memo[i][j] = (next + A[i][j]));
        } else {
            LL next = std::max(dp(i, j+1), dp(i+1, j));
            return (memo[i][j] = (next + A[i][j]));
        }
    } else if (i == 1) {
        LL next = dp(i, j+1);
        return (memo[i][j] = (next + A[i][j]));
    }
    return 0;
}

int main() {
    std::cin >> N;
    A.resize(2, VI(N));

    REP(i, 2) {
        REP(j, N) {
            std::cin >> A[i][j];
        }
    }
    memo.resize(2, VI(N, -1));

    long long ans = dp(0, 0);

    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
import math

def plot(x,y):
    print(f'{x:.8f} {y:.8f}')
    
def Koch(n,x1,y1,x2,y2):
    if n==0:
        plot(x1,y1)
        return
    sx=(2*x1+x2)/3
    sy=(2*y1+y2)/3
    tx=(x1+2*x2)/3
    ty=(y1+2*y2)/3
    ux=(tx-sx)*(1/2)-(ty-sy)*(math.sqrt(3)/2)+sx
    uy=(tx-sx)*(math.sqrt(3)/2)+(ty-sy)*(1/2)+sy
    Koch(n-1,x1,y1,sx,sy)
    Koch(n-1,sx,sy,ux,uy)
    Koch(n-1,ux,uy,tx,ty)
    Koch(n-1,tx,ty,x2,y2)
    
n=int(input())
Koch(n,0,0,100,0)
print('100.00000000 0.00000000')


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

using namespace std;

typedef long long ll;

struct LCA{
    static const int BITLEN_MAX = 30;
    vector<int> parent[BITLEN_MAX];
    vector<int> depth;
    int bitlen;

    void initialize(int N, const vector<int> edges[]){
        int root = 0;
        bitlen = 1;
        while((1<<bitlen) < N) bitlen += 1;
        for(int i=0; i<bitlen; i++) parent[i].resize(N);
        depth.resize(N, -1);

        dfs(root, -1, 0, edges);
        for(int k=0; k<bitlen-1; k++){
            for(int v=0; v<N; v++){
                if(depth[v] == -1) continue;
                if(parent[k][v] < 0){
                    parent[k+1][v] = -1;
                }else{
                    parent[k+1][v] = parent[k][parent[k][v]];
                }
            }
        }
    }

    void dfs(int v, int p, int d, const vector<int> edges[]){
        parent[0][v] = p;
        depth[v] = d;
        for(auto u : edges[v]){
            if(u != p) dfs(u, v, d+1, edges);
        }
    }

    int calc_lca(int u, int v){
        if(depth[u] > depth[v]) swap(u, v);
        for(int k=0; k<bitlen; k++){
            if( ((depth[v]-depth[u]) >> k) & 1 ) v = parent[k][v];
        }
        if(u == v) return u;
        for(int k=bitlen-1; k>=0; k--){
            if(parent[k][u] != parent[k][v]){
                u = parent[k][u];
                v = parent[k][v];
            }
        }
        return parent[0][u];
    }

    int calc_dist(int u, int v){
        int l = calc_lca(u, v);
        return depth[u] + depth[v] - depth[l]*2;
    }
};

int N;
vector<vector<int>> edges[101010];
vector<int> edges2[101010];

vector<int> need[101010];
map<int, int> res_num[101010], res_sum[101010];

int dist[101010];
int now_num[101010], now_sum[101010];


void dfs(int i, int p){
	for(int c : need[i]){
		res_num[i][c] = now_num[c];
		res_sum[i][c] = now_sum[c];
	}

	for(vector<int> e : edges[i]){
		int j = e[0], c = e[1], d = e[2];
		if(j == p) continue;

		dist[j] = dist[i] + d;
		now_num[c]++;
		now_sum[c] += d;
		dfs(j, i);
		now_num[c]--;
		now_sum[c] -= d;
	}
}

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

	int Q;
	cin >> N >> Q;

	rep(i, N-1){
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		a--; b--; c--;

		edges[a].push_back({b, c, d});
		edges[b].push_back({a, c, d});
		edges2[a].push_back(b);
		edges2[b].push_back(a);
	}

	LCA lca;
	lca.initialize(N, edges2);

	vector<int> X(Q), Y(Q), U(Q), V(Q), L(Q);
	rep(i, Q){
		cin >> X[i] >> Y[i] >> U[i] >> V[i];
		X[i]--; U[i]--; V[i]--;

		L[i] = lca.calc_lca(U[i], V[i]);
		need[U[i]].push_back(X[i]);
		need[V[i]].push_back(X[i]);
		need[L[i]].push_back(X[i]);
	}

	dfs(0, -1);

	rep(i, Q){
		int x = X[i], y = Y[i], u = U[i], v = V[i], l = L[i];

		int du = dist[u] - res_sum[u][x] + res_num[u][x] * y;
		int dv = dist[v] - res_sum[v][x] + res_num[v][x] * y;
		int dl = dist[l] - res_sum[l][x] + res_num[l][x] * y;
		int ans = du + dv - 2 * dl;
		cout << ans << endl;
	}
}


Measured memory_bytes: 74676
import itertools

N,M,Q = map(int,input().split())
a=[]
b=[]
c=[]
d=[]
for i in range(0,Q,1):
    tmp = list(map(int,input().split()))
    a.append(tmp[0])
    b.append(tmp[1])
    c.append(tmp[2])
    d.append(tmp[3])

max_score = -1
for i in itertools.combinations_with_replacement(range(1,M+1,1),N):
    score = 0
    for j in range(0,Q,1):
        if i[b[j]-1]-i[a[j]-1]==c[j]:
            score += d[j]
    if max_score < score:
        max_score = score

print(max_score)


Measured memory_bytes: 9164
a,b,c,d,e,f = gets.split.map(&:to_i)

answater = a
anssugar = 0
ansconcentration = 0

(30/a+1).times{|i|
  (30/b+1).times{|j|
    water = a*i+b*j
    break if water*100>f
    (f/c+1).times{|k|
      (f/d+1).times{|l|
        sugar = c*k+d*l
        next if water==0
        next if sugar>e*water || water*100+sugar>f
        concentration = sugar/(water*100+sugar).to_f
        if ansconcentration<concentration then
          answater = water
          anssugar = sugar
          ansconcentration = concentration
        end
      }
    }
  }
}

puts [answater*100+anssugar, anssugar]*' '

Measured memory_bytes: 1788
import java.io.BufferedReader;
import java.io.InputStreamReader;

// ÜèÉàüµ­È¢¦BvÄl
//public class Problem0008_SumOf4Integers {
public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			String line;
			
			while((line = reader.readLine()) != null) {
				int number = Integer.parseInt(line);
				int result = 0;
				for(int i = 0; i < 10; i++) {
					if(-1 < number - i && number - i < 28) {
						for(int j = 0; j < 10; j++) {
							if(-1 < number - i -j && number - i - j < 19) {
								for(int k = 0; k < 10; k++) {
									if(-1 < number -i -j -k && number -i -j -k < 10) {
										result++;
									}
								}
							}
						}
					}
				}
				System.out.println(result);
			}
			
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 9176