akhauriyash/Code-Regression huggingface dataset:
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll n,T,t[200001];
    std::cin >> n>>T;
    
    ll result = 0;
    for (int i = 0; i < n; i++) {
        std::cin >> t[i];
        if(i==0){
            result += T;
        }else if(i>0){
            if(t[i]-t[i-1]<T){
                result += t[i]-t[i-1];
            }else{
                result += T;
            }
        }
    }
    
    std::cout << result << std::endl;
    
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define pii pair<int, int>
#define vc vector
#define a first
#define b second
#define pb pusu_back
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (100000)

/////////////////////////////////////////////////////////

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> &V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

template<typename T>
T euclid(T a, T b){
  if(b == 0) return a;
  else return euclid(b, a % b);
}

vector<ll> fact(MAX, 0), fact_inv(MAX, 0);

/////////////////////////////////////////////////////////

//MOD of Combination

ll pow_mod(ll a, ll b){
	ll res = 1;
	while(b > 0){
		if(b & 1) res = res * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return res;
}

void prepare_comb_mod(ll n){
	fact[0] = 1LL;
	for(ll i = 0; i < n; i++) fact[i+1] = fact[i] * (i + 1) % MOD;
	fact_inv[n] = pow_mod(fact[n], MOD - 2);
	for(ll i = n - 1; i >= 0; i--) fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD;
}

ll comb_mod(ll n, ll r){
	return (fact[n] * fact_inv[r]) % MOD * fact_inv[n - r] % MOD;
}

/////////////////////////////////////////////////////////

//Union-Find Tree

int UFT_par[MAX];
int UFT_rank[MAX];

void UFT_init(int n){
  rep(i, 0, n){
    UFT_par[i] = i;
    UFT_rank[i] = 0;
  }
}

int UFT_find(int x){
  if(UFT_par[x] == x){
    return x;
  }else{
    return UFT_par[x] = UFT_find(UFT_par[x]);
  }
}

void UFT_unite(int x, int y){
  x = UFT_find(x);
  y = UFT_find(y);
  if(x == y) return;
  if(UFT_rank[x] < UFT_rank[y]){
    UFT_par[x] = y;
  }else{
    UFT_par[y] = x;
    if(UFT_rank[x] == UFT_rank[y]) UFT_rank[x]++;
  }
}

bool UFT_same(int x, int y){
  return UFT_find(x) == UFT_find(y);
}

/////////////////////////////////////////////////////////

void Main() {
  ll N, M; cin >> N >> M;
  vc<ll> A(N);
  rep(i, 0, N) cin >> A[i];
  map<ll, ll> mp;
  mp[0] = 1ll;
  ll sum = 0ll;
  rep(i, 0, N){
    sum += A[i];
    sum %= M;
    mp[sum]++;
  }
  ll res = 0;
  for(auto x : mp){
    res += x.b * (x.b - 1) / 2;
  }
  cout << res << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 6528
#include <bits/stdc++.h> 
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define per(i,n) for(long long i = (long long)(n-1);i >= 0;--i)
#define REP(i,s,t) for(long long i=s;i<t;i++)
#define PER(i,s,t) for(long long i=s;i>t;--i)
#define all(x) x.begin(),x.end()
#define sp(n) setprecision(n)
typedef long long ll;
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  cout<<c<<" "<<a<<" "<<b<<endl;
}

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

#define itn long long
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)(n);i>=0;--i)
#define debug(x) cout << #x << "=" << (x) << endl;
const ll MOD=1e9+7;

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;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
//template end

void solve(){
  while(1){
    int N;
    cin>>N;if(!N)break;
    int l=0,r=0,b=1,res=0;
    rep(i,N){
      string s;
      cin>>s;
      if(s[0]=='l')l^=1;
      else r^=1;
      if(l==b&&r==b){res++;b^=1;}
    }
    cout<<res<<endl;
  }
}
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  solve();
  return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const int MAX_N=2e5+3;


const unsigned long long B=1e12+7;


