akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string>
#include <string.h>
#include <math.h>
#include <iomanip>
#include <stdio.h>
using namespace std;

#define y1 huy
#define int64 long long
#define pii pair <int, int>
#define fr first
#define sc second
#define heap priority_queue
struct piii{
    int64 fr, sc, th;
    bool operator < (const piii &b){
        if (fr != b.fr) return fr < b.fr;
        if (sc != b.sc) return sc < b.sc;
        return th < b.th;
    }
};
///////////////////////////////////////////////
///////////////////////////////////////////////

const int oo = 1e9;
int m, n, k, x1, y1, x2, y2;
vector <vector <pii>> pn, ps, pw, pe;
vector <vector <int>> f;
vector <vector <bool>> dd;
vector <string> s;
queue <pii> qu;


void init(vector <vector <pii>> &a){
    a.resize(m + 2);
    for (int i = 0; i <= m + 1; i++)
        a[i].resize(n + 2);
}

void init(vector <vector <bool>> &a){
    a.resize(m + 2);
    for (int i = 0; i <= m + 1; i++)
        a[i].resize(n + 2, false);
}

void init(vector <vector <int>> &a){
    a.resize(m + 2);
    for (int i = 0; i <= m + 1; i++)
        a[i].resize(n + 2, oo);
}

pii getp(vector <vector <pii>> &p, pii u){
    pii tmp = p[u.fr][u.sc];
    if (tmp.fr >= 0 && tmp.fr < m && tmp.sc >= 0 && tmp.sc < n && dd[tmp.fr][tmp.sc])
        p[u.fr][u.sc] = getp(p, tmp);
    return p[u.fr][u.sc];
}

void go(vector <vector <pii>> &p, pii u, int val){
    pii v = u;
    while (1){
        u = getp(p, u);
        if (abs(u.fr - v.fr) + abs(u.sc - v.sc) > k) return;
        if (u.fr < 0 || u.fr >= m || u.sc < 0 || u.sc >= n || s[u.fr][u.sc] == '@')
            return;
        dd[u.fr][u.sc] = true;
        f[u.fr][u.sc] = val + 1;
        qu.push(u);
    }
}

int main(){
    cout << setprecision(2) << fixed;
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("input.txt", "r", stdin);
    cin >> m >> n >> k;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--, x2--, y1--, y2--;
    s.resize(m + 2);
    init(pn);
    init(ps);
    init(pw);
    init(pe);
    init(f);
    init(dd);
    for (int i = 0; i < m; i++)
        cin >> s[i];
    for (int i = 0; i < m; i++)
    for (int j = 0; j < n; j++){
        //if (s[i][j] == '@') dd[i][j] = true;
        pn[i][j] = {i - 1, j};
        ps[i][j] = {i + 1, j};
        pw[i][j] = {i, j - 1};
        pe[i][j] = {i, j + 1};
    }
    /*
    for (int i = 0; i <= m + 1; i++)
        dd[i][0] = dd[i][n + 1] = true;
    for (int i = 0; i <= n + 1; i++)
        dd[0][i] = dd[m + 1][i] = true;
    */
    f[x1][y1] = 0;
    qu.push(pii({x1, y1}));
    while (!qu.empty()){
        pii cur = qu.front();
        //cout << cur.fr << ' ' << cur.sc << ' ' << f[cur.fr][cur.sc] << endl;
        if (cur.fr == x2 && cur.sc == y2){
            cout << f[x2][y2];
            exit (0);
        }
        qu.pop();
        go(pn, cur, f[cur.fr][cur.sc]);
        go(ps, cur, f[cur.fr][cur.sc]);
        go(pw, cur, f[cur.fr][cur.sc]);
        go(pe, cur, f[cur.fr][cur.sc]);
    }
    cout << -1;
    return 0;
}


Measured memory_bytes: 110156
import java.io.*;// 从这行开始复制，这是第一行
import java.util.*;

public class Main {

    /**
     * TODO 提交的时候一定要设置为 true
     */
    private boolean submitFlag = true;

    private void solve() {
        int ans = 0;


        System.out.println(ans);
    }


    private void run() throws IOException {
        setReader();

        //TODO 从这里开始读入题目输入
        long x = nextLong();
        long y = nextLong();
        if (y - 2 * x >= 0 && (y - 2 * x) % 2 == 0 && (y - 2 * x) / 2 <= x) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }


    }


//    main以及输入输出========================================================================

    public static void main(String[] args) throws IOException {
        Main solution = new Main();
        solution.run();
        solution.reader.close();
    }

    /**
     * TODO 存档时，改一下moduleName
     */
    String moduleName = "atcoder-race";

    /**
     * 注意不同题目这里路径要设一下
     *
     * @throws IOException
     */
    private void setReader() throws IOException {
        if (submitFlag) {
            reader = new BufferedReader(new InputStreamReader(System.in));
        } else {
            String projectPath = System.getProperty("user.dir");
            String modulePath = projectPath + "/" + moduleName + "/src/main/java/";
            String className = this.getClass().getPackage().getName().replace(".", "\\");
            reader = new BufferedReader(new FileReader(modulePath + className + "\\input.txt"));
        }
    }

    private BufferedReader reader;
    private StringTokenizer tokenizer;

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    private String next() throws IOException {
        return nextToken();
    }

    private String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}


Measured memory_bytes: 32760
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    int N; cin >> N;
    int res = 0;

  for(int i = 1; i <= N; ++i) {
      int digits = 1;
      int _i = i;
      while(_i >= 10) {
        _i /= 10;
        ++digits;
      }
      
      if (digits%2 != 0) ++res;
    }
  
    cout << res << endl;
}


