akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define PI acos(-1)
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		int m,n;
		cin >> m >> n;
		rep(i,0,n){
			int t;
			cin >> t;
			m -= t;
		}
		if(m<0) cout << -1;
		else cout << m;
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n;
  cin>>n;
  map<string, int> mp;
  string s[252521];
  int ma=0;
  REP(i, n){
    cin>>s[i];
    ++mp[s[i]];
    CHMAX(ma, mp[s[i]]);
  }
  vector<string> ans;
  REP(i, n){
    if(mp[s[i]]==ma){
      ans.push_back(s[i]);
    }
  }
  sort(ALL(ans));
  int m=ans.size();
  int cur=0;
  while(cur<m){
    while(cur<m-1 && ans[cur]==ans[cur+1]){
      ++cur;
    }
    cout<<ans[cur]<<'\n';
    ++cur;
  }
  return 0;
}


Measured memory_bytes: 27632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < n; i++)
#define CloseIO std::ios::sync_with_stdio(false)
const ll N = 8e6+1000;
const ll Mod = 100;
const ll INF = 0x3f3f3f3f3f;
vector<pair<ll,ll> > mp(N);
int main(){
  ll n,m;
  cin>>n>>m;
  ll sum = 0;
  int flag = 0;
  int mi = 0x3f3f;
  int mx = -INF;
  for(int i = 1; i <= n; i++){
    ll k = m+i-1;
    sum += k;
    if(k == 0){
      flag = 1;
    }
    if(k < mi) mi = k;
    if(k > mx) mx = k;
  }
  if(abs(mx) != min(abs(mx),abs(mi))){
    mx = mi;
  }
  if(flag) cout<<sum;
  else cout<<sum - mx;
    return 0;
}


Measured memory_bytes: 125312
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

int f[2][300001];
int a[1015],b[1015];
int bo[1015],bo1[1000015];
int sum[1015];

int main(){
    int n;
    for (int i=1; i<=1000000; i<<=1) bo1[i]=1;
    while (scanf("%d",&n), n){
        for (int i=1; i<=n; ++i) scanf("%d",&a[i]);
        memset(bo,0,sizeof(bo));
        int ans=0;
        for (int I=1; I<=500; ++I)
            if (!bo[I]){
                for (int J=I; J<=500; J<<=1) bo[J]=1;
                int N=0;
                for (int i=1; i<=n; ++i)
                    if (a[i]%I==0 && bo1[a[i]/I]) b[++N]=a[i]/I;
                for (; N;){
                    sum[0]=0;
                    for (int i=1; i<=N; ++i) sum[i]=sum[i-1]+b[i];
                    f[0][0]=0;
                    int net=1,cur=0;
                    for (int i=1; i<=N; ++i){
                        for (int j=0; j<=sum[i]; ++j){
                            f[net][j]=-100000;
                            if (j>sum[i-1]) f[cur][j]=-100000;
                        }
                        for (int j=0; j<=sum[i]; ++j){
                            f[net][j]=f[cur][j];
                            if (b[i] && j>=b[i] && (((b[i]-1) & (j-b[i])))==0)
                                f[net][j]=max(f[net][j],f[cur][j-b[i]]+1);
                        }
                        swap(net,cur);
                    }
                    for (int i=1; i<=sum[N]; ++i)
                        if (bo1[i]) ans=max(f[cur][i],ans);
                    break;
                }
            }
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 5324
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


if __name__ == '__main__':
    b, c = map(int, input().split())
    ans = 0
    if c == 100:
        ans =(100 **b)*(c+1)
    else:
        ans =(100 **b)*c
    print(ans)



Measured memory_bytes: 5144
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    ll h;
    cin >> n >> h;
    ll a[n],b[n];
    REP(i,n){
        cin >> a[i] >> b[i];
    }
    sort(a, a + n);
    reverse(a, a + n);
    sort(b, b + n);
    reverse(b, b + n);
    int cnt = 0;
    REP(i,n){
        if(b[i] < a[0]) break;
        h -= b[i];
        cnt++;
        if(h <= 0){
            cout << cnt << endl;
            return 0;   
        }
    }
    cout << cnt + (h + a[0] - 1) / a[0] << endl;
    return 0;
}

Measured memory_bytes: 1792
function Main(input) {	input = input.split("\n");
	tmp = input[0].split(" ");
	var p = parseInt(tmp[0], 10)+parseInt(tmp[1], 10);
	var m = parseInt(tmp[0], 10)-parseInt(tmp[1], 10);
	var t = parseInt(tmp[0], 10)*parseInt(tmp[1], 10);
	console.log(Math.max(p,m,t));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <stdio.h>
#define MAX 10000

int parent(int i) {return i/2;}
int R(int i) {return 2*i+1;}
int L(int i) {return 2*i;}

int main(){
  int H,i,A[MAX];

  scanf("%d",&H);

  for(i=1;i<=H;i++) scanf("%d",&A[i]);

  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i)>=1) printf("parent key = %d, ",A[parent(i)]);
    if(L(i)<=H) printf("left key = %d, ",A[L(i)]);
    if(R(i)<=H) printf("right key = %d, ",A[R(i)]);
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2112
from bisect import bisect_left
from bisect import bisect_right

N = int(input())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort()
B.sort()
C.sort()
ans = 0
for b in B:
    a_left = min(len(A), bisect_left(A, b))
    c_right = min(len(C), bisect_right(C, b))
    ans += (a_left) * (len(C) - c_right)
print(ans)


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a[ohara],b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>n;
     rep(i,n)cin>>a[i];
    rep(i,n)ans+=a[i]-1;
    Cout(ans);

       
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define ii pair<int, int>
#define vii vector<ii>
#define vvi vector<vi>
#define vvii vector<vii>
#define ld long double
#define iii tuple<int, int, int>
#define N 1000005
#define sc scanf
#define pb push_back

int main() {

    int a, b, c, k;
    sc("%d %d %d %d", &a, &b, &c, &k);


    while(k > 0) {

        if(b <= a) {
            b*=2;
        }
        else if(c <= a || c <= b) {
            c*=2;
        }
        k--;
    }

    if(c > b && b > a) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }
}

