akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#C
s = list(input())
abc = list("-abcdefghijklmnopqrstuvwxyz-")
num = list("-0123456789-")
abc_cnt = [0]*28
num_cnt = [0]*12

for i in range(len(s)):
    for j in range(1,27):
        if s[i] == abc[j]:
            abc_cnt[j] += 1

for i in range(len(s)):
    for j in range(1,11):
        if s[i] == num[j]:
            num_cnt[j] += 1
ans = 0
abc_sum = sum(abc_cnt)
num_sum = sum(num_cnt)


while abc_sum > 0:
    start = 100
    current = 1
    while current < 27:
        if abc_cnt[current-1] == 0 and abc_cnt[current] > 0:
            start = min(start,current)

        if abc_cnt[current+1] == 0 and abc_cnt[current] > 0:
            ans += min(3, current - start + 1)
            abc_cnt[current] -= 1
            abc_sum -= 1
            break

        if abc_cnt[current] > 0:
            abc_cnt[current] -= 1
            abc_sum -= 1

        current += 1

while num_sum > 0:
    start = 100
    current = 1
    while current < 11:
        if num_cnt[current-1] == 0 and num_cnt[current] > 0:
            start = min(start,current)

        if num_cnt[current+1] == 0 and num_cnt[current] > 0:
            ans += min(3, current - start + 1)
            num_cnt[current] -= 1
            num_sum -= 1
            break

        if num_cnt[current] > 0:
            num_cnt[current] -= 1
            num_sum -= 1

        current += 1


print(ans)

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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

vector<vector<int>> B;

int	NewNode(vector<bool> &Node) {
	for (int i=0; i<Node.size(); i++) {
		if (!Node.at(i)) {
			Node.at(i)=true;
			return i;
		}
	}
	return -1;
}

void	NewLink(int A, int BB, int D) {
	B.push_back({A, BB, D});
}

void	Link(int Nfm, int NN, const int Nodefm, const int Nodeto, vector<bool> &Node) {
	if (1==NN) {
		NewLink(Nodefm, Nodeto, Nfm);
		return;
	}
	//if (0!=NN%3)
		for (int i=0; i<NN%3; i++) {
			NewLink(Nodefm, Nodeto, Nfm+NN-1-i);
		}
	NN -=NN%3;
	if (0==NN)
		return;
	int Nodemid=NewNode(Node);
	if (-1==Nodemid) {
		cout <<"No more node" <<endl;
		return;
	}
	NewLink(Nodefm, Nodemid, 0);
	NewLink(Nodefm, Nodemid, NN/3);
	NewLink(Nodefm, Nodemid, NN*2/3);
	Link(Nfm, NN/3, Nodemid, Nodeto, Node);
}