Measured memory_bytes: 256
/*
[abc128] E - Roadwork
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
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 = 2e5;
const int MAX_Q = 2e5;

int N, Q;
int S[MAX_N], T[MAX_N], X[MAX_N];
int D[MAX_Q];
vector<int> cx;

void solve() {
    for (int i = 0; i < N; i++) {
        S[i] -= X[i];
        T[i] -= X[i];
        cx.push_back(S[i]);
        cx.push_back(T[i]);
    }
    for (int i = 0; i < Q; i++) {
        cx.push_back(D[i]);
    }
    sort(cx.begin(), cx.end());
    cx.erase(unique(cx.begin(), cx.end()), cx.end());

    vector<pair<pii, bool>> line;
    for (int i = 0; i < N; i++) {
        int sx = lower_bound(cx.begin(), cx.end(), S[i]) - cx.begin();
        int tx = lower_bound(cx.begin(), cx.end(), T[i]) - cx.begin();
        line.push_back({{sx, X[i]}, true});
        line.push_back({{tx, X[i]}, false});
    }
    sort(line.begin(), line.end());

    vector<int> ans(cx.size());
    set<int> cur;
    int j = 0;
    for (int i = 0; i < (int)cx.size(); i++) {
        for (; j < (int)line.size() && line[j].first.first <= i; j++) {
            if (line[j].second) {
                cur.insert(line[j].first.second);
            } else {
                cur.erase(line[j].first.second);
            }
        }
        ans[i] = cur.empty() ? -1 : *cur.begin();
    }

    for (int i = 0; i < Q; i++) {
        int cd = lower_bound(cx.begin(), cx.end(), D[i]) - cx.begin();
        cout << ans[cd] << endl;
    }
}

int main() {
    cin >> N >> Q;
    for (int i = 0; i < N; i++) {
        cin >> S[i] >> T[i] >> X[i];
    }
    for (int i = 0; i < Q; i++) {
        cin >> D[i];
    }

    solve();

    return 0;
}


Measured memory_bytes: 23528
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

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


int main()
{
	ull a, b, c, d, e,ans;
	cin >> a >> b >> c >> d;

	ull ac, bc, ad, bd, ae, be;
	ac = (a - 1) / c;
	bc = b / c;
	ad = (a - 1) / d;
	bd = b / d;

	//ユークリッドの互除法
	ull tempC, tempD;
	tempC = max(c,d);
	tempD = min(c,d);
	ull temp = tempC%tempD;
	//cout << "temp: " << temp << endl;
	while (temp != 0) {
		tempC = tempD;
		tempD = temp;
		temp = tempC % tempD;
	}
	e = (c*d) / tempD;
	//cout << "最小公倍数: " << (c*d) / tempD << endl;

	ae = (a - 1) / e;
	be = b / e;

	ans = (b-a+1) - ((bc - ac) + (bd - ad) - (be - ae));
	cout << ans << endl;
	
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())

/*int P[10010];
void init(int n){//Union-find
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？
//セグメント木？？
*/

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
/*ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね
*/

//cerrはコメントアウトしなくても通る

int main(){
    int n,m;
    cin >> n>> m;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    }
    sort(a.begin(),a.end(),greater<int>());
    while(m>0){
        a[0]/=2;
        m--;
        //cerr<<a[0]<<endl;
        if(m==0){
            break;
        }
        for(int j=1;j<n;j++){
            if(a[j]>a[0]){
                a[j]/=2;
                //cerr<<a[j]<<endl;
                m--;
                if(m==0){
                    break;
                }
            }else{
                j=n;
            }
        }
        sort(a.begin(),a.end(),greater<int>());
    }
    ll ans=0;
    rep(i,n){
        ans+=a[i];
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  
  int s;
  int64_t ans=0;
  cin>>s;
  vector<int> vec(s);
  for(int i=0; i<s; i++){
    int a;
    cin>>a;
    vec.at(i)=a;
  }
  
  for(int i=0; i<s-1; i++){
    if(vec.at(i+1)<vec.at(i)){
      ans+=vec.at(i)-vec.at(i+1);
      vec.at(i+1)=vec.at(i);
    }
  }
  cout<<ans<<endl;
}
  



Measured memory_bytes: 3924
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

#define ceil(a,b) (a%b?a/b+1:a/b)

#define dump1(v) for(auto i:v) std::cout << i << ' '; std::cout << "\n";

struct FastIO
{
  FastIO() {
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(0); 
  }
}fastio;

struct ZAlgorithm
{
	std::vector<int> z;
	ZAlgorithm(std::string s) : z(s.size(),0) {
		int l,r;
		// [l,r)
		l=r=0;
		for(int i=1;i<s.size();i++) {
			if(i>=r) {
				l=r=i;
				while(r<s.size() && s[r]==s[r-l]) r++;
				z[i] = r-l;
				continue;
			}
			if(z[i-l]<r-i) {
				z[i] = z[i-l];
				continue;
			}
			l=i;
			while(r<s.size() && s[r]==s[r-l]) r++;
			z[i] = r-l;
			continue;
		}
		z[0] = s.size();
	}
};

int dfs(int i,int c,std::vector<int>&to,std::vector<int>&went) {
	if(to[c]==i) return -1;
	if(to[c]==-1) return 0;
	if(went[c]>0) return went[c];
	int x = dfs(i,to[c],to,went);
	if(x==-1) return -1;
	return went[c]=x+1;
}