int main(){
    long X;
    cin>>X;
    cout<<(int)(X/500)*1000+(int)(X%500/5)*5<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
#define mx 500001
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define mkp make_pair
//#define d double
int h,v;
void solve(){
cin>>h>>v;
vs vec(h);
rep(i,0,h) cin>>vec[i];
vvi dis(h,vi(v,-1));
ll ans=minf;
for(int i=0;i<h;i++){
	for(int j=0;j<v;j++){
		if(vec[i][j]=='.'){
			queue<pi> q;
			q.push(mkp(i,j));
			dis[i][j]=0;
			while(!q.empty()){
				pi p=q.front();
				q.pop();
				int x=p.f;
				int y=p.se;
				if(x+1<h && vec[x+1][y]=='.' && dis[x+1][y]==-1){
					dis[x+1][y]=dis[x][y]+1;
					q.push(mkp(x+1,y));
				}
				if(x-1>=0 && vec[x-1][y]=='.' && dis[x-1][y]==-1){
					dis[x-1][y]=dis[x][y]+1;
					q.push(mkp(x-1,y));
				}
				if(y+1<v && vec[x][y+1]=='.' && dis[x][y+1]==-1){
					dis[x][y+1]=dis[x][y]+1;
					q.push(mkp(x,y+1));
				}
				if(y-1>=0 && vec[x][y-1]=='.' && dis[x][y-1]==-1){
					dis[x][y-1]=dis[x][y]+1;
					q.push(mkp(x,y-1));
				}
			}
			// if(i==0 && j==4){
			// 	for(int rk=0;rk<h;rk++){
			// 		cout<<dis[rk];
			// 	}
			// }
			for(int r=0;r<h;r++){
				for(int w=0;w<v;w++){
					ans=max(ans,dis[r][w]);
					dis[r][w]=-1;
				}
			}
		}
	}
}
cout<<ans;
}
int32_t main(){
FIO;
int t=1;
//cin>>t;
while(t--){
	solve();
}
}



Measured memory_bytes: 256
using System;

namespace ITP1_10_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;
            while ((n = int.Parse(Console.ReadLine())) != 0)
            {
                string[] strs = Console.ReadLine().Split(' ');
                double[] a = new double[n];
                double sum = 0;
                for (int i = 0; i < n; i++)
                {
                    a[i] = double.Parse(strs[i]);
                    sum += a[i];
                }
                double avg = sum / n;
                sum = 0;
                for (int i = 0; i < n; i++)
                {
                    sum += (a[i] - avg) * (a[i] - avg);
                }
                Console.WriteLine(Math.Sqrt(sum / n));
            }
        }
    }
}

Measured memory_bytes: 9076
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	lint ans = 0;
	lint current = 0;
	cin >> N;

	vector<lint> a(N, 0);

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

	int left = 0, right = 0;

	current = 0;

	for (left = 0; left < N; left++)
	{
		if (right < left)
			current += a[right++];

		for (; right < N; right++)
		{
			if (current & a[right])
			{
				break;
			}
			current += a[right];
		}
		ans += right - left;
		if (left == right)
		{
			right++;
		}
		else
		{
			current -= a[left];
		}
	}

	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 1792
N, M = map(int, input().split())

st = [1] * (N+1)

for i in range(M):
    x = int(input())
    st[x] = 0


for i in range(2, N+1):
    if st[i]:
        st[i] = st[i-1] + st[i-2]

#print(st)
print(st[-1] % 1000000007)


Measured memory_bytes: 460020
import java.util.*;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String name = sc.next();
		int nl = name.length();
		int cnt=0;
		
		for(int i0=0; i0<N; ++i0){//N個の看板
//			System.out.println(i0);
			String old =sc.next();
			int ol = old.length();
			boolean flg=false;
			for(int i1=0; (nl-1)*i1+nl<=ol; ++i1){//文字の間隔
				for(int i2=0; i2<=ol-((nl-1)*i1+nl); ++i2){//一文字目のサーチ
					int check=0;
					for(int i3=0; i3<nl; ++i3){//チェック
//						System.out.println(i3+" "+(i2+i3*i1+i3));
						if(name.charAt(i3)==old.charAt(i2+i3*i1+i3)){
							++check;
						}
						if(check==nl){
							flg=true;
							break;
						}
					}
					if(flg) break;
				}
				if(flg) break;
			}
			if(flg) ++cnt;
		}	
		System.out.println(cnt);
		
	}
}

Measured memory_bytes: 20368
import sys
import bisect


input = sys.stdin.readline
a, b, q = map(int, input().split())
inf = 10**12
s_list = [-inf] + [int(input()) for _ in range(a)] + [inf]
s_list.sort()
t_list = [-inf] + [int(input()) for _ in range(b)] + [inf]
t_list.sort()
ans_list =[]
for _ in range(q):
    x = int(input())
    s_idx = bisect.bisect_right(s_list, x)
    t_idx = bisect.bisect_right(t_list, x)
    ans = inf
    for s in [s_list[s_idx-1], s_list[s_idx]]:
        for t in [t_list[t_idx-1], t_list[t_idx]]:
            ans = min(ans, min(abs(x-s), abs(x-t)) + abs(s-t))
    print(ans)


Measured memory_bytes: 14484
import collections
n = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c = collections.Counter(prime_factorize(n))
A = list(c.values())

def dg(x):
    x = int(x)
    y = ((x * 8 + 1) ** (1 / 2) - 1) // 2
    return y

ans = 0
for v in A:
    ans += int(dg(v))

print(ans)


Measured memory_bytes: 9696
N = int(input())
s = input()

black, white = [0] * (N+1), [0] * (N+1)
for i in range(N):
    if s[i] == "#":
        black[i+1] = black[i] + 1
        white[i+1] = white[i] 
    else:
        black[i+1] = black[i]
        white[i+1] = white[i] + 1

minChange = 100000
for i in range(N+1):
    minChange = min(black[i] - black[0] + white[N] - white[i], minChange)
print(minChange)