int	main() {
	int N;
	cin >>N;
	vector<bool> Node(21, false);
	Node.at(0)=true;
	Node.at(1)=true;
	Link(0, N, 1, 100, Node);
	int E=NewNode(Node);
	cout <<E <<' ' <<B.size() <<endl;
	for (int i=0; i<B.size(); i++) {
		if (B.at(i).at(1)==100)
			B.at(i).at(1)=E;
		cout <<B.at(i).at(0) <<' ' <<B.at(i).at(1) <<' ' <<B.at(i).at(2) <<endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int AC[100000];


int main(){
    int N, Q, l, r, cnt = 0;
    string S;
    cin >> N >> Q;
    cin >> S;
    AC[0] = 0;
    for(int i = 0; i < N - 1; i++){
        if(S[i] == 'A' && S[i + 1] == 'C'){
            AC[i + 1] = AC[i] + 1;
        }else{
            AC[i + 1] = AC[i];
        }
    }
    for(int i = 0; i < Q; i++){
        cin >> l >> r;
        cout << AC[r - 1] - AC[l - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
N = int(input())
testimo_ls = [ [] for i in range(N) ]
rst = 0
for i in range(N):
    A = int(input())
    for j in range(A):
        x, y = map(int, input().split(' '))
        testimo_ls[i].append([x - 1, y])
for i in range(1 << N):
    honest_ls = []
    for j in range(N):
        if i >> j & 1:
            honest_ls.append(j)
    is_ok = True
    for s in honest_ls:
        for t in testimo_ls[s]:
            if t[0] in honest_ls and t[1] == 0:
                is_ok = False
                break
            if t[0] not in honest_ls and t[1] == 1:
                is_ok = False
                break
    if is_ok:
        rst = max(rst, len(honest_ls))
print(rst)

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

int main() {
  string s;
  int left;
  int right;
  bool flag = false;
  
  cin >> s;
  for(int i=0;i<s.size();++i){
    if(s.at(i) == 'A' && !flag){
      left = i;
      flag = true;
    }

    if(s.at(i) == 'Z' && flag) right = i;
  }

  cout << right - left + 1 << endl;
  return 0;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
  ll n;
  map<char, ll> m;
  cin >> n;
  REP(i, n) {
    string s;
    cin >> s;
    m[s[0]]++;
  }
  char l[] = {'M', 'A', 'R', 'C', 'H'};
  ll cnt = 0;
  REP(i, 5) {
    REP(j, 5) {
      REP(k, 5) {
        if (i == j || j == k || i == k)
          continue;
        cnt += m[l[i]] * m[l[j]] * m[l[k]];
      }
    }
  }
  printf("%lld\n", cnt / 6);
}


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

int main(){
  string o,e;
  cin >> o >> e;
  
  int diff = o.size() - e.size();
  
  int n = e.size();
  rep(i,n){
    cout << o[i] << e[i];
  }
  if(diff!=0) cout << o[n] << endl;
}

Measured memory_bytes: 256
l=input().split()
ll=len(l)
i=0
for i in range(ll):
    l[i]=int(l[i])
a=l[0]+l[1]
b=l[2]+l[3]
if a>b:
    print("Left")
elif a<b:
    print("Right")
else:
    print("Balanced")

Measured memory_bytes: 3060
from bisect import bisect_right as br
a,b,q=map(int,input().split())
I=2<<60
s,t=[-I]+[int(input()) for _ in range(a)]+[I],[-I]+[int(input()) for _ in range(b)]+[I]
for question in range(q):
    x=int(input())
    b,d,r=br(s,x),br(t,x),I
    for S in [s[b-1],s[b]]:
        for T in [t[d-1],t[d]]:
            d1,d2=abs(S-x)+abs(T-S),abs(T-x)+abs(S-T)
            r=min(r,d1,d2)
    print(r)


Measured memory_bytes: 14336
n = int(input())
lst = list(map(int,input().split()))

flg = True
for i in range(n):
    if lst[i]%2!=0:
        continue
    if lst[i]%3==0 or lst[i]%5==0:
        continue
    else:
        flg=False
        break
print('APPROVED' if flg else 'DENIED')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const int MOD = 1000000007;
#define endl "\n"

struct mint{
  ll x;
  mint(ll x = 0): x((x % MOD + MOD) % MOD){}
  mint operator-() const {return mint(-x);}
  mint& operator+=(const mint a){
    if((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD - a.x) >= MOD) x-= MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a){
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a){
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a){
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if(t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a){
    mint res(*this);
    return res/=a;
  }
};

struct combination{
  vector<mint> fact, ifact;
  combination(int n): fact(n+1), ifact(n+1){
    assert(n < MOD);
    fact[0] = 1;
    for(int i = 1; i <= n; i++) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for(int i = n; i >= 1; i--) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k){
    if(k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  ll n, k;
  cin >> n >> k;
  k = min(k, n-1);
  combination c(n);

  mint ans;
  for(int i = 0; i <= k; i++){
    ans += c(n, i) * c(n - 1, i);
  }

  cout << ans.x << endl;
}

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


#define izryt bool

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

vector<int> g[100001];
int col[100001], fd[100001], n, m, q, a, b, c, qa[100001], qb[100001], qc[100001],sz[100001];

void dfs(int cp, int dis, int c) {
	if (!col[cp]) col[cp] = c;
	if (fd[cp] >= dis || dis == 0) return;
	fd[cp] = dis;
	REP(i,sz[cp])
		dfs(g[cp][i], dis - 1, c);
};

signed main() {
	scnaf("%d %d", &n, &m);
	REP(i, m) {
		scanf("%d %d", &a, &b);
		sz[--a]++;
		sz[--b]++;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	scanf("%d", &q);
	REP(i, q) {
		scanf("%d %d %d", &qa[q-i-1], &qb[q - i - 1], &qc[q - i - 1]);
	}
	
	REP(i, q) {
		dfs(--qa[i],qb[i],qc[i]);
	}

	REP(i, n) {
		printf("%d\n", col[i]);
	}
	return 0;
}

Measured memory_bytes: 8824
#ifdef loc
    #include "loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())

const int N = 100005;

int f[N], a[N];

int main() {
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.tie(0);
    int n;
    std::cin >> n;
    rep(i, 0, n) {
        std::cin >> a[i];
    }
    rep(i, 1, n) {
        f[i] = f[i - 1] + abs(a[i] - a[i - 1]);
        if(i > 1) {
            f[i] = std::min(f[i], f[i - 2] + abs(a[i] - a[i - 2]));
        }
    }
    std::cout << f[n - 1] << std::endl;
}


Measured memory_bytes: 1024
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
//ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int n,m;
vector<int> a;
vi g[114514];

int main(){
	cin>>n;
	bool flag=true;
	int hikaku=1;
	for(int i=0;i<20;i++){
		if(n==hikaku)flag=false;
		hikaku*=2;
	}
	
	if(!flag){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
		cout<<3<<" "<<n+1<<endl;
		for(int i=2;i<=n-1;i+=2){
			cout<<i+n<<" "<<i+n+1<<endl;
			cout<<i+n+1<<" "<<1<<endl;
			cout<<1<<" "<<i<<endl;
			cout<<i<<" "<<i+1<<endl;
		}
		if(n%2==0){
			int temp=1;
			while(temp<n)temp*=2;
			//cout<<temp<<endl;
			temp/=2;
			cout<<temp+n+1<<" "<<n<<endl;
			cout<<n-temp<<" "<<2*n<<endl;
		}
	}
}

Measured memory_bytes: 4992
import java.awt.*;
import java.awt.geom.*;
import java.io.*;

import java.util.*;
class Main {

	static char[] xx = new char[] {'S','H','C','D'};
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int m = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			if(m == -1 && f == -1 && r == -1) break;
			
			if(m == -1 || f == -1) {
				System.out.println("F");
				continue;
			}
			if(m + f >= 80) {
				System.out.println("A");
				continue;
			}
			else if(m + f >= 65) {
				System.out.println("B");
			}
			else if(m + f >= 50) {
				System.out.println("C");
			}
			else if(m +f < 30) {
				System.out.println("F");
			}
			else {
				System.out.println((r >= 50)?"C":"D");
			}
			
		}

	}
}

Measured memory_bytes: 19256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
void read(pp& x){ scanf("%d%d",&x.first, &x.second); }
void read(pll& x){ scanf("%lld%lld",&x.first, &x.second); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define sz(x) (int)(x).size()

int n, m;

vector<int> ao, ae;

void Answer(vector<int> A, vector<int> B){
	vector<int> br;
	for(int x:B) if(x) br.pb(x);
	for(int x:A) printf("%d ", x); putchar(10);
	printf("%d\n", sz(br));
	for(int x:br) printf("%d ", x);
	exit(0);
}

int main()
{
	read(n, m);
	rep(i, m){
		int x; read(x);
		if(x&1) ao.pb(x); else ae.pb(x);
	}
	if(ao.size() > 2u){
		puts("Impossible"); return 0;
	}
	if(ao.size() == 0u){
		if(ae.size() == 1u){
			Answer(ae, {1, ae[0]-1});
		} else {
			vector<int> bt = ae;
			bt[0]--; bt.back()++;
			Answer(ae, bt);
		}
	} else if(ao.size() == 1u){
		if(ae.size() == 0u){
			Answer(ao, {1, ao[0]-1});
		} else {
			vector<int> a;
			a.pb(ao[0]); a.insert(a.end(), all(ae));
			vector<int> bt = a;
			bt[0]--; bt.back()++;
			Answer(a, bt);
		}
	} else if(ao.size() == 2u){
		vector<int> a;
		a.pb(ao[0]); a.insert(a.end(), all(ae)); a.pb(ao[1]);
		vector<int> bt = a;
		bt[0]--; bt.back()++;
		Answer(a, bt);
	}
	return 0;
}


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

using namespace std;

int main()
{
    int A, B, C, X, Sum = 0, Total = 0;
    cin >> A >> B >> C >> X;

    for (int a = 0; a <= A; a++)
    {
        for (int b = 0; b <= B; b++)
        {
            for (int c = 0; c <= C; c++)
            {
                Sum = (500 * a) + (100 * b) + (50 * c);

                if (Sum == X)
                {
                    Total++;
                }
            }
        }
    }

    cout << Total;
}

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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> to(M*2);  
  for (int i=0; i<M*2 ; i++){
    int a;
    cin >> a;
    to.at(i) = a ;
  }
  for (int i=1; i<=N; i++){
    int Z=0;
    for (int j=0; j<M*2; j++){
      if (i == to.at(j)){
        Z++;
      }
    }
    cout << Z << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int A,B;
	scanf ("%d %d",&A, &B);
	
	if (A==1 && B==3){
		printf ("2");
	}
	else if (A==1 && B==2){
		printf ("3");
	}
		else if (A==2 && B==1){
		printf ("3");
	}
		else if (A==2 && B==3){
		printf ("1");
	}
		else if (A==3 && B==2){
		printf ("1");
	}
		else if (A==3 && B==1){
		printf ("2");
	}

	
	return 0;
}

Measured memory_bytes: 2076
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long

using namespace std;
int n,m,tx,ty;
int main()
{
    cin>>n>>m;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        cin>>tx;
        if(tx>=m)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

char s[20];
int query;

int M(){
	int i;
	int a = s[0]-'0',b,c;
	for( i = 1; i < strlen(s); i++ ){
		if( i%2 ){
			b = s[i+1]-'0';
			if( s[i] == '+'){
				while( i+3 < strlen(s) && s[i+2] == '*' ){
					c = s[i+3]-'0';
					b *= c;
					i += 2;
				}
				a += b;
			}
			else
				a *= b;
		}
	}
	return a;
}
int L(){
	int i;
	int a = s[0]-'0',b;
	
	for( i = 1; i < strlen(s); i++ ){
		if( i%2 ){
			b = s[i+1]-'0';
			if( s[i] == '+')
				a += b;
			else
				a *= b;
		}
	}
	return a;
}

int main(){
	cin >> s >> query;
	//cout << M() << " " << L() << endl;
	if( M() == query && L() == query )
		cout << "U";
	else if( M() == query ){
		cout << "M";
	}
	else if( L() == query ){
		cout << "L";
	}
	else{
		cout << "I";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MOD = 1e9+7;

long long Max = -INF;

int main(){
    int N, Q;cin >> N >> Q;
    string S; cin >> S;
    vector<int> T(N);
    for(int i = 0; i < S.size()-1; i++){
        if(S[i] == 'A' && S[i+1] == 'C') T[i+1] = 1;
    }
    for(int i = 1; i < S.size(); i++){
        T[i] = T[i-1]+T[i];
    }
    for(int i = 0; i < Q; i++){
        int l, r; cin >> l >> r; l--;r--;
        cout << T[r]-T[l] << endl;
    }

}

Measured memory_bytes: 1408
n = int(input())
xy = []
for _ in range(n):
    i = int(input())
    ls = []
    for _ in range(i):
        ls.append(list(map(int, input().split())))
    xy.append(ls)

ans = 0
for i in range(2**n):
    _true = [0]*n
    bl = True
    cnt = 0
    for j in range(n):
        if (i >> j) & 1:
            _true[j] = 1
    for j in range(n):
        if _true[j] == 1:
            for x, y in xy[j]:
                if _true[x-1] != y:
                    bl = False
                    break
    if bl:
        cnt = sum(_true)
    ans = max(ans, cnt)

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main()
{
    long long int H, W;
    cin >> H >> W;
    long long int num = 0;
    long long int a, b,c,d;
    //奇数行目
    a = (H+1) / 2;
    b = (W+1) / 2;
    c = H/2;
    d = W/2;
    num = a * b + c * d;
    if(H==1||W==1 )
        num = 1;
    cout << num << endl;

}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
A = [[x for x in input().rstrip().split()] for _ in range(N)]
ans = 0
for i in A:
    if i[1] == "JPY":
        ans += int(i[0])
    else:
        ans += 380000 * float(i[0])
print(ans)

Measured memory_bytes: 12432
N = int(input())
lists = [list(map(str, input().split())) for i in range(N)]

dict = {}
for i in lists:
    if not i[0] in dict.keys():
        dict[i[0]] = 0
    if i[0] in dict.keys():
        dict[i[0]] += 1

max_index = max(dict.values())
value_ = []
for i, j in dict.items():
    if j == max_index:
        value_.append(i)
value_ = sorted(value_)
# print(value_)

for i in value_:
    print(i)

Measured memory_bytes: 69760
n,k=input().split()
n,k=int(n),int(k)

a1=[int(i) for i in input().split()]
b1=[]
for i in range(len(a1)):
    b1.append([sum(x>a1[i] for x in a1[:i]),0])
#print(b1)
l=len(a1)
a1.extend(a1)
#print(a1)
for i in range(l):
    #print(i)
    b1[i][1]=sum(x>a1[i+l] for x in a1[:i+l])

c=0
for i in range(len(b1)):
    c+=(2*b1[i][0]+(k-1)*(b1[i][1]-b1[i][0]))*k//2
    if c>10**9+7:
        c=c%(10**9+7)

print(c)


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
const int N=100000;
int n;
int a[N+1];
int main(){
	scanf("%d",&n);
	set<int> s;
	for(int i=1;i<=n;i++)scanf("%d",a+i),s.insert(a[i]);
	if(s.size()==1)return puts(a[1]?"No":"Yes")&0;
	if(s.size()==2){
		if(*s.begin())return puts("No")&0;
		int cnt0=0,cnt1=0;
		for(int i=1;i<=n;i++)a[i]?cnt1++:cnt0++;
		puts(cnt1==cnt0*2?"Yes":"No");
	}
	else{
		int x=*s.begin();s.erase(s.begin());
		int y=*s.begin();s.erase(s.begin());
		int z=*s.begin();
		if((x^y)!=z)return puts("No")&0;
		int cntx=0,cnty=0,cntz=0;
		for(int i=1;i<=n;i++)a[i]==x?cntx++:a[i]==y?cnty++:cntz++;
		puts(cntx==cnty&&cntx==cntz?"Yes":"No");
	}
	return 0;
}
/*1
3
1 2 3
*/
/*2
4
1 2 4 8
*/

Measured memory_bytes: 4224
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define rep(i, j) FOR(i, 0, j, 1)
#define rrep(i, j) RFOR(i, j, 0, 1)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define endl "\n"
#define MOD 998244353
#define DEB(x) cout<<"##"<<x<<"##"<<endl;
ll fastex(int a,int b){
    if(b==0)
        return 1;
    ll t=fastex(a,b/2);
    if(b%2==0)
        return (t*t)%MOD;
    return (((t*t)%MOD)*a)%MOD;
}
ll modinv(int x){
    return fastex(x,MOD-2);
}
int main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
   int n,sum;
    cin>>n>>sum;
    int ar[n+1];
    //ar[0]=0;
    rep(i,n)
    cin>>ar[i];
    int dp[3005][3005]={0};
    dp[0][0]=fastex(2,n)%MOD;
    for(int i=0;i<n;i++){
        for(int j=0;j<=sum;j++){
            dp[i+1][j]=(dp[i+1][j]+dp[i][j])%MOD;
            //cout<<dp[i+1][j]<<" ";

            if(j+ar[i]<=sum){
                dp[i+1][j+ar[i]]=(dp[i+1][j+ar[i]]+dp[i][j]*modinv(2))%MOD;
                //cout<<dp[i+1][j+ar[i]]<<" ";
            }
        }
        cout<<endl;
    }
   
    cout<<dp[n][sum];
    return 0;
}

Measured memory_bytes: 38900
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <functional>
using namespace std;

typedef long long ll;

pair<ll, int> x[100003], y[100003];
vector<pair<ll, int>> edg[100003];
bool used[100003];

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; ++i) cin >> x[i].first >> y[i].first, x[i].second = y[i].second = i;
	sort(x, x + n); sort(y, y + n);
	for (int i = 0; i < n - 1; ++i) {
		edg[x[i].second].push_back({ abs(x[i].first - x[i + 1].first), x[i + 1].second });
		edg[x[i + 1].second].push_back({ abs(x[i].first - x[i + 1].first), x[i].second });
		edg[y[i].second].push_back({ abs(y[i].first - y[i + 1].first), y[i + 1].second });
		edg[y[i + 1].second].push_back({ abs(y[i].first - y[i + 1].first), y[i].second });
	}
	priority_queue<pair<ll, int>> que;
	used[0] = true;
	for (int i = 0; i < (int)edg[0].size(); ++i) que.push({ -edg[0][i].first, edg[0][i].second });
	ll ans = 0;
	while (!que.empty()) {
		ll d = -que.top().first; int pos = que.top().second; que.pop();
		if (used[pos]) continue;
		used[pos] = true;
		ans += d;
		for (int i = 0; i < (int)edg[pos].size(); ++i) {
			if (used[edg[pos][i].second]) continue;
			que.push({ -edg[pos][i].first, edg[pos][i].second });
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main(){
    long A, B, Q;
    long s[100002];
    long t[100002];
    cin >> A >> B >> Q;
    s[0] = -10e+17;
    s[A+1] = 10e+17;
    t[0] = -10e+17;
    t[B+1] = 10e+17;
    for(int i = 0; i < A; i++){
        cin >> s[i+1];
    }
    for(int i = 0; i < B; i++){
        cin >> t[i+1];
    }
    sort(s, s+A+2);
    sort(t, t+B+2);
    for(int i = 0; i < Q; i++){
        long x;
        cin >> x;
        long *sl = lower_bound(s, s+A+2, x);
        long *tl = lower_bound(t, t+B+2, x);
        long s1 = *(sl-1);
        long s2 = *sl;
        long t1 = *(tl-1);
        long t2 = *tl;
        long tmp1 = min(s2-t1+min(s2-x, x-t1), t2-s1+min(t2-x, x-s1));
        long tmp2 = min(max(s2-x, t2-x), max(x-t1, x-s1));
        cout << min(tmp1, tmp2) << endl;
    }
}

Measured memory_bytes: 2944
from heapq import heappush, heappop

class UnionFind:
    def __init__(self, size):
        self.data = [-1] * size
    def find(self, x):
        if self.data[x] < 0:
            return x
        else:
            self.data[x] = self.find(self.data[x])
            return self.data[x]
    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        if x != y:
            if self.data[y] < self.data[x]:
                x, y = y, x
            self.data[x] += self.data[y]
            self.data[y] = x
        return (x != y)
    def same(self, x, y):
        return (self.find(x) == self.find(y))
    def size(self, x):
        return -self.data[self.find(x)]

N, *XY = map(int, open(0).read().split())
XY = list(zip(*[iter(XY)] * 2))

YtoI = {y : i for i, (x, y) in enumerate(XY)}

XY.sort()

uf = UnionFind(N)
Q = []
for x, y in XY:
    T = []
    while Q and Q[0] < y:
        yy = heappop(Q)
        uf.union(YtoI[y], YtoI[yy])
        T.append(yy)

    if T:
        heappush(Q, T[0])
    else:
        heappush(Q, y)


for i in range(N):
    print(uf.size(i))

Measured memory_bytes: 59772
#include <stdio.h>
#include <math.h>
using namespace std;

int main()
{
    int n, x, mi, min = 100000, sum_m = 0;
    scanf("%d %d", &n, &x);
    for(int i = 0; i < n; i++){
        scanf("%d", &mi);
        sum_m += mi;
        if(mi < min) min = mi;
    }
    printf("%d", n + (int)(floor((x - sum_m) / min)));
    return 0;
}

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

enum JudgeResult {
    JR_AC,
    JR_WA,
    JR_TLE,
    JR_RE,
    JR_MAX_NUM
};

int main()
{
    int num_rows;
    int jr_counter[JR_MAX_NUM] = {0};
    cin >> num_rows;

    std::string input_row;
    for (int i=0; i<num_rows; i++) {
        // std::getline(std::cin, input_row);
        cin >> input_row;
        // note: next time we shall use regexp.
        if (input_row == "AC") {
            jr_counter[JR_AC]++;
        }
        else if (input_row == "WA") {
            jr_counter[JR_WA]++;
        }
        else if (input_row == "TLE") {
            jr_counter[JR_TLE]++;
        }
        else if (input_row == "RE") {
            jr_counter[JR_RE]++;
        }
        else {
            // do nothing
        }
    }

    cout << "AC x " << jr_counter[JR_AC] << endl;
    cout << "WA x " << jr_counter[JR_WA] << endl;
    cout << "TLE x " << jr_counter[JR_TLE] << endl;
    cout << "RE x " << jr_counter[JR_RE] << endl;

    return 0;
}

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

int main() {
    ll n;
    cin>>n;
    ll a[n],i,sum=0,sum1=0,p;
    vector<ll>v;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    for(i=0;i<n-1;i+=2){
        sum1+=(2*a[i]);
    }
    v.push_back(sum-sum1);
    for(i=n-2;i>=0;i--)
    {
        p=v.size();
        v.push_back((2*a[i])-v[p-1]);
    }
    for(i=v.size()-1;i>=0;i--)
    cout<<v[i]<<" ";
    cout<<endl;
	return 0;
}

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

const int MAXN = 100010;

inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = (x*10)+(ch^48);
	return x * f;
}

int n, st[MAXN], to[MAXN<<1];
int nxt[MAXN<<1], e;
inline void Add(int u, int v) {
	to[++e] = v, nxt[e] = st[u];
	st[u] = e;
}

int dp[MAXN], deg[MAXN];
bool isc[MAXN];

void dfs(int u, int fa) {
	int i, sn = 0;
	for(i = st[u]; i; i = nxt[i]) {
		if(to[i] == fa) continue;
		dfs(to[i], u), sn++;
	}
	if(sn == 0) dp[u] = isc[u] = 1;
	else if(sn == 1) {
		for(i = st[u]; i; i = nxt[i]) {
			if(to[i] == fa) continue;
			dp[u] = dp[to[i]];
			isc[u] = isc[to[i]];
		}
	}
	else {
		for(i = st[u]; i; i = nxt[i]) {
			if(to[i] == fa) continue;
			isc[u] |= isc[to[i]];
			dp[u] += dp[to[i]];
		}
		if(isc[u]) dp[u]--, isc[u] = false;
	}
}

int root;

int main() {

	int i;
	n = read();
	for(i = 1; i < n; i++) {
		int u = read()+1, v = read()+1;
		Add(u, v), Add(v, u);
		deg[u]++, deg[v]++;
	}
	for(i = 1; i <= n; i++)
		if(deg[i] >= 3) { root = i; break; }
	if(i > n) {
		printf("1\n");
		return 0;
	}
	dfs(root, 0);
	printf("%d\n", dp[root]);
	return 0;
}


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

int main(void)
{
	char vehi[1024][52 + 1];
	char *current;
	int n;
	char in[1025];
	
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++){
		int j;
		
		scanf("%s", in);
		current = vehi[i] + 26;
		memset(vehi[i], 0, 53 * sizeof(char));
		
		*current = in[0];
		j = 1;
		while (in[j] != '\0'){
			switch (in[j]){
				case '<':		 current--; break;
				case '>':		 current++; break;
				case '-':					break;
				default:  *current = in[j]; break;
			}
			j++;
		}
	}
	
	for (int i = 0; i < n; i++){
		int j;
		j = 0;
		while (vehi[i][j] == 0){
			j++;
		}
		while (vehi[i][j] != 0){
			printf("%c", vehi[i][j]);
			j++;
		}
		puts("");
	}
	
	return (0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int s=0;
	string f;
	cin>>f;
	for(int i=1;i<f.length();i++)
	{
		if(f[i-1]!=f[i])s++;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdbool.h>

int pic_num(char pic){
    int p;
    switch ( pic ){
        case 'S':
            p = 0;
            break;
        case 'H':
            p = 1;
            break;
        case 'C':
            p = 2;
            break;
        case 'D':
            p = 3;
            break;
    }
    return p;
}

char num_pic(int p){
    char pic;
    switch ( p ){
        case 0 :
            pic = 'S';
            break;
        case 1 :
            pic = 'H';
            break;
        case 2 :
            pic = 'C';
            break;
        case 3 :
            pic = 'D';
            break;
    }
    return pic;
}

int main(void){
    int n,p,l,i;
    char pic;
    bool card[4][13];
    for ( p = 0 ; p < 4 ; p++ ){
        for ( l = 0 ; l < 13 ; l++ ){
            card[p][l] = true;
        }
    }
    scanf("%d", &n);
    for ( i = 0 ; i < n ; i++ ){
        scanf("%*c%c %d", &pic, &l);
        card[pic_num(pic)][l-1] = false;
    }
    for ( p = 0 ; p < 4 ; p++ ){
        for ( l = 0 ; l < 13 ; l++ ){
            if ( card[p][l] ) {
                printf("%c %d\n", num_pic(p), l+1);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2072
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define ll long long
# define ln cout<<'\n'
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
 
ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

int factorial(int n)
{
    int x = 1; // 0! = 1

    for (int i = 1; i <= n; ++i)
        x *= i;

    return x;
}


using namespace std;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    string s;
    int cnt=0;
    cin >> s ;
    bool flag = true;
    if (s[0]!='A'){
        flag = false;
        cout << "WA"<<endl;
        exit(0);
    }

    
    for(int i=1;i<s.size();i++){
        if (isupper(s[i])){
            if (i==1 || i==s.size()-1 ||s[i]!='C'){
                cout <<"WA"<<endl;
                exit(0);
            }
            cnt+=1;
        }
    }
    if (cnt!=1){
        flag = false;
        cout << "WA"<<endl;
        exit(0);
    }
    cout<<"AC"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,j,n) for(int i=j;i<=n;i++)
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    if(n==5 || n==7 || n==3)
      cout<<"YES";
    else
      cout<<"NO";
}   
    
    
     

     
   





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

int main(){
    int n;
    cin >> n;
    int arr[] = {1, 2, 3};
    vector<int> a(n), b(n), c(n-1);
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    for (int i = 0; i < n; i++){
        cin >> b[i];
    }
    for (int i = 0; i < n-1; i++){
        cin  >> c[i];
    }

    int satisfiction = 0;

    for(int i = 0; i < a.size(); i++){
        satisfiction += b[a[i] - 1];
        if ((i <= a.size() - 2) && (a[i + 1] - a[i] == 1)){
            satisfiction += c[a[i] - 1];
        }
    }
    
    cout << satisfiction;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;

set<int> g[101010];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for (int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		g[a].insert(b);
		g[b].insert(a);
	}
	queue<int> q;
	for (int i=1;i<=n;i++){
		q.push(i);
	}
	int nn=n;
	while (!q.empty()){
		int x=q.front();
		q.pop();
		if (g[x].size()==2){
			for (int nx:g[x]){
				if (g[nx].size()==1){
					x=nx;
					break;
				}
			}
		}
		if (g[x].size()!=1) continue;
		int nx=*g[x].begin();
		if (g[nx].size()!=2) continue;
		for (int nnx:g[nx]){
			g[nnx].erase(nx);
			q.push(nnx);
		}
		g[nx].clear();
		g[x].clear();
		nn-=2;
	}
	for (int i=1;i<=n;i++){
		if (g[i].size()>=3){
			cout<<"First"<<endl;
			return 0;
		}
	}
	if (nn%2==1){
		cout<<"First"<<endl;
	}
	else{
		cout<<"Second"<<endl;
	}
}

Measured memory_bytes: 14848
def get_normal_form(seq_type):
    curr_char = ord('a')
    return "".join([chr(curr_char + int(i)) for i in seq_type])


def submit():
    n = int(input())

    def rec(category, acc, result):
        if len(acc) == n:
            result.append(acc)
            return result

        for c in range(category):
            result = rec(category, acc + str(c), result)
        result = rec(category + 1, acc + str(category), result)

        return result

    result = rec(1, "0", [])
    result.sort()
    for r in result:
        print(get_normal_form(r))


if __name__ == "__main__":
    submit()


Measured memory_bytes: 12656
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;++a) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define int_maxvalue numeric_limits<int>::max()
ll mod = 1e9 + 7;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int n;
		cin >> n;
		if (n == 0) { break; }
		ll a[4001];
		bool out[4001];
		rep(i, 4001) { a[i] = 0; out[i] = false; }
		bool flag = false;
		
		rep(i, n) {
			ll d, p, q;
			cin >> d >> p >> q;
			a[d] += p*q;
			if (a[d] >= 1000000 &&! out[d]) {
				flag = true;
				out[d] = true;
				cout << d << endl;
			}
		}
		/*for (int i = 1; i < 4001; i++) {
			if (a[i] >= 1000000) {
				flag = true;
				cout << i << endl;
			}
		}*/
		if (!flag) { cout << "NA" << endl; }
	}
	return 0;
}


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

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

vector<vector<P>> to; vector<ll> to_dist;

void Dijkstra(ll v){
  
  to_dist[v] = 0; 
  
  priority_queue<P, vector<P>, greater<P>> Q; 
  Q.push({0,v}); 
  
  while(!Q.empty()){
   
    P p = Q.top(); Q.pop();
    ll s = p.first; ll t = p.second; 
      for(auto ne: to[t]){
        ll x = ne.first; ll y = ne.second;
        
        if( to_dist[x] > to_dist[t] + y){
          to_dist[x] = to_dist[t] + y; Q.push({to_dist[x], x});}
      }
  }

}


int main(){
  ll N,M; cin >> N >> M;
  to.resize(N); to_dist = vector<ll> (N,INF);
  
  for(ll i = 0; i < N-1; i++){  to[i+1].push_back({i,0});}
  
  for(ll i = 0; i < M; i++){
    ll L,R,C; cin >> L >> R >> C; L--; R--; 
    to[L].push_back({R,C}); to[R].push_back({L,C});
  }
  
  Dijkstra(0);
  ll ans = to_dist[N-1]; 
  if( ans == INF){ ans = -1;} 
  
  cout << ans << endl; return 0;
}
    
  
 
  

Measured memory_bytes: 13048
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	Solver() {
		ios::sync_with_stdio( false );
	}

	void solve() {
		int N;
		cin >> N;

		int s = 0;
		vector<int> A( N+2 );
		for( int i = 1; i <= N; ++i ) {
			cin >> A[i];
			s += abs( A[i-1] - A[i] );
		}
		s += abs( A[N] );

		for( int i = 1; i <= N; ++i ) {
			int ans = s;
			ans -= abs( A[i-1] - A[i] ) + abs( A[i] - A[i+1] );
			ans += abs( A[i-1] - A[i+1] );
			cout << ans << '\n';
		}
	}
};

int main() {
	Solver().solve();
	return 0;
}


Measured memory_bytes: 1664
{-# LANGUAGE CPP #-}
module Main where

import qualified Data.Vector.Unboxed as V 
import qualified Data.Map.Strict as M
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Data.Char
import qualified Data.List as L

dump :: (Show a) => a -> IO()
#if __GLASGOW_HASKELL__ >= 800
dump x = print x
#else
dump _ = pure ()
#endif

-- "101010" -> [1,0,1,0,1,0]
readToList :: String -> [Int]
readToList [] = []
readToList (x:xs) = read [x] : readToList xs

 
readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt

getInt :: IO Int
getInt = readInt <$> BS.getLine

-- "10 10 10" -> [10, 10, 10]
getlist :: IO [Int]
getlist = (fmap (read . BS.unpack) . BS.words) <$> BS.getLine

-- "10 10 10" -> [10, 10, 10]
getIntVec :: Int -> IO (V.Vector Int)
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readmat :: Int -> IO [[Int]]
readmat rows = replicateM rows getlist

newtype UF a = UF (M.Map a a) deriving (Show) -- Map node parent

makeuf :: Int -> UF Int
makeuf n = let m = M.fromList $ zip [0..n] [0..n]
                in UF m

union :: (Eq a, Ord a) => a -> a -> UF a -> UF a
union l r uf@(UF m) = let lp = find l uf
                          rp = find r uf
                      in if lp == rp
                         then uf
                         else if size l uf < size r uf
                              then UF $ M.update (const $ Just rp) lp m
                              else UF $ M.update (const $ Just lp) rp m

find :: (Eq a, Ord a) => a -> UF a -> a
find x uf@(UF m) = let px = m M.! x
                in if px == x
                   then px
                   else find px uf -- TODO 貼り直し

size :: (Eq a, Ord a) => a -> UF a -> Int
size x (UF m) = M.size $ M.filter (\par -> par==x) m

genbit :: Int -> [[Int]]
genbit 0 = []
genbit 1 = [[0],[1]]
genbit len = do
  x <- [0,1]
  map (x:) $ genbit (len-1)

base :: Int
base = 10 ^ 9 + 7

forn :: (Num a, Enum a, Monad m) => a -> (a -> m b) -> m [b]
forn x = forM [0..(x-1)]

count :: (Eq a) => a -> [a] -> Int
count y = length . filter (== y)

main :: IO()
main = do
  [a,b] <- getlist
  print $ (a `div` gcd a b) * b
  


Measured memory_bytes: 508
input_line = input().rstrip().split(' ')

result = 'Balanced'
left_weight = int(input_line[0]) + int(input_line[1])
right_weight = int(input_line[2]) + int(input_line[3])

if (left_weight > right_weight):
	result = 'Left'
elif (left_weight < right_weight):
	result = 'Right'

print(result)


Measured memory_bytes: 2940
#include <cstdio>
#define MANX 60
#define ll long long
#define mod 1000000007
#define MAXN 60
char a[MAXN], b[MAXN];
int main() {
	int n, i = 1;
	ll ans = 1;
	bool flag; 
	scanf("%d", &n); 
	scanf("%s\n%s", a+1, b+1);
	if(n == 1) {
		printf("3\n");
		return 0;
	}	
	if(a[1] == a[2]) {
		flag = 1;
		i += 2;
		ans = 6;
	}
	else
	{
		flag = 0;
		i ++;
		ans = 3;
	}
	while(i <= n) {
		if(a[i] == b[i]) {
			if(flag == 1) {
				ans *= 1;
			} 
			else {
				ans = (ans*2) % mod;
			} 
			flag = 0; 
			i ++;
		}else { 
			if(flag == 1) {
				ans = (ans*3) % mod; 
			}else {
				ans = (ans*2) % mod;
			}
			flag = 1;
			i += 2;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <stdlib.h>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

bool compare_by_b(pair<string, uint32_t> a, pair<string, uint32_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

bool compare(pair<string, uint32_t> a, pair<string, uint32_t> b) {
  if (a.first != b.first) {
    return a.first < b.first;
  } else {
    return a.second > b.second;
  }
}

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

  vector<pair<string, uint32_t>> Rest(N);
  map<pair<string, uint32_t>, uint32_t> index;

  for (uint32_t i = 0; i < N; ++i) {
    cin >> Rest[i].first >> Rest[i].second;
    index[Rest[i]] = i + 1;
  }

  sort(Rest.begin(), Rest.end(), compare);

  for (uint32_t i = 0; i < N; i++) {
    cout << index[Rest[i]] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import math

n = int(input())
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]

a = 0

for i in range(n):
    tmp = 0
    for j in range(n-i-1):
        if p[i] > p[i+j+1]:
            tmp += 1
    a += tmp*math.factorial(n-1-i)


b = 0

for i in range(n):
    tmp = 0
    for j in range(n-i-1):
        if q[i] > q[i+j+1]:
            tmp += 1
    b += tmp*math.factorial(n-1-i)
    
print(abs(a-b))

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

int main(void){
	char s[3]={"\0"};

	scanf("%s",s);
	if(!strcmp(s,"ABC")){
		printf("ARC");
	}else{
		printf("ABC");
	}

	return 0;
}


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

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ld dp[311][311][311];
int cnt[3];

bool valid(int x, int y, int z)
{
	return (x>=0&&y>=0&&z>=0);
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=0;i<n;i++)
	{
		int x; cin>>x; x--; cnt[x]++;
	}
	dp[0][0][0]=0;
	for(int k=0;k<=cnt[2];k++)
	{
		for(int j=0;j<=n;j++)
		{
			for(int i=0;i<=n;i++)
			{
				if(i==0&&j==0&&k==0) continue;
				dp[i][j][k]=1;
				if(i>0) dp[i][j][k]+=ld(i)/ld(n)*dp[i-1][j][k];
				if(j>0) dp[i][j][k]+=ld(j)/ld(n)*dp[i+1][j-1][k];
				if(k>0) dp[i][j][k]+=ld(k)/ld(n)*dp[i][j+1][k-1];
				dp[i][j][k]*=ld(n)/ld(i+j+k);
				//cerr<<i<<' '<<j<<' '<<k<<' '<<dp[i][j][k]<<'\n';
			}
		}
	}
	cout<<fixed<<setprecision(15)<<dp[cnt[0]][cnt[1]][cnt[2]]<<'\n';
}


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

int main() {
    int N;
    string S;
    int K;
    cin >> N >> S >> K;
    int X = S[K-1];
    for(int i = 0; i < S.size(); i++) {
        if(S[i] != X) {
            S[i] = '*';
        }
    }
    cout << S << endl;
}



Measured memory_bytes: 256
s = input()
m = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"]

a = 0
b = 0
if s[0:2] in m:
  a = 1
if s[2:] in m:
  b = 1
  
if a == 0 and b == 0:
  print("NA")
elif a == 1 and b == 0:
  print("MMYY")
elif a == 0 and b == 1:
  print("YYMM")
else:
  print("AMBIGUOUS")

Measured memory_bytes: 3064
use input::Input;

fn main() {
    let mut input = Input::default();

    let n = input.parse();
    let k = input.parse();
    let mut p = (0..n).map(|_| input.parse()).collect::<Vec<u32>>();
    p.sort();

    let mut ans = 0;
    for i in 0..k {
        ans += p[i];
    }
    println!("{}", ans);
}

#[allow(dead_code)]
pub mod input {
    #[derive(Default)]
    pub struct Input(Vec<String>);

    impl Input {
        pub fn read_line(&mut self) -> String {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).ok().expect("read error");
            s
        }
        pub fn parse<T: std::str::FromStr>(&mut self) -> T {
            let x = if let Some(x) = self.0.pop() {
                x
            } else {
                let s = self.read_line();
                self.0 = s.split_whitespace().map(String::from).rev().collect();
                self.0.pop().expect("reached EOF")
            };
            x.parse().ok().expect("parse error")
        }
    }
}


Measured memory_bytes: 2172
// Author:: Mohammad Faisal
// BEGINNING WITH THE NAME OF ALMIGHTY GOD ALLAH
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  
  int n;
  cin >> n;
  int temp = n;
  long long seats=0;
  while(n--)
  {
    long long l,r;
    cin >> l >> r;
    seats+=abs(l-r);
  }
  cout<<seats+temp<<endl;
  return 0;
}


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

int main(){
  int x[5];
  int ans;
  rep(i,0,5){
    cin >> x[i];
    if(x[i]==0) ans = i+1;
  }
  cout << ans << endl;

  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    map<string, vector<pair<int, int>>> table;
    for (int i = 0; i < n; i++)
    {
        string s;
        int p;
        cin >> s >> p;
        table[s].push_back(make_pair(p, i + 1));
    }
    for (auto item : table)
    {
        vector<pair<int, int>> shops = item.second;
        sort(shops.begin(), shops.end(), greater<pair<int, int>>());
        for (auto s : shops)
        {
            cout << s.second << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256