signed main() {
	std::string s;
	std::string t;
	std::cin >> s >> t;

	std::string a = "";

	int t_sz = t.size();
	int s_sz = s.size();
	int f = ceil(t_sz,s_sz)+1;
	rep(i,f) a += s;

	std::string x = t + '$' + a;
	ZAlgorithm z(x);

	std::vector<int> zz(s_sz);
	rep(i,s_sz) zz[i] = z.z[t_sz+1+i];

	std::vector<int> to(s_sz,-1);
	rep(i,s_sz) if(zz[i]==t_sz) to[i] = (i+t_sz)%s_sz;

	std::vector<int> went(s_sz,0);
	rep(i,s_sz) {
		if(zz[i]!=t_sz) continue;

		if(dfs(i,i,to,went)==-1) {
			print(-1);
			return 0;
		}
	}
	int max = 0;
	for(auto i:went) max = std::max(max,i);
	print(max);
	return 0;
}


Measured memory_bytes: 48164
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
#include <cstdlib>
#include <map>
using ll = long long int;
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N), L(N, 0), R(N, 0);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    for (int i = 1; i < N; i++)
    {
        if (L[i - 1] < A[i - 1])
        {
            L[i] = A[i - 1];
        }
        else
        {
            L[i] = L[i - 1];
        }
        if (R[i - 1] < A[N - i])
        {
            R[i] = A[N - i];
        }
        else
        {
            R[i] = R[i - 1];
        }
    }
    reverse(R.begin(), R.end());
    for (int i = 0; i < N; i++)
    {
        cout << max(L[i], R[i]) << endl;
    }

    return 0;
}

Measured memory_bytes: 3968
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
import heapq

n, m = getList()

works = [[] for i in range(m+2)]

for i in range(n):
    a, b = getList()
    try:
        works[a].append(-b)
    except:
        pass

ans = 0
q = []
# print(works)
for i, day in enumerate(works[1:]):
    if i >= m:
        # print("be")
        break
    for work in day:
        heapq.heappush(q, work)
    if q:
        reward = heapq.heappop(q)
        ans += reward
    # print(q, ans)

print(-ans)

Measured memory_bytes: 70192
#include <stdio.h>

int n;
int in[100000][3];
int dp[100000][3];
int before = 4;
int next;

int max(int a, int b)
{
	if (a > b)
		return a;
	return b;
}
int main(int argc, char const *argv[])
{
	scanf("%d", &n);
	for (int i = 0;i < n; i++)
		scanf("%d %d %d", &in[i][0], &in[i][1], &in[i][2]);

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < 3; k++)
			{
				if(j == k)
					continue;
				dp[i+1][j] = max(in[i][j] + dp[i][k], dp[i+1][j]);
			}
		}
	}
	
	int ans = 0;
	int i = 0;
	while (i < 3)
		ans = max(ans, dp[n][i++]);
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;


int main()
{
    int N;
    cin>>N;
    cout<<N/2*(N/2+N%2)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int N,Q;
	while(cin >> N >> Q, N){
		map<int,int> data;
		rep(i,N){
			int m;
			cin >> m;
			rep(i,m){
				int t; cin >> t;
				data[t]++;
			}
		}
		
		int ret , mx = 0;
		for(map<int,int>::iterator it = data.begin(); it != data.end(); ++it){
				if((*it).second > mx){
					ret = (*it).first;
					mx = (*it).second;
				}
		}
		cout << (mx>=Q?ret:0) << endl;
	}
}

Measured memory_bytes: 916
S=int(input())
if S==1 or S==2:
  print(0)
  exit()
elif S==3:
  print(1)
  exit()
elif S==4:
  print(1)
  exit()
elif S==5:
  print(1)
  exit()
elif S==6:
  print(2)
  exit()
elif S==7:
  print(3)
  exit()
elif S==8:
  print(4)
  exit()
elif S==9:
  print(6)
  exit()

  
ans=[0]*max(S+1,9)
ans[3]=1
ans[4]=1
ans[5]=1
ans[6]=2
ans[7]=3
ans[8]=4
ans[9]=6

for i in range(10,S+1):
  ans[i]=(ans[i-1]+ans[i-3])%(pow(10,9)+7)

print(ans[S])

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

using namespace std;

int N, V;
string S;
vector< int > g[100000], h[100000];
bool v[100000];
int cost[100000];

int dfs(int idx, int par) {
  int ret = (S[idx] == 'W');
  for(auto &to : g[idx]) {
    if(to == par) continue;
    ret += dfs(to, idx);
  }
  if(ret > 0) {
    if(~par) {
      h[idx].push_back(par);
      h[par].push_back(idx);
    }
    ++V;
    v[idx] = true;
  }
  return ret;
}

int dp[100000];

int dfs2(int idx, int par) {
  int ret = 0;
  vector< int > ask{0, 0};
  for(auto &to : h[idx]) {
    if(to == par) continue;
    ret = max(ret, dfs2(to, idx));
    dp[idx] = max(dp[idx], dp[to]);
    ask.push_back(dp[to]);
  }
  dp[idx] += cost[idx];
  sort(ask.rbegin(), ask.rend());
  ret = max(ret, ask[0] + ask[1] + cost[idx]);
  return ret;
}

