akhauriyash/Code-Regression huggingface dataset:
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int N; R(N);
    VI a(N);
    REP(i,N){
        R(a[i]);
        a[i]-=i;
    }
    sort(ALL(a));
    LL an=0;
    for(int i=0;i<N-i-1;i++)an+=a[N-i-1]-a[i];
    W(an);
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=25;
const int inf=0x3f3f3f3f;
const int mod=1000000007;
int a,b,c,d,n;
struct node{
    double id;
    ll val;
    bool operator<(const node b)const{
        return val<b.val;
    }
}p[4];

int main(){
    for(int i=1;i<=4;i++)p[i-1].id=i;
    scanf("%d%d%d%d%d",&p[0].val,&p[1].val,&p[2].val,&p[3].val,&n);
    p[0].val*=8;
    p[1].val*=4;
    p[2].val*=2;
    sort(p,p+4);
   for(int i=0;i<4;i++){
        if(p[i].id==1)p[i].val/=8;
        else if(p[i].id==2)p[i].val/=4;
        else if(p[i].id==3) p[i].val/=2;

   }
    ll ans=0;
    int tot=0;
    while(n){
        if(p[tot].id==1){
            ans+=n*4*p[tot].val;
            n=0;
        }
        else if(p[tot].id==2){
            ans+=n*2*p[tot].val;
            n=0;
        }
        else if(p[tot].id==3){
            ans+=n*p[tot].val;
            n=0;
        }
        else{
            ans+=n/2*p[tot].val;
            n-=n/2*2;
        }
        tot++;
    }
    printf("%lld\n",ans);
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

using namespace std;

typedef long long lint;

void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
};

