akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main() {
	while (1) {
		bool bo[30][30] = { false };
		int a, b, dp[30][30] = { 0 };
		int n;
		cin >> a >> b;
		if (a == 0 && b == 0) return 0;
		cin >> n;
		for (int i = 0; i < n; i++) {
			int x, y;
			cin >> x >> y;
			bo[x][y] = true;
		}
		dp[1][0] = 1;
		for (int i = 1; i <= a; i++) {
			for (int j = 1; j <= b; j++) {
				if (bo[i][j]) dp[i][j] = 0;
				else dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
			}
		}
		cout << dp[a][b] << endl;
	}
	return 0;
}

Measured memory_bytes: 3008
#include<iostream>
using namespace std;
string s[999];int n;
bool check(string s,int l)
{
	if(s.size()<=l)return 0;
	bool ok=1;
	for(int i=0;i<l;i++)ok&=s[i]=='.';
	return ok&&s[l]!='.';
}
int f(int r,int l,int level)
{
	int first=r+1;
	string a=s[r];
	bool A;
	if(a[level]>='0'&&a[level]<='9')
	{
		return a[level]-'0';
	}
	else A=a[level]=='*';
	int ret=A?1:0;
	for(int i=r+2;i<=l;i++)
	{
		if(check(s[i],level+1))
		{
			int now=f(first,i-1,level+1);
			ret=A?ret*now:ret+now;
			first=i;
		}
	}
	int now=f(first,l,level+1);
	ret=A?ret*now:ret+now;
	return ret;
}
main()
{
	while(cin>>n,n)
	{
		for(int i=0;i<n;i++)cin>>s[i];
		cout<<f(0,n-1,0)<<endl;
	}
}



Measured memory_bytes: 3176
import java.util.Scanner;

public class Main {

	private static final int N = 5;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int result = 0;
			for (int i = 1; i <= N; i++) {
				int a = scanner.nextInt();
				if (0 == a) {
					result = i;
				}
			}
			System.out.println(result);
		}
	}
}


Measured memory_bytes: 35672
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
typedef long double la;
using namespace std;
 
int main(){
    ll x,i=2;
    cin >> x;
    while(1){
        if(x%i == 0){
            if(x == i){
                cout << x << endl;
                return 0;
            }else{
                x++;
                i=2;
            }
        }
        i++;
    }
}

Measured memory_bytes: 256
/**
 * File              : A.cpp
 * Author            : JCHRYS <jchrys@me.com>
 * Date              : 28.03.2020
 * Last Modified Date: 28.03.2020
 * Last Modified By  : JCHRYS <jchrys@me.com>
 */

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

bool is_coffe(string s) {
    return s[3] == s[2] && s[4] == s[5];
}