int main() {
  cin >> N;
  for(int i = 0; i < N - 1; i++) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  cin >> S;

  int root = -1;
  for(int i = 0; i < N; i++) {
    if(S[i] == 'W') root = i;
  }
  if(root == -1) {
    cout << 0 << endl;
    return 0;
  }
  dfs(root, -1);
  if(V == 1) {
    cout << 1 << endl;
    return 0;
  }

  int ret = 2 * (V - 1);
  for(int i = 0; i < N; i++) {
    if(v[i]) {
      int add = S[i] == 'W';
      add ^= h[i].size() & 1;
      ret += add;
      cost[i] = add;
    }
  }

  cout << ret - 2 * dfs2(root, -1) << endl;
}

Measured memory_bytes: 29312
#define _USE_MATH_DEFINES

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int main(){
	
	string str;
	cin >> str;
	
	int a, b, c, d;
	a = str[0] - '0';
	b = str[1] - '0';
	c = str[2] - '0';
	d = str[3] - '0';
	
	if(a + b + c + d == 7){
		cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
		return 0;
	}
	if(a + b + c - d == 7){
		cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
		return 0;
	}
	if(a + b - c + d == 7){
		cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
		return 0;
	}
	if(a + b - c - d == 7){
		cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
		return 0;
	}
	if(a - b + c + d == 7){
		cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
		return 0;
	}
	if(a - b + c - d == 7){
		cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
		return 0;
	}
	if(a - b - c + d == 7){
		cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
		return 0;
	}
	if(a - b - c - d == 7){
		cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
		return 0;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

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

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

int main()
{
    int n;
    string s, t;
    cin >> s >> t;

    if (s == t.substr(0,t.length() - 1))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
class Program
{
    //static List<string> str = new List<string>();
    static void Main(string[] args)
    {
        // 入力
        int N = int.Parse(Console.ReadLine());
        decimal ret = 0;
        for (int i = 0; i < N; i++ )
        {
            string[] input = Console.ReadLine().Split(' ');
            if(input[1].CompareTo("BTC") == 0)
            {
                ret += decimal.Parse(input[0]) * 380000;
            }
            else
            {
                ret += int.Parse(input[0]);
            }
        }

        Console.WriteLine(ret);
    }

}

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

using lint = long long;

struct node {
    int id;

    bool done;
    vector<int> tos;

    int nb;
    lint res;

    bool operator < (const node that) const {
        return nb > that.nb;
    }
};

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

    int n;
    cin >> n;
    vector<node> nodes(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        nodes[a].tos.push_back(b);
        nodes[b].tos.push_back(a);
    }
    for (int i = 0; i < n; i++) {
        nodes[i].id = i;
        nodes[i].nb = nodes[i].tos.size();
    }
    vector<int> cs(n);
    for (int i = 0; i < n; i++) {
        cin >> cs[i];
    }
    sort(cs.begin(), cs.end());

    priority_queue<node> que;
    for (int i = 0; i < n; i++) {
        if (nodes[i].tos.size() == 1) {
            que.push(nodes[i]);
        }
    }
    int pos = 0;
    while (!que.empty()) {
        node n = que.top();
        que.pop();
        int i = n.id;
        if (nodes[i].done == true) {
            continue;
        }
        nodes[i].done = true;
        nodes[i].res = cs[pos];
        pos++;
        for (int j: nodes[i].tos) {
            if (nodes[j].done == false) {
                nodes[j].nb--;
                que.push(nodes[j]);
            }
        }
    }

    lint ans = 0;
    for (int i = 0; i < n - 1; i++) {
        ans += cs[i];
    }
    cout << ans << endl;
    for (int i = 0; i < n; i++) {
        if (i) {
            cout << ' ';
        }
        cout << nodes[i].res;
    }
    cout << endl;

    return 0;
}

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

using namespace std;

int main(){
    int n,a,b;
    cin >> n;

    a = n/100;
    b = n%100;

    if(b >= 1 && b <= 12){
        if(a >= 1 && a <= 12){
            cout << "AMBIGUOUS" << endl;
        }else{
            cout << "YYMM" << endl;
        }
    }else{
        if(a >= 1 && a <= 12){
            cout << "MMYY" << endl;
        }else{
            cout << "NA" << endl;
        }
    }

    return 0;
}

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

#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

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

#define MOD 1000000007

lli dp[100001]; // i 段目の通り数
bool x[100001];

int main() {
    lli n, m;
    cin >> n >> m;
    lli a[m];
    REP(i, 0, m) {
        lli ai;
        cin >> ai;
        x[ai] = true;
    }

    lli count = 0;
    dp[0] = 1;
    if (x[1]) {
        dp[1] = 0;
        count++;
    }
    else
        dp[1] = 1;

    REPE(i, 2, n) {
        if (x[i]) {
            count++;
            if (count >= 2) {
                cout << 0 << endl;
                return 0;
            }
            continue;
        }
        else if (count == 1) {
            dp[i] = dp[i-2];
            count = 0;
        }
        else {
            dp[i] = (dp[i-1] + dp[i-2]) % MOD;
            count = 0;
        }
    }
    cout << dp[n] << endl;
}


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

#define Fast            ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define fWrite          freopen ("out.txt","w",stdout);
#define TC              int t;cin >> t;FOR(tc,1,t)
#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define all(a)          a.begin(),a.end()
#define MEM(a,x)        memset(a,x,sizeof(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)

#define Make(x,p)       (x  (1<<p))
#define DeMake(x,p)     (x & ~(1<<p))
#define Check(x,p)      (x & (1<<p))
#define popcount(x)     __builtin_popcount(x)

const LL mod=1e9+7;
const int N=50;
void MatMul(LL A[N][N], LL B[N][N])
{
    LL R[N][N];
    MEM(R,0);
    REP(i, N) REP(j, N) REP(k, N) R[i][j] = (R[i][j]%mod + (A[i][k] * B[k][j])%mod)%mod;
    REP(i, N) REP(j, N) B[i][j] = R[i][j];
    return;
}
void MatPow(LL R[N][N],LL M[N][N],LL P)
{
    while(P)
    {
        if(P & 1)
            MatMul(M,R);
        MatMul(M,M);
        P = P >> 1;
    }
}

int main()
{
    Fast
    LL n,k;
    cin >> n >> k;
    LL R[N][N],M[N][N];
    MEM(R,0);
    MEM(M,0);
    REP(i,n) REP(j,n) cin >> M[i][j];
    REP(i,n) REP(j,n) R[i][j]=M[i][j];
    MatPow(R,M,k-1);
    LL sum=0;
    REP(i,n) REP(j,n) sum=(sum+R[i][j])%mod;
    cout << sum;
}


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

int main() {
	int M;
	cin >> M;
	vector<int>a(M);
	for (int i = 0;i < M;i++) {
		cin >> a[i];
		if (i != 0)cout << " ";
		cout << a[i];
	}
	cout << endl;
	for (int i = 1;i < M;i++) {
		int v;
		v = a[i];
		int j;
		j = i - 1;
		while (j >= 0 && a[j] > v) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
		for (int k = 0;k < M;k++) {
			if (k != 0) cout << " ";
			cout << a[k];
		}cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3096
#include <cstdio>
#include <iostream>
#include <cmath>
#include <set>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
const int N=200000+10;
int n,w[N],v[N],W;
ll dp[N];
int main()
{
    //freopen("a.in","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>W;
    for(int i=1;i<=n;i++)cin>>w[i]>>v[i];
    for(int i=1;i<=n;i++){
    	for(int j=W;j>=w[i];j--){
    		dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
    	}
    }
    cout<<dp[W]<<"\n";
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define debug(x) cout<<#x<<"="<<x<<endl
using namespace std;

int len,a;

int main()
{
	cin>>a;
	while(len*(len+1)/2<a) len++;
	//debug(len);
	int tmp=len*(len+1)/2-a;
	for(int i=1;i<=len-tmp;i++) putchar(')');
	putchar('(');
	for(int i=1;i<=tmp;i++) putchar(')');
	for(int i=1;i<=len-1;i++) putchar('(');
	puts("");
	return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
using namespace std;

typedef long long lli;
const int MAX = 100;
int a[MAX][MAX][MAX];

int main(){
  int n,m;
  while(cin >> n >> m){
    lli v[50][6], ans = 0;
    vector<lli> v2[3];
    set<lli> s[3];
    map<lli,int> v3[3];
    for(int i=0;i<n;i++){
      for(int j=0;j<6;j++){
        cin >> v[i][j];
        s[j%3].insert(v[i][j]);
      }
    }

    for(int i=0;i<MAX;i++) for(int j=0;j<MAX;j++) for(int k=0;k<MAX;k++) a[i][j][k] = 0;
    for(int i=0;i<3;i++){
      for(set<lli>::iterator it = s[i].begin(); it != s[i].end(); it++){
        v2[i].push_back(*it);
        v3[i][*it] = v2[i].size()-1;
      }
    }

    for(int i=0;i<n;i++)
      for(int j=v3[0][v[i][0]];j<v3[0][v[i][3]];j++)
        for(int k=v3[1][v[i][1]];k<v3[1][v[i][4]];k++)
          for(int l=v3[2][v[i][2]];l<v3[2][v[i][5]];l++)
            a[j][k][l]++;

    for(int i=0;i<MAX-1;i++)
      for(int j=0;j<MAX-1;j++)
        for(int k=0;k<MAX-1;k++)
          if(a[i][j][k] >= m)
            ans += (v2[0][i+1]-v2[0][i]) * (v2[1][j+1]-v2[1][j]) * (v2[2][k+1]-v2[2][k]);

    cout << ans << endl;
  }
}

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);


/*
 * 2*(5**n)の倍数で見る。
 */

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	LL N;
	cin >> N;

	if((N % 2) == 1){
		printf("0\n");
		return 0;
	}

	LL ans = 0;
	LL w = 2*5;
	while(true){
		LL q = N / w;
		if(q == 0){
			break;
		}
		ans += q;
		w *= 5;
	}
	printf("%lld\n", ans);
	return 0;
}

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

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

using namespace std;

void execute()
{
	int N;
	cin >> N;
	int ans = 0;
	int max_height = 0;
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;

		if (max_height <= tmp)
			ans++;

		max_height = max(max_height, tmp);
	}
	cout << ans << endl;
	return;
}

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

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
open Printf
open Scanf

let readint () = scanf " %d" (fun x -> x)

let is_sorted a = 
  let ans = ref true in
  for i = 0 to Array.length a - 2 do
    if a.(i) > a.(i+1) then ans := false
  done;
  !ans

let () =
  let n = readint () in 
  let a = Array.init n (fun _ -> readint ()) in
  a.(0) <- a.(0) - 1;
  for i = 1 to n - 1 do
    if a.(i-1) < a.(i) then
      a.(i) <- a.(i) - 1
  done;
  printf "%s\n" @@ if is_sorted a then "Yes" else "No"



Measured memory_bytes: 5376
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define gap ' '
#define L(i) ((i) - (&i))

const int MAXN = 1e5+2;
const int MAX = 1e9+5;
const int MOD = 1e9+7;

int main(){
	int n; cin >> n;
	int ans[n+1];
	memset(ans,0,sizeof(ans));	
	for(int a = 1; a < 101; a++){
		for(int b = 1; b < 101; b++){
			for(int c = 1; c < 101; c++){
				int val = a*a+b*b+c*c+a*b+c*b+c*a;
				if(val > n) continue;
				ans[val]++;
			}
		}
	}
	for(int i = 1; i <= n; ++i)
		cout << ans[i] << endl;
	return 0;
}	


Measured memory_bytes: 3596
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, m = map(int, input().split())
graph = [0] + [[] for _ in range(n)]
for _ in range(m):
    n1, n2 = map(int, input().split())
    graph[n1].append(n2)
    graph[n2].append(n1)

from collections import deque

def bfs(graph, queue, dist, prev):
    while queue:
        current = queue.popleft()

        for c in graph[current]:
            if dist[c] != -1:
                continue
            else:
                dist[c] = dist[current] + 1
                prev[c] = current
                queue.append(c)

queue = deque([1])
dist = [0] + [-1] * n
prev = [0] + [-1] * n
dist[1] = 0
prev[1] = 0
bfs(graph, queue, dist, prev)

if -1 in prev:
    print('No')
else:
    print('Yes')
    for v in prev[2:]:
        print(v)


Measured memory_bytes: 93044
package main

import (
	"fmt"
	"math"
)

func main() {
	var k int
	var nums [3]int
	fmt.Scan(&nums[0])
	fmt.Scan(&nums[1])
	fmt.Scan(&nums[2])
	fmt.Scan(&k)

	max, others := maxAndOthersAdd(nums)
	two := math.Pow(2, float64(k))

	fmt.Println(max*int(two) + others)
}

func maxAndOthersAdd(nums [3]int) (max, othersAdd int) {
	max = nums[0]
	var maxIndex int
	for index, value := range nums {
		if max < value {
			max = value
			maxIndex = index
		}
	}

	othersAdd = 0
	for index, value := range nums {
		if maxIndex == index {
			continue
		}
		othersAdd += value
	}
	return max, othersAdd
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <queue>
#include <cstdio>
#define INF 999999999
using namespace std;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void shortestPath(const Graph &g, int s,
    vector<Weight> &dist, vector<int> &prev) {
  int n = g.size();
  dist.assign(n, INF); dist[s] = 0;
  prev.assign(n, -1);
  priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
  for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top(); Q.pop();
    if (prev[e.dst] != -1) continue;
    prev[e.dst] = e.src;
    for(auto &f:g[e.dst]) {
      if (dist[f.dst] > e.weight+f.weight) {
        dist[f.dst] = e.weight+f.weight;
        Q.push(Edge(f.src, f.dst, e.weight+f.weight));
      }
    }
  }
}

int main(){
	int H,W;
	cin>>H>>W;
	vector<string>v(H);
	for(int i=0;i<H;i++)cin>>v[i];
	vector<int>soldiers;
	int start,princess=-1;
	Graph g(H*W);
	for(int i=0;i<H;i++)for(int j=0;j<W;j++){
		if(v[i][j]=='#')continue;
		int x=i*W+j,y,f;
		if(v[i][j]=='%')start=x;
		if(v[i][j]=='@')princess=x;
		if(v[i][j]=='$')soldiers.push_back(x);
		if(i<H-1){
			y=(i+1)*W+j;
			if(v[i+1][j]!='#')g[x].push_back(Edge(x,y,1)),g[y].push_back(Edge(y,x,1));
		}
		if(j<W-1){
			y=i*W+j+1;
			if(v[i][j+1]!='#')g[x].push_back(Edge(x,y,1)),g[y].push_back(Edge(y,x,1));
		}
	}
	vector<Weight> dist;
	vector<int> prev;
	shortestPath(g,start,dist,prev);
	Weight sol=INF;
	for(int e:soldiers)sol=min(sol,dist[e]);
	puts(dist[princess]<sol ? "Yes" : "No");
}

Measured memory_bytes: 6608
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<queue>
#include<set>
#include<algorithm>
typedef long long ll;
#define INT 0x4f4f4f4f
using namespace std;
inline long long read()
{
    long long x=0,f=1;char a=getchar();
    while(a<48||a>57){if(a=='-')f=-f;a=getchar();}
    while(a>47&&a<58){x=10*x+(a-48);a=getchar();}
    return f*x;
}

int main()
{
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    set<int>a;
    int x;
    while(n--)
    {
        cin>>x;
        if(a.count(x))
            a.erase(x);
        else
            a.insert(x);
    }
    printf("%d",a.size());
    return 0;
}


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

int main(){
  long int n, m, l, A[100][100], B[100][100], C[100][100] = {};
  cin >> n >> m >> l;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      cin >> A[i][j];
    }
  }
  for(int i = 0; i < m; i++){
    for(int j = 0; j < l; j++){
      cin >> B[i][j];
    }
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      for(int k = 0; k < l; k++){
        C[i][k] += A[i][j] * B[j][k];
      }
    }
  }
  for(int i=0;i<n;i++){
				for(int j=0;j<l;j++){
					if(j!=l-1)cout<<C[i][j]<<" ";
					else cout<<C[i][j]<<endl;
				}
			}
			return 0;
}