Measured memory_bytes: 12808
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,x;
	scanf("%d %d",&n,&x);
	char a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	a[x-1]=a[x-1]+32;
	for(int i=0;i<n;i++)
	{
		cout<<a[i];
	}
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[3]:


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


# In[6]:


tmp = float('inf')
for hi in H[::-1]:
    if tmp >= hi:
        tmp = hi
    elif tmp == hi-1:
        tmp = hi - 1
    elif tmp < hi-1:
        print('No')
        break
else:
    print('Yes')


# In[ ]:






Measured memory_bytes: 14396
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
#include<numeric>
#include<queue>
#include<string>
#include<vector>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
ll mod = 1000000007;
using namespace std;
priority_queue<ll int>A;//きゅー
int main(void)
{
	int N;
	char S[100010];
	scanf("%d%s", &N,S);
	if (N % 2 == 1) {
		printf("No");
		return 0;
	}
	for (int i = 0; i < N / 2; i++) {
		if (S[i] != S[i + N / 2]) {
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
	


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<pair<int,int> > g[100005];
int j[100005];

int main() {
	// your code goes here
    int n,i,a[100005],b[100005],k=0,c[100005];
    bool used[100005]={0};
    cin >> n;
    for(i=0;i<n-1;i++){
        cin >> a[i] >> b[i];
        if(a[i]>b[i]) swap(a[i],b[i]);
        g[a[i]].push_back({b[i],i});
        g[b[i]].push_back({a[i],i});
    }
    for(i=0;i<n;i++) {
        j[i]=g[i].size();
        k=max(k,j[i]);
    }
    cout << k << endl;
    queue<int> que;
    que.push(1);
    while(!que.empty()){
        int q=que.front();
        used[q]=true;
        que.pop();
        int pb;
        for(i=0;i<j[q];i++){
            if(used[g[q][i].first]){
                pb=c[g[q][i].second];
            }
        }
        int memo=1;
        for(i=0;i<j[q];i++){
            if(used[g[q][i].first]) continue;
            que.push(g[q][i].first);
            if(memo==pb) memo++;
            c[g[q][i].second]=memo;
            memo++; 
        }
    }
    for(i=0;i<n-1;i++) cout << c[i] << endl;
    return 0;
}

Measured memory_bytes: 8192
import java.util.Scanner;

class Main {
    private static void mark(int x, int y, int flag, char[][] data, int[][] map) {
        for (int i = x + 1; i < data.length; i++) {
            if (data[i][y] == '.' && (map[i][y] & flag) == 0) {
                map[i][y] |= flag;
                mark(i, y, flag, data, map);
            } else {
                break;
            }
        }
        for (int i = x - 1; i >= 0; i--) {
            if (data[i][y] == '.' && (map[i][y] & flag) == 0) {
                map[i][y] |= flag;
                mark(i, y, flag, data, map);
            } else {
                break;
            }
        }
        for (int j = y + 1; j < data[0].length; j++) {
            if (data[x][j] == '.' && (map[x][j] & flag) == 0) {
                map[x][j] |= flag;
                mark(x, j, flag, data, map);
            } else {
                break;
            }
        }
        for (int j = y - 1; j >= 0; j--) {
            if (data[x][j] == '.' && (map[x][j] & flag) == 0) {
                map[x][j] |= flag;
                mark(x, j, flag, data, map);
            } else {
                break;
            }
        }
    }

    private static void solve() {
        final Scanner scanner = new Scanner(System.in);

        while (true) {
            final int w = scanner.nextInt();
            final int h = scanner.nextInt();
            if (w == 0 && h == 0) {
                break;
            }

            final char[][] data = new char[h][];
            final int[][] map = new int[h][w];
            for (int i = 0; i < h; i++) {
                    data[i] = scanner.next().toCharArray();
            }
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    switch (data[i][j]) {
                        case 'B':
                            mark(i, j, 0x1, data, map);
                            break;
                        case 'W':
                            mark(i, j, 0x2, data, map);
                            break;
                        default:
                            break;
                    }
                }
            }
            int black = 0;
            int white = 0;
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    switch (map[i][j]) {
                        case 0x1:
                            black++;
                            break;
                        case 0x2:
                            white++;
                            break;
                        default:
                            break;
                    }
                }
            }
            System.out.println(black + " " + white);
        }
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 0
n,k = gets.chomp.split(" ").map(&:to_i)
div = 10**9 + 7
fact = Array.new(n+1,1)
for i in 1..n do
    fact[i] = fact[i-1] * i
    fact[i] = fact[i]
end

for i in 1..k do
    n1 = n-k+1
    k1 = i
    n2 = k-1
    k2 = i-1
    op1 = fact[n1]*fact[n2]
    op2 = fact[k1]*fact[n1-k1]*fact[k2]*fact[n2-k2]
    puts (op1/op2)%div
end


Measured memory_bytes: 20732
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
#ifdef KEV
#define DE(i, e) cerr << #i << ' ' << i << e
void debug(auto L, auto R) { while (L < R) cerr << *L << " \n"[L+1==R], ++L; }
#else
#define DE(...) 0
void debug(...) {}
#endif
const int maxn = 300010;
int n, a[maxn], st[maxn];
signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	for (int i = 0;i < n;++i)
		cin >> a[i], st[i] = i;
	sort(st, st+n, [&](int x, int y) {
		return a[x] < a[y];
	});
	int res = 0;
	for (int i = 0;i < n;++i)
		if ( (i^st[i])&1 ) ++res;
	assert(res % 2 == 0);
	cout << res / 2 << '\n';
}


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

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

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