int main() {
    string s;
    cin >> s;
    if (is_coffe(s)) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


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

class Dice {
public:
	Dice() {
		face[0] = &T;
		face[1] = &S;
		face[2] = &E;
		face[3] = &W;
		face[4] = &N;
		face[5] = &B;
	}
	void setFace() {
		for (int i = 0; i < 6; i++)
			cin >> *face[i];
	}
	int getFace(char c) {
		switch (c) {
		case 'T': return T;
		case 'S': return S;
		case 'E': return E;
		case 'W': return W;
		case 'N': return N;
		case 'B': return B;
		}
	}
	void setCommand() {
		cin >> command;
	}
	void move(char c) {
		switch (c) {
		case 'E': move(E, T, W, B); break;
		case 'N': move(N, T, S, B); break;
		case 'S': move(S, T, N, B); break;
		case 'W': move(W, T, E, B); break;
		}
	}
	void move() {
		for (int i = 0; i < command.size(); i++)
			move(command[i]);
	}
	void move(int& a, int& b, int& c, int& d) {
		int temp = a;
		a = b;
		b = c;
		c = d;
		d = temp;
	}
private:
	int* face[6];
	int T, S, E, W, N, B;
	string command;
};

int main() {
	Dice dice2;
	dice2.setFace();
	int q, a, b;
	cin >> q;
	while (q--) {
		cin >> a >> b;
		if (dice2.getFace('W') == a)
			dice2.move('E');
		else if (dice2.getFace('E') == a)
			dice2.move('W');
		while (dice2.getFace('T') != a)
			dice2.move('N');
		if (dice2.getFace('S') == b)
			cout << dice2.getFace('E') << endl;
		else if (dice2.getFace('E') == b)
			cout << dice2.getFace('N') << endl;
		else if (dice2.getFace('N') == b)
			cout << dice2.getFace('W') << endl;
		else cout << dice2.getFace('S') << endl;
	}
	return 0;
}


Measured memory_bytes: 3092
def solve():
    N,M = map(int,input().split())
    A = sorted([int(i) for i in input().split()], reverse=True)
    B = sorted([int(i) for i in input().split()], reverse=True)

    # IndexError対策
    A += [0]
    B += [0]
    
    MOD = 10**9 + 7

    ans = 1
    # A,Bでxより大きい値の数
    biggerX_a, biggerX_b = 0, 0
    for x in range(N*M, 0, -1):
        if A[biggerX_a] > x:
            return 0
        if B[biggerX_b] > x:
            return 0
        
        if A[biggerX_a] == B[biggerX_b] == x:
            tmp = 1
            biggerX_a += 1
            biggerX_b += 1
        elif A[biggerX_a] == x:
            tmp = biggerX_b
            biggerX_a += 1
        elif B[biggerX_b] == x:
            tmp = biggerX_a
            biggerX_b += 1
        else:
            # (N*M-x)個は既に埋まっている
            tmp = biggerX_a * biggerX_b - (N*M - x)
            if tmp <= 0:
                return 0
        
        ans = (ans * tmp) % MOD

    return ans

if __name__ == "__main__":
    print(solve())

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

typedef long long ll;
const ll mod = 1e9 + 7;

ll modpow(ll a, ll b, ll p = 1e9+7){
    if(b == 0)  return 1;

    if(b % 2 == 0){
        ll d = modpow(a, b/2, p);
        return (d*d) % p;
    }else{
        return (a%p * modpow(a, b-1, p)) % p;
    }
}

struct ModComb{
    vector<ll> po, inv;
    ll N;

    ModComb(ll n) : N(n), po(n), inv(n) {
        po[0] = 1;
        for(int i = 1; i < N; i++)  po[i] = (po[i-1] * i) % mod;
        inv[N-1] = modpow(po[N-1], mod-2, mod);
        for(int i = N-2; i >= 0; i--)   inv[i] = (inv[i+1] * (i+1)) % mod;
    }
    
    ll nCk(ll n, ll k){
        if(k == 0)  return 1;
        if(n < k)   return 0;
        return (((po[n]*inv[n-k])%mod)*inv[k])%mod;
    }

    ll nPk(ll n, ll k){
        if(k == 0)  return 1;
        if(n < k)   return 0;
        return (po[n]*inv[n-k])%mod;
    }

    ll nHk(ll n, ll k){
        if(n == 0 && k == 0)    return 1;
        return nCk(n+k-1, k-1);
    }
};

int main(){
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    ModComb mc(2*n);
    // 総人数、1グループの人数
    vector<vector<ll>> dp(n+1, vector<ll>(n+1, 0));
    
    vector<ll> memo(n+1);
    for(int j = c; j <= d; j++) memo[j] = modpow(mc.po[j], mod-2);

    dp[0][a-1] = 1;
    for(int mem = a; mem <= b; mem++){
        for(int i = 0; i <= n; i++){
            dp[i][mem] = dp[i][mem-1];
            ll f = modpow(mc.inv[mem], c);
            for(int j = c; j <= min(d, i/mem); j++){
                (dp[i][mem] += dp[i-mem*j][mem-1]*mc.nPk(n-(i-mem*j), mem*j)%mod*memo[j]%mod*f%mod) %= mod;
                (f *= mc.inv[mem]) %= mod;
            }
        }
    }
    cout << dp[n][b] << endl;
    return 0;
}

Measured memory_bytes: 8192
n = int(input())
a = list(map(int, input().split()))

o = []

MOD = 10**9 + 7

for b in range(60):
    count = 0
    x = 2**b
    for i in range(n):
        if (a[i] & x) == 0:
            count += 1
    o.append(count)

sum = 0
for b in range(60):
    sum += (o[b] * (n - o[b])) * 2**b

print(sum % MOD)


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

int main() {
  int N,A,x;
  cin>>N;
  cin>>A;
  x=N%500;
  if (x==0){
   cout<<"Yes"<<endl; 
  }
  else if (x<=A){
   cout<<"Yes"<<endl; 
  }
  else{
   cout<<"No"<<endl; 
  }
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define for_(i, s, e) for (int i = s; i < e; i++)
#define for__(i, s, e) for (ull i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;

ll po(int k) {
    ll a = 1;
    for_(i, 0, k)  a *= 10;
    return a;
}

int n;
int ct = 9;

vector<vector<ll>> pre(10), current(10);
ll solve(int l) {
    ll p = po(l);
    current[0] = pre[0];
    // current[1].push_back(p);
    // cout << p << endl;
    for (int k: pre[0]) {
        current[1].push_back(p+k);
        // cout << p+k << endl;
        ct += 1;
        if (ct == n) return current[1].back();
    }
    for_(i, 1, 10) {
        ll temp = p*i;
        if (i-1 > 0) {
            for (int k: pre[i-1]) {
                current[i].push_back(temp+k);
                // cout << temp+k << endl;
                ct += 1;
                if (ct == n) return current[i].back();
            }
        }
        
        for (int k: pre[i]) {
            current[i].push_back(temp+k);
            // cout << temp+k << endl;
            ct += 1;
            if (ct == n) return current[i].back();
        }

        if (i+1 < 10) {
            for (int k: pre[i+1]) {
                current[i].push_back(temp+k);
                // cout << temp+k << endl;
                ct += 1;
                if (ct == n) return current[i].back();
            }
        }
    }

    return -1;
}

int main() {
    // freopen("test.in", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for_(i, 0, 10) current[i].push_back(i);
    if (n < 10) {
        cout << n << endl;
        exit(0);
    }
    for_(i, 1, 12) {
        current[0].insert(current[0].end(), pre[1].begin(), pre[1].end());
        pre = current;
        current.assign(10, {});
        ll ans = solve(i);
        if (ans != -1) {
            cout << ans << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n, q;
    string s;
    vector<int> pos;
    cin >> n >> q >> s;
    for(int i = 1; i < n; i++) {
        if (s[i] == 'C' && s[i-1] == 'A')
            pos.push_back(i);
    }
    int l, r;
    while(q--) {
        cin >> l >> r;
        auto beg = lower_bound(pos.begin(), pos.end(), l);
        auto ed = lower_bound(pos.begin(), pos.end(), r);
        cout << distance(beg, ed) << endl;
    }
    return 0;
}



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

//#define int long long
typedef long long ll;
const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int D;
    cin >> D;
    vector<int> c(26);
    for (int i=0;i<26;i++) cin >> c[i];
    vector<vector<int>> s(D,vector<int>(26));
    for (int i=0;i<D;i++){
        for (int j=0;j<26;j++){
            cin >> s[i][j];
        }
    }
    vector<int> t(D);
    //初期t[i]の決定
    for (int i=0;i<D;i++) {
        t[i] = i % 26;
    }

    ll oldsum = -INF;
    for (int m=0;m<100000;m++){
        //ここでt[i]を更新していく
        int dd = rand()%D;
        int qq = rand()%26;
        int oldval = t[dd];
        t[dd] = qq;
        //=======================
        ll sum = 0;
        vector<int> last(26);
        for (ll i=0;i<D;i++){
            sum += s[i][t[i]];
            last[t[i]] = i+1;
            for (int j=0;j<26;j++){
                sum -= c[j]*(i+1-last[j]);
            }
        }
        if (sum > oldsum) {
            oldsum = sum;
        } else {
            t[dd] = oldval;
        }
    }
    for (int i=0;i<D;i++){
        cout << t[i]+1 << "\n";
    }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
char a[3006],b[3006];
int po[3005][3005],co[3005][3005];
main()
{
	scanf("%s%s",&a[1],&b[1]);
	int r=strlen(&a[1]),c=strlen(&b[1]);
	for(int i = 1;i <= r;i++)//a
	{
		for(int j = 1;j <= c;j++)//b
		{
			if(a[i]==b[j])
			{
				po[i][j]=-1;
				co[i][j]=co[i-1][j-1]+1;
			}
			else
			{
				if(co[i-1][j]>co[i][j-1])
				{
					co[i][j]=co[i-1][j];
					po[i][j]=10;
				}
				else
				{
					co[i][j]=co[i][j-1];
					po[i][j]=100;
				}
			}
		}
	}
	/*for(int i=  1;i <= r;i++)
	{
		for(int j = 1;j <= c;j++)
		printf("%d",co[i][j]);
		printf("\n");
	}*/
	vector<int>v;
	while(r!=0 && c!=0)
	{
		if(po[r][c]==-1)
		{
			v.push_back(r);
			r--;
			c--;
		}
		else if(po[r][c]==10)
		{
			r--;
		}
		else
		{
			c--;
		}
	}
	for(int i = v.size()-1;i >= 0;i--)
	printf("%c",a[v[i]]);
}

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

 
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	int l, r;
	
	cin >> l >> r;
	
	if(l == 0) cout << 0 << "\n", exit(0);
	
	int d = (r/2019) - (l-1)/2019;
	
	if(d > 0) cout << 0 << "\n", exit(0);
	
	int mn = 2e9, val;
	
	for(int i = l; i < r; i++){
		for(int j = i+1; j <= r; j++){
			val = ((i%2019) * (j%2019)) % 2019;
			mn = min(mn, val);
		}
	}
	
	cout << mn << "\n";
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")


vector<pair<int,int>> xx;
signed main(){
	cout<<fixed<<setprecision(7);
	
	int N, M, A, B, a = 0, b = 0, t = 0, ans = 0;
	
	cin>>N;
	
	rep(i,N){
		cin>>A>>B;
		xx.push_back(make_pair(A,0));
		xx.push_back(make_pair(B+1,1));
	}
	
	sort(xx.begin(), xx.end());
	for(int i = 0; i < xx.size();i++){//cout<<i<<" "<<xx[i].first<<" "<<t<<endl;
		if(!xx[i].second)t++;
		else t--;
		while(i!=xx.size()-1&&xx[i].first==xx[i+1].first){
			i++;
			if(!xx[i].second)t++;
			else t--;
		}
		ans = max(ans,t);
	}
	
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 7020
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
#define int long long
int read() {
	char cc = getchar(); int cn = 0, flus = 1;
	while(cc < '0' || cc > '9') {  if( cc == '-' ) flus = -flus;  cc = getchar();  }
	while(cc >= '0' && cc <= '9')  cn = cn * 10 + cc - '0', cc = getchar();
	return cn * flus;
}
const int N = 2e5 + 5 ; 
int n, q, cnt, A[N], B[N], C[N], fa[N], b[N * 2] ; 
struct E {
	int x, y, z ; 
} e[N * 2];
bool cmp( E x, E y ) {
	return x.z < y.z ; 
} 
int fd( int x ) {
	return ( fa[x] == x ) ? x : fa[x] = fd(fa[x]) ;
}
signed main()
{
	n = read(), q = read() ; memset( b, 63, sizeof(b) ) ;
	rep( i, 1, q ) {
		A[i] = read() + 1, B[i] = read() + 1, C[i] = read() ; 
		e[++ cnt].x = A[i], e[cnt].y = B[i], e[cnt].z = C[i] ; 
		b[A[i]] = min( b[A[i]], C[i] + 1 ), b[A[i] + n] = min( C[i] + 1, b[A[i] + n] ),
		b[B[i]] = min( b[B[i]], C[i] + 2 ), b[B[i] + n] = min( C[i] + 2, b[B[i] + n] );
	}
	for( re int i = 2; i <= 2 * n; ++ i )
		b[i] = min( b[i - 1] + 2, b[i] ) ;
	for( re int i = 1; i <= n; ++ i )
		e[++ cnt].x = i, e[cnt].y = ( i == n ) ? 1 : i + 1 , 
		e[cnt].z = min( b[i], b[i + n] ), fa[i] = i;
	sort( e + 1, e + cnt + 1, cmp ) ; int Ans = 0 ;
	rep( i, 1, cnt ) {
		int u = e[i].x, v = e[i].y ;
		u = fd(u), v = fd(v) ;
		if( u == v ) continue ; 
		Ans += e[i].z, fa[u] = v ;
	}
	printf("%lld\n", Ans ) ;
	return 0;
}


Measured memory_bytes: 22144
#include<bits/stdc++.h>
using namespace std;
#define int long long
int a[10];
int32_t main()
{
     cin >> a[0] >> a[1] >> a[2];
     sort(a, a+3);
     int ans = 99999999999;
     do{
          int r = abs(a[0]-a[1]) + abs(a[1]-a[2]);
          ans = min(ans, r);
     }
     while(next_permutation(a, a+3));
     cout << ans;
     return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

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

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int gcd(int x,int y){
  int u,v,w;
  u=min(x,y);
  v=max(x,y);
  w=v%u;
  while(w>0){
    v=u;
    u=w;
    w=v%u;
  }
  return u;
}
int main(){
  int n,x,y,z,i,ans;
  cin>>n>>y;
  vector<int> d(n);
  for(i=0;i<n;i++){
    cin>>x;
    z=abs(x-y);
    if(i==0) ans=z;
    else ans=gcd(ans,z);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3748
namespace Coder {
  class Scanner {
    private buffer: string = '';
    private stdinQueue: any = [];

    constructor() {
      process.stdin.resume();
      process.stdin.setEncoding('utf8');
      process.stdin.on(
        'data',
        (chunk): void => {
          this.buffer += chunk;
          while (this.stdinQueue.length > 0) {
            const i = this.buffer.indexOf('\n');
            if (i < 0) {
              break;
            }
            let line = this.buffer.substr(0, i);
            if (line.endsWith('\r')) {
              line = line.slice(0, -1);
            }
            this.buffer = this.buffer.substr(i + 1);
            this.stdinQueue.shift()(line);
          }
        },
      );
    }
    public getLine(): Promise<string> {
      return new Promise((resolve, reject) => {
        const i = this.buffer.indexOf('\n');
        if (i >= 0 && this.stdinQueue.length == 0) {
          let line = this.buffer.substr(0, i);
          if (line.endsWith('\r')) {
            line = line.slice(0, -1);
          }
          this.buffer = this.buffer.substr(i + 1);
          resolve(line);
        } else {
          this.stdinQueue.push(resolve);
        }
      });
    }

    public close(): void {
      process.stdin.pause();
    }
  }

  async function slove() {
    const sc = new Scanner();
    const [t, x] = (await sc.getLine()).split(' ').map((x) => +x);
    console.log((t / x).toFixed(10));
    sc.close();
  }

  slove();
}


Measured memory_bytes: 7628
#include<cstdio>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<map>
#define rep(X,Y) for(int (X)=0;(X)<(Y);++(X))
#define pb push_back
#define eb emplace_back
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> pi4;

int dist[55][55][55][55],dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template<typename T> ostream& operator<<(ostream& os, vector<T> &v){
  cout<<"{";
  rep(i,v.size())os<<v[i]<<","<<endl;cout<<"}"<<endl;
  return os;
}
template<typename T,typename S> ostream& operator<<(ostream& os, pair<T,S> &v){
  os<<"("<<v.X<<","<<v.Y<<")";
  return os;
}

int main(){
  int n;
  while(cin>>n){//cout<<"["<<n<<"]"<<endl;
    if(!n)break;
    map<int,pii> mp;
    rep(i,n){
      string str;
      cin>>str;
      char c=str[0];
      if(c=='W'){
	int m,l,pre=0;
	cin>>m>>l;
	//cout<<m<<","<<l;
	vector<pii> ad;
	for(auto it=mp.begin(); it!=mp.end(); ++it){
	  if(pre!=it->X){
	    int d=min(l,it->X-pre);
	    ad.eb(pre,pre+d);
	    l-=d;
	  }
	  pre=it->Y.X;
	}
	if(l)
	  ad.eb(pre,pre+l);
	//cout<<ad;
	rep(i,ad.size())
	  mp[ad[i].X]=pii(ad[i].Y,m);
      }else if(c=='D'){
	int m;
	cin>>m;
	//cout<<m<<endl;
	map<int,pii> tmp=mp;
	mp.clear();
	for(auto it=tmp.begin();it!=tmp.end();++it){
	  if(it->Y.Y!=m)
	    mp[it->X]=it->Y;
	}
      }else{
	int m;
	cin>>m;
	auto it=mp.upper_bound(m);
	if(it==mp.begin()){
	  cout<<-1<<endl;
	}else{
	  --it;
	  //cout<<*it<<endl;
	  if(it->X <= m && m < it->Y.X){
	    cout<<it->Y.Y<<endl;
	  }else{
	    cout<<-1<<endl;
	  }
	}
      }
      //for(auto it=mp.begin();it!=mp.end();++it)cout<<*it;    cout<<endl;
    }cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp76 {
    class Program {
        static void Main(string[] args) {
            string n = Console.ReadLine();
            string answer = confirm753(int.Parse(n));
            Console.WriteLine(answer);
        }

        static string confirm753(int num) {
            string answer = string.Empty;

            switch(num) {
                case 3:
                    return "YES";
                    break;
                case 5:
                    return "YES";
                    break;
                case 7:
                    return "YES";
                default:
                    return "NO";
            }
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int main (){
  long a,b,c,d,e,f;
  cin>>a>>b>>c>>d;
  e=max(a*c,a*d);
  f=max(b*c,b*d);
  cout<<max(e,f)<<endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		for(int i = 0; i < N; i++) a[i] = sc.nextInt();
		int first = Integer.MIN_VALUE, second = Integer.MIN_VALUE;
		for(int i = 0; i < N; i++) {
			if(a[i] > first) {
				first = a[i];
			}else if(a[i] > second) {
				second = a[i];
			}
		}
		for(int i = 0; i < N; i++) {
			if(a[i] != first) System.out.println(first);
			else System.out.println(second);
		}
	}
}


Measured memory_bytes: 90624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

int main()
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;

    bool ok = true;
    ok = ok && y + r <= h && y - r >= 0;
    ok = ok && x + r <= w && x - r >= 0;

    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

const int bound = 80, vb = 20000;
bool dp[bound][bound][vb];
int a[bound][bound];
int b[bound][bound];

int main(){
	int h, w; cin >> h >> w;
	for( int i = 0; i < h; ++i ){
		for( int j = 0; j < w; ++j ){
			cin >> a[i][j];
		}
	}
	for( int i = 0; i < h; ++i ){
		for( int j = 0; j < w; ++j ){
			cin >> b[i][j];
		}
	}
	dp[0][0][abs(a[0][0]-b[0][0])] = true;
	for( int l = 0; l <= h+w-2; ++l ){
		for( int i = 0; i <= l && i < h; ++i ){
			int j = l-i;
			if( j >= w ) continue;
			for( int k = 0; k < vb; ++k ){
				if( i+1 < h ){
					int d = abs(a[i+1][j]-b[i+1][j]);
					dp[i+1][j][k+d] |= dp[i][j][k];
					dp[i+1][j][abs(k-d)] |= dp[i][j][k];
				}
				if( j+1 < w ){
					int d = abs(a[i][j+1]-b[i][j+1]);
					dp[i][j+1][k+d] |= dp[i][j][k];
					dp[i][j+1][abs(k-d)] |= dp[i][j][k];
				}
			}
		}
	}
	int ans = inf;
	for( int k = 0; k < vb; ++k ){
		if( dp[h-1][w-1][k] ) ans = min(ans, k);
	}
	cout << ans << endl;
}

Measured memory_bytes: 125440
#include <bits/stdc++.h>
     
            using namespace std;
            typedef long long ll;
     
     
     
     
            int main(){
     
    int n,k;
    cin >> n >> k ;
    int X[n];
    for(int i=0 ; i<n ; i++){
        cin >> X[i] ;
    }
    ll Cost[n];
    for(int i=0 ; i<n ; i++){
        Cost[i]=1e9+5;
    }
    //cout << Cost[2] <<endl;
    if(n==1){
        cout << 0 <<endl;
        return 0;
    }
     
    Cost[0]=0;
    Cost[1]=abs(X[1]-X[0]);
     
    if(n==2){
        cout << Cost[n-1];
        return 0;
    }
    for(int i=2 ; i<n ; i++){
    for(int j=k ; j>=0  ; j--){
            if(i-(j)>=0){
                  //  cout << Cost[i] << " , " << i <<endl;
        Cost[i]=min(Cost[i],Cost[i-(j)]+abs(X[i]-X[i-(j)]));
       // cout << Cost[i] << " , "<< i <<endl;
       // cout << Cost[i-(j)] << " , "<< i-(j) <<endl;
            }
    }
    }
     
    cout << Cost[n-1];
     
     
     
              return 0;
            }

Measured memory_bytes: 4716
#include <bits/stdc++.h>
using namespace std;
#define test(t) int t; cin>>t; while(t--)
#define p1(x) { cout << " [" << #x << ": " << x << "]\n"; }
#define p2(x) { cout << " [" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]\n"; }
#define pb push_back
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
 
 
void solve()
{
	int n, x, ans=0;
	vector<int> a;
	cin>>n;
	F0R(i, n) {
		cin>>x;
		a.pb(x);
	}
	FOR(i, 0, n) {
		FOR(j, i+1, n) {
			FOR(k, j+1, n){
				if(!(a[i]+a[j]<=a[k] or a[i]+a[k]<=a[j] or a[j]+a[k]<=a[i]) and a[i]!=a[j] and a[j]!=a[k] and a[i]!=a[k]) 
				{
				    // p1(a[i]);
				    // p1(a[j]);
				    // p1(a[k]);
				    // cout<<endl;
				    ans++;
				}
			}
		}
	}
	cout<<ans<<endl;
}
 
int main() {
	// your code goes here
	// test(t)
		solve();
	return 0;
}
 

Measured memory_bytes: 3644
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
int main(){
  int x;
  cin>>x;
  if(x==0){
    cout<<1<<endl;
  }
  else if(x==1){
    cout<<0<<endl;
  }
  return 0;
}

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

int main(){
	string card, swap;
	int cnt, shu;
	while(1){
		cin >> card;
		if(card == "-") break;
		cin >> cnt;
		for(int i = 0; i < cnt; i++){
			cin >> shu;
			swap = card.substr(0, shu);
			card.erase(card.begin(), card.begin() + shu);
			card += swap;
		}
		cout << card << endl;
	}
	return 0;
}


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

int main() {
  int x;cin>>x;
  if(x <1200) cout << "ABC" << endl;
  else cout << "ARC" << endl;
}


Measured memory_bytes: 256
N = int(input())
town_list = []
for _ in range(0, N):
  tmp = list(map(int, input().split()))
  town_list.append(tmp)

import itertools
import math

ans = 0.0
i = 0
for route in itertools.permutations(town_list):
  i += 1
  before_town = False
  route_length = 0
  for town in route:
    if before_town is False:
      before_town = town
      continue
    route_length += math.sqrt(((before_town[0] - town[0]) ** 2) + ((before_town[1] - town[1]) ** 2))
    before_town = town
  ans += route_length

print(ans / i)

Measured memory_bytes: 39536
Mod = 10**9 + 7

N = gets.to_i
C = Array.new( N + 1 )
N.times{ |i| C[i] = gets.to_i }

dp = Array.new(N+1,0)
h = {}

dp[0] = 1
(1..N).each do |i|
  
  c = C[i-1]
  dp[i] = dp[i-1]
  
  if h[c] && h[c] < i-1
    dp[i] += dp[h[c]]
  end
  
  dp[i] %= Mod
  h[c] = i
end

p dp[-1]

Measured memory_bytes: 18172
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mset(m,v) memset(m,v,sizeof(m))
#define pr(a,s) printf("Case #%lld: %lld\n",a,s)
#define mod 1000000007
#define mp make_pair
#define all(a)                a.begin(),a.end()
#define pb push_back
#define scan(a) scanf("%d",&a)
#define scanl(a) scanf("%lld",&a)
#define se second
#define fi first
#define pi 3.14159265358979323
#define pii pair<ll,ll>

#define trace1(x)             cout <<#x<<": "<<x<< endl;
#define trace2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;


const int MAXM = 2e5+3;
const ll inf = 1e15;

vector<int> v;
int n, d;
ll dp[MAXM][2][102];

ll recur(int idx,int tight, int sum)
{
	if (idx == n and sum == 0)	return 1LL;
	if (idx == n)	return 0LL;
	if (dp[idx][tight][sum] != -1)	return dp[idx][tight][sum];
	ll ret = 0;
	if (tight) {
		for (int i=0;i<v[idx];i++){
			ret += recur(idx+1, 0, (sum+i)%d);
			if (ret >= mod)	ret %= mod;
		}
		ret += recur(idx+1, 1, (sum+v[idx])%d);
		if (ret >= mod)	ret %= mod;
	} else {
		for (int i=0;i<10;i++){
			ret += recur(idx+1, 0, (sum+i)%d);
			if (ret >= mod)	ret %= mod;
		}
	}
	return dp[idx][tight][sum] = ret;
}

ll solve(string s, int d)
{
	mset(dp,-1);
	n = s.size();
	for (int i=0;i<n;i++){
		v.pb(s[i]-'0');
	}
	return recur(0, 1, 0);
}

int main()
{
	string s;
	cin>>s;
	cin>>d;
	cout << (solve(s, d) - 1 + mod)%mod << endl;
	return 0;	
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int dx[] = {-1,0,1,0};
int dy[] = {0,-1,0,1};
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int H, W;
  cin >> H >> W;
  VS vs(H);
  cin >> vs;

  bool ok = true;
  REP(y,H) REP(x,W){
	if(vs[y][x] == '#'){
	  bool ng = true;
	  REP(d,4){
		int tx = x + dx[d];
		int ty = y + dy[d];
		if(0 <= tx && tx < W && 0 <= ty && ty < H && vs[ty][tx] == '#')
		  ng = false;
	  }
	  if(ng)
		ok = false;
	}
  }
  cout << (ok? "Yes": "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb	push_back
const int INF = 0x3f3f3f3f;
const int T = 10;
const int N = 1e4+2;
int cost[T] = {0,2,5,5,4,5,6,3,7,6}, ok[T], dp[N], n, m;
vector<int> ans;

void build(int used) {
    if(used <= 0) return;
    int nxt;
    for(int i = 1; i <= 9; i++) {
        if(!ok[i] or used-cost[i] < 0) continue;
        if(dp[used-cost[i]] == dp[used]-1) nxt = i;
    }
    ans.pb(nxt);
    build(used-cost[nxt]);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> m;
    memset(dp, -INF, sizeof dp);
    for(int i = 0; i < m; i++) { int x; cin >> x; ok[x] = 1; }
    dp[0] = 0;
    for(int i = 1; i < T; i++) {
        if(!ok[i]) continue;
        for(int j = 0; j+cost[i] <= n; j++)
            dp[j+cost[i]] = max(dp[j+cost[i]], dp[j]+1);
    }
    build(n);
    sort(ans.begin(),ans.end(), greater<int>());
    for(auto x : ans) cout << x;
    cout << endl;
    return 0;
}



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

int main(){
  long N;
  cin >> N;
  int a[100001];
  int d[100001];
  a[0] = 0; // 原点から始める
  for (long i = 1; i <= N; ++i){
    cin >> a[i];
  }
  a[N+1] = 0; //最後に原点に戻る
  long sum = 0;
  int c2_0, c2_1, c1_0 = 0;
  // 抜かないパターンを計算しながら
  // 各要素に対して抜いた場合の節約分を計算する
  for (long i = 1; i <= N+1; ++i){
    // 抜かないパターン
    c2_1 = c1_0; // 2つ前から1つ前の要素
    c1_0 = abs(a[i]-a[i-1]); // 1つ前から現在の要素
    sum += c1_0;
    c2_0 = abs(a[i] - a[i-2]); // 2つ前から現在の要素
    d[i] = c2_1 + c1_0 - c2_0; // 前回を飛ばしてきた場合
  }
  for (long i = 1 ; i <= N; ++i){
    cout << sum - d[i+1] << endl;
  }
  return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

vi to[200005];
vi ans;

void dfs(int v, int p = -1) {
  for (int u : to[v]) {
    if (u == p) continue;
    ans[u] += ans[v];
    dfs(u,v);
  }
  return;
}

int main () {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int N, Q; cin >> N >> Q;
  REP(i,N-1) {
    int a, b; cin >> a >> b;
    --a; --b;
    to[a].PB(b);
    to[b].PB(a);
  }

  ans.resize(N);
  REP(i,Q) {
    int p, x; cin >> p >> x;
    --p;
    ans[p] += x;
  }

  dfs(0);
  REP(i,N) {
    cout << ans[i] << "\n";
  }
  
  return 0;
}


Measured memory_bytes: 23552
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.PriorityQueue;
import java.util.Comparator;

public class Main {
    static void dijkstra(ArrayList<Node> nodes, int start){
        Comparator<Node> comparator = new NodeCostComparator();
        PriorityQueue<Node> pq      = new PriorityQueue<Node>(10, comparator);
        nodes.get(start).cost = 0;
        pq.add(nodes.get(start));
        
        while (!pq.isEmpty()){
        	Node done_node = pq.poll();
        	for (int i = 0; i < done_node.edge_to.size(); i++){
        		int to 	 	 = done_node.edge_to.get(i);
        		int cost 	 = done_node.edge_cost.get(i);
        		int new_cost = done_node.cost + cost;
        		int to_cost  = nodes.get(to).cost;
        		if (to_cost < 0 || new_cost < to_cost){
        			nodes.get(to).cost = new_cost;
        			if (!pq.contains(nodes.get(to))){
        				pq.add(nodes.get(to));
        			}
        		}
        	}
        }
    }
    static void print_results(ArrayList<Node> nodes){    
        for (int i = 0; i < nodes.size(); i++){
            int cst = nodes.get(i).cost;
            if (cst == -1){
                System.out.println("INF");
            }else{
                System.out.println(cst);
            }
        }
    }
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int V = Integer.parseInt(line[0]);
        int E = Integer.parseInt(line[1]);
        int r = Integer.parseInt(line[2]);
        ArrayList<Node> nodes = new ArrayList<Node>();
        for (int i = 0; i < V; i++){
            ArrayList<Integer> edge_to   = new ArrayList<Integer>();
            ArrayList<Integer> edge_cost = new ArrayList<Integer>();
            Node node = new Node(-1, edge_to, edge_cost);
            nodes.add(node);
        }
        
        for (int i = 0; i < E; i++){
            String[] line2 = br.readLine().split(" ");
            int s = Integer.parseInt(line2[0]);
            int t = Integer.parseInt(line2[1]);
            int d = Integer.parseInt(line2[2]);
            nodes.get(s).edge_to.add(t);
            nodes.get(s).edge_cost.add(d);
        }
        dijkstra(nodes, r);
        print_results(nodes);
    }
}
class NodeCostComparator implements Comparator<Node>{
    @Override
    public int compare(Node x, Node y){
        int value = x.cost - y.cost;
        if (value < 0){
            return -1;
        }
        if (value > 0){
            return 1;
        }
        return 0;
    }
}

class Node{
    int cost;
    ArrayList<Integer> edge_to;
    ArrayList<Integer> edge_cost;
    
    Node(int cost, ArrayList<Integer> edge_to, ArrayList<Integer> edge_cost){
        this.cost       = cost;
        this.edge_to    = edge_to;
        this.edge_cost  = edge_cost;
    }
}

Measured memory_bytes: 137140
#include <bits/stdc++.h>
using namespace std;
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define sz(x)             (int)((x).size())
#define int               long long
#define M                 40000000000007LL
#define MM                998244353
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount

template<typename T1,typename T2>
std::istream& operator>>(std::istream& in,pair<T1,T2> &a)
{
	in>>a.fr>>a.sc;
	return in;
}
template<typename T1,typename T2>
std::ostream& operator<<(std::ostream& out,pair<T1,T2> &a)
{
	out<<a.fr<<" "<<a.sc;
	return out;
}

int a[404],dp[404][404];
int calc(int x,int y){
	if(x==y)return 0;
	int &ans=dp[x][y];
	if(ans!=-1)return ans;
	ans=M;
	rep(i,x,y){
		ans=min(ans,a[y]-a[x-1]+calc(x,i)+calc(i+1,y));
	}
	return ans;
}
void solve(){
	mem1(dp);
	int n;
	cin>>n;
	rep(i,1,n+1)cin>>a[i],a[i]+=a[i-1];
	
	cout<<calc(1,n);
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif
	#ifdef DSU
		cleardsu(MAXDSUSIZE);
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 1536
n,m=map(int,input().split())
fav=[1 for i in range(m+1)]

for i in range(n):
    k=list(map(int,input().split()))
    for j in range(1,m+1):
    
        if fav[j]==1:
        

            if j not in k[1:]:
                
                fav[j]=0

print(sum(fav)-1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,val,sum=0;
	vector<int> v;
	vector<int> c;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>val;
		v.push_back(val);
	}
	for(int i=0;i<n;i++){
		cin>>val;
		c.push_back(val);
	}
	for(int i=0;i<n;i++){
		v[i]-=c[i];
	}
	for(int i=0;i<n;i++){
		if(v[i]>0) sum+=v[i];
	}
	cout<<sum<<endl;
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    for(int i=97;i<123;i++){
        if(s.find((char)i) == string::npos){
            cout << (char)i << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int n;
int a[100001];

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

	cin >> n;
	rep(i, n)cin >> a[i+1];

	int sum = 0;
	rep(i, n )sum += abs(a[i + 1] - a[i]);
	sum += abs(a[n]);

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


	return 0;
}

Measured memory_bytes: 1664
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld  double
#define pii pair<int,int>
#define pb push_back
#define N 300003
#define inf (ll)1e9+11
#define warmup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int mod=1e9+7;

signed main()
{
    warmup
    
    string s;
    cin>>s;
    int n=s.size();
    while(n--)
        cout<<'x';
    
    return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MAX (int)1e9 + 99
#define maxof(a,b,c) max(a,max(b,c))
#define minof(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vb vector<bool>
#define ll long long
#define ull unsigned long long
#define vll vector<ll>
#define pa pair<int, int>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define MOD 1000000007
#define bitcnt(x) __builtin_popcount(x)
#define gcd(a,b) __gcd(a,b)
#define all(x) (x).begin(),(x).end()
#define ts(x) to_string(x)
#define set0(x) memset(x, 0, sizeof(x))
const double pi = 3.14159265358979323846;
ll binpow(ll, ll);
ll mult(ll, ll);
ll add(ll , ll);
ll division(ll, ll);
ll nCr(ll, ll);
ll inv(ll);
void calc();
template<class T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) {if (!v.empty()) {os << v.front();for (int i = 1; i < v.size(); ++i) os << ' ' << v[i];} return os;}
const int N=50010;
//ll fact[N];

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


    //dp[i] - no of candies we have taken so far

    vi dp(k+1,0);
    dp[0] = 1;

    for(int c = 0; c < n; c++)
    {
        int x;
        cin>>x;
        vi pref(k+1,0);
        for(int used = k; used>=0; used--)
        {
            int tmp = dp[used];
            int L = used+1;
            int R = used + min(x, k - used);
            if(L<=R)
            {
                pref[L] = add(pref[L],tmp);
                if(R+1 <= k)
                    pref[R+1] = add(pref[R+1], -1*tmp);
            }
            
        }

        int sum = 0;
        for(int i = 0;i<=k; i++)
        {
            sum = add(sum, pref[i]);
            dp[i] = add(dp[i], sum);
        }
    } 

    cout<<dp[k];
}

int main()
{
    fastio;
    
    int t=1;
    //cin>>t;
    
    rep(i,t)
    {
        solve();
        cout<<"\n";
    }
    return 0;
}

ll add(ll a, ll b){
    a+=b;
    while(a>=MOD) a-=MOD;
    while(a<0) a+=MOD;
    return a;
}

ll mult(ll a, ll b){
    return (a * 1ll * b) % MOD;
}


ll binpow(ll a, ll b){
    ll c = 1;
    while(b > 0)
    {
        if(b % 2 == 1)
            c = mult(c, a);
        a = mult(a, a);
        b /= 2;
    }
    return c;   
}

ll inv(ll a){
    return binpow(a, MOD-2);
}

ll division(ll a, ll b){
    return mult(a, inv(b));
}

/*ll nCr(ll n, ll r){
    if(r > n) return 0;
    return division(fact[n], mult(fact[n-r], fact[r]));
}

void calc(){
    fact[0] = 1;
    srep(i,1,N-1)
        fact[i] = (i*1ll*fac[i-1])%MOD;

}*/

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

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

    char str1[n],str2[n];
    cin>>str1>>str2;

    for(int i=0;i<n;i++)
    {
        cout<<str1[i]<<str2[i];
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long h = sc.NextLong();
        long w = sc.NextLong();
        long[,] map = new long[h, w];

        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                map[i, j] = sc.NextLong();
            }
        }

        List<string> answers = new List<string>();

        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w - 1; j++)
            {
                if (map[i, j] % 2 == 1)
                {
                    map[i, j + 1]++;
                    answers.Add((i + 1) + " " + (j + 1) + " " + (i + 1) + " " + (j + 2));
                }
            }
        }

        for (int i = 0; i < h - 1; i++)
        {
            if (map[i, w - 1] % 2 == 1)
            {
                map[i + 1, w - 1]++;
                answers.Add((i + 1) + " " + w + " " + (i + 2) + " " + w);
            }
        }

        Console.WriteLine(answers.Count);

        foreach (var answer in answers)
        {
            Console.WriteLine(answer);
        }
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

int main(){
    while(1){
        int a,b,bm=0,s;
        for(int i=0;i<5;i++){
            cin >> a >> b;
            if(a==0&&b==0)goto end;
            if(bm<a+b){
                bm=a+b;
                s=i;
            }
        }
        if(s==0)cout << "A ";
        else if(s==1)cout << "B ";
        else if(s==2)cout << "C ";
        else if(s==3)cout << "D ";
        else if(s==4)cout << "E ";
        cout << bm << endl;
    }
        end:;
    return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
#define REP(i,a,b) \
for(int i=int(a);i<=int(b);i++)
#define DEP(i,a,b) \
for(int i=int(a);i>=int(b);i--)
#define TR(c, it) \
for (auto it = (c).begin(); it != (c).end(); it++)

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n,m,i,j,k,l;
	cin>>n;
	REP(i,0,400){
		REP(j,-400,i-1){
			if(pow(i,5)-pow(j,5)==n)
			{
				cout<<i<<" "<<j;
				return 0;

			}
		}
	}
	
}


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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.sync_with_stdio(false); cin.tie(0);
	cin.exceptions(cin.failbit);

	ll acc = 0, cnt = 0;

	string s; cin >> s;
	for (char c : s) {
		if (c == 'B') cnt++;
		else acc += cnt;
	}
	cout << acc << endl;
}


Measured memory_bytes: 720