Measured memory_bytes: 3764
#include <iostream>
#include <algorithm>

using namespace std;

int gcd(int a, int b)
{
 	return (min(a, b) == 0 ? max(a, b) : gcd(max(a, b)%min(a,b), min(a, b)));
}
            
int main()
{
    int no_of_elements;
    cin >> no_of_elements;

    int array_gcd;
    for(int i = 1; i <= no_of_elements; i++)
    {
        int health;
        cin >> health;
        array_gcd = (i == 1 ? health : gcd(array_gcd, health));
    }

    cout << array_gcd;
    return 0;
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
  
  //スペース区切り　input[0] が tmp[0], tmp[1],...
	tmp = input[0].split(" ");
  
  //この時点では全部文字列（数値に変換しないといけない）

	//文字列から10進数に変換するときはparseIntを使います
	var a = parseInt(tmp[0], 10);
	var b = parseInt(tmp[1], 10);
	var s = (a+b)/2;
	//出力
	console.log('%d', Math.ceil(s));
  
  //%は符号付き10進数, %sは文字列
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#A complete binary tree is a binary tree in which every internal node
#has two children and all leaves have the same depth.

H = int(input()) #รับ input จำนวนข้อมูลทั้งหมด

nodes = list(map(int, input().split())) #รับค่าnode ใน1บรรทัด splitเป็นintเก็บใน List

for i in range(H):
    parent = (i+1) // 2 - 1
    left = 2 * (i+1) - 1
    right = 2 * (i+1)

    print('node {}: key = {}, '.format(i+1, nodes[i]), end='')
    if i != 0:
        print('parent key = {}, '.format(nodes[parent]), end='')
    if left < H:
        print('left key = {}, '.format(nodes[left]), end='')
    if right < H:
        print('right key = {}, '.format(nodes[right]), end='')

    print('')



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

const int MAX_V = 100010;
const int MAX_LOG_V = 110;

vector<vector<int>> G(MAX_V);
int root;

int parent[MAX_LOG_V][MAX_V]; // 親を2^k回辿って到達する頂点（根を通り過ぎる場合は-1）
int depth[MAX_V];             // 根からの深さ

void dfs(int v, int p, int d){
    parent[0][v] = p;
    depth[v] = d;
    for(int i=0; i<G[v].size(); i++){
        if(G[v][i] != p) dfs(G[v][i], v, d+1);
    }
}

void init(int V){
    dfs(root, -1, 0);
    
    for(int k=0; k+1<MAX_LOG_V; k++){
        for(int v=0; v<V; v++){
            if(parent[k][v] < 0) parent[k+1][v] = -1;
            else parent[k+1][v] = parent[k][parent[k][v]];
        }
    }
}

int lca(int u, int v){
    // uとvの深さが同じになるまで親を辿る
    if(depth[u] > depth[v]) swap(u, v);

    for(int k=0; k<MAX_LOG_V; k++){
        if((depth[v] - depth[u]) >> k & 1){
            v = parent[k][v];
        }
    }

    if(u == v) return u;

    for(int k=MAX_LOG_V-1; k>=0; k--){
        if(parent[k][u] != parent[k][v]){
            u = parent[k][u];
            v = parent[k][v];
        }
    }
    return parent[0][u];
}

int main(){
    int n; cin>>n;
    for(int i=0; i<n; i++){
        int k; cin>>k;
        for(int j=0; j<k; j++){
            int c; cin>>c;
            G[i].emplace_back(c);
            G[c].emplace_back(i);
        }
    }

    init(n);

    int q; cin>>q;
    while(q--){
        int u, v; cin>>u>>v;
        cout << lca(u, v) << endl;
    }
}


Measured memory_bytes: 56360
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int>A(N+1,0);
  for(int i=1;i<=N;i++)
    cin>>A.at(i);
  vector<int>B(N+1);
  for(int i=N;0<i;i--){
    int ans=0;
    for(int j=2;j*i<=N;j++)
      ans+=B.at(i*j);
    int b=(ans+A.at(i))%2;
    B.at(i)=b;
  }
  int M=0;
  for(int i=1;i<=N;i++)
    if(B.at(i)==1)
      M++;
  cout<<M<<endl;
  for(int i=1;i<=N;i++)
    if(B.at(i)==1)
      cout<<i<<" ";
  cout<<endl;
   return 0;
}