#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 REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vector<pll> P(N);
    REP(i,0,N) cin >> P[i].first >> P[i].second;

    pll p1 = P[0], p2 = P[0], p3 = P[0], p4 = P[0];
    ll k1 = -INF, k2= -INF, k3 = -INF, k4 = -INF;
    REP(i,0,N) {
        if(-P[i].first + P[i].second > k1) {
            k1 = -P[i].first + P[i].second;
            p1 = P[i];
        }
        if(P[i].first + P[i].second > k2) {
            k2 = P[i].first + P[i].second;
            p2 = P[i];
        }
        if(P[i].first - P[i].second > k3) {
            k3 = P[i].first - P[i].second;
            p3 = P[i];
        }
        if(-P[i].first - P[i].second > k4) {
            k4 = -P[i].first - P[i].second;
            p4 = P[i];
        }
    }

    vec D(6);
    D[0] = abs(p1.first-p2.first) + abs(p1.second-p2.second);
    D[1] = abs(p1.first-p3.first) + abs(p1.second-p3.second);
    D[2] = abs(p1.first-p4.first) + abs(p1.second-p4.second);
    D[3] = abs(p2.first-p3.first) + abs(p2.second-p3.second);
    D[4] = abs(p2.first-p4.first) + abs(p2.second-p4.second);
    D[5] = abs(p3.first-p4.first) + abs(p3.second-p4.second);
    
    DESC(D);
    PR(D[0]);

    return 0;
}

/*



*/

Measured memory_bytes: 6360
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#define mod (int)(1e9 + 7)
#define pb push_back
#define int long long
using namespace std;
typedef pair<int,int> pii;

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

  if(s[0]=='W' || s[s.size()-1]=='W'){
    cout<<0<<endl;
    return 0;
  }

  bool hako[2*n+1];

  hako[0]=false;
  hako[s.size()-1]=true;

  int l,r;
  l=r=0;

  for(int i=1;i<s.size()-1;i++){
    if(s[i]!=s[i-1]){
      hako[i]=hako[i-1];
    }
    else{
      hako[i]=!hako[i-1];
    }
  }

  // for(int i=0;i<s.size();i++){
  //   if(hako[i]) cout<<"R";
  //   else cout<<"L";
  // }cout<<endl;

  for(int i=0;i<s.size();i++){
    if(hako[i]) r++;
    else l++;
  }

  if(l!=r){
    cout<<0<<endl;
    return 0;
  }
  l=r=0;
  int res=1;

  int n_=n;
  for(int i=1;i<n;i++){
    n_*=i;
    n_%=mod;
  }

  for(int i=0;i<s.size();i++){
    if(!hako[i]) l++;
    else{
      res*=(l-r);
      res%=mod;
      r++;
    }
  }
  cout<<(res*n_)%mod<<endl;

  return 0;
}


Measured memory_bytes: 772
#include<algorithm>
#include<cstdio>
#include<functional>
#include<iostream>
#include<cfloat>
#include<climits>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<time.h>
#include<vector>
using namespace std;
string s;
int main(){
	cin >> s;
	int ans = 700;
	for(int i = 0; i < 3 ; ++ i)
		ans += (s[i] == 'o') * 100;
	cout << ans << endl;
	system("pause");
	return 0;
}

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

void solve(){
	
	int n,t ;
	cin>>n>>t  ;

	vector<int> v(n) ;

	rep(i,n){
		cin>>v[i] ;
	}

	vector<pair<int,int>> answer ;

	int pointer=0 ;

	rep(i,n){

		if(i==0){
			answer.push_back({v[i],v[i]+t}) ;
			continue ;
		}
		else{

			if(v[i]<answer[pointer].second){

				answer[pointer].second=v[i]+t ;

			}else{

				answer.push_back({v[i],v[i]+t}) ;				
				pointer++ ;

			}

		}

	}
	
	ll a=0 ;

	for(auto x:answer){
		//cout<<x.first<<" "<<x.second<<"\n" ;
		a+=x.second-x.first ;

	}
	
	cout<<a ;
}