Measured memory_bytes: 3300
import heapq
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

i=j=k=0
HQ = []
heapq.heapify(HQ)
heapq.heappush(HQ,(-(A[i]+B[j]+C[k]),(i,j,k)))
alreadyAdded = set()
alreadyAdded.add((i,j,k))
for _ in range(K):
    valueNeg,index = heapq.heappop(HQ)
    print(-valueNeg)
    l,m,n = index
    nextIndex = []
    if l+1 < X:
        nextIndex.append((l+1,m,n))
    if m+1 < Y:
        nextIndex.append((l,m+1,n))
    if n+1 < Z:
        nextIndex.append((l,m,n+1))
    for l,m,n in nextIndex:
        if (l,m,n) not in alreadyAdded:
            heapq.heappush(HQ,(-(A[l]+B[m]+C[n]),(l,m,n)))
            alreadyAdded.add((l,m,n))

Measured memory_bytes: 5232
//
// Created on 2020/07/25.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int a,b,c;
    cin>>a>>b>>c;
    int k;
    cin>>k;
    for (int i = 0; i <= k; ++i) {
        for (int j = 0; j <= k - i; ++j) {
                int l = k - (i + j);
                int red,green,blue;
                red = a;
                green = b;
                blue = c;
                red = red * (int)pow(2,i);
                green = green * (int)pow(2,j);
                blue = blue * (int)pow(2,l);
                if(green > red && blue > green){
                    cout<<"Yes"<<endl;
                    return 0;

                }
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 4020
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;

int main(){

	int N,left = 1,right = 1,length,ans = 0;

	scanf("%d",&N);

	if(N==1){
		printf("1\n");
		return 0;
	}

	int* RIGHT = new int[N];
	int* LEFT  = new int[N];
	int* LOC_R = new int[N];
	int* LOC_L = new int[N];
 	for(int i = 0; i < N; i++){
		RIGHT[i] = 0;
		LEFT[i] = 0;
	}

	char* buf = new char[N+1];
	scanf("%s",buf);

	for(length = 0; buf[length] != '\0'; length++){
		if(buf[length] == '>'){
			RIGHT[length] = right;
			LOC_R[right] = length;
			right++;
		}
	}
	for(int i = 1; i < length; i++){
		if(RIGHT[i] == 0)RIGHT[i] = RIGHT[i-1];
	}

	for(int i = length-1; i >= 0; i--){
		if(buf[i] == '<'){
			LEFT[i] = left;
			LOC_L[left] = i;
			left++;
		}
	}
	for(int i = length-2; i >= 0; i--){
		if(LEFT[i] == 0)LEFT[i] = LEFT[i+1];
	}

	for(int i = 0; i < length; i++){
		if(buf[i] == '>'){
			if(i == length-1){
				ans = max(ans,1);
			}else{
				if(RIGHT[i] > LEFT[i+1]){
					ans = max(ans,N-(LOC_R[RIGHT[i]-LEFT[i+1]]));
				}else{
					ans = max(ans,LOC_L[LEFT[i]+1-RIGHT[i]]+1);
				}
			}
		}else{
			if(i == 0){
				ans = max(ans,1);
			}else{
				if(RIGHT[i-1] >= LEFT[i]){
					ans = max(ans,N-(LOC_R[RIGHT[i]+1-LEFT[i]]));
				}else{
					ans = max(ans,LOC_L[LEFT[i]-RIGHT[i]]+1);
				}
			}
		}
	}

	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 3964
#1. input
n = int(input())
a = list(map(int, input().split()))

#2. make distance list
a.append(0)
a.insert(0,0)
costs = []

for i in range(n+1):
    costs.append(abs(a[i+1]-a[i]))

#3. calculate each cost
total = sum(costs)
for i in range(n):
    print(total - costs[i] - costs[i+1] + abs(a[i+2]-a[i]))

Measured memory_bytes: 14048
main = do
  [a,b] <- map read . words <$> getLine :: IO [Int]
  let
    g1 = [1,3,5,7,8,10,12]
    g2 = [4,6,9,11]
    g3 = [2]
    inG1 = a `elem` g1 && b `elem` g1
    inG2 = a `elem` g2 && b `elem` g2
    inG3 = a `elem` g3 && b `elem` g3
  putStrLn $ if inG1 || inG2 || inG3 then "Yes" else "No"

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
#define inf 1000000000
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back

ll x, ans;

ll solve(ll a){
if(a<=0) return 0;
if(a<=6) return 1;
else if(a<=11) return 2;

else return (a/11)*2;

}


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

cin >> x;

ll temp = x%11;
if(x<12)temp=0;

ans = solve(x) + solve(temp);

cout << ans << endl;


return 0;}


Measured memory_bytes: 256
// #include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
 
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}
     
 //using namespace __gnu_pbds;
 //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
// mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); for randomized solution
vector<int> v[2000+1];
int fin[2001];
void bfs(int u,int n)
{
	bool vis[n+1];
	memset(vis,false,sizeof(vis));
	int dis[n+1];
	memset(dis,0,sizeof(dis));
	queue<int> q;
	q.push(u);
	vis[u]=1;
	while(!q.empty())
	{
		int u=q.front();
		q.pop();
		for(auto i:v[u])
		{
			if(vis[i])
				continue;
			dis[i]=dis[u]+1;
			vis[i]=1;
			q.push(i);
		}
	}
	for(int i=1;i<=n;i++)
		fin[dis[i]]++;
}
int32_t main()
{
    IOS
    
        
    int n,x,y;
    cin>>n>>x>>y;
    for(int i=1;i<=n;i++)
    {
    	v[i].push_back(i+1);
    	v[i+1].push_back(i);
    }
    v[x].push_back(y);
    v[y].push_back(x);
    memset(fin,0,sizeof(fin));
    for(int i=1;i<=n;i++)
    {
    	bfs(i,n);
    }
    for(int i=1;i<=n-1;i++)
    	cout<<fin[i]/2<<endl;

}       


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

inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;}

