akhauriyash/Code-Regression huggingface dataset:
import numpy as np


class FastFourierTransform:
	"""FFT
	"""

	def multiplySameArr(self,A):
		""" multiply by FFT(A*A)
		"""
		N=1
		# 1. N > deg(g) + deg(h)となる2の冪乗を選ぶ
		while N < 2*len(A): N *= 2

		# 2. 離散フーリエ変換の計算
		nf = np.zeros(N,int)
		nf[:len(A)]=A
		nf=np.fft.fft(nf)
		nf = nf * nf

		# 3. 離散フーリエ逆変換
		nf=np.fft.ifft(nf)

		# コピー
		ans = np.zeros(N,int)
		for n in range(N):
			# 係数を1/N倍 => np.fftの場合、すでに実行済
			#ans.append( round(nf[n].real / N) )
			if nf[n].real != 0:
				ans[n] = int(nf[n].real + 0.5)

		return ans

if __name__ == "__main__":
	N=int(input())
	A=list(map(int,input().split()))

	P=200_003
	rootP=2

	# order of 1 to P-1 after fft
	order=[1]
	x=rootP
	while x!=1:
		order.append(x)
		x *= rootP
		x %= P

	ORDER_SIZE=len(order)	# 200_002

	# create order index
	where=np.zeros(P,int)
	for i in range(ORDER_SIZE):
		where[ order[i] ] = i

	# count non zero items
	prevCnt = np.zeros(P,int)
	resCnt = np.zeros(P,int)
	for n in range(N):
		if A[n] != 0:
			prevCnt[ where[A[n]] ] += 1
			# remove Ax * Ax pattern count
			resCnt[ (A[n] * A[n]) % P ] -= 1

	# fft to cnt (calc nC2 and all Ax * Ay)
	clsFFT = FastFourierTransform()
	fftRes = clsFFT.multiplySameArr(prevCnt)

	for r in range(len(fftRes)):
		if fftRes[r] != 0:
			# get result(Ax*Ay==resCnt.index) Cnt by summary fftRes
			resCnt[ order[ r % ORDER_SIZE ] ] += fftRes[r]

	ans = 0
	for p in range(P):
		if resCnt[p] != 0:
			# remove j <= i pattern count 
			# and
			# calc summary value((Ax * Ay cnt) * (Ax * Ay)))
			ans += (resCnt[p] // 2) * p

	print(ans)



Measured memory_bytes: 81128
N = int(input())
H = list(map(int, input().split()))

Cost = [0 for i in range(N)]
Cost[0] = 0
Cost[1] = abs(H[1] - H[0])

for i in range(2, N) :
    Cost[i] = min(Cost[i - 1] + abs(H[i] - H[i - 1]), Cost[i - 2] + abs(H[i] - H[i - 2]))

print(Cost[N - 1])

Measured memory_bytes: 52856
n = int(input())
ss = {}
for i in range(n):
    s = input()
    if s[0] in ['M', 'A', 'R', 'C', 'H']:
        if s[0] in ss.keys():
            ss[s[0]] += 1
        else:
            ss[s[0]] = 1

sss = list(ss.values())
res = 0
if len(ss.keys()) <= 2:
    res = 0
elif len(ss.keys()) == 3:
    res = sss[0] * sss[1] * sss[2]
elif len(ss.keys()) == 4:
    res = sss[0] * sss[1] * sss[2] + sss[0] * sss[1] * sss[3] + sss[0] * sss[2] * sss[3] + sss[1] * sss[2] * sss[3]
elif len(ss.keys()) == 5:
    res = sss[0] * sss[1] * sss[2] + sss[0] * sss[1] * sss[3] + sss[0] * sss[1] * sss[4] + sss[0] * sss[2] * sss[3] \
          + sss[0] * sss[2] * sss[4] + sss[0] * sss[3] * sss[4] + sss[1] * sss[2] * sss[3] + sss[1] * sss[2] * sss[4] \
          + sss[1] * sss[3] * sss[4] + sss[2] * sss[3] * sss[4]
print(res)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

string dp[55];
string s[55];
map<string, int> mp;

bool ischar(char c){
    if('a'<=c&&c<='z')return true;
    if('A'<=c&&c<='Z')return true;
    if(c=='['||c==']'||c==':'||c=='*')return true;
    return false;
}
string rec(int idx){
    if(dp[idx]!="")return dp[idx];
    string ret="";
    int i=1;
    while(ischar(s[idx][i]))++i;
    while(1){
        ++i;
        if(s[idx][i]=='*')break;
        if(s[idx][i]=='['){
            char cur=0;
            while(ischar(s[idx][i])){
                if(s[idx][i]=='A')cur+=8;
                if(s[idx][i]=='T')cur+=4;
                if(s[idx][i]=='G')cur+=2;
                if(s[idx][i]=='C')cur+=1;
                ++i;
            }
            ret+=cur;
        }
        else {
            string nxt="";
            while(ischar(s[idx][i])){
                nxt+=s[idx][i];++i;
            }
            ret+=rec(mp[nxt]);
        }
        if(ret.size()>300){
            ret.resize(300);
            return dp[idx]=ret;
        }
    }
    return dp[idx]=ret;
}

ll dpp[55][55][55][55];
int main(){
    int a,g,c,t;
    cin>>a>>g>>c>>t;
    int n;
    scanf("%d ",&n);
    rep(i,n){
        getline(cin,s[i]);
    }
    rep(i,n){
        s[i]+=" *";
        string na="";
        int j=0;
        while(s[i][j]!=':'){
            na+=s[i][j++];
        }
        mp[na]=i;
    }
    string res = rec(0);
    if(res.size()!=a+g+c+t){
        cout<<0<<endl;
        return 0;
    }
    dpp[0][0][0][0]=1;
    n=res.size();
    rep(i,51)rep(j,51)rep(k,51)rep(l,51){
        dpp[i][j][k][l]%=mod;
        if(i+j+k+l>=n)break;
        int cur=i+j+k+l;
        cur=res[cur];
        if(cur&8)dpp[i+1][j][k][l]+=dpp[i][j][k][l];
        if(cur&4)dpp[i][j+1][k][l]+=dpp[i][j][k][l];
        if(cur&2)dpp[i][j][k+1][l]+=dpp[i][j][k][l];
        if(cur&1)dpp[i][j][k][l+1]+=dpp[i][j][k][l];
    }
    cout<<dpp[a][g][c][t]<<endl;
    return 0;
}


Measured memory_bytes: 67228
/*******************************
* BASMILLAHHIR RAHMANNIR RAHIM *
* MD SHAHINUR RAHMAN           *
* DATE: 16/sep/2020            *
* DEPT. OF CSE                 *
* LEADING UNIVERSITY, SYLHET   *
*******************************/
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
#include<string>
#include<stdlib.h>
#include<math.h>
#define shahin std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
const int nax=1000*1007;
const int mod = 1e9 + 7;
 
using namespace std;
char wcz[nax];
 
bool fu(int a, int b){
    return (a>b);
}
int gcd(int x,int y){
    return x?gcd(y%x, x):y;
}
 
void fun(){
    ll tc,A=0,B=0;
    cin >> tc;
    while(tc--)
    {
                ll a, b;
                cin >> a>>b;
                if(a==b)A++;
                if(A==3)B=1;
                if(a!=b) A=0;
    }
    if(B==1)cout<<"Yes";
    else cout << "No";
}
int main()
{
    shahin
 /*   int tc,i=1,sum=0,A=0,B=0;
    cin >> tc;
    while(tc--)
    {
    //cout << "Case " << i << ": ";
        fun();
    //i++;
    }*/ 
    fun();
   
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

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

  int n, m; cin >> n >> m;
  vector<tuple<int, int, int> > tp(m);
  rep(i, m) {
    int p, y; cin >> p >> y;
    tp[i] = make_tuple(p, y, i);
  }
  sort(tp.begin(), tp.end());

  vector<pair<int, int> > id(m);
  vector<int> cnt(n+1, 0);
  rep(i, m) {
    int p, y, idx;
    tie(p, y, idx) = tp[i];
    cnt[p]++;
    id[idx] = make_pair(p, cnt[p]);
  }

  rep(i, m) {
    cout << setw(6) << setfill('0') << id[i].first;
    cout << setw(6) << setfill('0') << id[i].second << '\n';
  }
  return 0;
}


Measured memory_bytes: 3840
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N,p[56];

int main() {

	scanf("%d", &N);

	rep(i,N) scanf("%d", &p[i]);
	int s[56];
	rep(i, N) s[i] = p[i];
	sort(s, s + N);
	int c = 0;
	rep(i, N) {
		c += !!(s[i] - p[i]);
	}

	if (c <= 2) {
		printf("YES\n");
	}else
		printf("NO\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int mx = -1e10, mn = 1e10;
int main() {
    int n;
    cin >> n;
    for(int i=0; i<n; i++) {
        int a;
        scanf("%d", &a);
        mx = max(a, mx);
        mn = min(a, mn);
    }
    cout << mx - mn << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll a,b,c; cin>>a>>b>>c;
    if(a%2==0 || b%2==0 || c%2==0){
        cout<<0<<endl;
        return 0;
    }else{
        vector<ll> v={a,b,c};
        sort(v.begin(), v.end(), greater<ll>());
        cout<<v[1]*v[2]<<endl;
    }
    return 0;
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound


signed main() {
    int N, L;
    cin >> N >> L;
    int sum = 0;
    int minv = INF;
    rep(i, N) {
        int a = L + i;
        sum += a;
        if (abs(minv) > abs(a)) {
            minv = a;
        }
    }
    cout << sum - minv << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i_len=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back
#define mp make_pair

int main()
{
    ll N, K;
    cin >> N >> K;

    double p = 0.0;
    ll a, c;
    REP(i,1,N+1) {
        a = i;
        c = 1;
        while(a < K) {
            a = a << 1;
            c = c << 1;
        }
        p += 1.0 / c;
    }
    p /= N;
    cout << setprecision(12) << p << 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;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int i = 0;
    while(a > 0 && c > 0){
        if(i%2 == 0) c -= b;
        else a -= d;
        i++;
    }
    if(a > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;

const int inf=0x3f3f3f3f;
int n,m,sx,sy,pre_ver[111][111],pre_hor[111][111];
char s[111][111];

int dp[111][111][111],ndp[111][111][111];

int getver(int i,int j,int jj){return pre_ver[i][jj]-pre_ver[i][j-1];}
int gethor(int j,int i,int ii){return pre_hor[ii][j]-pre_hor[i-1][j];}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)
	{
		pre_ver[i][j]=pre_ver[i][j-1]+(s[i][j]=='o');
		pre_hor[i][j]=pre_hor[i-1][j]+(s[i][j]=='o');
		if(s[i][j]=='E')
		{
			sx=i;
			sy=j;
		}
	}
	
	int ans=0;
	dp[0][0][0]=0;
	for(int l=0;l<=sy-1;l++)
	{
		memset(ndp,0,sizeof(ndp));
		for(int r=0;r<=m-sy;r++)for(int u=0;u<=sx-1;u++)for(int d=0;d<=n-sx;d++)
		{
			ans=max(ans,dp[r][u][d]);
			int nl=max(sy-l,r+1),nr=min(sy+r,m-l),nu=max(sx-u,d+1),nd=min(sx+d,n-u);
			if(sy-l>r+1)ndp[r][u][d]=max(ndp[r][u][d],dp[r][u][d]+gethor(sy-l-1,nu,nd));
			if(sy+r<m-l)dp[r+1][u][d]=max(dp[r+1][u][d],dp[r][u][d]+gethor(sy+r+1,nu,nd));
			if(sx-u>d+1)dp[r][u+1][d]=max(dp[r][u+1][d],dp[r][u][d]+getver(sx-u-1,nl,nr));
			if(sx+d<n-u)dp[r][u][d+1]=max(dp[r][u][d+1],dp[r][u][d]+getver(sx+d+1,nl,nr));
		}
		memcpy(dp,ndp,sizeof(dp));
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

int main()
{
    long long n;
    cin >> n;
    char ch = 'a' - 1;
    string ans = "";
    while(n > 0){
        int lefted = n % 26;
        n = n/26;
        if(lefted > 0)
            ans += (ch + lefted);
        else{
            ans += 'z';
            n -= 1;
        }
    } 
    reverse(ans.begin(), ans.end());
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int i;
  if(n==2){
    cout << 2;
    return 0;
  }
  for(i=n;i<100004;i++){
    bool is=true;
    for(int j=2;j<n;j++){
      if(i%j==0){
        n++;
        is=false;
        break;
      }
    }
    if(is){
      cout << i;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
while(1){
int i,j,n,m,o=1,s=0;
static int p[1001]={0},up[1001*1001]={0};
scanf("%d%d",&n,&m);
if(n==0&&m==0)return 0;
for(i=1;i<=n;i++){
scanf("%d",&p[i]);
for(j=i;j>=0;j--){
up[o]=p[i]+p[j];
o++;
}
}
sort(up,up+o);
for(i=0;i<o;i++){
if(up[i]+*(upper_bound(up,up+o,m-up[i])-1)<=m)s=max(s,up[i]+*(upper_bound(up,up+o,m-up[i])-1));
}
printf("%d\n",s);
}
return 0;
}



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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int ans[510][510];

void solve(vector<int> v, int num){

  if(v.size()==1){
    return;
  }

  int n = v.size();
  int mid = (n + 1)/2;

  for(int i = 0; i < mid; i++){
    for(int j = mid; j < n; j++){
      ans[v[i]][v[j]] = num;
    }
  }

  vector<int> vec1, vec2;
  for(int i = 0; i < mid; i++){
    vec1.push_back(v[i]);
  }
  for(int i = mid; i < n; i++){
    vec2.push_back(v[i]);
  }

  solve(vec1, num+1);
  solve(vec2, num+1);

  return;

}

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

  int n;
  cin >> n;

  vector<int> a(n);
  rep(i, n){
    a[i] = i;
  }

  solve(a, 1);

  rep(i, n-1){
    rep(j, i+1, n){
      cout << ans[i][j] << " ";
    }
    cout << endl;
  }

  return 0;
}


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

using namespace std;

int a, b;

int main () {
	cin >> a >> b;
	if(a <= 0 && b >= 0 || a >= 0 && b <= 0) {
		cout << "Zero";
		return 0;
	}
	if(a < 0 && b < 0 && (a - b) % 2 == 0) {
		cout << "Negative";
	}
	else {
		cout << "Positive";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define mod 1000000007 
#define rep(i,j,l) for(int i=j;i<=l;i++)
#define dec(i,j,l) for(int i=j;i>=l;i--) 
#define setz(a) memset(a,0,sizeof(a)); 
using namespace std;
typedef long long ll;
typedef unsigned long long ull; 
/* int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; */ // 4 Direction
/* int dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1}; */ // 8 Direction
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction


int main()
{  ios_base::sync_with_stdio(0); 
   cin.tie(NULL);
   int m,n;
   cin>>m>>n;
   char c[m][n];
   ll a[m][n];    
   setz(a);
   rep(i,0,m-1)
    rep(j,0,n-1) 
    {  cin>>c[i][j];
    }  
    int i,j;
     i=0;j=0;
    while(c[0][j]=='.' && j<n) 
    {
        a[0][j]=1;
        j++;
    }
    i=0;j=0;
    while(c[i][0]=='.'&& j<m) 
    {
        a[i][0]=1;
        i++;
    }   
    
    rep(i,1,m-1) 
     rep(j,1,n-1) 
      {
          if(c[i][j]=='.')  
          {  
              if(c[i-1][j]=='.')
              a[i][j]=(a[i][j]%mod+a[i-1][j]%mod)%mod;
              if(c[i][j-1]=='.') 
              a[i][j]=(a[i][j]%mod+a[i][j-1]%mod)%mod;
              
          }
      }   
      cout<<a[m-1][n-1];
   return 0;            
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define ll long long
#define ull  unsigned long long
#define pb push_back

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 200000;
int a[N], cnt[N], d[N];
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w", stdout);
    int n;
    cin >> n;
    for (int i = 1; i < n; i++){
        int u, v, x;
        cin >> u >> v >> x;
        a[u] ^= x;
        a[v] ^= x;
    }
    for (int i = 0; i < n; i++){
        cnt[a[i]]++;
    }
    int ans = 0;
    int s = 0;
    for (int i = 1; i < 16; i++){
        ans += cnt[i] / 2;
        if (cnt[i] % 2) s |= (1 << i);
    }
    for (int i = 0; i < (1 << 16); i++) d[i] = 1e9;
    d[s] = 0;
    queue < int > q;
    q.push(s);
    while(!q.empty()){
        int mask = q.front();
        q.pop();
        for (int i = 1; i < 16; i++){
            if (mask & (1 << i))
            for (int j = i + 1; j < 16; j++){
                if (mask & (1 << j))
                for (int l = 0; l < 16; l++){
                    int x = (i ^ l);
                    int y = (j ^ l);
                    int c = 1;
                    int newmask = mask;
                    newmask ^= (1 << i);
                    newmask ^= (1 << j);
                    if (newmask & (1 << x) && x != 0) c++;
                    if (newmask & (1 << y) && y != 0) c++;
                    newmask ^= (1 << x);
                    newmask ^= (1 << y);
                    if (d[newmask] > d[mask] + c){
                        d[newmask] = d[mask] + c;
                        q.push(newmask);
                    }
                }
            }
        }
    }
    cout << ans + min(d[0], d[1]);
}


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

using namespace std;

typedef long long ll;

int main() {
    string s, t;
    cin >> s >> t;
    int n = (int)s.size();
    vector<int> cnt(26, -1);
    for (int i = 0; i < n; ++i) {
        if (cnt[s[i] - 'a'] != -1 && t[cnt[s[i] - 'a']] != t[i]){
            cout << "No" << endl;
            return 0;
        }

        cnt[s[i] - 'a'] = i;
    }

    cnt = vector<int> (26, -1);
    for (int i = 0; i < n; ++i) {
        if (cnt[t[i] - 'a'] != -1 && s[cnt[t[i] - 'a']] != s[i]){
            cout << "No" << endl;
            return 0;
        }

        cnt[t[i] - 'a'] = i;
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 776
S = input()
if(S == 'SSS'):
  print(0)
elif(S == 'RSS' or S == 'SRS' or S == 'SSR' or S == 'RSR'):
  print(1)
elif(S == 'RRS' or S == 'SRR'):
  print(2)
else:
  print(3)

Measured memory_bytes: 61860
def d_triangles():
    from bisect import bisect_right
    N = int(input())
    L = sorted([int(i) for i in input().split()])

    ans = 0
    for max_index in range(2, N):
        for second_index in range(1, max_index):
            b, c = L[second_index], L[max_index]
            # b <= c となるように辺を選ぶ (ソートしておけば簡単)。
            # 残りの辺の長さを a として、三角不等式は c < a + b ⇔ a > c - b である。
            # よって二分探索で長さが c - b より大きく b より小さな辺を求めればよい。
            third_index = bisect_right(L, c - b)
            if third_index < second_index:
                ans += second_index - third_index
    return ans

print(d_triangles())

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


int64_t gcd(int64_t a, int64_t b) {
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

int64_t lcm(int64_t a, int64_t b) {
   return a * b / gcd(a, b);
}

int main() {
	int64_t a, b, c, d;
    cin >> a >> b >> c >> d;

	int64_t l_ =b/lcm(c,d)-(a-1)/lcm(c,d);
    int64_t c_ = b/c-(a-1)/c;
    int64_t d_ = b/d-(a-1)/d;
    cout<<(b-a+1)-c_-d_+l_<<endl;
}


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

int main()
{
	string s;
	int l,r,ans=0;
	cin >> s;
	for(l=0,r=s.size()-1;r-l>1 || s[r]!=s[l];)
	{
		if(s[l]==s[r]) l++,r--;
		else if(s[l]=='x') l++,ans++;
		else if(s[r]=='x') r--,ans++;
		else break;
	}
	if(r-l>1 || s[r]!=s[l]) cout << "-1\n";
	else cout << ans << "\n";
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,ch,cw,dh,dw;
  cin>>h>>w>>ch>>cw>>dh>>dw;
  ch--;
  cw--;
  dh--;
  dw--;
  vector<string> s(h);
  for(int i=0;i<h;i++)
    cin>>s.at(i);
  vector<vector<int>> l(h,vector<int>(w,h*w));
  priority_queue<vector<int>,vector<vector<int>>,greater<vector<int>>> q;
  q.push({0,ch,cw});
  while(!q.empty()){
    int gl=q.top().at(0);
    int gy=q.top().at(1);
    int gx=q.top().at(2);
    q.pop();
    if(gl>=l[gy][gx])
      continue;
    l[gy][gx]=gl;
    for(int my=-2;my<=2;my++)
      for(int mx=-2;mx<=2;mx++)
        if(my!=0||mx!=0)
          if(gy+my>=0&&gy+my<h&&gx+mx>=0&&gx+mx<w&&s[gy+my][gx+mx]=='.')
            if(gl+(abs(my)+abs(mx)==1?0:1)<l[gy+my][gx+mx])
              q.push({gl+(abs(my)+abs(mx)==1?0:1),gy+my,gx+mx});
  }
  cout<<(l[dh][dw]==h*w?-1:l[dh][dw])<<endl;
}

Measured memory_bytes: 11936
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vll a(n), b(n), c(n);
  re(i, n) std::cin >> a[i];
  re(i, n) std::cin >> b[i];
  re(i, n) std::cin >> c[i];
  ll ans = 0;
  sort(a.begin(), a.end());
  sort(c.begin(), c.end());
  for(int i=0;i<n;i++){
    ll aa = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
    ll cc = upper_bound(c.begin(), c.end(), b[i]) - c.begin();
    //std::cout << aa << " " << (n-cc) << '\n';
    ans += aa*(n-cc);
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 2688
#include<iostream>
    #include<algorithm>
    #include<vector>
    #include<queue>
    #include<cmath>
    #include<tuple>
    #include<string>
    typedef unsigned long long ll;
    #define rep(i,a,b) for(int i=(a);i<(b);i++)
    #define F first
    #define S second
    using namespace std;
    const ll INF = 1e12;
     
    int main() {
      vector<char> s(4);
      bool judge=true;
      rep(i,0,4){
        cin>>s[i];
        if(i>0&&s[i]==s[i-1])judge=false;
      }
      if(judge)cout<<"Good"<<endl;
      else cout<<"Bad"<<endl;
      return 0;
    }

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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)

signed main () {
  string s;
  cin >> s;
  int k;
  cin >> k;
  vector<string> a;
  REP(i, s.size()) {
    FOR(j, i, i+5) {
      a.pb(s.substr(i, j - i + 1));
    }
  }
  sort(a.begin(), a.end());

  vector<string> b;
  b.pb(a[0]);
  FOR(i, 1, a.size()) {
    if(a[i] != a[i-1]) {
      b.pb(a[i]);
      if(b.size() == k) break;
    }
  }
  cout << b[k - 1] << endl;
}


Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <queue>
#define int long long
using namespace std;

int n,a[100000],child[100000];
vector<int> G[100000];
bool flag = true;

int dfs(int v,int par){
	if(G[v].size() == 1) return a[v];
	int sum = 0,ma = 0;
	for(int i = 0;i < G[v].size();i++){
		int to = G[v][i];
		if(par == to) continue;
		int ans = dfs(to,v);
		if(ans < 0) return -1;
		sum += ans;
		ma = max(ma,ans);
	}
	if(sum - a[v] < 0 || min(sum - ma,sum / 2) < sum - a[v] || a[v] * 2 - sum < 0) {
		flag = false;
		return -1;
	}
	return a[v] * 2 - sum;
}

signed main(){
	cin >> n;
	for(int i = 0;i < n;i++) cin >> a[i];
	for(int i = 0;i < n - 1;i++){
		int u,v;
		cin >> u >> v;u--;v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	if(n == 2){
		if(a[0] == a[1]) cout << "YES" << endl;
		else cout << "NO" << endl;
		return 0;
	}
	int v = 0;
	while(G[v].size() == 1) v++;
	if(dfs(v,-1)) flag = false;
	if(flag) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 13184
s = input()
nbits = 2**(len(s)-1)
ans = 0
for bit in range(nbits):
  tmp = []
  for i in range(nbits):
    if bit & (1 << i):
      tmp.append(i)
  curr = 0
  for x in tmp:
    ans += int(s[curr:x+1])
    curr = x + 1
  ans += int(s[curr:])

print(ans)

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

int main(){
	int n;
	cin >> n;
    map<string, int> m;
    for(int i=0; i<n; ++i){
        string s; cin >> s;
        ++m[s];
    }
    cin >> n;
    for(int i=0; i<n; ++i){
        string s; cin >> s;
        --m[s];
    }

    int ans=0;
    for(auto i : m){
        ans = max(ans,i.second);
    }
	cout << ans << endl;
}

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

signed main()
{
	string strA, strB;
	int arrA[1000000], arrB[1000000];
	cin >> strA >> strB;
	arrA[0] = 0;
	arrB[0] = 0;
	for(int j = 0;j<=strA.length();j++)
	{
		if(strA[j]=='A') arrA[j+1] = arrA[j] + 1;
		else arrA[j+1] = arrA[j] + 2;
//		cout << arrA[j+1] << " ";
	}
	for(int j = 0;j<=strB.length();j++)
	{
		if(strB[j]=='A') arrB[j+1] = arrB[j] + 1;
		else arrB[j+1] = arrB[j] + 2;
	}
	int t; cin >> t;
	while(t--)
	{
		int a, b, c, d; cin >> a >> b >> c >> d;
		int suma = 0, sumb = 0;
		suma = arrA[b] - arrA[a-1];
		sumb = arrB[d] - arrB[c-1];
		suma %= 3; sumb %= 3;
		if(suma==sumb) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 4564
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m,l;
	cin>>n>>m>>l;
	long long a[n][m],b[m][l],c[n][l]={};
	for(int i=0;i<n;i++) 
	  for(int j=0;j<m;j++) cin>>a[i][j];
	for(int i=0;i<m;i++) 
	  for(int j=0;j<l;j++) cin>>b[i][j];
	for(int i=0;i<n;i++){
		for(int j=0;j<l;j++){
			for(int k=0;k<m;k++) c[i][j]+=a[i][k]*b[k][j];
			cout<<c[i][j];
			if(j!=l-1) cout<<" ";
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3316
from collections import deque
li=[i for i in range(1,10)]
def bfs(K):
    d=deque()
    for i in range(1,10):
        d.append(str(i))
    while(len(li)<K):
        s=d[0]
        d.popleft()
        now=[int(s+s[-1])]
        if(s[-1]!='0'):
            now.append(int(s+str(int(s[-1])-1)))
        if(s[-1]!='9'):
            now.append(int(s+str(int(s[-1])+1)))
        now.sort()
        for i in range(len(now)):
            li.append(now[i])
            d.append(str(now[i]))
K=int(input())
bfs(K)
print(li[K-1])

Measured memory_bytes: 56060
#include <stdio.h>

int find_digit(int i)
{
  int sum = 0;
  while(0 < i)
  {
    sum += i % 10;
    i /= 10;
  }
  return (sum);
}

int main(void)
{
  int n, a, b;
  int sum = 0, i = 0, ret = 0;

  scanf(" %d %d %d", &n, &a, &b);
  for(i = 1;i <= n;i++)
  {
    sum = find_digit(i);
    if (a <= sum && sum <= b)
      ret += i;
  }
  printf("%d\n", ret);
}

Measured memory_bytes: 1684
S = int(input())
if S < 3:
    print(0)
else:
    MODULO = int(1e9+7)
    dp = [0,0,0,1]
    for i in range(4,S+1):
        x = dp[i-3] + dp[i-1]
        x %= MODULO
        dp.append(x)
    print(dp[-1])

Measured memory_bytes: 9088
#include <iostream>
#include <string>
#include<algorithm>
#include<vector>

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int pre = -999;
	rep(i, n) {
		if (pre <= a[i] - 1) {
			pre = a[i] - 1;
		}
		else if (pre <= a[i]) {
			pre = a[i];
		}
		else {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

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

const int M = 1000000007;

vector<vector<int>> adj;


struct Point {
    int id;
    // double x, y;
    Point() {}
    Point(int id) : id(id) {}
    // Point(double x, double y): x(x), y(y) {}
    int distance(const Point &p) const {
        return adj[id][p.id] == -1 ? M : adj[id][p.id];
    }
};

int calc_mst(const vector<Point>& points) {
    int n = points.size();
    vector<int> dist(n, M);
    vector<bool> visited(n);
    int p = 0;
    int res = 0;
    while (true) {
        visited[p] = true;
        int mind = M, minj = -1;
        for (int j = 0; j < n; ++j) {
            if (visited[j]) continue;
            dist[j] = min(dist[j], points[p].distance(points[j]));
            if (mind > dist[j]) {
                mind = dist[j];
                minj = j;
            }
        }
        if (minj == -1) break;
        p = minj;
        res += mind;
    }
    return res;
}

int main(int argc, char **argv) {
    int n;
    cin >> n;
    adj = vector<vector<int>>(n, vector<int>(n));
    vector<Point> p(n);
    for (int i = 0; i < n; ++i) {
        p[i] = Point(i);
        for (int j = 0; j < n; ++j) {
            cin >> adj[i][j];
        }
    }
    cout << calc_mst(p) << '\n';
    return 0;
}



Measured memory_bytes: 3188
from sys import stdin

h,w = [int(x) for x in stdin.readline().rstrip().split()]
li = [stdin.readline().rstrip() for _ in range(h)]

now = 0

for i in range(h):
    if "#" in li[i][:now]:
        print("Impossible")
        exit()
    for j in range(now,w-1):
        if li[i][j] == "#" and li[i][j+1] == ".":
            now = j
        if li[i][w-2] == "#" and li[i][w-1] == "#":
            now = w-1
    if now <= 3:
        if "#" in li[i][now+1:]:
            print("Impossible")
            exit()
print("Possible")

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

#define FIO                     ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod                     1000000007
#define eps                     1e-9
#define setbits                 __builtin_popcount
#define gcd                     __gcd
#define rep(i,a,b)              for(int i=a;i<=b;i++)
#define repr(i,b,a)             for(int i=b;i>=a;i--)
#define forn(i,n)               for(int i=0;i<n;i++)
#define all(a)                  a.begin(), a.end()
#define in(a,b)                 ( (b).find(a) != (b).end())
#define pb                      push_back
#define fill(a,v)               memset(a, v, sizeof a)
#define endl                    "\n"
#define ff                      first
#define ss                      second
#define mp                      make_pair
#define minin(a)                *min_element (all(a))
#define maxin(a)                *max_element(all(a))
#define asort(c)                sort(all(c))
#define dsort(c)                sort(all(c), greater<int>()) 
#define PI                      3.14159265358979323846
#define int                     long long
typedef  vector<int>                 vi;
typedef  pair<int, int>              ii;
typedef  vector<ii>                 vii;
typedef  set<int>                    si;
typedef  map<int, int>              mii;
typedef  long double                 ld;



clock_t time_p=clock();
void timer()
{
    time_p=clock()-time_p;
    cerr<<"Execution Time: "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

int32_t main()
{
  FIO

 
  string s;
  cin>>s;

  for(char c: s)
  {
    if(c=='1')
      cout<<9;
    else if(c=='9')
      cout<<1;
    else
      cout<<c;
  }

  timer();
  return 0;
}  

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

double dis(ll a, ll b) { return sqrt(pow(a, 2) + pow(b, 2)); }

int main() {
  double n, d;
  cin >> n >> d;
  ll count = 0;
  rep(i, n) {
    ll x, y;
    cin >> x >> y;
    if (dis(x, y) <= d) count++;
  }
  cout << count << endl;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (1LL << 55)
#define MOD (1000 * 1000 * 1000 + 7)
#define maxk 100111

typedef long long ll;
typedef long double ld;

int k;
int dp[maxk];
bool used[maxk];
queue<int> q;

int main(){
	scanf("%d", &k);

	memset(dp, 0x3f3f, sizeof(dp));
	for(int i = 1; i <= 9; i++){
		q.push(i);
		dp[i] = i;
	}

	while(!q.empty()){
		int val = q.front();
		q.pop();

		for(int i = 0; i <= 9; i++){
			int v = (val * 10 + i) % k;
			if(dp[v] > dp[val] + i){
				dp[v] = dp[val] + i;
				if(!used[v]){
					used[v] = 1;
					q.push(v);
				}
			}
		}
		used[val] = 0;
	}

	printf("%d\n", dp[0]);
	return 0;
}

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

using namespace std;

int main(){
    long N;
    cin >> N;
    int ans =0;
    for(long i=2;i*i<N;i++){
      int crt=0;
      while(N%i==0){
        crt++;
        N/=i;
      }
      int j=1;
      while(crt>=j){
        crt-=j;
        ans++;
        j++;}
    }
    if(N!=1){
      ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <string.h>

int main(){
	int H, W, i, j;
	scanf("%d%d", &H, &W);
	char S[H][W][6];
	for(i = 0; i < H; i++){
		for(j = 0; j < W; j++){
			scanf("%s", S[i][j]);
		}
	}
	for(i = 0; i < H; i++){
		for(j = 0; j < W; j++){
			if(strcmp(S[i][j], "snuke") == 0){
				printf("%c%d\n", (char)(j + (int)'A'), i + 1);
				return 0;
			}
		}
	}
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

using ld = long double;
ld a,b,h,m;
static const long double pi = 3.141592653589793;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	std::cout<<std::fixed<<std::setprecision(30);
	cin>>a>>b>>h>>m;
	ld ax = -(ld)a * cos(pi*(ld)h/6.0+pi*m/360.0);
	ld ay = (ld)a * sin(pi*(ld)h/6.0+ pi*m/360.0);
	ld bx = -(ld)b * cos(pi*(ld)m/30.0);
	ld by = (ld)b * sin(pi*(ld)m/30.0);
	ld dis = sqar(ax-bx) + sqar(ay-by);
	print(sqrt(dis));
	return 0;
}

Measured memory_bytes: 4184
/*
𝓐𝓾𝓽𝓱𝓸𝓻:-
𝓢𝓪𝓾𝓻𝓪𝓫𝓱𝓼𝓱𝓪𝓭𝓸𝔀
------------------------
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopb(i,a,b) for(int i=a;i>=b;i--)
#define fore(name)  for(auto it=name.begin();it!=name.end();it++)
#define w  int t;cin>>t;while(t--)
#define pb(x) push_back(x)
#define in(y) insert(y)
#define bitscount 32
#define make(x,y) make_pair(x,y)
#define LOAD_FACTOR_set(name) name.reserve(32768);name.max_load_factor(0.25);
#define LOAD_FACTOR_map(name) name.reserve(1024);name.max_load_factor(0.25);
#define lcm(a,b) ((a*b))/(__gcd(a,b))
#define int long long int
#define REDBULL ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define all(x) (x).begin(), (x).end()


typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ordered_justset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

struct HASH {
	size_t operator()(const pair<int, int>&x)const {
		return ((int)x.first) ^ (((int)x.second) << 32);
	}
};
struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};
typedef pair<int, int> pi;
#define UNMAP(name) unordered_map<int,int,custom_hash> name
#define MAX 10000000000000
void solve()
{
	int n;
	cin >> n;
	int a[n];
	loop(i, 0, n)
	cin >> a[i];
	int max1 = a[0];
	int ans = 0;
	for (int i = 1; i < n; i++)
	{
		if (a[i] < max1)
		{
			ans += abs(a[i] - max1);
			// max1 = max(max1, abs(a[i] - max1));
		}
		max1 = max(max1, a[i]);
		// cout << max1 << " ";
	}
	cout << ans << endl;
}
int32_t main()
{
	REDBULL
	// w
	solve();

	return 0;
}

Measured memory_bytes: 5216
import math;

n, m = map(int, input().split(" "));
ab = [];
for i in range(0, n):
    ab.append(input().split(" "));

cd = [];
for i in range(0, m):
    cd.append(input().split(" "));

for i in range(0, n):
    dist=9999999999999
    nearm=0;
    for j in range(0, m):
         dist2 = math.fabs(int(ab[i][0]) - int(cd[j][0])) + math.fabs(int(ab[i][1]) - int(cd[j][1]));
         if dist2 < dist:
            dist = dist2;
            nearm=j;
    print(nearm+1);


Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <string>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>

using namespace std;

int main()
{	
 	//freopen("in.txt","r",stdin);
 	//freopen("out.txt","w",stdout);
    int n;
    scanf("%d", &n);
    int x = n / 15 * 200;
    printf("%d\n", n * 800 - x);
 	return 0;
}

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

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

Measured memory_bytes: 256
N,M=[int(s) for s in input().split()]
H=[int(s) for s in input().split()]
peak=[0 for _ in range(N)]
edge=[set() for _ in range(N)]
for i in range(M):
  a,b=[int(s) for s in input().split()]
  edge[a-1].add(b-1)
  edge[b-1].add(a-1)

ans=0
for i in range(N):
  if peak[i]==-1:
    continue
  h=H[i]
  for e in edge[i]:
    if H[e]>h:
      peak[i]=-1
      break
    elif H[e]==h:
      peak[i]=-1
      peak[e]=-1
      break
    else:
      peak[e]=-1
  else:
    peak[i]=1
    ans+=1
print(ans)
      
  

Measured memory_bytes: 46144
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<ll> A(N);
  for(int i=0;i<N;++i) {
    cin>>A[i];
    A[i] -= i+1;
  }
  sort(A.begin(), A.end());
  ll ans = 0;
  for(int i=0;i<N;++i) {
    ans += abs(A[i]-A[(N-1)/2]);
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 4844
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define Rep(i, a, b) for(ll i = a; i <= b; i++)
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i]>>y[i];
#define _GLIBCXX_DEBUG
#define V vector<ll>
using namespace std;
using ll = long long;

int main(){
    int n,m;
    cin>>n>>m;
    V a(n),b(n),c(m),d(m);
    cinf(n,a,b);
    cinf(m,c,d);
    rep(i,0,n){
        int ans=-1;
        int mindis=1001001001;
        rep(j,0,m){
            int dis=abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(dis<mindis){
                ans=j+1;
                mindis=dis;
            }
        }
        cout<<ans<<"\n";
    }
}

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

#define L(X) ((X)*2)
#define R(X) ((X)*2+1)
#define P(X) ((X)/2)

void maxHeapify(int *h, int sz, int i){
  int t,mx = i;
//  cout << "MH: " << i << " ";
  if (L(i)<=sz && h[mx]<h[L(i)]) mx = L(i);
  if (R(i)<=sz && h[mx]<h[R(i)]) mx = R(i);
//  cout << mx << endl;
  if (mx!=i){
    t = h[i]; h[i] = h[mx]; h[mx] = t;
    if (L(mx)<=sz) maxHeapify(h,sz,mx);
  }
}

void build(int *h, int sz){
  for (int i=P(sz); i>=1; i--) maxHeapify(h,sz,i);
}

int main(void){
  int h[500010];
  int n;
  
  cin >> n;
  for (int i=0; i<n; i++){
    cin >> h[i+1];
  }
  build(h,n);
  for (int i=1; i<=n; i++){
    cout << " " << h[i];
  }
  cout << endl;
  return 0;
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int main()
{
    int n;
    while(cin >>n,n)
    {
        vector<int> a(n);
        rep(i,n) scanf(" %d", &a[i]);

        int ans=n;

        //?????????????????????????????????
        rep(i,n)for(int j=1; j<=3; ++j)
        {
            if(a[i]==j) continue;

            int tmp=n;

            //???????????????
            vector<int> c(a);
            c[i]=j;

            //top,bottom
            int t=i,b=i;
            int st=t,sb=b;

            int col=j;

            //printf("i,j= %d, %d\n",i,j);
            bool first=true;
            while(1)
            {
                while(t>=0 && c[t]==col) --t;
                while(b<n && c[b]==col) ++b;

                //printf(" t=%d, st=%d, sb=%d, b=%d\n", t,st,sb,b);

                int num=(b-sb)+(st-t);
                if(first)
                {
                    num-=1;
                    first=false;
                }
                //printf(" num=%d\n",num);

                if(num>=4)
                {
                    //?¶???????
                    tmp-=num;
                    st=t;
                    sb=b;
                }
                else break;

                if(t==-1 && b==n) break;
                else if(t==-1) col=c[b];
                else if(b==n) col=c[t];
                else
                {
                    if(c[t]==c[b]) col=c[t];
                    else break;
                }
            }

            ans=min(ans,tmp);
        }

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

Measured memory_bytes: 3248
//coded b vishal mourya - the legendary coder
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define f(a,b) for(ll i = a ; i < b ; i++ )
#define fj(a,b) for(ll j = a ; j < b ; j++ )
#define fk(a,b) for(ll k = a ; k < b ; k++ )
#define fasthoja ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main(void){
    fasthoja;
    char s; cin >> s;
    cout << ++s << "\n";

 return 0;
}


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

const int MAX_N = 1 << 17;

struct LazySegTree {
	int n;
	struct S {
		int flag;
		int len;
		int sum;
		int l, r;
		S() : flag(0), len(1), sum(0), l(0), r(0) {}
	};
	S node[2 * MAX_N - 1];
	void init(int n_) {
		n = 1;
		while(n < n_) n *= 2;
	}
	void build() {
		for(int i = n - 2; i >= 0; i--) {
			node[i] = merge(node[2 * i + 1], node[2 * i + 2]);
		}
	}

	void propagate(int k) {
		S& t = node[k];
		if(!t.flag) return;
		if(2 * k + 1 < 2 * n - 1) {
			S& l = node[2 * k + 1];
			S& r = node[2 * k + 2];
			l.flag = r.flag = 1;
			int x = t.l;
			l.l = l.r = r.l = r.r = x;
			l.sum = r.sum = x;
		}
		t.flag = 0;
	}

	S merge(S l, S r) {
		S ret;
		ret.len = l.len * 2;
		ret.sum = l.sum + r.sum;
		if(l.r && r.l) ret.sum--;
		ret.l = l.l;
		ret.r = r.r;
		return ret;
	}

	void query(int a, int b, int x) { query(a, b, x, n, 0, 0, n); }

	void query(int a, int b, int x, int len, int k, int l, int r) {
		if(r <= a || b <= l) return;
		propagate(k);
		if(a <= l && r <= b) {
			node[k].flag = 1;
			node[k].l = node[k].r = x;
			node[k].sum = x;
			propagate(k);
			return;
		}
		query(a, b, x, len / 2, k * 2 + 1, l, (l + r) / 2);
		query(a, b, x, len / 2, k * 2 + 2, (l + r) / 2, r);
		node[k] = merge(node[2 * k + 1], node[2 * k + 2]);
	}
};

int n;
int b[100000];

LazySegTree st;

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

	cin >> n;
	st.init(n);
	string s;
	cin >> s;
	for(int i = 0; i < n; i++) {
		b[i] = s[i] - '0';
	}

	for(int i = 0; i < n; i++) {
		int idx = i + st.n - 1;
		auto& node = st.node[idx];
		node.l = node.r = node.sum = b[i];
	}
	st.build();

	int q;
	cin >> q;
	for(int t = 0; t < q; t++) {
		int l, r, x;
		cin >> l >> r >> x;
		l--;
		st.query(l, r, x);
		auto node = st.node[0];
		cout << node.sum << endl;
	}
}

Measured memory_bytes: 8852
#include <bits/stdc++.h>
using std::cout;
using std::endl;
using std::cin;

int main(){
	long n, s = 0; cin >> n; std::vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
		
		s += a[i];
	}
	
	if(s % (n * (n + 1) / 2)){
		cout << "NO" << endl;
		return 0;
	}
	s /= n * (n + 1) / 2;
	
	std::vector<int> d(n);
	for(int i = 0; i < n; i++) d[i] = a[(i + 1) % n] - a[i] - s;
	for(int i = 0; i < n; i++){
		if(d[i] % n or d[i] > 0){
			cout << "NO" << endl;
			return 0;
		}
	}
	
	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 1024
#! /usr/bin/env perl
use strict;
use warnings;

my $x = <>;
chomp $x;

my $title = ();
my $min = ();

for my $i (0..$x-1){
    my $tmp = <>;
    chomp $tmp;
    my @a_tmp =   split / /,$tmp; #array_tmp
    push @$title, $a_tmp[0];
    push @$min, $a_tmp[1]; 
}

my $sleep_titile = <>;
chomp $sleep_titile;
my $flag = 0;
my $ans = 0;

for my $j (0..$x-1){
    if($flag ==1){
        $ans += $min->[$j];    
    }

    if($title->[$j] eq $sleep_titile){
        $flag = 1;
    }

}

print $ans;

Measured memory_bytes: 640
#include<bits/stdc++.h>
using ll= long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()

#define INF (ll)1e9 //10^9:∞
#define LLINF (ll)1e12
#define MOD (ll)(1e9+7) //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)
#define endl "\n"

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/


/*.....................DEFINE FUNCTIONS ......................*/



/*.........................kemkemG0...........................*/
signed main() {
	__MAGIC__


	string S;
	cin>>S;
	bool ok=false;
	REP(i,S.size()){
		if(S[i]=='7')ok=true;
	}
	YesNo(ok);

	



	

		return 0;
}


Measured memory_bytes: 3588