int main(){
	
	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

Measured memory_bytes: 5964
points = list(map(int, input().split(' ')))
point1 = {'x': points[0], 'y': points[1]}
point2 = {'x': points[2], 'y': points[3]}

delta_x = point2['x'] - point1['x']
delta_y = point2['y'] - point1['y']

point3 = {
  'x': point2['x'] - delta_y,
  'y': point2['y'] - (-delta_x)
}

delta_x = point3['x'] - point2['x']
delta_y = point3['y'] - point2['y']

point4 = {
  'x': point3['x'] - delta_y,
  'y': point3['y'] - (-delta_x)
}

print(point3['x'], point3['y'], point4['x'], point4['y'])

Measured memory_bytes: 3064
N = gets.to_i
AS = [
  nil,
  [nil, *gets.split.map(&:to_i)],
  [nil, *gets.split.map(&:to_i)],
]
ans = 0
for d in 1..N
  y = 1
  sum = 0
  for x in 1..N
    sum += AS[y][x]
    if x == d
      y = 2
      sum += AS[y][x]
    end
  end
  ans = sum if sum > ans
end
p ans


Measured memory_bytes: 1788
n=int(input())
ba=[]
for i in range(n):
  a,b=map(int,input().split())
  ba.append([b,a])
ba.sort()
t=0
for i in range(n):
  t+=ba[i][1]
  if t<=ba[i][0]:
    continue
  else:
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 38088
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 
                                                           
*/
/* }}} */

#include <bits/stdc++.h>
using namespace std;

// #define int long long

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define print(x) cout << x << '\n'
#define Fi first
#define Se second

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = 999999999;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool is_uruu(int y) {return y % 4 == 0 && y % 100 != 0 || y % 400 == 0;}
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}

/* }}} */

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vi a(2 * n); REP(i, 2 * n) cin >> a[i];
  sort(a.begin(), a.end(), greater<int>());

  ll ans = 0;
  for (int i = 1; i < n * 2; i += 2) {
    ans += a[i];
  }

  print(ans);

  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N,M;
  int p[100000];
  char S1[100000];//WA AC 確認用
  char S2[100000];//入力対処用
  int ansp[100000]={};//1ならAC済み
  int ansWAp[100000]={}; //AC済み問題なら回答に足す
  int ansWA = 0;//回答
  int ansAC = 0;//回答
  int i;
  scanf("%d %d",&N,&M);
  for(i=0;i<M;i++){
    scanf("%d %c %c",&p[i],&S1[i],&S2[i]);
    if(ansp[p[i]]!=1 && S1[i]=='W') //ACしていないもののWA
      ansWAp[p[i]]++;
    else if(ansp[p[i]]!=1 && S1[i]=='A'){ //ACしていないもののAC
      ansAC++;
      ansp[p[i]] = 1;
      //ACした問題のWAを回答に加算
      if(ansp[p[i]]==1)
        ansWA += ansWAp[p[i]];
    }
  }
    
  printf("%d %d",ansAC,ansWA);
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int n,k,c,last=-1e9;
string s;
vector<int> v1,v2;
int main(){
	cin>>n>>k>>c>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='o'&&v1.size()<k&&i-last>c){
			v1.push_back(i);
			last=i;
		}
	}
	last=1e9;
	for(int i=n-1;i>=0;i--){
		if(s[i]=='o'&&v2.size()<k&&last-i>c){
			v2.push_back(i);
			last=i;
		}
	}
	for(int i=0;i<k;i++)
		if(v1[i]==v2[k-i-1])
			cout<<v1[i]+1<<endl;
	return 0;
}

Measured memory_bytes: 3448
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

template <typename Abelian>
struct BITRangeAdd {
  BITRangeAdd(int n_, const Abelian UNITY = 0) : n(n_), UNITY(UNITY) {
    ++n;
    dat_const.assign(n, UNITY);
    dat_linear.assign(n, UNITY);
  }

  void add(int left, int right, Abelian val) {
    if (right < ++left) return;
    for (int i = left; i < n; i += i & -i) {
      dat_const[i] -= val * (left - 1);
      dat_linear[i] += val;
    }
    for (int i = right + 1; i < n; i += i & -i) {
      dat_const[i] += val * right;
      dat_linear[i] -= val;
    }
  }

  Abelian sum(int idx) {
    Abelian res = UNITY;
    for (int i = idx; i > 0; i -= i & -i) res += dat_linear[i];
    res *= idx;
    for (int i = idx; i > 0; i -= i & -i) res += dat_const[i];
    return res;
  }

  Abelian sum(int left, int right) {
    if (right <= left) return UNITY;
    return sum(right) - sum(left);
  }

  Abelian operator[](const int idx) { return sum(idx, idx + 1); }

private:
  int n;
  const Abelian UNITY;
  vector<Abelian> dat_const, dat_linear;
};

int main() {
  int n, m; cin >> n >> m;
  vector<pair<int, pair<int, int>>> lr(n);
  REP(i, n) {
    int l, r; cin >> l >> r;
    lr[i] = {r - l + 1, {l, r}};
  }
  sort(ALL(lr));
  reverse(ALL(lr));
  BITRangeAdd<int> bit(m + 1);
  FOR(d, 1, m + 1) {
    while (!lr.empty() && lr.back().first < d) {
      --n;
      int l, r; tie(l, r) = lr.back().second;
      lr.pop_back();
      bit.add(l, r + 1, 1);
    }
    int ans = n;
    for (int sta = d; sta <= m; sta += d) ans += bit[sta];
    cout << ans << '\n';
  }
  return 0;
}