Measured memory_bytes: 2432
import itertools,math
n,d = [int(u) for u in input().split(" ")]
ps = [[int(u) for u in input().split(" ")] for row in range(n)]

r = 0
for i,j in itertools.combinations(range(n),2):
  a = ps[i]
  b = ps[j]
  l = sum([(x-y)*(x-y) for x,y in zip(a,b)])
  l2 = math.floor(math.sqrt(l))
  if l2*l2 == l:
    r+=1
print(r)

Measured memory_bytes: 38384
#include <iostream>
using namespace std;
bool usable(int n, int a[]){
    bool flg=false;//0以外の数字が出てきているか
    int b[5];
    b[4]=n%10;
    b[3]=((n-b[4])%100)/10;
    b[2]=((n-b[4]-b[3]*10)%1000)/100;
    b[1]=((n-b[4]-b[3]*10-b[2]*100)%10000)/1000;
    b[0]=((n-b[4]-b[3]*10-b[2]*100-b[1]*1000)%1000000)/10000;
    for (int i=0; i<5; i++){
        if (flg==false && b[i]==0){//まだ０が出てなくて、今0

            continue;
        }
        else{
            flg=true;
            if (a[b[i]]==1){
                return false;
            }
        }
    }
    return true;
}



int main(){
    int n,k,x;
    cin >> n >> k;
    int a[10]={0,0,0,0,0,0,0,0,0,0};
    for (int i=0; i<k; i++){
        cin >> x ;
        a[x]=1;//1ならば使用不可
    }
    
    while (usable(n,a)==false){
        n++;
    }
    cout << n;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<utility>
#include<string.h>
#include<queue>
#include<stack>
using namespace std;

typedef long long ll; 
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(void)
{
    char s[1005]={};
    int w;
    scanf("%s\n",s);
    scanf("%d",&w);
    int len=strlen(s);
    for(int i=0;i<len;i+=w)printf("%c",s[i]);
    printf("\n");
    return 0;
}

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

using namespace std;

int main()
{
    int n,h,x,k=0;
    cin>>n>>h;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        if(x>=h)
            k++;
    }
    cout<<k;
    return 0;
}


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

using namespace std;
typedef long long ll;
ll a[200005];
ll b[200005];
ll tmpA[200005];
ll cnt=0;
void merge_sort(int l, int r, ll *A) {
	if (l >= r)
    {
        if(b[l]>=0)
            cnt++;
        return ;
    }
	int mid = (l + r) >> 1;
	merge_sort(l, mid, A);
	merge_sort(mid + 1, r, A);
	ll pl = l, pr = mid + 1, tmpp = 0;
	while(pl <= mid && pr <= r) {
		if (A[pl] <= A[pr]) tmpA[tmpp++] = A[pl++],cnt +=r - pr + 1;
		else tmpA[tmpp++] = A[pr++];
	}
	while(pl <= mid) tmpA[tmpp++] = A[pl++];
	while(pr <= r) tmpA[tmpp++] = A[pr++];
	for (int i = 0; i < tmpp; i++) A[i + l] = tmpA[i];
}

int main()
{
    int N;
    ll K;
    scanf("%d%lld",&N,&K);
    ll sum=0;
    for(int i=0;i<N;i++)
    {
        scanf("%lld",&a[i]);
        a[i]-=K;
        sum+=a[i];
        b[i]=sum;
    }
    merge_sort(0,N-1,b);
    printf("%lld",cnt);

}



Measured memory_bytes: 4992
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