using namespace std;

const int maxn = 1e5 + 50;

int n , m , a[maxn] , cr = 0;
long long ans[maxn] , Add[maxn] , Del[maxn] , Cntadd[maxn] , Cntdel[maxn] , FixAdd[maxn] , FixDel[maxn];

int main( int argc , char * argv[] ){
	n = read() , m = read();
	for(int i = 1 ; i <= n ; ++ i){
		a[i] = read();
		-- a[i];
	}
	for(int i = 1 ; i < n ; ++ i){
		int x = a[i] , y = a[i + 1];
		int c1 = ( y - x + m ) % m;
		if( c1 == 0 ){
			continue;
		}else if( c1 == 1 ){
			++ cr;
			continue;
		}
		int st = a[i + 1] - (c1 - 1);
		if( st < 0 ){
			st += m;
			Add[0] += (a[i+1]+1);
			Del[a[i+1]] += (a[i+1]+1);
			Cntadd[0] += 1;
			Cntdel[a[i+1]] += 1;

			Add[st] += (m);
			Del[m-1] += (m);
			Cntadd[st] += 1;
			Cntdel[m-1] += 1;
			FixAdd[st] += a[i + 1] + 1;
			FixDel[m - 1] += a[i + 1] + 1;

			if( a[i + 1] + 1 <= st - 1 ){
				FixAdd[a[i + 1] + 1] += c1;
				FixDel[st - 1] += c1;
			}
		}else{
			Add[st] += (a[i+1]+1);
			Del[a[i+1]] += (a[i+1]+1);
			Cntadd[st] += 1;
			Cntdel[a[i+1]] += 1;
			if( st ){
				FixAdd[0] += c1;
				FixDel[st - 1] += c1;
			}
			if( a[i + 1] + 1 < m  ){
				FixAdd[a[i + 1] + 1] += c1;
				FixDel[m - 1] += c1;
			}
		}
	}
	for(int i = 0 ; i < m ; ++ i)
		ans[i] = cr;
	long long sum = 0 , cnt = 0 , KS = 0;
	for(int i = 0 ; i < m ; ++ i){
		sum += Add[i] , cnt += Cntadd[i] , KS += FixAdd[i];
		ans[i] += (sum - 1LL * cnt * i + KS);
		sum -= Del[i] , cnt -= Cntdel[i] , KS -= FixDel[i];
	}
	long long Mi = 1LL << 60;
	for(int i = 0 ; i < m ; ++ i)
		Mi = min( Mi , ans[i] );
	printf( "%lld\n" , Mi );
	return 0;
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll x; cin >> x;
  cout << x + x*x + x*x*x;
}