Measured memory_bytes: 5248
import math
n,d=map(int, input().split())
x=[[0 for _ in range(d)] for _ in range(n)]
for j in range(n):
    x[j]=list(map(int, input().split()))
count=0
    
for i in range(n):
  for j in range(i+1,n):
    dis=0
    for k in range(d):
      dis+=(x[i][k]-x[j][k])**2
    if math.sqrt(dis)==int(math.sqrt(dis)):
      count+=1
print(count)

Measured memory_bytes: 3064
A=input()
B=input()
flag="EQUAL"

if len(A)!=len(B):
    if(len(A)>len(B)):
        print("GREATER")
    else:
        print("LESS")
else:
    for i in range(len(A)):
        if A[i] > B[i]:
            flag="GREATER"
            break
            
        elif A[i] < B[i]:
            flag="LESS"
            break
    print(flag)

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

int n = 0;
deque<int>Num;

int main(){
    scanf("%d", &n);
    if(n % 2 == 0 ){
        for(int i = 1; i <= n; i++){
            int x;
            scanf("%d", &x);
            if(i % 2 == 0) Num.push_front(x);
            else Num.push_back(x);
        }
    }
    else{
        for(int i = 1; i <= n; i++){
            int x;
            scanf("%d", &x);
            if(i % 2 == 1) Num.push_front(x);
            else Num.push_back(x);
        }
    }
    for(auto Pos : Num){
        printf("%d ", Pos);
    }
    return 0;
}


Measured memory_bytes: 2944
//Looked editorial

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define all(v) v.begin(), v.end()
#define f(n) for(int i=1; i<=n; i++) 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);cerr.tie(NULL);
#define rep(i,a,b) for(int i=a; i<b; i++) 
#define repd(i,a,b) for(int i=a-1; i>=b; i--)
#define pii pair <int, int> 
#define yass cout<<"YES"<<endl;
#define noo cout<<"NO"<<endl;
#define bye {cout<<-1; return 0;}
int inf=-1e18;
const int mod= 1e9+7;
int n,m,k,t=1,x,y,z,l,r,w,d,q,ct,ans,f; int a[200005]; string s,p; set<int> si;  map<int,int> mi; priority_queue<int,vector<int>,greater<int>> pqai;

signed main(){  
cin>>n>>t;
f(n){cin>>a[i]; if(i>1)if(a[i]-a[i-1]<t)ans+=t-a[i]+a[i-1];}
cout<<n*t-ans;

}



Measured memory_bytes: 1792
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr ll inf = INT32_MAX / 2;
constexpr ll INF = LLONG_MAX / 2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }

    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int A, B, X;
    cin >> A >> B >> X;
    if (A <= X && A + B >= X) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 3628
#include <stdio.h>
int main(void)
{
    int a, b;
    scanf("%d", &a);
    scanf("%d", &b);
    if ( a - b < 0 )
         puts("a < b");
    else if ( a - b > 0)
         puts("a > b");
    else
         puts("a == b");
    return 0;
}