LL n;
LL a[303030];
LL bitcnt[64];
const LL mod = 1e9 + 7;
int main(){
    cin >> n;
    REP(i, n){
        cin >> a[i];
        REP(j, 64){
            if((1LL << j) & a[i])bitcnt[j]++;
        }
    }
    LL ans = 0;
    REP(i, 64){
        LL num = bitcnt[i] * (n - bitcnt[i]) % mod;
        (ans += num * ((1LL << i) % mod)) %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
// AOJ 0157
#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<sstream>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef pair<int,int> P;

const int NMAX = 150;

vector<P> ichiro, jiro;
int n, m;
int idp[NMAX], jdp[NMAX];
int index[NMAX], jndex[NMAX];
map<pair<int,int*>, int> table;

void init() {
  REP(i, NMAX) {
    idp[i] = jdp[i] = 0;
    index[i] = jndex[i] = 0;
  }
  jiro.clear();
  ichiro.clear();

  jiro.push_back(make_pair(0,0));
  ichiro.push_back(make_pair(0,0));
  table.clear();
}

bool bigger(P big, P small) {
  return (big.first > small.first and big.second > small.second);
}

int lowerb(P mine, vector<P> his) {
  int len = his.size();
  for (int i = 1; i < len; i++) {
    if (not bigger(mine, his[i])) {
      return i - 1;
    }
  }
  return len - 1;
}

int rec(int i, int* mine, int* his) {
  auto it = table.find(make_pair(i, mine));
  if (it != table.end()) {
    return it->second;
  }
  if (i == 0) {
    return 0;
  } else {
    int ans = 1 + max(rec(i - 1, mine, his), rec(mine[i], his, mine));
    table.insert(make_pair(make_pair(i, mine), ans));
    return ans;
  }
}

int solve() {
  for (int i = 1; i <= n; i++) {
    index[i] = lowerb(ichiro[i], jiro);
  }

  for (int j = 1; j <= m; j++) {
    jndex[j] = lowerb(jiro[j], ichiro);
  }

  return max(rec(n, index, jndex), rec(m, jndex, index));
}

int main() {
  while (cin >> n and n) {
    init();
    REP(i, n) {
      int h, r;
      cin >> h >> r;
      ichiro.push_back(make_pair(h, r));
    }

    cin >> m;
    REP(i, m) {
      int h, r;
      cin >> h >> r;
      jiro.push_back(make_pair(h, r));
    }

    cout << solve() << endl;
  }
}

Measured memory_bytes: 1224
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
using namespace std;


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


int main(){
  int n;
  cin >> n;
  vector<int> A(n + 2);
  rep(i, n) {
    int a;
    cin >> a;
    A[i + 1] = a;
  }

  int sum = 0;
  for(int i = 1; i < n + 2; ++i){
    sum += abs(A[i] - A[i - 1]);
  }


  for(int i = 1; i <= n; ++i){
    int ans;
    ans = sum - abs(A[i] - A[i - 1]) - abs(A[i + 1] - A[i]) + abs(A[i + 1] - A[i - 1]);
    cout << ans << endl;
  }

}


Measured memory_bytes: 1664
{-# LANGUAGE TypeApplications #-}

import           Control.Applicative
import           Control.Arrow
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8         as B
import           Data.Char
import           Data.List
import qualified Data.Vector.Unboxed           as V
import           Data.Maybe

main = do
  [n, d] <- map (read @Int) . words <$> getLine
  pts    <-
    replicateM n $ (\[x, y] -> (x, y)) . map (read @Int) . words <$> getLine
  print
    . length
    . filter (d * d >=)
    . map (uncurry (+) . duplicate (***) (duplicate (*)))
    $ pts
  where duplicate f x = f x x



Measured memory_bytes: 163480
#define NDEBUG
#include <cassert>

template <class Monoid, template <class> class Container> class segment_tree {
public:
	using value_structure = Monoid;
	using value_type = typename value_structure::value_type;
	using container_type = Container<value_type>;
	using const_reference = typename container_type::const_reference;
	using size_type = typename container_type::size_type;

private:
	size_type size_, capacity;
	container_type c;
	static size_type getsize(const size_type size) {
		size_type ret = 1;
		while (ret < size)
			ret <<= 1;
		return ret;
	}
	void recalc(const size_type index) {
		c[index] = value_structure::operation(c[index << 1], c[index << 1 | 1]);
	}

public:
	segment_tree() : size_(0), capacity(0), c() {}
	explicit segment_tree(const size_type size)
		: size_(size), capacity(getsize(size_)),
		c(capacity << 1, value_structure::identity()) {}

	bool empty() const { return !size_; }
	size_type size() const { return size_; }

	const_reference operator[](const size_type index) const {
		assert(index < size());
		return c[index + capacity];
	}
	value_type fold(size_type first, size_type last) const {
		assert(first <= last);
		assert(first <= size());
		assert(last <= size());
		value_type ret_l = value_structure::identity(),
			ret_r = value_structure::identity();
		for (first += capacity, last += capacity; first < last;
			first >>= 1, last >>= 1) {
			if (first & 1)
				ret_l = value_structure::operation(ret_l, c[first++]);
			if (last & 1)
				ret_r = value_structure::operation(c[last - 1], ret_r);
		}
		return value_structure::operation(ret_l, ret_r);
	}
	template <class F> size_type search(const F &f) const {
		if (f(value_structure::identity()))
			return 0;
		if (!f(c[1]))
			return size() + 1;
		value_type acc = value_structure::identity();
		size_type i = 1;
		while (i < capacity)
			if (!f(value_structure::operation(acc, c[i <<= 1])))
				acc = value_structure::operation(acc, c[i++]);
		return i - capacity + 1;
	}

	void update(size_type index, const value_type &value) {
		assert(index < size());
		index += capacity;
		c[index] = value;
		while (index >>= 1)
			recalc(index);
	}
};

#include <algorithm>
#include <limits>
template <class T> class min_monoid {
public:
	using value_type = T;
	static value_type operation(const value_type &x, const value_type &y) {
		return ::std::min(x, y);
	}
	static value_type identity() {
		return 2147483647;
	}
	static value_type reverse(const value_type &x) { return x; }
};

#include <cstdio>
#include <vector>

template<class T> using vec_alias = ::std::vector<T>;

int main() {
	using uint = unsigned int;

	uint n, q;
	scanf("%u%u", &n, &q);

	segment_tree<min_monoid<uint>, vec_alias> seg(n);

	while (q--) {
		uint c, x, y;
		scanf("%u%u%u", &c, &x, &y);

		if (c)
			printf("%u\n", seg.fold(x, y + 1));
		else
			seg.update(x, y);
	}

	return 0;
}



Measured memory_bytes: 3408
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
#include <numeric>
#include <iterator>
#include <math.h>
#include <list>
using namespace std;

int main(void){
  string s;

  cin >> s;
  int Q;
  cin >> Q;
  int dir = 1;
  list<char>neko;
  for(int i =0; i < s.size(); i++){
      neko.push_back(s[i]);
  }
  for(int i =0; i < Q; i++){
    int T1;
    cin >> T1;
    switch(T1)
    {
    case 1:
      dir *= -1;
      break;
    case 2:
      int T2;
      cin >> T2;
      char c;
      cin >> c;
      if(T2 == 2){
        if(dir == -1){
          neko.push_front(c);
        }else{
          neko.push_back(c);
        }
      }else{
        if(dir == -1){
          neko.push_back(c);
        }else{
          neko.push_front(c);
        }
      }
      break;
    }
  }

  if(dir == -1){
    reverse(neko.begin(), neko.end());
  }
  for(auto it = neko.begin(); it != neko.end(); ++it){
    cout << *it;
  }
  cout << endl;
  return 0;
}

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

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int n;
  cin >> n;
  
  string s, t, ans;
  cin >> s >> t;

  for (int i = 0; i < (int)s.size(); ++i) {
  ans += s[i];
  ans += t[i];
  }

  cout << ans << '\n';
  }

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

ll solve(ll n) {
  if (n % 2 == 1) return 0;

  ll res = 0;
  n /= 2;
  while (n) {
    res += n / 5;
    n /= 5;
  }
  return res;
}

int main() {
  ll n;
  cin >> n;
  cout << solve(n) << endl;
}

Measured memory_bytes: 3592
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

function gcd(a,b){return b?gcd(b,a%b):a;}

var mod = 1e9+7;
function mul(a,b){return ((a>>16)*b%mod*65536+(a&65535)*b)%mod;}
function pow(a,n){for(var r=1;n;a=mul(a,a),n>>=1)if(n&1)r=mul(a,r);return r;}
function mput(n){return (n%mod+mod)%mod;}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next();
  var az = 0, bz = 0, z = 0;
  var map = new Map();
  for(var i = 0; i < n; i++){
    var a = nextbig(), b = nextbig();
    if(a === 0n && b === 0n){z++; continue;}
    if(a === 0n){az++; continue;}
    if(b === 0n){bz++; continue;}
    var c = gcd(a,b);
    a /= c, b /= c;
    if(a < 0)a = -a, b = -b;
    if(map.has(a)){
      if(map.get(a).has(b))map.get(a).set(b,map.get(a).get(b)+1);
      else map.get(a).set(b,1);
    }else{
      map.set(a,new Map());
      map.get(a).set(b,1);
    }
  }
  var ans = pow(2,az) + pow(2,bz) - 1;
  for(var [i0,i1] of map){
    for(var [j0,j1] of i1){
      var t = 0;
      if(j0 < 0){
        if(map.has(-j0) && map.get(-j0).has(i0))continue;
      }else{
        if(map.has(j0) && map.get(j0).has(-i0))t = pow(2,map.get(j0).get(-i0))-1;
      }
      t += pow(2,j1);
      ans = mul(ans,t);
    }
  }
  return mput(ans-1+z);
}

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

int main(){
    string s;
    cin >> s;
    int counter = 0;
    if(s[0] == '1') ++counter;
    if(s[1] == '1') ++counter;
    if(s[2] == '1') ++counter;
    cout << counter << endl;
}

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

int main () {
  int N;
  cin >> N;
  vector<int> a(N);
  
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N - 1; j++){
      if (a.at(j) < a.at(j + 1)) {
        int s = a.at(j);
        int t = a.at(j + 1);
        a.at(j) = t;
        a.at(j + 1) = s;
      }
    }
  }
  
  int sum = 0;
  
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) sum += a.at(i);
    else sum -= a.at(i);
  }
  cout << sum << endl;
}
  

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