Measured memory_bytes: 3608
<?php
ini_set("memory_limit", "-1");
fscanf(STDIN, "%d", $num_count);
$target_num = array_map("intval", explode(" ", trim(fgets(STDIN))));
$count = 0;
merge_sort(0, $num_count);

echo implode(" ", $target_num), "\n";
echo $count, "\n";

function merge($left, $mid, $right) {
    global $target_num, $count;
    
    $n1 = $mid - $left;
    $L = [];
    for ($i = 0; $i < $n1; $i++) {
        $L[] = $target_num[$left+$i];
    }
    $L[$n1] = PHP_INT_MAX;

    $n2 = $right - $mid;
    $R = [];
    for ($i = 0; $i < $n2; ++$i) {
        $R[] = $target_num[$mid+$i];
    }
    $R[$n2] = PHP_INT_MAX;

    $i = 0;
    $j = 0;
    for ($k = $left; $k < $right; $k++) {
        if ($L[$i] <= $R[$j]) {
            $target_num[$k] = $L[$i];
            $i++;
        } else {
            $target_num[$k] = $R[$j];
            $j++;
        }
        ++$count;
    }
}

function merge_sort($left, $right) {
    if ($left+1 < $right) {
        $mid = floor(($left + $right)/2);
        merge_sort($left, $mid);
        merge_sort($mid, $right);
        merge($left, $mid, $right);
    }
}



Measured memory_bytes: 167300
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	vector<bool> is_prime(55556,true);
	is_prime[0]=false;
	is_prime[1]=false;
	
	for(int i=2;i<=55555;i++){
		if(!is_prime[i])continue;
		for(int j=i*2;j<=55555;j+=i)is_prime[j]=false;
	}
	
	int N;
	cin>>N;
	
	vector<int> ans;
	for(int i=0;i<=55555;i++){
		if(i%10!=1)continue;
		if(!is_prime[i])continue;
		ans.push_back(i);
	}
	
	for(int i=0;i<N;i++){
		if(i!=0)cout<<' ';
		cout<<ans[i];
	}
	cout<<endl;
	
			
	
    return 0;
}


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

int main() {
  string t;
  cin >> t;
  
  for (int i = 0; i < (int)t.size(); i++) {
    if (t.at(i) == '?')
      t.at(i) = 'D';
  }
  
  cout << t << endl;
  
  return 0;
}

Measured memory_bytes: 3716