Measured memory_bytes: 2124
#include <iostream>
using namespace std;
#define rep(i,q) for(int i = 0; q > i; i++)
int naga(int s){
  int kai = 0;
  while(s != 0) s /= 10, kai++;
  return kai;
}
int abss(int s){
  return (s < 0 ? s * -1 : s);
}
int main(){
  long long a;
  cin >> a;  //3桁抜き出す
  int off = 1;
  int kinzi = 1000;
  for(int i = 0; naga(a) - 1 > i; i++){
    int san = (a / off) % 1000;
    if(kinzi > abss(san - 753))kinzi = abss(san-753);
    off *= 10;
  }
  cout << kinzi << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int tc; cin>>tc;
	while(tc--){
		int x,y,w,h,n; cin>>x>>y>>w>>h>>n;
		int res=0;
		for(int i=0;i<n;i++){
			int a,b; cin>>a>>b;
			if(x<=a && a<=x+w && y<=b && b<=y+h)
				res++;
		}
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#!/usr/bin/python3

S = input()
m = 0
for i in range(0, len(S)):
    for j in range(i, len(S)+1):
        sub = S[i:j]
        #print(i, j, sub)
        if all(x in 'ATCG' for x in sub):
            m = max(len(sub), m)
print(m)



Measured memory_bytes: 2940
// https://abc111.contest.atcoder.jp/tasks/abc111_b

#include<iostream>
#include<climits>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
int main(){

	int n;
	cin >> n;
	
	
	for(int i = n; i <= 999; i++)
	{
		int ichi = i%10;
		int juu = (i/10)%10;
		int hyaku = (i/100)%10;
		if(ichi == juu && juu==hyaku){
			cout << i << endl;
			return 0;
		}
	}
	
	return 0;
}

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

int main(){
    string S;
    long long K;
    cin >> S >> K;
    map<char,int> mp;
    for(char& c : S) mp[c]++;
    long long ans = 0;
    int l = 0, r = 0;
    bool fl = true;
    int ag = 0;
    while(r < S.size()){
        while(S[l] == S[r] && r < S.size()) r++;
        ans += (r - l) / 2;
        if(l == 0 && S[0] == S[S.size() - 1]) {
            if((r - l) % 2 == 0) fl = false;
            else ag++;
        }
        if(r == S.size() && (r - l) % 2 == 1 && S[0] == S[S.size() - 1]) {
            if(fl) ans++;
            ag++;
        }
        l = r;
    }
    ans *= K;
    if(ag == 2 && K > 1) ans--;
    if(mp.size() == 1) ans = S.size() * K / 2;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
//
struct poi{
  int X;int Y;int Z;
  bool operator<(const poi&R)const{
    return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
  }
};
//
int P[30];
bool check(){
	bool F;
  if(P[0]==P[1]&&P[1]==P[2]&&P[2]==P[3]&&P[3]==P[4]&&P[4]==P[5]&&P[5]==P[6]&&P[6]==P[7]&&P[7]==P[8]){
		F=true;
	}else{
		F=false;
	}
	if(F&&P[9]==P[10]&&P[10]==P[11]){
		F=true;
	}else{
		F=false;
	}
	if(F&&P[12]==P[13]&&P[13]==P[14]){
		F=true;
	}else{
		F=false;
	}
	if(F&&P[15]==P[16]&&P[16]==P[17]){
		F=true;
	}else{
		F=false;
	}
	if(F&&P[18]==P[19]&&P[19]==P[20]){
		F-true;
	}else{
		F=false;
	}
	if(F&&P[21]==P[22]&&P[22]==P[23]&&P[23]==P[24]&&P[24]==P[25]&&P[25]==P[26]&&P[26]==P[27]&&P[27]==P[28]&&P[28]==P[29]){
		F=true;
	}else{
		F=false;
	}
	return F;
}
int ans=8;
void DFS(int now){
	if(check()){
	  ans=min(ans,now);
		return;
	}else if(now==8){
		return;
	}else{
		swap(P[6],P[21]);
		swap(P[7],P[22]);
		swap(P[8],P[23]);
		swap(P[12],P[17]);
		swap(P[9],P[11]);
		DFS(now+1);
	  swap(P[6],P[21]);
		swap(P[7],P[22]);
		swap(P[8],P[23]);
		swap(P[9],P[11]);
		swap(P[12],P[17]);
		//
		swap(P[0],P[27]);
		swap(P[1],P[28]);
		swap(P[2],P[29]);
		swap(P[14],P[15]);
		swap(P[18],P[20]);
		DFS(now+1);
    swap(P[0],P[27]);
		swap(P[1],P[28]);
		swap(P[2],P[29]);
		swap(P[14],P[15]);
		swap(P[18],P[20]);
		//
		swap(P[2],P[21]);
		swap(P[5],P[24]);
		swap(P[8],P[27]);
		swap(P[11],P[18]);
		swap(P[12],P[14]);
		DFS(now+1);
		swap(P[2],P[21]);
		swap(P[5],P[24]);
		swap(P[8],P[27]);
		swap(P[11],P[18]);
		swap(P[12],P[14]);
	  //
		swap(P[0],P[23]);
		swap(P[3],P[26]);
		swap(P[6],P[29]);
		swap(P[9],P[20]);
		swap(P[15],P[17]);
		DFS(now+1);
	  swap(P[0],P[23]);
		swap(P[3],P[26]);
		swap(P[6],P[29]);
		swap(P[9],P[20]);
		swap(P[15],P[17]);
		//
	}
}
//
int main(){
	int N;
	cin>>N;
	FOR(i,0,N){
		FOR(j,0,30){
			cin>>P[j];
		}
		ans=8;
		DFS(0);
		cout<<ans<<endl;
	}
	return 0;
}



Measured memory_bytes: 3084
N = int(input())
X = list(map(int,input().split()))

INF = 10**7

def cost(x,p):
    return (x-p)**2

X.sort()
ans = INF
for p in range(X[0],X[N-1]+1):
    sum = 0
    for i in range(N):
        sum += cost(X[i],p)
    ans = min(ans,sum)

print(ans)


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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

const int N = 1e5+1;
int n, k, a[N], dp[N];

int main()
{
  fastio;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) dp[i] = INF;
  dp[1] = 0;
  for (int i = 2; i <= n; i++){
    for (int j = max(1, i - k); j < i; j++){
      dp[i] = min(dp[i], dp[j] + abs(a[j] - a[i]));
    } 
  }
  cout << dp[n];
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>

int main()
{
	int a;
	int b;
	int c;
	std::cin >> a >> b;
	c = (a+b)/2;
	if ((a+b)%2 == 1) {
		c += 1;
	}
	std::cout << c << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int a[50][50]={},w,h,box[2500][2],rear=-1,front=0;

int bfs(int i,int j){
  int b;
  rear++;
  if(i==h-1&&j==w-1)
    return a[i][j];
  if(i>0&&a[i-1][j]==0){
    box[front][0]=i-1;
    box[front++][1]=j;
    a[i-1][j]=a[i][j]+1;
  }
  if(j>0&&a[i][j-1]==0){
    box[front][0]=i;
    box[front++][1]=j-1;
    a[i][j-1]=a[i][j]+1;
  }
  if(i<h-1&&a[i+1][j]==0){
    box[front][0]=i+1;
    box[front++][1]=j;
    a[i+1][j]=a[i][j]+1;
  }
  if(j<w-1&&a[i][j+1]==0){
    box[front][0]=i;
    box[front++][1]=j+1;
    a[i][j+1]=a[i][j]+1;
  }
  if(front>rear)
    b=bfs(box[rear][0],box[rear][1]);
  else return -1;
  return b;
}

int main(){
  int i,j,cnt=0,b;
  char s[50];
  scanf("%d %d",&h,&w);
  for(i=0;i<h;i++){
    scanf("%s",s);
    for(j=0;j<w;j++){
      if(s[j]=='#'){
        a[i][j]=-1;
        cnt++;
      }
    }
  }
  a[0][0]=1;
  b=bfs(0,0);
  if(b!=-1)
    printf("%d\n",w*h-b-cnt);
  else printf("-1\n");
}

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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []
    s = string.ascii_letters

    while True:
        n = I()
        if n == 0:
            break
        a = LI()
        l = len(a)
        t = S()
        r = ''
        for i in range(len(t)):
            c = t[i]
            b = a[i%n]
            ci = s.index(c)
            r += s[ci-b]
        rr.append(r)

    return '\n'.join(map(str, rr))


print(main())




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

int main(){
	string s;
	cin >> s;
	int j = 0, answer = 0;
	for (int i = 0; i < s.size(); ++i){
		if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') j++;
		else{
			if(answer < j) answer = j;
			j = 0;
		}
	}
	if(answer < j) answer = j;
	printf("%d\n", answer);
	return 0;
}

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

#define pb push_back
#define all(a) begin(a), end(a)
#define deb(x) cout << #x << " = " << x << endl
template <typename T> vector<T> readVector(int n) { vector<T> res(n); for (int i = 0 ; i < n ; i++) cin >> res[i]; return res; }

void yes() {cout << "YES" << "\n";}
void no() {cout << "NO" << "\n";}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int x;
  	cin >> x;
  	if(x >= 30) {
      cout << "Yes" << endl;
    } else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
long divitor(long q){
   long t=0;
    while(q>0){
    q/=10;
    t++;
    }
    return t;
    }

int main()
{
  long n,ans,i;
    cin>>n;
	ans=divitor(n);
    for( i=1;i*i<=n;i++){
      if(n%i==0){
      long s=max(divitor(i),divitor(n/i));
	   ans=min(ans,s);
		
        }
   }
      cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
h, w = gets.chomp.split.map(&:to_i)
s = Array.new(h) { gets.chomp.chars }
(0...h).each do |x|
  (0...w).each do |y|
    next if s[x][y] == "."
    flg = false
    [[x - 1, y], [x + 1, y], [x, y - 1], [x, y + 1]].each do |nx, ny|
      next if nx < 0 || ny < 0 || nx >= h || ny >= w
      flg = true if s[nx][ny] == "#"
    end
    if flg == false
      puts "No"
      exit
    end
  end
end
puts "Yes"

Measured memory_bytes: 2300
n = int(input())
s = input()

alp = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'
a = ''
for ss in s:
    a += alp[int(alp.find(ss))+n]
print(a)

Measured memory_bytes: 3060
import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29

def main():
    w,h,n = map(int,input().split())
    face = [[0 for j in range(w)] for i in range(h)]
    for i in range(n):
        x,y,a = map(int,input().split())
        if a == 1:
            for j in range(x):
                for k in range(h):
                    face[k][j] = 1
        elif a == 2:
            for j in range(x,w):
                for k in range(h):
                    face[k][j] = 1
        elif a == 3:
            for j in range(y):
                for k in range(w):
                    face[j][k] = 1
        else:
            for j in range(y,h):
                for k in range(w):
                    face[j][k] = 1
    ans = 0
    for i in range(h):
        for j in range(w):
            if face[i][j] == 0:
                ans += 1
    print(ans)
    return

if __name__=='__main__':
    main()


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/

bool asc( const pll& left, const pll& right ) {
    return left.second == right.second ? left.first < right.first : left.second < right.second;
}

int main() {
  ll N,t,check;
  vector<pll> Data;
  cin >> N;
  REP(i,N){
		int x,y;
    pll pr;
		cin >> x >> y;
		pr.first = x;
    pr.second = y;
    Data.push_back(pr);
	}
  sort(Data.begin(), Data.end(), asc);
  t = 0;
  check = 0;
  REP(i,N){
    t = t+Data[i].first;
    if(t > Data[i].second){
      check = 1;
    }
  }
  if(check == 1){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 6512