int main() {
    string s;
    cin >> s;
    char top = s[0], last = *(s.end() - 1);
    if (top == last ^ s.length() % 2 == 0) cout << "Second" << endl;
    else cout << "First" << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db long double
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define mi map<int,int>
#define ml map<ll,ll>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define MAX 4294967295
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MAXN 15000005
#define inf 1e8
#define PI acos(-1.0)
#define N 200005
 
int n,m,k,sx,sy,fx,fy;
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

bool valid(int x,int y){
	return (x>=0 && y>=0 && x<n && y<m);
}
 
void solve(){
    cin>>n>>m>>k;
    cin>>sx>>sy>>fx>>fy;
    sx--, sy--, fx--, fy--;
    vector<vi> dis(n+1,vi(m+1,inf)), a(n+1,vi(m+1));
    for(int i=0;i<n;i++){
    	for(int j=0;j<m;j++){
    		char c;
    		cin>>c;
    		if(c == '@') a[i][j] = 1;
    	}
    }
    queue<pii> q;
    dis[sx][sy] = 0;
    q.push({sx,sy});
    while(!q.empty()){
    	pii p = q.front();
    	int x = p.fi;
    	int y = p.se;
    	q.pop();
    	for(int i=0;i<4;i++){
    		for(int l=1;l<=k;l++){
    			int nx = x + dx[i]*l;
    			int ny = y + dy[i]*l;
    			if(!valid(nx,ny) || a[nx][ny] || dis[x][y]+1 > dis[nx][ny]) break;
    			if(dis[nx][ny] != inf) continue;
    			dis[nx][ny] = dis[x][y] + 1;
    			q.push({nx,ny});
    		}
    	}
    }
    if(dis[fx][fy] == inf) cout<<-1<<endl;
    else cout<<dis[fx][fy]<<endl;
}
 
signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int t;
    //cin>>t;
    t = 1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 22764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
const int MOD = 1e9 + 7;
 
vector<long long> fact_inv, inv, Com;
 
/*  init_nCk :二項係数のための前処理
    計算量:O(n)
*/
void init_nCk(int n, int SIZE) {
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
    Com.resize(SIZE + 5);
    Com[0] = 1;
    for (int i = 1; i < SIZE + 5; i++) {
        Com[i] = Com[i - 1] * ((n - i + 1) * inv[i] % MOD) % MOD;
    }
}
 
/*  nCk :MODでの二項係数を求める(前処理 int_nCk が必要)
    計算量:O(1)
*/
long long nCk(int k) {
    assert(!(k < 0));
    return Com[k];
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main() {
	ll n,a,b;
	cin>>n>>a>>b;
	init_nCk(n,10000000);		
	ll sum1= modpow(2, n, 1000000007)-1 ;

    // 計算例
    ll A=nCk(a);
    ll B=nCk(b);
    ll sum2=A+B;
    sum2%=inf;
    ll ans=sum1-sum2;
    if(ans<0){
    	ans+=inf;
    }
    cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 237644
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt(); sc.nextLine()
    val S = Array.fill(N)(sc.nextLine().sorted)
    val count =
      scala.collection.mutable.Map[String, Int]() ++
        S.groupBy(identity).mapValues(_.length - 1)

    var r = BigInt(0)
    var i = 0
    while (i < N) {
      val c = count(S(i))
      if (c > 0) {
        r += c
        count.update(S(i), c - 1)
      }
      i += 1
    }

    println(r)
  }

}

Measured memory_bytes: 159676
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define cans cout << ans << endl;
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl; 
typedef long long ll;


int main(){
    int n;
    cin >> n;
    map<int,int> mp;
    for(int i=1; i<=n; i++){
        int a;
        cin >> a;
        mp[a] = i;
    }
    for(int i=1; i<=n; i++){
        cout << mp[i] << " ";
    }
    cout << endl;
    return 0;
}

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

#define INF (1 << 18)

typedef long long ll;

int main(){
    int N;
    ll M;
    cin >> N >> M;
    vector<ll> a(M);
    vector<int> b(M);
    vector<vector<int>> c(M, vector<int>(N));
    for(int i = 0; i < M; i++) {
        cin >> a[i] >> b[i];
        for(int j = 0; j < b[i]; j++) {
            cin >> c[i][j];
        }
    }
    vector<int> key(M, 0);
    for(int i = 0; i < M; i++){
        for(int j = 0; j < b[i]; j++){
            key[i] |= 1 << (c[i][j] - 1);
        }
    }
    vector<ll> dp((1 << N) + 1);    //dp[i] 宝箱を状態iにするための最小費用
    for(int i = 0; i < (1 << N); i++) {
        dp[i] = INF;
    }
    dp[0] = 0;
    for(int i = 0; i < (1 << N); i++) {
        for(int j = 0; j < M; j++) {
            dp[key[j] | i] = min(dp[key[j] | i], dp[i] + a[j]);
        }
    }
    cout << (dp[(1 << N) - 1] < INF ? dp[(1 << N) - 1] : -1) << endl;
    cin >> N;
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

vector<ll> graph[300000];

int main()
{
  int m, d;
  cin >> m >> d;

  int ans = 0;
  for (int i = 1; i <= m; ++i)
  {
    for (int j = 1; j <= d; ++j)
    {
      int d1 = j / 10;
      int d2 = j % 10;
      if (d1 < 2 || d2 < 2)
        continue;
      if (i == d1 * d2)
      {
        ans++;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9+10;
#define rrep(i,n) for(int i = 1;i <= n;i++)

int n, z, w, used[2002][2];
int a[2002], dp[2002][2];//0:x 1:yの番
int solve(int role, int p, int x, int y){
	if(dp[p][role] && used[p][role])return dp[p][role];
	used[p][role] = 1;
	if(p == n){
		if(!role)return abs(x-a[n]);
		else return abs(y-a[n]);
	}
	
	int ans;
	if(!role)ans = 0;
	else ans = inf;
	for(int i = n;i >= p+1;i--){
		if(!role)ans = max(ans, solve(1, i, a[i], y));
		else ans = min(ans, solve(0, i, x, a[i]));
	}
	return dp[p][role] = ans;
}

int main(){
	scanf("%d%d%d", &n, &z, &w);
	rrep(i,n)scanf("%d", &a[i]);
	int ans = solve(0, 0, z, w);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
int w, h;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
char hatake[100][100];

void dfs(int x, int y, char c);

int main() {
  char buf[101];
  int a;
  char c;

  while (1) {
    cin >> h >> w;
    if (!w && !h) break;

    for (int i=0; i<h; i++) {
      cin >> buf;
      memcpy(hatake[i], buf, sizeof(char)*w);
    }

    a = 0;
    for (int i=0; i<h; i++) {
      for (int j=0; j<w; j++) {
        if (hatake[i][j]!='.') {
          c = hatake[i][j];
          hatake[i][j]='.';
          dfs(j,i,c);
          a++;
        }
      }
    }
    cout << a << endl;
  }
  return 0;
}

void dfs(int x, int y, char c) {
  int nx, ny;
  for (int i=0; i<4; i++) {
    nx = x + dx[i];
    ny = y + dy[i];
    if (nx>=0 && nx<w && ny>=0 && ny<h && hatake[ny][nx]==c) {
      hatake[ny][nx] = '.';
      dfs(nx, ny, c);
    }
  }
}

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

int main(){
  ll N;
  ll sum = 0;
  cin >> N;
  rep(i, N){
    if((i%3) && (i%5)) sum += i;
  }
  cout << sum << endl;
    
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}
int dfs(int v, ll N, bool visited[nmax])
{
    bool all_visited = true;

    for (int i = 0; i < N; i++)
    {
        if (!visited[i])
        {
            all_visited = false;
        }
    }

    if (all_visited)
    {
        return 1;
    }
    int ret = 0;
    for (size_t i = 0; i < N; i++)
    {
        if (!graph[v][i])
        {
            continue;
        }
        if (visited[i])
        {
            continue;
        }

        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }

    return ret;
}


void solve(long long N, std::string S){
    int ans =0;
    int cur = 0;
    for(size_t i = 0; i < S.size(); i++)
    {
        if(S[i] == 'I'){
            cur++;
            ans = max(ans,cur);
        }else{
            cur--;
        }
    }

    cout << ans << endl;
    
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())

def dist(a, b):
    return min(abs(a - b), n - abs(a - b))

a, b = n, 1
S = set()
for i in range(m):
    if 2 * dist(a, b) == n or dist(a, b) in S:
        a -= 1
    print(a, b)
    S.add(dist(a, b))
    a -= 1
    b += 1

Measured memory_bytes: 17472
n = int(input())
L = list(map(int, input().split()))

out = 0

for i in range(n):
    for j in range(n - i - 1):
        j_i = i + j + 1
        for k in range(n - j_i - 1):
            k_i = j_i + k + 1
            L1 = L[i]
            L2 = L[j_i]
            L3 = L[k_i]
            if L1 != L2 and L2 != L3 and L3 != L1:
                M = [L1, L2, L3]
                M.sort()
                if M[2] < M[0] + M[1]:
                    # print(M)
                    out += 1
print(out)

Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
const int N=1e5+10;
ll a[N],b[N],c[N],dp[N][5];
int main()
{
	int n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%lld%lld%lld",&a[i],&b[i],&c[i]);
	}
	dp[1][1]=a[1];dp[1][2]=b[1];dp[1][3]=c[1];
	for(i=2;i<=n;i++)
	{
		dp[i][1]=max(dp[i-1][2],dp[i-1][3])+a[i];
		dp[i][2]=max(dp[i-1][1],dp[i-1][3])+b[i];
		dp[i][3]=max(dp[i-1][1],dp[i-1][2])+c[i];
	}
	ll ans=max(max(dp[n][1],dp[n][2]),dp[n][3]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6528
#define Link "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0348"

#include <iostream>
#include <cstdio>

#define TASK "Sevens"

using namespace std;

void OpenFile()
{
    freopen(TASK".INP","r",stdin);
    freopen(TASK".OUT","w",stdout);
}

bool b[14];

void Enter()
{
    fill(b+1,b+13+1,0);
    for (int i=1;i<=6;++i) {
        int x;
        cin >> x;
        b[x] = 1;
    }
}

void Init()
{

}

bool BT(int l, int r, bool p)
{
    if (l == 1 && r == 13)
        return p;
    if ((l == 1 || b[l-1] != p) && (r == 13 || b[r+1] != p))
        return BT(l,r,p^1);
    if (1 < l && b[l-1] == p && BT(l-1,r,p^1) == p)
        return p;
    if (r < 13 && b[r+1] == p && BT(l,r+1,p^1) == p)
        return p;
    return p ^ 1;
}

void Solve()
{
    if (BT(7,7,1))
        cout << "yes";
    else
        cout << "no";
    cout << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //OpenFile();

    int T;
    for (cin>>T;T>0;--T) {
        Enter();
        Init();
        Solve();
    }
}



Measured memory_bytes: 3240
from collections import deque
INF = 10**9

N, M = map(int,input().split())

G = [[] for _ in range(3*N)]
for _ in range(M):
    u, v = map(int,input().split())
    u, v = u-1, v-1

    G[u].append(v+N)
    G[u+N].append(v+2*N)
    G[u+2*N].append(v)

s, t = map(int,input().split())
s, t = s-1, t-1

dist = [INF] * (3*N)
dist[s] = 0

Q = deque([s])
while len(Q) > 0:
    u = Q.popleft()
    for v in G[u]:
        if dist[v] == INF:
            dist[v] = dist[u] + 1
            Q.append(v)

if dist[t] == INF:
    print(-1)
else: 
    print(dist[t] // 3)

Measured memory_bytes: 61304
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int k = gi();
    int x = gi();
    int mn = MAX(-1000000, x-k+1);
    int mx = MIN(1000000, x+k-1);

    for (int i = mn; i <= mx; i++)
        printf("%d%c", i, (i == mx ? '\n' : ' '));

    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {

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

	public void run() {
		Scanner sc = new Scanner();
		int a = sc.nextInt();
		int b = sc.nextInt();
		long diff = b - a;
		System.out.println(diff * (diff + 1) / 2 - b);
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		int nextInt() {
			return (int) nextLong();
		}
	}

}


Measured memory_bytes: 23124
from itertools import permutations
N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))

l = sorted(list(permutations(list(range(1,N+1)))))


a = 0
b = 0
for i,s in enumerate(l):
    if P == s:
        a = i
    if Q == s:
        b = i
print(abs(a-b))



Measured memory_bytes: 46192
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

#[proconio::fastout]
fn main() {
    proconio::input!{
        n: usize,
        m: i32,
        q: usize,
        abcd: [(Usize1, Usize1, i32, i32); q],
    }
    let tmp: Vec<i32> = vec![];
    let mut seqs: Vec<Vec<i32>> = vec![];
    gen_seqs(1..=m, n, tmp, &mut seqs);
    let mut ans = 0;
    // eprintln!("{:?}", seqs);
    for seq in seqs {
        let point: i32 = abcd.iter().map(|(a, b, c, d)| {
            if seq[*b] - seq[*a] == *c { *d }
            else { 0 }}).sum();
        ans = max(ans, point);
    }
    println!("{}", ans);
}

// range: a..=b にたいして a <= a1 <= ... <= an <= b を満たす数列を列挙
// 呼び出し時には空のベクトル: Vec<i32> を渡す
use std::ops::RangeInclusive;
fn gen_seqs(range: RangeInclusive<i32>, n: usize, state: Vec<i32>, res: &mut Vec<Vec<i32>>) {
    if n == 0 {
        res.push(state);
        return;
    }
    let end = *range.end();
    for i in range {
        let mut state = state.clone();
        state.push(i);
        gen_seqs(i..=end, n - 1, state, res);
    }
}



Measured memory_bytes: 11412
import sys
import numpy as np

if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC
    cc = CC('my_module')

    @cc.export('lower_bound', '(i8[:],i8[:],i8,i8,i8)')
    def lower_bound(A, F, ok, ng, k):
        while ok - ng > 1:
            mid = (ok + ng) // 2
            y = A - mid // F
            if y[y > 0].sum() <= k:
                ok = mid
            else:
                ng = mid
        return ok

    cc.compile()
    exit(0)

from my_module import lower_bound
n, k = map(int, input().split())
A = np.array(list(map(int, input().split())))
F = np.array(list(map(int, input().split())))
A = np.sort(A)
F = np.sort(F)[::-1]

ok = 10 ** 16
ng = -1

print(lower_bound(A, F, ok, ng, k))


Measured memory_bytes: 53720
fun main(args: Array<String>){
    val inp = readLine()!!.split(" ")
    val num = inp[0].toInt()
    val yen = inp[1].toInt()
    var ans = false

    //i:10000
    //j:5000
    //k:1000
    loop@for(i in 0..num){
        if(yen < i*10000){
            continue
        }
        for(j in 0..num-i){
            if(yen < i*10000 + j*5000){
                continue
            }
            for(k in 0..num-i-j){
                if(yen < i*10000 + j*5000 + k*1000){
                    continue
                }
                else if(yen == i*10000 + j*5000 + k*1000){
                    if(i + j + k == num){
                        println("$i $j $k")
                        ans = true
                        break@loop
                    }
                }
            }
        }
    }

    if(ans == false) {
        println("-1 -1 -1")
    }

}


Measured memory_bytes: 37964
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String[] S = sc.nextLine().split(" ");
    Deque<Integer> deq = new ArrayDeque<>();
    for(int i = 0; i < N; i++){
      int n = Integer.parseInt(S[i]);
      if(N % 2 == i % 2){
        deq.addLast(n);
      }else{
        deq.addFirst(n);
      }
    }
    
    while(deq.size() > 1){
      System.out.print(deq.pop());
      System.out.print(" ");
    }
    System.out.println(deq.pop());
  }
}

Measured memory_bytes: 71316