akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
vector<int> G[210];
int d[210];

void solve() {
	cin >> N;
	rep(i, 0, N) {
		rep(j, 0, N) {
			char a; cin >> a;
			if(a == '1') G[i].pb(j);
		}
	}
	int res = 0;
	rep(q, 0, N) {
		fill(d, d + N, inf);
		d[q] = 0;
		queue<int> que;
		que.push(q);
		while(!que.empty()) {
			int v = que.front(); que.pop();
			rep(i, 0, sz(G[v])) {
				int n = G[v][i];
				if(d[n] == inf) {
					d[n] = d[v] + 1;
					que.push(n);
				}
				else {
					if(d[n] % 2 == d[v] % 2) {
						cout << -1 << "\n";
						return;
					}
				}
			}
		}
		rep(i, 0, N) {
			MAX(res, d[i] + 1);
		}
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 512
import sys
from collections import deque
input = sys.stdin.readline
H, W = map(int, input().split())
S = [input()[:-1] for _ in [0]*H]
dirs = [(-1, 0), (1, 0), (0, -1), (0, 1)]

def bfs(h, w, H, W):
    visited = [False]*(W*H)
    q = deque()
    q.append((0, h, w))
    while q:
        d, h, w = q.popleft()
        if visited[h*W+w]:
            continue
        visited[h*W+w] = True

        for dh, dw in dirs:
            nh, nw = h+dh, w+dw
            if 0 <= nh < H and 0 <= nw < W:
                if visited[nh*W+nw] or  S[nh][nw] == '#':
                    continue
                q.append((d+1, nh, nw))
    return d, h, w

ans = 0
for h, _S in enumerate(S):
    for w, s in enumerate(_S):
        if s == '.':
            d, _, _ = bfs(h, w, H, W)
            if d > ans:
                ans = d

print(ans)


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

#ifndef DEBUG
#define DEBUG false
#endif

#define REP(t,i,a,b) for(t i = a; i < b; ++i)
#define EREP(t,i,a,b) for(t i = a; i <= b; ++i)
#define REPR(t,i,a,b) for(t i = a; i > b; --i)
#define EREPR(t,i,a,b) for(t i = a; i >= b; --i)

typedef long long ll;

using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::string;

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

    string s;
    cin >> s;

    REP(int, i, 0, s.length()) {
        char c = s[i];
        if(i%2 == 1) {
            if (c != 'L' && c != 'U' && c != 'D') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (c != 'R' && c != 'U' && c != 'D') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.algorithm, std.array, std.math;
void main(){
	while(1){
		auto n = readln.chomp.to!int;
		if(n==0) break;
		int sum;
		real ans=0;
		auto s = readln.split.map!(to!int);
		for(int i;i<n;++i)
			sum += s[i];
		real ave =sum/cast(real)n;
		for(int i;i<n;++i)
			ans += (s[i]-ave)^^2;
		writefln("%.5f",sqrt(ans/n));
	}
}

Measured memory_bytes: 2544
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef long double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc())
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

const int N = 50;
ll dp[2][N][N][N][N], ans;
int n, mat[N][N], vis[2][N][N][N][N];
ll dfs(int p,int a,int b,int c,int d) {
  if (vis[p][a][b][c][d]) return dp[p][a][b][c][d];
  if (p == 0) {
    if (a == b+1 || c == d+1) return 0;
    vis[p][a][b][c][d] = 1;
    ll &ret = dp[p][a][b][c][d];
    rep (x, a, b) rep (y, c, d) if (mat[x][y])
      ret += dfs(1, a, x-1, x+1, b) * dfs(1, c, y-1, y+1, d);
    return ret;
  } else {
    if (a == b+1 && c == d+1) return 1;
    if (a == b+1 || c == d+1) return 0;
    vis[p][a][b][c][d] = 1;
    ll &ret = dp[p][a][b][c][d];
    rep (x, a, b) rep (y, c, d)
      ret += dfs(0, a, x, y, d) * dfs(1, x+1, b, c, y-1);
    return ret;
  }
}
int main() {
  read(n);
  n = n * 2;
  rep (i, 1, n) {
    string tmp;
    cin >> tmp;
    rep (j, 0, n-1)
      mat[i][j+1] = tmp[j] - '0';
  }
  rep (i, 2, n) if (mat[1][i])
    ans += dfs(1, 2, i-1, i+1, n);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 119680
#include <bits/stdc++.h>
using namespace std;
void display(vector<int> v) {

  for (int i = 0; i < v.size(); i++) {
    if (i)
      cout << " ";
    cout << v[i];
  }
  cout << endl;
}
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  vector<int> p(v), nx(v);
  prev_permutation(p.begin(), p.end());
  next_permutation(nx.begin(), nx.end());
  if (p < v)
    display(p);
  display(v);
  if (nx > v)
    display(nx);
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  ll n,ans=0,as=0;
  cin>>n;
  vector<ll> a(n);
  fr(i,n) cin>>a[i];
  sort(a.begin(),a.end());
  if(n==2){cout<<a[1]-a[0]<<endl;return 0;}
  fr(i,n){
    if(i<(n+1)/2) ans-=2*a[i];
    if(n%2&&i==(n+1)/2-2) ans+=a[i];
    if(i==(n+1)/2-1) ans+=a[i];
    if(i>=(n+1)/2) ans+=2*a[i];
    if(1-n%2&&i==(n+1)/2) ans-=a[i];
  }
  reverse(a.begin(),a.end());
  fr(i,n){
    if(i<(n+1)/2) as-=2*a[i];
    if(n%2&&i==(n+1)/2-2) as+=a[i];
    if(i==(n+1)/2-1) as+=a[i];
    if(i>=(n+1)/2) as+=2*a[i];
    if(1-n%2&&i==(n+1)/2) as-=a[i];
  }
  cout<<max(ans,-as)<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
template<typename T> T gcd(T a,T b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;

int c[3][3];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  FOR(i, 0, 3)FOR(j, 0, 3) cin >> c[i][j];
  FOR(i, 1, 3)FOR(j, 1, 3){
    if((c[i][j] - c[i-1][j] != c[i][j-1] - c[i-1][j-1]) || (c[i][j] - c[i][j-1] != c[i-1][j] - c[i-1][j-1])){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

int main() {
    int k;
    int input[3];
    scanf("%d %d %d", &input[0], &input[1], &input[2]);
    scanf("%d", &k);
    sort(input, input+3); 
    for (int i = 0; i < k; i++) {
        input[2] *= 2;
    }
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        ans += input[i];
    }
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int a, b;
  cin >> a >> b;
  int ans = -1;
  rep(i, 1e5) {
    double s8 = (double)i * 0.08;
    double s10 = (double)i * 0.1;
    if((int)s8 == a && (int)s10 == b) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
shops = []
for i in range(n):
    s, p = map(str, input().split())
    p = int(p)
    shops += [(i+1, s, p)]

from operator import itemgetter
shops = sorted(shops, key=itemgetter(2), reverse=True)
shops = sorted(shops, key=itemgetter(1))

for num, s, p in shops:
    print(num)




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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e6+23;

vector<int> v[N];
map<int, int> m;

void solve() {
  for (int i = 1; i < N; ++i) {
    for (int j = i; j < N; j+=i) {
      v[j].push_back(i);
    }
  }
  int n; scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int a; scanf("%d", &a);
    ++m[a];
  }
  int ans = 0;
  for (const auto &p: m) {
    if (p.second > 1) continue;
    bool found = false;
    for (int e: v[p.first]) {
      if (e == p.first) continue;
      if (m.count(e)) {
	found = true;
	break;
      }
    }
    if (!found) ++ans;
  }
  printf("%d", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 124992
#include <stdio.h>
int main(void){
    char served[200];
    char pick[100];
    int i=0;
    int j=0;
    int k,l,cnt=0;
 
    scanf("%s",served);
    scanf("%s",pick);
     
    while(1){
        if(served[i++]=='\0') break;
    }
    while(1){
        if(pick[j++]=='\0') break;
    }
 
 
    for(k=i-1; k<=2*i-3; k++){
        served[k]=served[k-i+1];
    }
    
   for(l=0; l<=2*i-j; l++){
      if(served[l] == pick[cnt]){
          while(1){
              if(served[l+cnt]==pick[cnt]) cnt++;
              else break;
          }
        if(cnt == j-1)break;
        else cnt=0;
      }
   }
    
   if(cnt) printf("Yes\n");
   else printf("No\n");
    
   return 0;
}
 

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

int main() {
  long long n,a,b;
  cin >> n >> a >> b;
  if(b-a>2&&n>a) {
    cout << a + (n-a+1)/2*(b-a) + (n-a+1)%2 << endl;
  }
  else {
    cout << n+1 << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,a[2],b[2],c[2],d[2],z,y,x,w,i;
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		for(i=0;i<n;i++){
			scanf("%d %d %d %d %d %d %d %d ",&a[0],&b[0],&c[0],&d[0],&a[1],&b[1],&c[1],&d[1]);
			x=a[0]*a[1]-b[0]*b[1]-c[0]*c[1]-d[0]*d[1];
			y=a[0]*b[1]+a[1]*b[0]+c[0]*d[1]-c[1]*d[0];
			z=a[0]*c[1]+a[1]*c[0]-b[0]*d[1]+b[1]*d[0];
			w=a[0]*d[1]+a[1]*d[0]-c[0]*b[1]+c[1]*b[0];
			printf("%d %d %d %d\n",x,y,z,w);
		}
	}
	return 0;
}


Measured memory_bytes: 2704
#include <bits/stdc++.h>
const int INF = 1e9;
const int MODk = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N,M;cin >> N >> M;
    vector<vector<int>> vec;
    for(int a = 0;a < M;a++){
        int K;cin >> K;
        vector<int> e;
        for(int b = 0;b < K;b++){
            int c;cin >> c;
            e.push_back(c);
        }
        vec.push_back(e);
    }
    vector<int> p;
    for(int a = 0;a < M;a++){
        int b;cin >> b;
        p.push_back(b);
    }
    int mass[N];
    int ans = 0;
    function<void(int)> rekkyo = [&](int i){
        if(i == N){
            for(int a = 0;a < M;a++){
                bool t =  false;
                int cnt = 0;
                for(int b = 0;b < vec.at(a).size();b++){
                    if(mass[vec.at(a).at(b)-1])cnt++;
                }
                if(cnt%2 != p.at(a)){
                    return;
                }
            }
            ans++;
            return ;
        }
        mass[i] = 0;rekkyo(i+1);
        mass[i] = 1;rekkyo(i+1);
    };
    rekkyo(0);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    
    n, d= map(int, input().split())
    cnt = 0
    for _ in range(n):
        x, y = map(int, input().split())
        
        if x*x+y*y <= d*d:
            cnt += 1
    print(cnt)

        

if __name__ == '__main__':
    main()

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
string A,B;
int main(){
  cin >> A >> B;
  if(A.size()>B.size()) cout << "GREATER" << endl;
  else if(A.size()<B.size()) cout << "LESS" << endl;
  else{
    if(A>B) cout << "GREATER" << endl;
    else if(A<B) cout << "LESS" << endl;
    else cout << "EQUAL" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<complex>
#include<ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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; }

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;

int main(void)

{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << ketasitei;
	
	ll n, m;
	cin >> n >> m;
	vector<ll> k(m);
	vector<vector<ll>> s(m, vector<ll>());

	rep(i, m)
	{
		ll tmp;
		cin >> k[i];
		rep(j, k[i])
		{
			cin >> tmp;
			s[i].push_back(tmp);
		}
	}
	vector<ll> p(m);
	rep(i, m)
	{
		cin >> p[i];
	}
	
	ll ans = 0;

	for (ll i = 0; i < (1LL << n); i++)
	{
		ll tmp = i;
		ll os = 0;
		for (ll j = 0; j < m; j++)
		{
			ll on = 0;
			for (ll k = 0; k < s[j].size(); k++)
			{
				on += (tmp >> (s[j][k] - 1)) & 1;
			}
			if (on % 2 == p[j])
				os++;
		}

		if (os == m)
			ans++;
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
// Problem : A - αlphabet
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin>>s;
	if(s[0] >= 'a' && s[0] <= 'z')
	{
		cout<<"a";
	}
	else
	{
		cout<<"A";
	}
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;
ll g,d;
ll p[11];
ll c[11];
ll sum=0,ans=MOD;
int used[11];
void dfs(ll t,ll s,ll times){
  used[t]=1;
  //cout<<t<<" "<<s<<" "<<times<<endl;
  for(int i=1;i<=p[t];i++){
    s+=100*t;
    times++;
    if(s>=g){
      ans=min(ans,times);
      return;
    }
  }
  s+=c[t];
  if(s>=g){
    ans=min(ans,times);
    return;
  }
  for(int i=1;i<=d;i++){
    if(used[i]) continue;
    dfs(i,s,times);
    used[i]=0;
  }
}

int main(){

  cin>>d>>g;
  ll m[d+1]={};

  for(int i=1;i<=d;i++){
    cin>>p[i]>>c[i];
    m[i]=p[i]*i*100+c[i];
  }
  for(int i=1;i<=d;i++){
    dfs(i,0,0);
    used[i]=0;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main()
{
	int N, A[100] = { 0 }, B[100] = { 0 }, C[100] = {0}, 
		manzoku = 0;
	cin >> N;
	for (int i = 1; i < N+1; i++)
	{
		cin >> A[i];
	}
	for (int i = 1; i < N+1; i++)
	{
		cin >> B[i];
	}
	for (int i = 1; i < N; i++)
	{
		cin >> C[i];
	}

	for (int i = 1; i < N+1; i++)
	{
		manzoku += B[i];

	}
	for (int i = 1; i < N; i++)
	{
		if (A[i + 1] - A[i]==1)
		{
			manzoku += C[A[i]];
		}
		else
		{

		}
	}
	cout << manzoku << endl;
	return 0;
}

Measured memory_bytes: 256
const main = (input) => {
  const n = input.trim()

  let ans = 0
  for (let v of n) ans += parseInt(v, 10)

  return console.log(ans % 9 === 0 ? 'Yes' : 'No')
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 35608
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc.Split(bufio.ScanWords)
	a, b, c := nextInt(), nextInt(), nextInt()
	ok := true
	if a != b && b != c && c != a {
		ok = false
	} else if a == b && b == c {
		ok = false
	}
	if ok {
		puts("Yes")
	} else {
		puts("No")
	}
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
hoge = input()
N,T = list(map(int,hoge.split(' ')))
c = []
t = []
for i in range(N):
    fuga = list(map(int,input().split(' ')))
    c.append(fuga[0])
    t.append(fuga[1])
min_c = 2000
for i in range(N):
    if t[i] <= T:
        if min_c > c[i]:
            min_c = c[i]
if min_c == 2000:
    print('TLE')
else:
    print(min_c)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007  //998244353
#include<string.h>
#define inf 1000000000000000000
#define maxn 200006
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
#define endl '\n'
#define mapint_iterator map<int,int> :: iterator
#define mapll_iterator map<ll,ll> :: iterator
#define setint_iterator set<int> :: iterator
#define setll_iterator set<ll> :: iterator
#define setpint_iterator set<pint> :: iterator
#define setpll_iterator set<pll> :: iterator
#define trace(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 cout1(a) cout<<a<<endl
#define cout2(a,b) cout<<a<<' '<<b<<endl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define vcout(v,i) cout<<v[i].fi<<" "<<v[i].se<<endl
typedef priority_queue<ll,vector<ll>,greater<ll> > pqset;
typedef priority_queue<pint,vector<pint>,greater<pint> > pqset_ll;
#define pb push_back
#define fi first
#define se second
#include<ext/pb_ds/assoc_container.hpp>
ll dxk[]={0,0,1,-1,1,1,-1,-1};
ll dyk[]={1,-1,0,0,1,-1,1,-1};
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> os_pair;
#define acc (ios::sync_with_stdio(false),cin.tie(0))
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>0;i--)
#define repeat(i,start,n) for(ll i=start;i<n;i++)
#define print(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" ";}
ll ll_max(ll a,ll b,ll c){return max(a,max(b,c));}
int int_max(int a,int b,int c){return max(a,max(b,c));}
ll ll_min(ll a,ll b,ll c){return min(a,min(b,c));}
int int_min(int a,int b,int c){return min(a,min(b,c));}
ll max(int a,ll b){ return max((ll)a,b);}
ll min(int a,ll b){ return min((ll)a,b);} 
ll min(ll a,int b){ return min(a,(ll)b);}
ll max(ll a,int b){ return max(a,(ll)b);}
ll dx[]={0,0,1,-1};
ll dy[]={1,-1,0,0};
//ifstream cin("b_read_on.txt"); ofstream cout("output3.txt");
//Chronology: Binary Search,Greedy,dp,dfs and similar
//Use (<<) for multiplication
//Use (>>) for division
// In dp, first try top-down,then bottom-up
//ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed;cerr.tie(NULL);cout.precision(10);
// find_by_order -> value at index
// order_of_key -> index of value
void solve(int countu){
	ll n;
	cin>>n;
	ll sum=0;
	repeat(i,1,n+1)
		repeat(j,1,n+1)
			repeat(k,1,n+1){
				sum+=__gcd(i,__gcd(j,k));
			}
	cout1(sum);
}
int main(){
    int t=1;
	//cin>>t;
	int countu=1;
    while(t--){
    	solve(countu);
    	countu++;
    }
    
}

Measured memory_bytes: 3636
n = gets.to_i

n.times do
  order = gets.chomp.chars
  order.delete('-')
  train = []
  li = 0
  ti = 0
  limit = order.size - 3
  train << order[li].bytes.first
  
  until limit < li
    car1 = order[li].bytes.first
    car2 = order[li+2].bytes.first
    way = order[li+1]
    
    if way == '<'
      if train.include?(car2)
        ti -= 1
      else
        train.insert(ti, car2)
      end
    elsif way == '>'
      ti += 1
      train.insert(ti, car2) unless train.include?(car2)
    end
    
    li += 2
  end
  
  puts train.map(&:chr).join
end

Measured memory_bytes: 6128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
using namespace std;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

/* ユークリッドの互除法 最大公約数*/
ll gcd(ll a, ll b) {
	ll r;
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}



/*最小公倍数*/
ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}

/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}

//小数点9桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll n,k,ans=0;
    cin>>n>>k;
    while(n>k-1){
        n=n/k;
        ans++;
    }
    cout<<ans+1<<endl;

    
}


Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double ld;

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


int main() {
    ll a;
    cin >> a;
    ll ans = a + (a*a) + (a*a*a);
    cout << ans << endl;
}




Measured memory_bytes: 3628
using System.Linq;
using System.Collections.Generic;
using System;

public static class combi
{
    public static IEnumerable<IEnumerable<T>> Comb<T>(this IEnumerable<T> items, int r)
    {
        if (r == 0)
        {
            yield return Enumerable.Empty<T>();
        }
        else
        {
            var i = 1;
            foreach (var x in items)
            {
                var xs = items.Skip(i);
                foreach (var c in Comb(xs, r - 1))
                    yield return c.Before(x);
                i++;
            }
        }
    }
    public static IEnumerable<T> Before<T>(this IEnumerable<T> items, T first)
    {
        yield return first;
        foreach (var i in items)
            yield return i;
    }
}

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var d = new Dictionary<char, int>();
        var c = new char[] { 'M', 'A', 'R', 'C', 'H' };
        foreach (var x in c)
            d[x] = 0;
        for (int i = 0; i < n; i++)
        {
            var s = Console.ReadLine().Trim();
            if (d.ContainsKey(s[0]))         d[s[0]]++;
            
        }
        var ans = 0L;
        var a = c.Comb(3);
        foreach (var xx in a)
        {
            var ret = 1L;
            foreach (var xxx in xx)
                ret *= d[xxx];
            ans += ret;
        }
        Console.WriteLine(ans);
    }
}


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

int main(){
    set<unsigned> data;
    int N;
    cin >> N;
    for(int i=0;i<N;i++){
        int p[3];
        cin >> p[0] >> p[1] >> p[2];
        sort(p,p+3);
        data.insert(p[0]*1000000 + p[1]*1000 + p[2]);
    }
    cout << N-data.size() << endl;

    return 0;
}


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

int main() {
	int a[4],count=0;
	for(int i=0;i<3;i++) cin>>a[i];
	sort(a,a+3);
	for(int i=1;i<3;i++) count+=a[i]-a[i-1];
	cout<<count;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
	using namespace std;
	int main()
	{
	
	int n, k ,q;
	cin >>n >>k >>q;
	int z= q;
	long long a[n];
	int x;
	for(int i = 0; i < n; ++i){
		a[i] = k;
	}
	while(q--){
		cin >> x;
		a[x-1]++;
	}
	for(int i = 0; i < n; ++i){
		
		a[i] -= z;
		if(a[i] <= 0) cout << "No\n";
		else cout << "Yes\n";
	}
	return 0;
	}

Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;

int N, H, ans = 0, current_max = 0, past = 0;

int main() {
  cin >> N;
  for(int i=0; i<N; i++) {
    scanf("%d", &H);
    if(past < H) {
      ans = max(ans, current_max);
      current_max = 0;
    } else {
      current_max++;
    }
    past = H;
  }
  ans = max(ans, current_max);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
prime = [3,5,7,11,13] #9は素数ではない！
count = 0
#x^1, y^1,z^1の場合
for i in range(5):
    for j in range(i+1, 5):
        for k in range(j+1, 5):
            if prime[i]*prime[j]*prime[k] <=N:
                count += 1

#x^3, y^1の場合
for i in range(4):
    for j in range(i+1, 4):
        if prime[i]**3 * prime[j] <= N:
            count+= 1
        if prime[i] * prime[j]**3 <= N:
            count += 1
print(count)
"""
count = 0
for i in range(1,N+1,2):
    yakusuu = 0
    for j in range(1,i+1):
        if i%j == 0:
            yakusuu += 1
    if yakusuu == 8:
        print(i)
        count += 1
print(count)
"""

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

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

// #define int long long

/* cpp template {{{ */

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

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

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

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

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

/* }}} */

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int W, H, N;
  int px, py;
  cin >> W >> H >> N;
 
  cin >> px >> py;
  int ans = 0;
  REP(i, N - 1){
    int nx, ny;
    cin >> nx >> ny;
    if (px > nx && py < ny || px < nx && py > ny){
      ans += abs(px - nx) + abs(py - ny);
    } else {
      ans += max(abs(px - nx), abs(py - ny));
    }
    px = nx; py = ny;
  }
  print(ans);
  
  return (0);
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define MOD 1000000007
//for(int i=0; i<n; ++i)
using namespace std;
#define all(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " is " << (x) << endl
#define ll long long

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

    int n, w, sumval = 0;
    cin >> n >> w;
    vector<int> wt(n), val(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> wt[i] >> val[i];
        sumval += val[i];
    }

    vector<int> dp(sumval + 1, w + 1);
    dp[0] = 0;
    for (int i = 0; i < n; ++i)
        for (int j = sumval; j - val[i] >= 0; --j)
        {
            dp[j] = min(dp[j], wt[i] + dp[j - val[i]]);
        }

    int sol = 0;
    for (int i = sumval; i >= 0; --i)
        if (dp[i] <= w)
        {
            sol = i;
            break;
        }

    cout << sol << endl;

    return 0;
}

Measured memory_bytes: 3708
// 2011/07/20 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		double n;
		cin >> n;
		if(n<0.0)
			break;

		int n16 = (int)(n*16.0);		// 16{µÄC¬_ÈºØèÌÄ
		if(n*16.0!=(double)n16||n16>=4096){	// §ÀÉûÜçÈ¢ê
			cout << "NA" << endl;
			continue;
		}

		int bin[12];
		for(int i=0; i<12; i++){
			bin[i] = n16%2;
			n16 /= 2;
		}

		for(int i=11; i>=4; i--)
			cout << bin[i];
		cout << '.';
		for(int i=3; i>=0; i--)
			cout << bin[i];
		cout << endl;
	}

	return 0;
}

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

ll divisor=1e9+7;
int main(){
	int n,m;
	cin>>n>>m;
	int mx=100;
	int ans[n]={};
	int h[n];
	rep(i,n){
		cin>>h[i];
	}
	
	rep(i,m){
		int a,b;
		cin>>a>>b;
		int ma=min(h[a-1],h[b-1]);
		if(ma==h[a-1]){
			ans[a-1]=mx;
		}
		if(ma==h[b-1]){
			ans[b-1]=mx;
		}
	}
	int count=0;
	rep(i,n){
		if(ans[i]!=mx)count++;
	}
	puts(count);
	
}

Measured memory_bytes: 4416
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    int match[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    rep(i,M) cin >> A[i];

    sort(A.begin(), A.end(), greater<int>());

    int dp[N + 1];
    rep(i,N+1) dp[i] = -MOD;
    dp[0] = 0;
    for (int i = 1; i <= N; i++) {
        rep(j,M) {
            if (i - match[A[j]] >= 0) {
                dp[i] = max(dp[i], dp[i - match[A[j]]] + 1);
            }
        }
    }

    int count = N;

    rep(i,dp[N]) {
        rep(j,M) {
            if ((dp[count] == 1 && match[A[j]] == count) || (dp[count] != 1 && count - match[A[j]] >= 0 && dp[count - match[A[j]]] + 1 == dp[count])) {
                count -= match[A[j]];
                cout << A[j];
                break;
            }
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


int main() {

	ll N, M;
	cin >> N >> M;
	vll x(N), y(N), z(N);
	rep(i, N) cin >> x[i] >> y[i] >> z[i];

	ll ans = -1;
	rep(bit, 8) {
		ll a = (bit & 1) ? -1 : 1, b = ((bit >> 1) & 1) ? -1 : 1 , c = ((bit >> 2) & 1) ? -1 : 1;
		vll w(N);
		rep(i, N) w[i] = x[i] * a + y[i] * b + z[i] * c;
		sort(all(w), greater<ll>());

		ll tmp = 0; rep(i, M) tmp += w[i];
		ans = max(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
namespace CsProgramSpace
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = "";
            for(int i = 1; i<= n; i++)
            {
                if(i%3==0)
                    s += " "+i.ToString();
                else if(i%10==3)
                    s += " " + i.ToString();
                else if(i.ToString().IndexOf("3")>-1)
                    s += " " + i.ToString();
            }
            Console.WriteLine(s);
        }
    }
}


Measured memory_bytes: 36992
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007
#define INIT mod * 3000

long long int result[111][100010] = {};
long long int resultsum[111][100010] = {};

int main()
{
	int n, k;
	cin >> n >> k;
	int a[111];
	int suma[111] = {};
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		suma[i] = suma[i - 1] + a[i];
	}

	result[0][0] = 1;
	resultsum[0][0] = 1;
	for(int j = 1; j <= a[1]; j++){
		resultsum[0][j] = resultsum[0][j - 1];
	}
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= min(k, suma[i]); j++){
			// result[i][j] = result[i - 1][j] + ... + result[i - 1][j - a[i]];
			//  = resultsum[i - 1][j] - resultsum[i - 1][j - a[i] - 1];
			result[i][j] = resultsum[i - 1][j];
			if(j - a[i] - 1 >= 0) result[i][j] = (result[i][j] - resultsum[i - 1][j - a[i] - 1] + mod) % mod;
			// cout << i << " " << j << " " <<  result[i][j] << endl;
		}
		if(i == n) continue;
		resultsum[i][0] = result[i][0];
		for(int j = 1; j <= min(k, suma[i + 1]); j++){
			resultsum[i][j] = (resultsum[i][j - 1] + result[i][j]) % mod;
		}
	}
	cout << result[n][k] << endl;
	return 0;
}

Measured memory_bytes: 160000
n=int(input())
a=list(map(int,input().split()))
b=[0]+a+[0]
c=0
for i in range(n+1):
  c+=abs(b[i+1]-b[i])
for i in range(n):
  x=abs(b[i+2]-b[i])
  y=abs(b[i+2]-b[i+1])+abs(b[i+1]-b[i])
  d=y-x
  print(c-d)

Measured memory_bytes: 14048
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <map>
#include <deque>
#define MAX_N 100
#define MAX_T 200
#define INF 1000000000000
typedef long long ll;
using namespace std;

int main(){
  ll n;
  ll l[102],r[102],v[102];
  ll rv[40000];
  double ans=0.0;
  cin>>n;
  
  l[0]=0;r[0]=0;
  for(int i=0;i<n;i++){
    int t;
    cin>>t;
    l[i+1]=r[i];
    r[i+1]=l[i+1]+2*t;
  }
  l[n+1]=r[n];r[n+1]=l[n+1];

  v[0]=0;v[n+1]=0;
  for(int i=0;i<n;i++){
    cin>>v[i+1];
    v[i+1]*=2;
  }
  for(int i=0;i<r[n+1];i++){
    rv[i]=200;
    for(int j=0;j<=n+1;j++){
      if(i<l[j]){
        rv[i]=min(rv[i],v[j]+l[j]-i);
      }else if(i>r[j]){
        rv[i]=min(rv[i], v[j]+i-r[j]);
      }else{
        rv[i]=min(rv[i],v[j]);
      }
    }
    ans+=rv[i];
  }
  printf("%.10lf\n",ans/4.0);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
   int a,b;

   scanf("%d %d",&a ,&b);

   if(a < b){
      puts("a < b");
   }else if(b < a){
      puts("a > b");
   }else if(a == b){
      puts("a == b");
   }

   return 0;
}

Measured memory_bytes: 1748
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long ll;

ll Euclidean(ll A, ll B)
{
    if(A < B) swap(A, B);
    ll r = A % B;
    while(r > 0) {
        A = B;
        B = r;
        r = A % B;
    }
    return B;
}

ll Main(ll A, ll B)
{
    ll r = Euclidean(A, B);
    ll ans = 1;
    ll mx = r;
    for(ll i = 2; i*i <= mx; i++) {
        if(r%i) continue;
        else {
            ans++;
            while(!(r%i)) r/=i;
        }
    }
    if(r>1) ans++;
    return ans;
}

int main(void){
    ll A, B;
    cin >> A >> B;
    cout << Main(A, B) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<stdlib.h>
#include<set>
#include<string>
#include<queue>
#include<map>
#include<stack>
#include <algorithm>

using namespace std;

int main(){
	int w, h;
	int sx, sy;
	int dx[4] = { 1, 0, -1, 0 }, dy[4] = {0 , 1 , 0 , -1};
	char str[20];

	cin >> w >> h;
	do{
		int masu[20][20] = { 0 };
		int check_masu[20][20] = { 0 };

		for (int i = 0; i < h; i++){
			cin >> str;
			for (int j = 0; j < w; j++){
				masu[j][i] = str[j];
				if (masu[j][i] == '@'){
					sx = j; sy = i;
				}
			}
		}

		int x, y;
		int count = 0; //count looked check
		stack< pair<int, int> > s;
		s.push(make_pair(sx, sy));	//set start place 
		while (s.size()){
			x = s.top().first;
			y = s.top().second;
			s.pop();

			if (check_masu[x][y] == 'c' || masu[x][y] == '#')
				continue;

			check_masu[x][y] = 'c';	//looked
			count++;

			for (int i = 0; i < 4; i++){
				if ((0 <= x + dx[i] && x + dx[i] < w)
					&& (0 <= y + dy[i] && y + dy[i] < h)){

					s.push(make_pair(x + dx[i], y + dy[i]));
				}
			}
		}

		cout << count << endl;

		cin >> w >> h;
	} while (w != 0 && h != 0);

	return 0;
}

Measured memory_bytes: 1224
n = int(raw_input())
s = range(1,14)
h = range(1,14)
c = range(1,14)
d = range(1,14)
 
for i in range(n):
    q,r = raw_input().split()
    if q == 'S':
        s[int(r)-1] = 0
    elif q == 'H':
        h[int(r)-1] = 0
    elif q == 'C':
        c[int(r)-1] = 0
    elif q == 'D':
        d[int(r)-1] = 0
 
a = 'S '
for i in range(13):
    if s[i] != 0:
        print a + str(s[i])
a = 'H '
for i in range(13):
    if h[i] != 0:
        print a + str(h[i])
a = 'C '
for i in range(13):
    if c[i] != 0:
        print a + str(c[i])
a = 'D '
for i in range(13):
    if d[i] != 0:
        print a + str(d[i])

Measured memory_bytes: 6484
/*
[abc148] F - Playing Tag on Tree
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 1e5 + 5;
const int MAX_V = MAX_N;
const int MAX_LOG_V = 32;

int V;
vector<int> g[MAX_V];
int par[MAX_LOG_V][MAX_V];
int dep[MAX_V];

void dfs_lca(int v, int p = -1, int d = 0) {
    par[0][v] = p;
    dep[v] = d;
    for (int to : g[v]) {
        if (to == p) {
            continue;
        }
        dfs_lca(to, v, d + 1);
    }
}

int lca(int u, int v) {
    if (dep[u] > dep[v]) {
        swap(u, v);
    }
    for (int k = 0; k < MAX_LOG_V; k++) {
        if (((dep[v] - dep[u]) >> k) & 1) {
            v = par[k][v];
        }
    }
    if (u == v) {
        return u;
    }
    for (int k = MAX_LOG_V - 1; k >= 0; k--) {
        if (par[k][u] != par[k][v]) {
            u = par[k][u];
            v = par[k][v];
        }
    }
    return par[0][u];
}

void init(int root) {
    dfs_lca(root);
    for (int k = 1; k < MAX_LOG_V; k++) {
        for (int v = 0; v < V; v++) {
            par[k][v] = (par[k - 1][v] < 0) ? -1 : par[k - 1][par[k - 1][v]];
        }
    }
}

int N;
int TK, AO;

ll solve() {
    V = N;
    init(AO);

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int w = lca(i, TK);
        if (dep[w] > dep[TK] - dep[w]) {
            ans = max(ans, dep[i] - 1);
        }
    }
    ans = max(ans, 0);

    return ans;
}

int main() {
    cin >> N >> TK >> AO;
    TK--, AO--;
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 22400
n = [int(x) for x in input()]

op_num = len(n) - 1

for i in range(2 ** op_num):
    op = ['+'] * op_num
    for j in range(op_num):
        if (i >> j) & 1:
            op[op_num - 1 - j] = '-'

    op.append('')
    formula = ''
    for x, o in zip(n, op):
        formula += str(x) + o
    if eval(formula) == 7:
        print(formula + '=7')
        break


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

int main()
{
	string S; cin >> S;
  	bool result = false;
  	if(S[0]==S[1] && S[2]==S[3] && S[0]!=S[2]) result = true;
    if(S[0]==S[2] && S[1]==S[3] && S[0]!=S[1]) result = true;
    if(S[0]==S[3] && S[1]==S[2] && S[0]!=S[1]) result = true;
  	if(result) cout << "Yes";
  	else cout << "No";
  	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main()
{
	int i,k;
	int r,c;
	int data[500][500]={0};
	scanf("%d %d", &r, &c);
	for(i=0; i<r; i++){
		for(k=0; k<c; k++){
			scanf("%d", &data[i][k]);
			data[i][c]+=data[i][k];
			data[r][k]+=data[i][k];
		}
	}
	for(i=0; i<c; i++){
		data[r][c]+=data[r][i];
	}
	for(i=0; i<r+1; i++){
		for(k=0; k<c+1; k++){
			if(k>0){
				printf(" ");
			}
			printf("%d", data[i][k]);
		}
		printf("\n");
	}
	return 0;
}

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

struct Node {
	int key;
	int parent = -1;
	int left = -1;
	int right = -1;
};

Node T[251];

void prop(int num) {
	int div = num / 2;
	int tmp = num % 2;
	T[num].parent = div;
	if (tmp == 0) {
		T[div].left = num;
	}
	else {
		T[div].right = num;
	}
	
}

int main() {
	int n;
	cin >> n;
	cin >> T[1].key;
	for (int i = 2; i <= n; i++) {
		cin >> T[i].key;
		prop(i);
	}
	for (int i = 1; i <= n; i++) {
		cout << "node " << i << ": key = " << T[i].key << ", ";
		if (T[i].parent != -1) {
			cout << "parent key = " << T[T[i].parent].key << ", ";
		}
		if (T[i].left != -1) {
			cout << "left key = " << T[T[i].left].key << ", ";
		}
		if (T[i].right != -1) {
			cout << "right key = " << T[T[i].right].key << ", ";
		}
		cout << endl;
	}
}



Measured memory_bytes: 3124