void dfs(int v, int p, int& x, map<int, vector<int> >& edges,
            map<int, int>& counters, vector<int>& counts)
{
    x += counters[v];
    counts[v] = x;
    for (int child : edges[v])
        if (child != p) {
            dfs(child, v, x, edges, counters, counts);
        }
    x -= counters[v];
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, Q;
    cin >> N >> Q;
    map<int, vector<int> > edges;
    for (int i = 0;i < N - 1;i++) {
        int a, b;
        cin >> a >> b;
        a--;b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    map<int, int> counters;
    for (int q = 0;q < Q; q++) {
        int p, x;
        cin >> p >> x;
        counters[p - 1] += x;
    }

    vector<int> counts(N);
    int X = 0;
    dfs(0, -1, X, edges, counters, counts);
    for (int i = 0;i < N;i++)
        cout << counts[i] << " ";
    cout << endl;
    return 0;
};


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

using namespace std;

int main () {
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1;i <= n;i ++) {
		int x;
		cin >> x;
		ans ^= (x % 2);
	}
	if (ans) cout << "NO";
	else cout << "YES";
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    k, s = map(int, input().split())
    answer = solve(k, s)
    return answer


def solve(k, s):
    count = 0
    for i in range(k + 1):
        for j in range(k + 1):
            z = s - i - j
            if 0 <= z and z <= k:
                count += 1
    return count

print(main())


Measured memory_bytes: 2940
// Problem : A - Five Variables
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vstr vector<string>
#define vdb vector<double>
#define vbool vector<bool>
#define vvi vector<vector<int> >
#define mii map<int,int>
#define pb push_back
#define pii pair<int,int>
#define vpair vector<pii > 
#define mkp make_pair
#define scan(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) {cout<<a[i]<<' ';}cout<<'\n'
#define mem(a,v) memset(a,v,sizeof(a))
#define loop(i,a,b) for (int i = a; i < b; i++)
#define loope(i,a,b) for (int i = a; i <= b; i++)
#define bloop(i,a,b) for(int i = a;i>=b;i--)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::fixed );std::cout.precision(9)
#define PI 3.14159265
#define S second
#define F first
#define CHECK cout<<"CHEDEDWB"<<endl
#define CHECK1(a) cout<<a<<endl
#define CHECK2(a,b) cout<<a<<' '<<b<<endl;
#define br '\n'
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
using namespace std;
int mod = 1e9+7;
int inf = 1e18;
int m_inf = INT_MIN;
// int extendedgcd(int a,int b,int &x,int &y){
	// if(a == 0){
		// x = 0; y = 1;
		// return b;
	// }
	// int x1,y1;
	// int d = extendedgcd(b%a,a,x1,y1);
	// x = y1 - (b/a)*x1;y = x1;
	// return d;
// }
// int expmod(int a,int b) {
// 	if(b == 1) return a;
// 	if(b == 0) return 1;
// 	int m1 = expmod(a,b/2)%mod;
// 	if(b%2) return ((m1*m1)%mod*a%mod)%mod;
// 	return (m1*m1)%mod;
// }
// int power(int a,int b) {
// 	if(b == 1) return a;
// 	if(b == 0) return 1;
// 	int m1 = power(a,b/2);
// 	if(b%2) return m1*m1*a;
// 	return m1*m1;
// }
// int logn(int n, int r) 
// { 
//     return (n > r - 1) ? 1 + logn(n / r, r) : 0; 
// } 

// int nCr(int n,int r)
// {
	// r = min(r,n-r);
	// if(r<0)
		// return 0;
	// if(r == 0)
		// return 1;
	// int ans = 1;
	// for(int i = 1;i<=r;i++)
	// {
		// ans = ans*(n-i+1)/i;
	// }
	// return ans;
// 		
// }
// vi factmod(int n)
// {
	// vi ans(n+1);
	// ans[0] = 1;
	// loop(i,1,n+1)
	// {
		// ans[i] = (ans[i-1]*i)%mod;
	// }
	// return ans;
// }
// int nCrmod(int n,int r,vi &fact)
// {
	// int x1,y1;
	// extendedgcd(fact[r],mod,x1,y1);
	// int x2,y2;
	// extendedgcd(fact[n-r],mod,x2,y2);
	// int ans = (fact[n]*((x1+mod)%mod))%mod;
	// ans = (ans*((x2+mod)%mod))%mod;
	// return ans;
// }

// void dfs(vector<vector<int> > &adj,int root,vbool &vis)
// {
// 	vis[root] = true;
// 	for(int i = 0;i<adj[root].size();i++){
// 		int v = adj[root][i];
// 		if(!vis[v])		
// 			dfs(adj,v,vis);
// 	}
// }

int32_t main() 
{
	FastIO; PRECISION;
	int t = 1;
	// cin>>t;
	while(t--)
	{
		vi arr(5);
		scan(arr,5);
		loop(i,0,5)
		{
			if(arr[i] == 0)
			{
				cout<<i+1<<'\n';
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3576
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

D = INT()
print("Christmas"," ", end ="")
for _ in range(25-D):
	print("Eve ",end="")

print()

Measured memory_bytes: 5148
#include<iostream>
#include<algorithm>
#include<functional>
#include <string>
#include<iomanip>
#include<cstdio>
#include<math.h>
#include<set>
#include<stack>
#include<map>
#include<queue>
#include<cstring>
#include<vector>
#include <type_traits>
typedef long long int ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
#define MIN -93193111451418101
#define INF 931931114518101
using namespace std;
typedef pair<ll, ll>P;
template<typename T, typename U>
std::enable_if_t<std::rank<T>::value == 0> fill_all(T& arr, const U& v) {
	arr = v;
}
template<typename ARR, typename U>
std::enable_if_t<std::rank<ARR>::value != 0> fill_all(ARR& arr, const U& v) {
	for (auto& i : arr) {
		fill_all(i, v);
	}
}
#define MAX_NUM 50
long long comb[MAX_NUM + 1][MAX_NUM + 1];

ll par[100000], depth[100000];
static void calc_comb()
{
	for (uint32_t i = 0; i <= MAX_NUM; i++) {
		for (uint32_t j = 0; j <= i; j++) {
			if ((j == 0) || (i == j)) {
				comb[i][j] = 1;
			}
			else {
				comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
			}
		}
	}
}
#define yo 100001
typedef pair<double, double> dop;
//------------------変数-----------------------//
ll n, m, a[100010] = {}, cnt = 0, num[1001] = {};
string str;
ll h, w;
//-------------------関数----------------------//


int main() {
	cin >> h >> w;
	REP(i, h) {
		REP(j, w) {
			char hoge; cin >> hoge;
			a[(int)hoge - (int)'a']++;
		}
	}
	REP(i, 80) {
		ll izryt = a[i];
		if (izryt == 0) { continue; }
		if (a[i] % 4 == 0) { continue; }
		izryt %= 4;
		if (izryt % 2 == 0) { num[2]++; continue; }
		if (izryt / 2) { num[1]++; num[2]++; }
		else { num[1]++; }
	}
	//cout << num[1] << endl << num[2] << endl;
	if (h % 2 == 1 && w % 2 == 1) {
		if (num[1] > 1) { cout << "No" << endl; return 0; }
		if (num[2] > h/2+w/2) { cout << "No" << endl; return 0; }
	}
	else if (h % 2 == 0 && w % 2 == 0) {
		if (num[1] || num[2]) { cout << "No" << endl; return 0; }
	}
	else if(h%2==0){
		if (num[1] ) { cout << "No" << endl; return 0; }
		if(num[2]>h/2){ cout << "No" << endl; return 0; }
	}
	else {

		if (num[1]) { cout << "No" << endl; return 0; }
		if (num[2]>w / 2) { cout << "No" << endl; return 0; }
	}
	cout << "Yes" << endl;
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> piipi;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back

piipii c[405];
piipii rotate(piipii x){
    return mp(mp(x.se.se, x.fi.fi), mp(x.fi.se, x.se.fi));
}

ll get_idx(piipii x){
    return x.fi.fi*1ll*1000*1000*1000 + x.fi.se*1ll*1000*1000 + x.se.fi*1ll*1000 + x.se.se;
}
gp_hash_table<ll, int> dp;

void add(piipii p){
    for(int k=0;k<4;k++){
        dp[get_idx(p)]++;
        p = rotate(p);
    }   
}
void del(piipii p){
    for(int k=0;k<4;k++){
        dp[get_idx(p)]--;
        p = rotate(p);
    }
}


int main(){
    int n;
    scanf("%d", &n);   
    for(int i=1;i<=n;i++){
        scanf("%d%d%d%d", &c[i].fi.fi, &c[i].fi.se, &c[i].se.fi, &c[i].se.se);
        add(c[i]);
    }
    ll ans = 0;
    for(int i=1;i<=n;i++){
        piipii p1 = c[i];
        del(p1);
        for(int j=1;j<=n;j++){
            if(i == j) continue;
            piipii p2 = c[j];
            del(p2);
            for(int k=0;k<4;k++){
                ll res = 1;
                piipii tmp1 = mp(mp(p1.fi.se, p1.fi.fi), mp(p2.fi.se, p2.fi.fi));
                piipii tmp2 = mp(mp(p1.fi.se, p2.fi.fi), mp(p2.se.se, p1.se.fi));
                piipii tmp3 = mp(mp(p1.se.se, p1.se.fi), mp(p2.se.se, p2.se.fi));
                piipii tmp4 = mp(mp(p2.fi.se, p1.fi.fi), mp(p1.se.se, p2.se.fi));
                if(dp.find(get_idx(tmp1)) != dp.end()){
                    res *= dp[get_idx(tmp1)];
                    del(tmp1);
                }
                else res = 0;
                if(dp.find(get_idx(tmp2)) != dp.end()){
                    res *= dp[get_idx(tmp2)];
                    del(tmp2);
                }
                else res = 0;
                if(dp.find(get_idx(tmp3)) != dp.end()){
                    res *= dp[get_idx(tmp3)];
                    del(tmp3);
                }
                else res = 0;
                if(dp.find(get_idx(tmp4)) != dp.end()){
                    res *= dp[get_idx(tmp4)];
                    del(tmp4);
                }
                else res = 0;

                ans += res;

                if(dp.find(get_idx(tmp1)) != dp.end()){
                    add(tmp1);
                }
                if(dp.find(get_idx(tmp2)) != dp.end()){
                    add(tmp2);
                }
                if(dp.find(get_idx(tmp3)) != dp.end()){
                    add(tmp3);
                }
                if(dp.find(get_idx(tmp4)) != dp.end()){
                    add(tmp4);
                }

                p2 = rotate(p2);
            }
            add(p2);
        }
        add(p1);
    }
    printf("%lld\n", ans/6);
}

Measured memory_bytes: 3904
#include<bits/stdc++.h>
using namespace std;
 int main()
 {
 cin.tie(0);
 cout.tie(0);
 ios_base::sync_with_stdio(false);
 int n;
 cin>>n;
 int out = n+pow(n,2)+pow(n,3);
 cout<<out<<endl;
 return 0;
 }


Measured memory_bytes: 4108
var stdin = require('fs').readFileSync('/dev/stdin', 'utf8');

var input = stdin.toString().trim().split('\n');
var cols = input[0].split(' ');
var a = parseInt(cols[0] , 10);
var b = parseInt(cols[1] , 10);
var area = a * b;
var around = (a + b) * 2;
console.log(area , around);

Measured memory_bytes: 15596
#include<iostream>
#include<cstdio>
#include<cstring>
namespace Wo_Zhen_Cai_A
{
	typedef long long ll;
	const int N=2010,MOD=1000000007;
	inline void inc(ll a,ll &b){b=(a+b)%MOD;} 
	ll qpow(ll a,ll b){ll c=1;for(;b;b>>=1,a=a*a%MOD)if(b&1)c=c*a%MOD;return c;}
	ll fact[N*N],ifact[N*N];
	ll C(int n,int m){return fact[n]*ifact[n-m]%MOD*ifact[m]%MOD;}
	ll f[N][N];
	int n,k;
	void solve()
	{
		scanf("%d%d",&n,&k);
		if(k==1){printf("1\n");return;}
		fact[0]=1;for(int i=1,tmp=n*k;i<=tmp;i++)fact[i]=fact[i-1]*i%MOD;
		ifact[n*k]=qpow(fact[n*k],MOD-2);
		for(int i=n*k;i;i--)ifact[i-1]=ifact[i]*i%MOD;

		f[0][0]=1;
		for(int i=0;i<=n;i++)
			for(int j=i;j<=n;j++)
			{
				if(i+j==0)continue;

				if(i)inc(f[i-1][j],f[i][j]);
				if(j)inc(f[i][j-1]*C(k*i+(k-1)*(j-i-1)+k-2,k-2)%MOD,f[i][j]);


//				printf("f[%d][%d] = %lld\n",i,j,f[i][j]);
			}
		printf("%lld\n",f[n][n]*fact[n]%MOD);
	}
}
int main()
{
	Wo_Zhen_Cai_A::solve();
	return 0;
}


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

using namespace std;
int main() {
    int n, a, b;
    int c = 0, ca = 0, cb = 0;
    cin >> n >> a >> b;
    int p[n];
    for(int i = 0; i < n; i++){
        cin >> p[i];
        if(p[i] <= a) c++;
        else if(p[i] >= a + 1 && p[i] <= b) ca++;
        else if(p[i] >= b + 1) cb++;
    }
    cout << min(min(c, ca), cb) << endl;

}

Measured memory_bytes: 256
from itertools import permutations

def mapt(fn, *args):
    return tuple(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))


def calc(i, h):
    return all(h[i] >= h[j] for j in range(i))


def main():
    ans = 1000
    data = [int(input()) for i in range(5)]
    for row in permutations(data, 5):
        time = 0
        for index, i in enumerate(row):
            if index == 4:
                time += i
                continue
            remain = i % 10
            if remain:
                time += i + (10-remain)
            else:
                time += i
        ans = min(ans, time)
    print(ans)



main()

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

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

int N,R;

const int MAT=402;
int mat[402][402];
ll dp[303][303][303];
ll p2[101010];
ll mo=1000000007;

int gf2_rank(int A[MAT][MAT],int n) { /* input */
	int i,j,k;
	FOR(i,n) {
		int be=i,mi=n+1;
		for(j=i;j<n;j++) {
			FOR(k,n) if(A[j][k]) break;
			if(k<mi) be=j,mi=k;
		}
		if(mi>=n) break;
		FOR(j,n) swap(A[i][j],A[be][j]);
		
		FOR(j,n) if(i!=j&&A[j][mi]) {
			FOR(k,n) A[j][k] ^= A[i][k];
		}
	}
	return i;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	p2[0]=1;
	FOR(i,101000) p2[i+1]=p2[i]*2%mo;
	
	cin>>N;
	FOR(y,N) FOR(x,N) cin>>mat[y][x];
	R=gf2_rank(mat,N);
	dp[0][0][0]=1;
	FOR(i,N) {
		FOR(x,R+1) FOR(y,N-R+1) if(dp[i][x][y]) {
			ll v=dp[i][x][y]*p2[x+y]%mo;
			// no new rank
			(dp[i+1][x][y]+=v)%=mo;
			// common rank
			if(x<R) (dp[i+1][x+1][y]+=v*(p2[R-x]+mo-1))%=mo;
			// single rank
			if(y<N-R) (dp[i+1][x][y+1]+=v*(p2[N-x-y]-p2[R-x]+mo))%=mo;
		}
	}
	
	//FOR(x,R+1) FOR(y,N-R+1) cout<<x<<" "<<y<<" "<<dp[N][x][y]<<endl;
	
	ll ret=0;
	FOR(y,N-R+1) (ret+=dp[N][R][y]*p2[N*(N-R-y)])%=mo;
	cout<<ret<<endl;
	
}


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


Measured memory_bytes: 216576
import itertools

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

list_ = list(range(1, n + 1))

for num ,v in enumerate(itertools.permutations(list_, n)):
    if p == list(v):
        res_p = num + 1
        break
for num ,v in enumerate(itertools.permutations(list_, n)):
    if q == list(v):
        res_q = num + 1
        break
ans = abs(res_p - res_q)

print(ans)

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC

int main(){
    int n;cin>>n;
    string a,b,c;cin>>a>>b>>c;
    int ans=0;
    for(int i=0;i<n;i++){
        if(a[i]!=b[i]&&b[i]!=c[i]&&a[i]!=c[i]){
            ans+=2;
        }
        else if(a[i]==b[i]&&b[i]==c[i]){
            continue;
        }
        else ans+=1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3640
from collections import deque
import re
import sys
sys.setrecursionlimit(100000)

class AC:
    
    def __init__(self,num,parent,char):
        self.num = num
        self.parent = parent
        self.char = char
        self.d = {}
        self.failure = None
        
    def insert(self,string,num):
        if not string[0] in self.d:
            self.d[string[0]] = AC(num,self,string[0])
            num+=1
        if not string[1:] == "":
            return self.d[string[0]].insert(string[1:],num)
        else:
            return num
        
    def setFailure(self):
        tmp = self.parent.failure
        while(True):
            if self.char in tmp.d:
                self.failure = tmp.d[self.char]
                break
            else:
                if tmp.num == 0:
                    self.failure = tmp
                    break
                else:
                    tmp = tmp.failure
    
    def setFailureRoot(self):
        self.failure = self
    
    def setFailureFirstLayer(self):
        self.failure = self.parent
       
    def transition(self,string):
        if string == "":
            return []
        elif string[0] in self.d:
            tmp = self.d[string[0]]
            num = "{0:09d}".format(tmp.num) 
            return [num]+tmp.transition(string[1:])
        else:
            if self.num == 0:
                num = "{0:09d}".format(self.num)
                return [num]+self.transition(string[1:])
            else:
                return self.failure.transition(string)
    
H,W = [int(i) for i in input().split()]
A = [input() for _ in range(H)]
R,C = [int(i) for i in input().split()]
B = [input() for _ in range(R)]

root = AC(0,None,"")
root.setFailureRoot()
num=1
for i in B:
    num = root.insert(i,num)
d = deque()
for i in root.d.values():
    i.setFailureFirstLayer()
    for j in i.d.values():
        d.appendleft(j)
while(len(d)>0):
    tmp = d.pop()
    tmp.setFailure()
    for i in tmp.d.values():
        d.appendleft(i)
        
trans = ["" for i in range(W)]
for i in A:
    tmp = root.transition(i)
    for j,k in enumerate(tmp):
        trans[j] = trans[j]+k+"#"

ans=""
for i in B:
    ans = ans+root.transition(i)[-1]+"#"

ansd = deque()
for i,j in enumerate(trans):
    obj = re.search(ans,j)
    c = 0
    while(obj):
        s = obj.start()
        if (i-C+1)<0:
            print(i)
        ansd.append(((c+s)//10,i-C+1))
        obj = re.search(ans,j[c+s+10:])
        c += s+10

for i in sorted(ansd):
    print(i[0],i[1])


Measured memory_bytes: 234668
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
ll n,a[200005],b[200005];
int main() {
slld(n);
ll x=n/2+1;
for(int i=1;i<=n;i++)
{
    slld(a[i]);
    if(i%2!=n%2)
        b[x+i/2]=a[i];
    else
        b[x-i/2]=a[i];
}
for(int i=1;i<=n;i++)
    pss("%lld ",b[i]);
pss("\n");
    return 0;
           } 

Measured memory_bytes: 5248
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut playlist: Vec<(String, usize)> = Vec::new();
    for _ in 0..n {
        let s = iterator.next().unwrap().to_string();
        let t: usize = iterator.next().unwrap().parse().unwrap();
        playlist.push((s, t));
    }
    let x: String = iterator.next().unwrap().to_string();

    let mut ans: usize = 0;
    let mut sleeping: bool = false;
    for music in playlist {
        if sleeping {
            ans += music.1;
        } else {
            if music.0 == x {
                sleeping = true;
            }
        }
    }
    return ans.to_string();
}


Measured memory_bytes: 2136
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
    int n;
    cin >> n;
    int x[n], y[n];
    for(int i = 0; i < n; i++) cin >> x[i];
    for(int i = 0; i < n; i++) cin >> y[i];
    double d[4] = {};
    for(int i = 0; i < n; i++){
        d[0] += abs(x[i] - y[i]);
        d[1] += pow(abs(x[i] - y[i]), 2);
        d[2] += pow(abs(x[i] - y[i]), 3);
        d[3] = max(abs(x[i] - y[i]), d[3]);
    }
    double o = 1, p;
    for(int i = 0; i < 3; i++){
        p = o / (i + 1);
        d[i] = pow(d[i], p);
        printf("%.6f\n", d[i]);
    }
    printf("%.6f\n", d[3]);
}



Measured memory_bytes: 3336
import sys
sys.setrecursionlimit(10000)

def Hdfs(pat,hw):
    if len(pat)==hw:
        p=pat[:]
        Hlist.append(p)
        return
    else:
        pat.append(0)
        Hdfs(pat,hw)
        pat.pop()
        pat.append(1)
        Hdfs(pat,hw)
        pat.pop()

def Wdfs(pat,hw):
    if len(pat)==hw:
        p=pat[:]
        Wlist.append(p)
        return
    else:
        pat.append(0)
        Wdfs(pat,hw)
        pat.pop()
        pat.append(1)
        Wdfs(pat,hw)
        pat.pop()

H,W,K=map(int,input().split())
c=[input() for _ in range(H)]
ans=0

cnt=0
Hlist=[]
Wlist=[]
Hdfs([],H)
Wdfs([],W)
for i in Hlist:
    for j in Wlist:
        cnt=0
        for h in range(H):
            for w in range(W):
                if i[h]==0 and j[w]==0 and c[h][w]=="#":
                    cnt+=1
        if cnt==K:
            ans+=1
print(ans)


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

int main(){
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x3, y3, x4, y4;
  x2-=x1;
  y2-=y1;
  x4=-y2;
  y4=x2;
  x3=x2+x4;
  y3=y2+y4;
  cout << x3+x1 << ' ' << y3+y1 << ' ' << x4+x1 << ' ' << y4+y1 << endl;
}


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


int main(){
  ll n,m,x;cin>>n>>m>>x;
  vector<vector<ll>> ca(n,vector<ll>(m+1));
  for(int i=0;i<n;i++)for(int j=0;j<m+1;j++)cin>>ca[i][j];
  
  ll money=1e9;
  for(int i=0;i<(1<<n);i++){
    bitset<12> s(i);
    vector<ll> und(m+1,0);
    for(int j=0;j<n;j++)
      if(s.test(j))
        for(int k=0;k<m+1;k++)
          und[k]+=ca[j][k];
    ll mx=und[1];
    for(int j=2;j<m+1;j++)mx=min(mx,und[j]);
    if(mx>=x)money=min(money,und[0]);
  }
  if(money==1e9)cout<<-1<<endl;
  else cout<<money<<endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    //std::stack<int> stack;
    int n;
    cin >> n;
    int ans[n+1][n+1] = {0};
    for(int i = 0; i < n; i++){
        int index, k;
        cin >> index >> k;
        for(int j = 0; j < k; j++){
            int jndex;
            cin >> jndex;
            ans[index][jndex] = 1;
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j < n; j++){
            cout << ans[i][j] << " ";
        }
        cout << ans[i][n];
        cout << endl;
    }
    //cout << masu << endl;
    return 0;
}






Measured memory_bytes: 3100
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static long[] arr;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        arr = new long[n];
        for(int i = 0; i < n; i++) {
            arr[i] = sc.nextLong() - (i+1);
        }

        Arrays.sort(arr);

        long right = 1000000000;
        long left = -1000000000;
        while(Math.abs(left - right) > 2) {
            //System.err.println(left+" "+right);
            long midLeft = left + (right - left)/3;
            long midRight = left + (right - left)*2/3;
            long midLeftResult = calc(midLeft);
            long midRightResult = calc(midRight);
            if(midLeftResult > midRightResult) {
                left = midLeft;
            } else {
                right = midRight;
            }
        }
       // System.err.println(left+" "+right);
        long[] results = new long[3];
        results[0] = calc(left);
        results[1] = calc(left+1);
        results[2] = calc(left+2);
        Arrays.sort(results);
        System.out.println(results[0]);
    }

    static long calc(long b) {
        long result = 0;
        for(long num : arr) {
            result += Math.abs(num - b);
        }
        return result;
    }
}


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


int main(void){
    int n;
    char w[105][12];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s",w[i]);
    }
    //choufuku check
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(strcmp(w[i],w[j])==0){printf("No");return 0;}
        }
    }

    //shiritori check

    for(int i=0;i<n-1;i++){
        if(w[i][strlen(w[i])-1]!=w[i+1][0]){printf("No");return 0;}
    }
    printf("Yes\n");
}

Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();
            var k = cin.nextLong();
            var a = cin.ArrayLong(n);

            Array.Sort(a);
            

            if(n <= k)
            {
                Console.WriteLine(0);
            }
            else
            {
                var ans = 0L;
                for (int i = 0; i < (n-k); i++)
                {
                    ans += a[i];
                }

                Console.WriteLine(ans);
            }

            
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


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

int main() {
    int n;
    cin >> n;
    vector<long long> a(n), b(n), c(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n; i++) cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    long long ans = 0;
    for (int i = 0; i < n; i++) {
        long long x = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        long long y = c.end() - upper_bound(c.begin(), c.end(), b[i]);
        ans += x * y;
    }

    /*
    for (int i = 0; i < n; i++) cout << a[i] << " ";
    cout << endl;
    for (int i = 0; i < n; i++) cout << b[i] << " ";
    cout << endl;
    for (int i = 0; i < n; i++) cout << c[i] << " ";
    cout << endl;
    */

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

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

int main(){

	int h, w, k;
	cin >> h >> w >> k;

	vector<string> s(h);
	for(int i=0; i<h; i++){
		cin >> s[i];
	}

	int ans = 0;
	for(int is=0; is<1<<h; is++){
		for(int js=0; js<1<<w; js++){
			int cnt = 0;
			for(int i=0; i<h; i++){
				for(int j=0; j<w; j++){
					if(is >> i & 1) continue;
					if(js >> j & 1) continue;
					if(s[i][j] == '#') cnt++;
				}
			}
			if(cnt==k) ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;
const int flp=1e-6;
const int dflp=1e-12;
const int inf=2e9;
const int minf=-2e9;
const ll inf64=9e18;
const ll minf64=-9e18;

#ifdef WIN32
inline int getchar_unlocked()
{
    return _getchar_nolock();
}
inline void putchar_unlocked(char c)
{
    _putchar_nolock(c);
}
#endif

inline int raw_char()
{
    return getchar_unlocked();
}

inline int read_char()
{
    char c;
    do
    {
        c=getchar_unlocked();
    } while(c<33);
    return c;
}

inline void print_char(char c)
{
    putchar_unlocked(c);
}

template<typename T=ll>
inline T read_int()
{
    T temp=0;
    bool neg=0;
    char c=read_char();
    if(c=='-')
    {
        neg=1;
        c=raw_char();
    }
    while(c>='0'&&c<='9')
    {
        temp=temp*10+c-'0';
        c=raw_char();
    }
    return neg?-temp:temp;
}

template<typename T=ll>
inline void print_int(T x)
{
    if(x==0)
    {
        print_char('0');
        return;
    }
    char buff[24];
    int idx=0;
    if(x<0)
    {
        print_char('-');
        x=-x;
    }
    while(x)
    {
        buff[idx++]=x%10+'0';
        x/=10;
    }
    while(idx)
        print_char(buff[--idx]);
}

inline void read_str(std::string &s,char delim='\n',bool skip_whtspc=0,int bufsize=8192)
{
    char t[bufsize],c;
    if(skip_whtspc)
        c=read_char();
    else
        c=raw_char();
    int idx=0;
    while(c!=delim)
    {
        t[idx++]=c;
        c=raw_char();
    }
    t[idx]=0;
    raw_char();
    s=t;
}

inline void read_cstr(char *s,char delim='\n',bool skip_whtspc=0)
{
    char c;
    if(skip_whtspc)
        c=read_char();
    else
        c=raw_char();
    int idx=0;
    while(c!=delim)
    {
        s[idx++]=c;
        c=raw_char();
    }
    s[idx]=0;
    raw_char();
}

inline void print_str(std::string s)
{
    int len=s.length();
    for(int i=0;i<len;++i)
        print_char(i);
}

inline void print_cstr(const char *s)
{
    while(*s)
        print_char(*s++);
}

ll pow(int a,int b,ll m=inf64)
{
    ll ret=1;
    while(b)
        if(b&1)
        {
            ret*=a;
            --b;
        }
        else
        {
            b>>=1;
            ret*=ret;
        }
    return ret;
}

ll gcd(ll a,ll b)
{
    while(b)
    {
        ll t=a;
        a=b;
        b=a%b;
    }
    return a;
}

ll lcm(ll a,ll b)
{
    ll t=gcd(a,b);
    return a/t*b/t;
}

template<typename T>
int fcmp(T a,T b,T eps)
{
    T t=a-b;
    if(abs(t)<=eps)
        return 0;
    if(t>=-eps)
        return 1;
    return -1;
}

int main()
{
    int n=read_int();
    vector<int> x(n);
    for(auto &i:x)
        i=read_int();
    vector<ll> dp(n);
    dp[1]=abs(x[0]-x[1]);
    for(int i=2;i<n;++i)
        dp[i]=min(dp[i-2]+abs(x[i]-x[i-2]),dp[i-1]+abs(x[i]-x[i-1]));
    print_int(dp[n-1]);
    print_char('\n');
    return 0;
}


Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        long n = sc.nextLong();
        long k = sc.nextLong();

        n = n % k;

        while (true) {
            long tmp = Math.abs(n - k);
            if (n <= tmp)
                break;
            n = tmp;
        }

        System.out.println(n);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 32696
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
ans = 0
for i in range(1,n+1):
    if i % 3 == 0:
        continue
    elif i % 5 == 0:
        continue
    ans += i
print(ans)

Measured memory_bytes: 67972
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

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

        cout << (n + 1) / 2 << endl;

        return 0;
}


Measured memory_bytes: 256
import math

r, g, b, n = map(int, input().split())
ball = [0, r, g, b]
count = 0

for i in range(n+1):
    for j in range(n+1):
        m = math.floor((n-i*r-j*g)/b)
        if i*r+j*g+m*b == n and m >= 0:
            count += 1
            
print(count)

Measured memory_bytes: 42716
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;
 
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;
 
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 GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

signed main()
{
  string s; cin>>s;
  
  ll lmax=0; // <の連続数
  ll rmax=0; // >
  bool flg1=false; // >< ブロック
  bool flg2=false; // <> ブロック内折り返し
  ll now=0; // 同文字連続数
  ll ans=0;
  rep(i,s.size()){
    if(flg1){
      rmax=now;
      ll maxv=max(lmax,rmax);
      // cout<<maxv<<endl;
      ans+=maxv;
      lmax=0;
      rmax=0;
      now=0;
      flg1=false;
    }
    if(i<s.size()&&s[i]=='>'&&s[i+1]=='<')flg1=true;
    
    if(flg2){
      lmax=now;
      now=0;
      flg2=false;
    }
    ans+=now;
    now++;
    if(i<s.size()&&s[i]=='<'&&s[i+1]=='>')flg2=true;
  }
  ans+=now;
  cout<<ans<<endl;
}

Measured memory_bytes: 900
/******************************************
* NICK : nikhilsinghh59 *
******************************************/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"

#define PB push_back
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
const int M = 1e9+7;

int main()
{   
    ll ar[5];
    ll ans;
    for(ll i=0;i<5;i++){
        cin >> ar[i];
        if(!ar[i]) {
            ans =i+1;
        }
    }
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
const int N = 100030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const int mod =    1e9+7;
int n,m;

int dp[1010][1010];
int main()
{ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n>>m;
string s[n];
rep(i,0,n)
cin>>s[i];
dp[1][1]=1;
rep(i,0,n)
rep(j,0,m)
{
	if(i==0&&j==0)
	;
	else
	if(s[i][j]!='#')
	dp[i+1][j+1]=(dp[i][j+1]+dp[i+1][j])%mod;
}
cout<<dp[n][m];
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define lo long
const int lmax=1999999999;
const long long lmx=1999999999999999999;
int n;
pair<double,int> a[404];
double t,k,s,mn=999999999;
int main(){std::ios::sync_with_stdio(false);
cin>>n;
for(int i=0;i<n;i++)
{
	cin>>a[i].first;
	a[i].second=i;
	s+=a[i].first;
}
k=s/n;
for(int i=0;i<n;i++)
{
	mn=min(mn,abs(a[i].first-k));
}
for(int i=0;i<n;i++)
{
	if(mn==abs(k-a[i].first))
	{
		cout<<i<<endl;
		return 0;
	}
}
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
               *       * *       *
               *        *        *
                *               *
                 *             *
                  *           *
                   *         *
                    *       *
                     *     *
                      *   *
                       * *
                        *



*/





Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

ll ans = 0;

int main(void){
	int a, b; cin >> a >> b;
	rep(i, 1000000){
		int aa, bb;
		aa = i*0.08;
		bb = i*0.10;
		if(aa == a && bb == b){
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

	void solve(){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int[] x=new int[n];
		for(int i=0;i<n;i++)x[i]=sc.nextInt();
		int d_sum=0;
		for(int i=0;i<n;i++) {
			int d1=2*Math.abs(x[i]);
			int d2=2*Math.abs(x[i]-k);
			d_sum+=Math.min(d1, d2);
		}
		System.out.println(d_sum);
	}
}


Measured memory_bytes: 21844
<?php
    while(!feof(STDIN))
    {
        $stdin[] = fgets(STDIN);
    }

    $n = $stdin[0];
    $cards = explode(' ', $stdin[1]);

    for ($i=0; $i < $n; $i++) {
        $cards[$i] = (int)$cards[$i];
    }

    rsort($cards, SORT_NUMERIC);

    $alice = 0;
    $bob = 0;
    $answer = 0;

    for($i=0; $i<$n; $i++)
    {
        if ($i % 2 == 0)
        {
            $alice = $alice + $cards[$i];
        }
        else
        {
            $bob = $bob + $cards[$i];
        }
    }

    $answer = $alice - $bob;
    echo $answer;
?>

Measured memory_bytes: 4604
import numpy as np
N = int(input())
A = np.array(input().split(), np.int64)
MOD = 10**9+7

U = 10**6 + 10
T = np.zeros(U, np.bool)
T[2] = 1
T[3::2] = 1

for p in range(3,U,2):
  if p*p>U:
    break
  if T[p]==1:
    T[p*p::p+p] = 0

pls = np.where(T==1)[0].tolist()
M = pls[:1000]

B = A.copy()
lcm = 1
for p in M:
  e = 0
  while np.any(A%p==0):
    A[A%p==0] //= p
    e += 1
  lcm *= p**e
  lcm %= MOD
for x in set(A.tolist()):
  lcm *= x
  lcm %= MOD
x = sum(pow(c, MOD-2, MOD) for c in B.tolist())
print(x*lcm%MOD)

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

ll N,M;
ll X[100000];
ll XD[100000];
int main(void){
    cin >> N >> M;
    rep(i,M)cin>>X[i];
    sort(X,X+M);
    rep(i,M-1)XD[i] = X[i+1] - X[i];
    sort(XD,XD+M-1);
    ll ans=0;
    rep(i,M-N) ans+=XD[i];
    cout << ans << endl;
}


Measured memory_bytes: 1792