akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace  std;

void fnInput(vector<int> &rvnSort)
{
  int nMaxSiz;
  cin >> nMaxSiz;
  
  rvnSort.resize(nMaxSiz);
  for (int i = 0; i < nMaxSiz; i++)
    cin >> rvnSort[i];
}

void fnInsertionSort(vector<int> &rvnSort, int nGap, int &rnSortCnt)
{
  for (int nSorting = nGap; nSorting < rvnSort.size() ; nSorting++)
  {
    int nTrg = rvnSort[nSorting];
    int nSorted = nSorting - nGap;

    while (nSorted >= 0         &&
           nTrg < rvnSort[nSorted])
    {
      rvnSort[nSorted + nGap] = rvnSort[nSorted];
      nSorted -= nGap;

      rnSortCnt++;
    }
    rvnSort[nSorted + nGap] = nTrg;
  }
}

void fnShellSort(vector<int> &rvnSort, vector<int> &rvnGap, int &rnSortCnt)
{
  for (int nGap = 1; nGap <= rvnSort.size(); nGap = 3 * nGap + 1)
    rvnGap.push_back(nGap);
  
  for (int i = rvnGap.size() - 1; i >= 0; i--)
    fnInsertionSort(rvnSort, rvnGap[i], rnSortCnt);
}

void fnOutput(const vector<int> &cnrvnSort, const vector<int> &cnrvnGap, int nSortCnt)
{
  cout << cnrvnGap.size() << endl;

  for (int i = cnrvnGap.size() - 1; i >= 0; i--)
  {
    if (i != cnrvnGap.size() - 1) cout << " ";
    cout << cnrvnGap[i];
  }
  cout << endl;

  cout << nSortCnt << endl;

  for (int i = 0; i < cnrvnSort.size(); i++)
    cout << cnrvnSort[i] << endl;
}

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

  vector<int> vnSort;
  vector<int> vnGap;
  int nSortCnt = 0;

  fnInput(vnSort);
  fnShellSort(vnSort, vnGap, nSortCnt);
  fnOutput(vnSort, vnGap, nSortCnt);

  return 0;
}

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

long long s;

int main()
{
    scanf("%lld",&s);
    long long t=ceil(sqrt(s));
    printf("0 0 %lld %lld 1 %lld",t,t*t-s,t);
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
    int a,b,c=0;
    int i,l;
    
    scanf("%d%d",&a,&b);
    while(c<a){c=(2*b+1)*i;
    i++;
    l=i-1;}
    printf("%d",l);
    return 0;
    }


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
long long a[1010],b[1010],c[1010];
priority_queue<long long,vector<long long>,greater<long long>> bc,abc;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int i,j,x,y,z,k;
	cin >> x >> y >> z >> k;
	for(i=0;i<x;i++) cin >> a[i];
	for(i=0;i<y;i++) cin >> b[i];
	for(i=0;i<z;i++) cin >> c[i];
	for(i=0;i<y;i++){
		for(j=0;j<z;j++){
			if(bc.size()<k) bc.push(b[i] + c[j]);
			else if(bc.top()<b[i] + c[j]){
				bc.pop();
				bc.push(b[i] + c[j]);
			}
		}
	}
	vector<long long> v,w;
	while(bc.size()){
		v.push_back(bc.top());
		bc.pop();
	}
	for(i=0;i<x;i++){
		for(j=0;j<v.size();j++){
			if(abc.size()<k){
				abc.push(a[i] + v[j]);
			}else if(abc.top()<a[i] + v[j]){
				abc.pop();
				abc.push(a[i] + v[j]);
			}
		}
	}
	while(abc.size()){
		w.push_back(abc.top());
		abc.pop();
	}
	for(i=k-1;i>=0;i--){
		cout << w[i] << endl;
	}
}
	

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;

int main(){
	
	int a, b, c, x, y, ans=0;
	cin >> a >> b >> c;
	x=abs(a-b);
	y=abs(b-c);
	if(a==b && b==c){
		if(a%2==0){
			cout << -1 << endl;
		} else {
			cout << 0 << endl;
		}
	} else {
		while(x%2==0 && y%2==0){
			x/=2;
			y/=2;
			ans++;
		}
		cout << ans << endl;
	}

	return 0;
}


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

typedef long long ll;

int main()
{
  ll n,k,a;
  bool b[11]={};

  for(int i=0;i<11;i++)b[i]=true;

  cin>>n>>k;
  for(int i=0;i<k;i++){
    cin>>a;
    b[a]=false;
  }

  for(int c=n;;c++){
    ll tmp=c;
    bool flag=true;
    while(1){
      flag=flag&b[tmp%10];
      tmp/=10;
      if(tmp==0)break;
    }
    if(flag){
      cout<<c<<endl;
      break;
    }
  }

  return 0;
}


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

const int MAX_NUM = 100003;
bool prime[MAX_NUM + 1];

void make_prime_table(void) {
	int sqrt_max;

	fill(&prime[0], &prime[MAX_NUM], true);
	prime[0] = prime[1] = false;
	for (int i = 4; i <= MAX_NUM; i += 2) prime[i] = false;
	sqrt_max = (int)sqrt((double)MAX_NUM);
	for (int i = 2; i <= sqrt_max; i++) {
		if (prime[i]) {
			for (int j = i * i; j <= MAX_NUM; j += i)
				prime[j] = false;
		}
	}
}

int main(void) {
	int X;
	cin >> X;

	make_prime_table();
	if (X != 2 && X % 2 == 0) ++X;
	int ans = MAX_NUM;
	for (int i = X; i < MAX_NUM; ++i) {
		if (prime[i]) {
			ans = i;
			break;
		}
	}

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


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

typedef long long ll;
using namespace std;

typedef long double ldouble;

const ll MAXN = 1000001;

int n, sum = 1;
bool a[MAXN];

int f(int n){
    if(a[n] == true) return sum;
    a[n] = true;
    if(n % 2 == 1){
        sum += 1;
        return f(3 * n + 1);
    }else{
        sum += 1;
        return f(n / 2);
    }
}

int main()
{
    cin >> n;
    cout << f(n);
  	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    int x = n * 100 / 108;
    while (true) {
        int m = x * 108 / 100;
        if (m == n) {
            std::cout << x << std::endl;
            return 0;
        } else if (m - n >= 1) break;
        x++;
    }

    std::cout << ":(" << std::endl;

    return 0;
}


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

int main() {
	
	int n,m;
	cin >> n >> m;
	vector<vector<int>> s(m,vector<int>(n));
	vector<int> k(m),p(m);
	for(int i=0; i<m; i++){
		cin >> k.at(i);
		for(int j=0; j<k.at(i); j++) {
			int l;
			cin >> l;
			s.at(i).at(l-1)=1;
		}
	}
	
	for(auto &i:p) cin >> i;
	
	int cnt =0;
	for(int i=0; i<(1<<n); i++){
		vector<int> l(m);
		for(int j=0; j<n; j++){
			for(int q=0; q<m; q++){
				if(i&(1<<j)) {
					if(s.at(q).at(j)==1){
						l.at(q)++;
					}
				}
			}
		}
		bool flg=1;
		for(int q=0; q<m; q++){
			if(l.at(q)%2!=p.at(q)) flg=0; 
		}
		if(flg) cnt++;
	}
	cout << cnt << endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin>>n>>s;
  int c=0;
  for(int i=2;i<n;i++)
    if(s.at(i-2)=='A'&&s.at(i-1)=='B'&&s.at(i)=='C')
      c++;
  cout<<c<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    ios;
    int a,b,c;
    cin >> a >> b >> c;
    cout << (( (c - (a-b)) > 0)? (c - (a-b)) : 0);
    return 0;
}


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

public class ABC {
    private static void Main(string[] args) {
        var n = ReadInt();
        if (n < 3) { Console.WriteLine("0"); return; }
        var l = ReadIntsAsArrayAsc();
        Console.WriteLine(CountSuitableTriangle(0, 1, 2, 0, n, l));
    }

    private static int CountSuitableTriangle(int i, int j, int k, int count, int n, int[] l) {
        if ((l[i] + l[j] > l[k]) && (l[i] != l[j]) && (l[j] != l[k]) && (l[i] != l[k])) count++;
        if (k != n - 1) return CountSuitableTriangle(i, j, k + 1, count, n, l);
        else if (j != n - 2) return CountSuitableTriangle(i, j + 1, j + 2, count, n, l);
        else if (i != n - 3) return CountSuitableTriangle(i + 1, i + 2, i + 3, count, n, l);
        else return count;
    }

    private static int ReadInt() => int.Parse(Console.ReadLine().Trim());
    private static int[] ReadIntsAsArrayAsc() => Console.ReadLine().Trim().Split().Select(x => int.Parse(x)).OrderBy(x => x).ToArray();
}

Measured memory_bytes: 33476
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define gt getchar()
#define ll long long
#define File(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
inline int in()
{
	int k=0;char ch=gt;
	while(ch<'-')ch=gt;
	while(ch>'-')k=k*10+ch-'0',ch=gt;
	return k;
}
const int N=2e5+5;
const ll inf=1ll<<60;
ll a[N],as[N],x[N],y[N],xs[N],ys[N],L[N],R[N];
inline void cmin(ll &x,ll y){if(x>y)x=y;}
int main()
{
	int n=in();
	for(int i=1;i<=n;++i)a[i]=in(),x[i]=~a[i]&1,y[i]=a[i]<=2?2-a[i]:a[i]&1;
	for(int i=1;i<=n;++i)xs[i]=xs[i-1]+x[i],ys[i]=ys[i-1]+y[i],as[i]=as[i-1]+a[i];
	ll mn=L[0]=R[n]=0;
	for(int i=1;i<=n;++i)cmin(mn,as[i]-ys[i]),L[i]=mn+ys[i];
	mn=ys[n];
	for(int i=n-1;~i;--i)cmin(mn,as[n]-as[i]+ys[i]),R[i]=mn-ys[i];
	ll ans=mn=inf;
	for(int i=0;i<=n;++i)cmin(mn,L[i]-xs[i]),cmin(ans,R[i]+mn+xs[i]);
	printf("%lld\n",ans);
	return 0;
}


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

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

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/07/20  Problem: ABC 134 C / Link: http://abc134.contest.atcoder.jp/tasks/abc134_c  ----- */

template<typename Monoid>
struct SegmentTreeFastAry {
	using nd = typename Monoid::t;
	const int ARY_SIZE;
	vector<nd> node;
public:
	SegmentTreeFastAry(int n) : ARY_SIZE(n), node(2 * ARY_SIZE, Monoid::id()) {}
	void set_val(int i, const nd val) {
		i += ARY_SIZE; node[i] = val;
		while (i > 1) { i >>= 1;	node[i] = Monoid::merge(node[i << 1], node[(i << 1) + 1]); }
	}
	inline nd query(int l, int r) {
		if (l >= r) return Monoid::id(); nd vl = Monoid::id(), vr = Monoid::id();
		for (l += ARY_SIZE, r += ARY_SIZE; l != r; l >>= 1, r >>= 1) {
			if (l & 1) vl = Monoid::merge(vl, node[l++]); if (r & 1) vr = Monoid::merge(node[--r], vr);
		}	return Monoid::merge(vl, vr);
	}
};



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

	LL N; cin >> N;
	vector<LL> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}


	struct singleMax {
		using t = LL;
		static t id() { return -LINF; }
		static t merge(const t&l, const t&r) {
			return max(l, r);
		}
	};
	SegmentTreeFastAry<singleMax> seg(N + 2);

	FOR(i, 0, N)seg.set_val(i + 1, a[i]);

	FOR(i, 0, N) {
		LL ans = max(seg.query(1, i + 1), seg.query(i + 2, N + 1));
		cout << (ans) << "\n";
	}
	return 0;
}


Measured memory_bytes: 6272
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}


int main() {
    ll n;
    cin >> n;
    vector<ll>a(n+1);
    rep(i,n) cin >> a[i];
    sort(a.rbegin(),a.rend());
    int cnt = 0;
    int ans = 0;
    rep(i,n) {
        cnt++;
        if(a[i] != a[i+1]) {
            if(cnt%2 == 1) ans++;
            cnt = 0;
        }   
    }
    cout << ans << endl;
}

Measured memory_bytes: 4048
import java.io.*;
import java.util.*;
public class Main
{
  public static void main(String args[])throws IOException
  {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer(br.readLine());
    int s = Integer.parseInt(st.nextToken());
    int w = Integer.parseInt(st.nextToken());
    if(s>w)
    	System.out.println("safe");
    else
    	System.out.println("unsafe");
    	}
    	}
    

Measured memory_bytes: 32536
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define int long long
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define forn(b) for(int i = 0; i < b; i++)
#define rforn(b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
const ll mod = (ll)1e9 + 7;
    
signed main(){
    speed;
    int n, k; cin >> n >> k;
    vi v(n);
    forn(n) cin >> v[i];
    int ans = 0;
    for(int i = 0; i < n - 1; i++) {
        if(v[i] > k) {
            ans += v[i] - k;
            v[i] = k;
        }
        if(v[i] + v[i + 1] > k) {
            ans += (v[i] + v[i + 1]) - k;
            v[i + 1] = k - v[i];
        }
    }
    cout << ans;
}

Measured memory_bytes: 3992
n = int(input())
graph = [[] for _ in range(n)]
for i in range(n):
    in_list = list(map(int, input().split()))
    u = in_list[0]
    graph[u - 1] = in_list[2:]

d = [0 for _ in range(n)]
f = [0 for _ in range(n)]
time = 0

def dfs(now, prev, graph, d, f):
    if d[now] != 0:
        return d, f
    global time
    time += 1
    d[now] = time
    if not graph[now]:
        f[now] = time + 1
        time += 1
        return
    for k in graph[now]:
        if k - 1 == prev or d[k-1] !=0:
            continue
        dfs(k - 1, now, graph, d, f)
    else:
        time += 1
        f[now] = time
    return d, f



for i in range(n):
    d, f = dfs(i, 0, graph, d, f)
    print(i+1, d[i], f[i])



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

int n,a[100005][3],dp[100005][3];

int main() {
    scanf("%d",&n);

    for(int i=0;i<n;++i)    scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);
    dp[0][0] = a[0][0]; dp[0][1] = a[0][1]; dp[0][2] = a[0][2];


    for(int i=1;i<n;++i)
        for(int j=0;j<3;++j)
            dp[i][j] = max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]) + a[i][j];

//    for(int i=0;i<n;++i)
//        printf("%d %d %d\n",dp[i][0],dp[i][1],dp[i][2]);
    printf("%d",max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])));
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int k;
	string s;
	cin>>k>>s;
	if(k<LEN(s)){
		rep(i,k)cout<<s[i];
		cout<<"..."<<endl;
	}else{
		cout<<s<<endl;
	}
}

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

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

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

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;
const ll INF = 1e9 + 7;

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


/////////////////////////////////////////////////////////////////////////////////////////

int main(){
    ll n,m;
    cin >> n >> m;
    ll ans;

    if (n == 1 and m == 1) ans = 1;
    else if (n == 1) ans = m - 2;
    else if (m == 1) ans = n - 2;
    else{
        ans = (n - 2)*(m - 2);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
stack<int>st;
queue<int>q;
vector<int>v,v1,v2,v3;
set<int>stt;
set<int>::iterator set_it;
map<string,int>mp;
//initialy map er all index er value zero thake;
//map er jonno this pointer(->) use korte hoy
//akta value dakhar jonno staristics pointer(*) use  korte hoy
// one more value print korar jonno this pointer(->) use korte hoy (must be)
map<string,int>::iterator map_it;
long long int a[20007];
long long int i,j,k,l,m,n,cnt=0,sum=0,mx=0,mn=0;
string s,s1,s2;
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            for(k=1;k<=n;k++)
            {
                sum+=__gcd(__gcd(i,j),k);
            }
        }
    }
    cout<<sum<<endl;

    return 0;
}



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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = INF + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 1000 + 7;

int n, m;
string s[N];

bool read () {
	if (scanf("%d%d", &n, &m) != 2)
		return false;
	static char buf[N];
	forn(i, n){
		scanf("%s", buf);
		s[i] = buf;
	}
	return true;
}

int dp[N][N];

void solve() {	
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	forn(i, n) forn(j, m){
		if (i + 1 < n && s[i + 1][j] == '.') dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
		if (j + 1 < m && s[i][j + 1] == '.') dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % MOD;
	}
	printf("%d\n", dp[n - 1][m - 1]);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
	
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

	while(read()) {	
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; i++) cin >> h[i];
  sort(h.begin(), h.end());
  ll ans = 0;
  for (int i = 0; i < n - k; i++) ans += h[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
H, N = map(int, input().split())
spells = []
for i in range(N):
  A, B = map(int, input().split())
  spells.append({"attack":A, "cost":B})

# O(HN)
dp = [0]
for i in range(H):
  dp.append(2147483648)
  
for h in range(H):
  for spell in spells:
    index = min(h+spell["attack"], H)
    current_min_mp = dp[index] 
    new_mp = dp[h] + spell["cost"]
    if (new_mp < current_min_mp):
      dp[index] = new_mp

print(dp[-1])

Measured memory_bytes: 74244
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

H,W = inpl()
h,w = inpl()

print(H*W - (H*w+h*W-h*w))


Measured memory_bytes: 4332
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
	if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes";
	else cout<<"No";
}

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

#define int int_least64_t

int inner_ab(string const& s) {
  int n=s.size();
  int cnt=0;
  for (int i = 0; i+1 < n; ++i) {
    if (s[i]=='A' && s[i+1]=='B')
      ++cnt;
  }
  return cnt;
}

signed main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);

  int n; cin >> n;
  int ans=0;
  int Bx=0;
  int xA=0;
  int BA=0;
  {
    string s;
    for (int i = 0; i < n; ++i) {
      cin >> s;
      ans += inner_ab(s);
      if (s.front()=='B' && s.back()=='A')
        ++BA;
      else if (s.front()=='B')
        ++Bx;
      else if (s.back()=='A')
        ++xA;
    }
  }
  auto get_BA = [&]() {
                  if (BA) { --BA; return true; }
                  return false;
                };
  auto get_A = [&]() {
                 if (xA) { --xA; return true; }
                 return get_BA();
               };
  auto get_B = [&]() {
                 if (Bx) { --Bx; return true; }
                 return get_BA();
               };
  if (get_A()) {
    while (get_BA())
      ++ans;
    for (;;) {
      if (!get_B()) break;
      ++ans;
      if (!get_A()) break;
    }
  }
  cout << ans << '\n';
}



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

int main() {
    int i, j, k, n, x, count=0;

    cin >> n >> x;
    while(n!=0||x!=0){
    for(i=1;i<n-1;i++){
        for(j=i+1;j<n;j++){
            for(k=j+1;k<=n;k++){
                if(i+j+k==x){
                    count++;
                }
            }
        }
    }
    cout << count << endl;
    count = 0;
    cin >> n >> x;
    }

    return 0;
}


Measured memory_bytes: 3100
s = input()
t = input()
s_length = len(s)
t_length = len(t)

dp = [[0 for j in range(t_length+1)] for i in range(s_length+1)]
#dp[i][j] = s[:i]とt[:j]に置けるLCS
for i in range(s_length):
    for j in range(t_length):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j]+1
        else:
            dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1])

#print(dp)
#print(dp[s_length][t_length])

ans = ""
i = s_length
j = t_length
while i>0 and j > 0:
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        i -= 1
        j -= 1
        ans = s[i] + ans

print(ans)

Measured memory_bytes: 119900
from math import factorial


def cmb(n, r):
    if n-r < 0 or r < 0:
        return 0
    else:
        return factorial(n) // (factorial(r) * factorial(n - r))


def solve(n, k):
    if n == [] or sum(n) == 0:
        if k == 0:
            return 1
        else:
            return 0

    for i in range(len(n)):
        if n[i] != 0:
            break

    n = n[i:]

    l = len(n)
    ans = 0

    # n-1桁からKこ取る
    tmp1 = (9**k)*cmb(l-1, k)

    # 最上位から1つ（最上位の数以外）とる。
    tmp2 = (n[0]-1)*(9**(k-1))*cmb(l-1, k-1)

    # 最上位からその数をとる。
    if k > 1:
        tmp3 = solve(n[1:], k-1)
    elif k == 1:
        if len(n) == 1:
            tmp3 = 1
        else:
            tmp3 = solve(n[1:], k-1)
    else:
        tmp3 = 0

    ans = tmp1 + tmp2 + tmp3
    return int(ans)


n = list(map(int, input()))
k = int(input())

print(solve(n, k))


Measured memory_bytes: 38512
i=lambda t: list(map(int,t.split()))
l=i(input())
x=i(input())
y=i(input())
x.append(l[2])
y.append(l[3])
x.sort()
y.sort()
if l[3]-l[2]<1:
    print("War")
elif y[0]-x[l[0]]<1:
    print("War")
else:
    print("No War")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll= long long;
using ld= long double;
using P =pair<ll,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 sort(a) sort(ALL(a))//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 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define in(T, x) T x;cin >> x;//Tは型,xが入力値
#define vec(T,a,n,x) vector<T> a(n,x);
#define vec2(T,a,n,m) vector<vector<T>> a(n,vector<T>(m));
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define out(x) cout << x << endl//出力
#define bout(b) if(b){out("Yes");}else{out("No");}//真偽問題に対する出力
#define ain(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}//配列の宣言と入力
#define a2in(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}//2つの配列を同時宣言、入力

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }//dp表とかで最大値更新するやつ
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }//最小値更新


signed main(){
  in(ll,N);in(ll,K);
  ll inf=INF;
  vec(ll,dp,110000,inf);
  ain(ll,h,N);
  dp[0]=0;
  REP(i,N){
    FOR(j,1,K+1){
      chmin(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
    }
  }
  out(dp[N-1]);
   

}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(b>a)return 0;
	if(a==b)return 1;
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n,a[55],cnt[15],ans;
signed main(){
	cin>>n;
	cnt[0]++;
	rep(i,n){
		cin>>a[i];
		cnt[a[i]]++;
	}
	if(n>24){
		puts("0");
		return 0;
	}
	if(n>12){
		if(cnt[0]>=2||cnt[12]>=2){
			puts("0");
			return 0;
		}
		for(int i=1;i<=11;i++){
			if(cnt[i]>=3){
				puts("0");
				return 0;
			}
			
		}
		cout<<1<<endl;
		return 0;
	}
	if(cnt[12]>=2){
		puts("0");
		return 0;
	}
	rep(i,(1<<n)){	
		vector<int>v;
		rep(j,n){
			if((i>>j)&1)v.pb(a[j]);
			else v.pb(24-a[j]);
		}
		v.pb(0);
		v.pb(24);
		sort(all(v));
		int memo=24;
		rep(j,v.size()-1)memo=min(memo,v[j+1]-v[j]);
		ans=max(ans,memo);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import math
N,D = map(int,input().split())
X = []

#! /usr/bin/python2.7
#平方数判定
def try_square_root_naive(n):
    m = int(n**.5)
    return m if abs(m*m - n) < 1e-6 else None
 
  
for i in range(N):
  x = list(map(int,input().split()))
  X.append(x)

count = 0  
for i in range(N):
  for j in range(N):
    if(i < j):
      dist = 0
      for k in range(D):
        dist += (X[i][k] - X[j][k])*(X[i][k] - X[j][k])
      if(try_square_root_naive(dist) != None):
        count += 1
 
print(count)

Measured memory_bytes: 3064
#include <stdio.h>


int main()
{
	int a,b,c,d;
	int num;
	scanf("%d", &num);
	a = num / 1000;
	b = (num - a * 1000) / 100;
	c = (num - a * 1000 - b * 100) / 10;
	d = num % 10;

	if ((a == b)||(b==c)||(c==d)) {
		printf("Bad\n");
	}
	else {
		printf("Good\n");
	}
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define db double
#define ld long double
#define rep(i,n) for(ll i=0;i<n;i++)
#define rev(i,n) for(ll i=n;i>=0;i--)
#define rep_a(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define debug(x) do { std::cerr << #x << ": " << x << std::endl; } while (0);
#define debugg(x,y) do { std::cerr << #x << ": " << x << "  "<< #y << ": " << y << std::endl; } while (0);
#define debugggg(i,j,k,ans) std::cerr << #i << ": " << i << "  "<< #j << ": " << j <<#k << ": " << k <<#ans << ": " << ans << std::endl;
const long long mod = 998244353;
const long long MOD = 1000000007;
typedef vector<ll>              vll;
typedef vector<string>          vstr;
typedef vector<char>            vchar;
typedef vector<pair<ll,ll> >    vpll;
typedef set<ll>                 sll;
typedef set<string>             sstr;
typedef set<pair<ll,ll> >       spll;
typedef map<ll,ll>              mllll;
typedef map<string,ll>          mstrll;
typedef queue<ll>               qll;
map<ll,ll>mp; 
int solve()
{
  int n,w;cin>>n>>w;
  vll wt(n+1),v(n+1);
  rep(i,n){cin>>wt[i+1];cin>>v[i+1];}
  vector<vll>dp(w+1,vll(n+1,0));
  rep_a(i,1,w+1)
  {
    rep_a(j,1,n+1)
    {
      if(i>=wt[j])
      dp[i][j] = max(v[j] + dp[i-wt[j]][j-1] , dp[i][j-1]);
      else dp[i][j] = dp[i][j-1];
    }
  }
  ll ans = 0;
  rep(i,w+1)
  {
    ans = max(dp[i][n],ans);
  }
  cout<<ans<<endl;
  return 0;
}
 
int main()
{
  fast;
	/* #ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#else
	#endif */
	solve();
	/* #ifndef ONLINE_JUDGE
	cout<<"\nTime Elapsed: "<<1.0*clock()/ CLOCKS_PER_SEC <<" Sec\n";
	#endif */
	return 0;
}

Measured memory_bytes: 85164
#include<stdio.h>
long long dp[2][21];
int n,i,j,x;
int main(){
	scanf("%d",&n);
	for(i=0;i<=20;i++)dp[1][i]=0;
	scanf("%d",&x);
	dp[1][x]=1;
	for(i=0;i<n-2;i++){
		scanf("%d",&x);
		for(j=0;j<=20;j++){
			dp[i%2][j]=0;
			if(j+x<=20)dp[i%2][j]+=dp[(i+1)%2][j+x];
			if(j-x>=0)dp[i%2][j]+=dp[(i+1)%2][j-x];
		}
	}
	scanf("%d",&x);
	printf("%lld\n",dp[(n-1)%2][x]);
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define N 100005
int i,j,k,l,s,n,a[N][2],tot,dis[N];
long long m,ans;
char c[N];
/*map<int,int>ma;
int i,j,k,l,s,n,m,mex[N];
inline int work(int x) {
	ma.clear();
	ma[0]=1;
	for (int i=1;i<=x;i++) {
		s=0;
		for (int j=x-1;j>=x-i;j--) s^=mex[j];
		ma[s]=1;
	}
	for (int i=0;i<=x;i++) if (!ma[i]) return i;
} 
int main() {
	mex[0]=0;
	for (i=1;i<=30;i++) mex[i]=work(i);
	for (i=1;i<=30;i++) printf("%d %d %d\n",i,mex[i],i&(-i));
	
}*/
inline long long Mex(long long x) {
	return x&(-x);
}
inline void Insert() {
	l=strlen(c);
	int gt=1;
	for (int i=0;i<l;i++) {
		if (!a[gt][c[i]-48]) dis[a[gt][c[i]-48]=++tot]=dis[gt]+1;
		gt=a[gt][c[i]-48];
	}
}
int main() {
	scanf("%d%lld",&n,&m);
	tot=1;
	for (i=1;i<=n;i++) {
		scanf("%s",c);
		Insert();
	}
	for (int i=1;i<=tot;i++) for (int j=0;j<=1;j++) 
		if (!a[i][j]) 
			ans^=Mex(m-dis[i]);
	if (ans) puts("Alice");
	else puts("Bob");
}

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

string S;
long long counter=0;
int w=1;

int main()
{
    cin>>S;

    for (int i=0; i<S.size(); i++)
    {
        if (S[i]=='W')
        {
            counter=counter+i-(w-1);
            w++;
        }
    }

    cout<<counter<<endl;
}

Measured memory_bytes: 3748
/**
*    created: 21.06.2020 21:04:02
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcount(bit)
#define mod 1000000007
#define pi acos(-1.0)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    int l = 0;
    int r = 26;
    int p = 26;
    for (int i = 1; i <= 11; i++) {
        if (l < n && n <= r) {
            int t = n - l;
            // pで考える
            string s = "";
            int div = 1;
            int q = p / 26;
            while(q > 0) {
                rep(j,26) {
                    if (j*q < t && t <= (j+1)*q) {
                        s += (char)('a' + j);
                        t = t - j * q;
                        q /= 26; 
                    }
                }
            }
            cout << s << endl;
            return 0;
        }
        l = r;
        p *= 26;
        r += p;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
	int x, y, s;
	while (cin >> x >> y >> s) {
		if (x == 0 && y == 0 && s == 0) {
			break;
		}
		int ans = 0;
		for (int i = 1; i < s; i++) {
			int a = i;
			int b = s - i;
			int aa, bb;
			aa = (a * 100) / (100 + x);
			while (aa*(100 + x) / 100 <= a) {
				aa++;
			}
			aa--;
			bb = (b * 100) / (100 + x);
			while (bb*(100 + x) / 100 <= b) {
				bb++;
			}
			bb--;
			if (aa*(100 + x) / 100 != a || bb*(100 + x) / 100 != b) {
				continue;
			}
			int c = (int)(aa*(100 + y) / 100) + (int)(bb*(100 + y) / 100);
			ans = max(ans, c);
		}
		cout << ans << endl;
	}
	return 0;
}


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

#if DEBUG && !ONLINE_JUDGE
    #include "header.h"
#else
    #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
    return;
}
#define N 100005
int dp[N][3], a[N][3];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(20);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    preprocess();
    int n; cin>>n;
    rep(i,1,n+1) {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    memset(dp,0,sizeof dp);
    dp[1][0] = a[1][0];
    dp[1][1] = a[1][1];
    dp[1][2] = a[1][2];
    rep(i,2,n+1) {
        rep(j,0,3) {
            rep(k,0,3) {
                if(j==k) continue;
                dp[i][j] = max(dp[i][j], dp[i-1][k] + a[i][j]);
            }
        }
    }
    cout<<max(dp[n][0], max(dp[n][1], dp[n][2]))<<endl;
}



Measured memory_bytes: 2560
package main

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

func solution(n int, d [][2]int) string {
	out, c := 0, 0
	max := func(x, y int) int {
		if x > y {
			return x
		}
		return y
	}

	for i := range d {
		if d[i][0] == d[i][1] {
			c++
		} else {
			c = 0
		}
		out = max(out, c)
	}
	if out >= 3 {
		return "Yes"
	}
	return "No"
}

func main() {
	r := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(r, &n)
	d := make([][2]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &d[i][0], &d[i][1])
	}
	fmt.Println(solution(n, d))
}


Measured memory_bytes: 1844
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

long solve(long n, long k, std::vector<long>& hps)
{
  if (k >= n) return 0;
  std::sort(hps.begin(), hps.end());
  return std::accumulate(hps.begin(), hps.begin() + n - k, 0l);
}

int main()
{
  long n, k;
  std::cin >> n >> k;
  std::vector<long> hps(n);
  for (auto& h : hps) {
    std::cin >> h;
  }

  std::cout << solve(n, k, hps) << std::endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<stack>
using namespace std;
static const int N = 8;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
static const int NIL = -1;

int n, ans, M[N][N];//nは頂点数、Mは隣接行列
int color[N], d[N], f[N], tt; //color:状態,d:iの発見時刻,f:iの隣接リスト調査完了時刻,tt:時間
int nt[N];//uの隣の頂点をどこまで見たか記録

//u に隣接するvを番号順に取得
int next(int u){
    for(int v = nt[u]; v < n; v++){
//        cout << nt[u] << endl;
        nt[u] = v + 1;//uの隣の頂点をどこまで見たか記録
        if( M[u][v] ) return v;
    }
    nt[u] = 0;
    return NIL;
}

//スタックを用いた深さ優先探索
void dfs_visit(int r){
    for(int i = 0; i < n; i++) nt[i] = 0;

    stack<int> S;//訪問途中の頂点を退避するスタック
    S.push(r);
    color[r] = GRAY;
    d[r] = ++tt;

    while( !S.empty()){
        int u = S.top();//uが現在訪問中の頂点
        int v = next(u);
//        cout << u << " " << v << endl;
        if(v != NIL){//vがNULLではなかったら
            if(color[v] == WHITE){
                color[v] = GRAY;//訪問したらGRAYに
                d[v] = ++tt;
                S.push(v);
                bool flag = 1;
                for(int i = 0; i < n; i++){
                    if(color[i] != GRAY){
                        flag = 0;
                    }
                }
                if(flag){
                    ans++;
                }
            }
        }else{
            S.pop();//訪問完了したらSから退避しましょう
            color[u] = WHITE;//退避した場所は白に戻す
            f[u] = ++tt;
        }
    }
}

void dfs_init(){
    //初期化
    for(int i = 0; i < n; i++){
        color[i] = WHITE;
        nt[i] = 0;
    }
    tt = 0;

    //未訪問のuを始点として深さ優先探索
    dfs_visit(0);
    
}

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

    //隣接行列初期化
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            M[i][j] = 0;
        }
    }

    //隣接行列読み込み
    for(int i = 0; i < m; i++){
        scanf("%d %d", &a, &b);
        M[a-1][b-1] = 1;
        M[b-1][a-1] = 1;
    }
    ans = 0;
    dfs_init();

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    
    vector<long long> A(X), B(Y), C(Z);
    
    for (int i = 0; i < X; i++) cin >> A[i];
    for (int i = 0; i < Y; i++) cin >> B[i];
    for (int i = 0; i < Z; i++) cin >> C[i];
    
    vector<long long> AB;
    
    for (int i = 0; i < X; i++) {
        for (int j = 0; j < Y; j++){
            AB.push_back(A[i] + B[j]);    
        }
    }
    
    sort(AB.begin(), AB.end());
    reverse(AB.begin(), AB.end());
    
    vector<long long> ABC;
    
    for (int i = 0; i < min(K, (int)AB.size()); i++) {
        for (int j = 0; j < Z; j++){
            ABC.push_back(AB[i] + C[j]);    
        }
    }
    
    sort(ABC.begin(), ABC.end());
    reverse(ABC.begin(), ABC.end());
    
    for (int i = 0; i < K; i++) {
        cout << ABC[i] << endl;
    }
}

Measured memory_bytes: 43368
def calc(operand, x, y):
    if operand == '+':
        return int(x) + int(y)
    if operand == '-':
        return int(x) - int(y)
    if operand == '*':
        return int(x) * int(y)

p = []
p = input().split()
stack = []

for i in p:
    if i.isdigit() == True:
        stack.append(int(i))

    else:
        y = stack.pop()
        x = stack.pop()
        stack.append(calc(i, x, y))

print(stack[0])


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

ll dp[10005];
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,p; cin >> n >> p;
  bool allzero= true;
  REP(i,n){
      ll tmp; cin >> tmp;
      if(tmp%2)allzero = false;
  }
  if(allzero){
      if(p){
          cout << 0 << endl;
      }else{
          cout << (1ll<<n) << endl;
      }
  }else{
      cout << (1LL<<(n-1)) << endl;
  }

}

Measured memory_bytes: 256
import heapq


def dijkstra(start, n_nodes, edges):
    dist = [float("inf")] * n_nodes
    dist[start] = 0
    q = [(dist[start], start)]
    heapq.heapify(q)

    while q:
        d, i = heapq.heappop(q)
        if d > dist[i]:
            continue

        for w, j in edges[i]:
            if d + w < dist[j]:
                dist[j] = d + w
                heapq.heappush(q, (dist[j], j))

    return dist


def main():
    N = int(input())
    edges = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        edges[a].append((c, b))
        edges[b].append((c, a))

    Q, K = map(int, input().split())
    K -= 1
    query = []
    for _ in range(Q):
        x, y = map(int, input().split())
        x -= 1
        y -= 1
        query.append((x, y))
    dist = dijkstra(K, N, edges)
    for x, y in query:
        ans = dist[x] + dist[y]
        print(ans)


main()


Measured memory_bytes: 59752
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#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,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//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() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll X = 0,  K=0, D =0;
    cin(X);cin(K);cin(D);

    X = abs(X);

    //vll X(N);
    ll ans = 0;
    //REP(i,N) cin(X[i]);
    ll a = X / D;
    ll b = X % D;
    if(min(b, abs(b-D))!=b){
        b = abs(abs(X) - D*(a+1));
        a++;
        
    }
    if(a > K){ans = X - K*D;}
    if(a == K){ans = b;}
    if(a < K){
        int rem = K - a;
        if(rem%2==0) ans = b;
        if(rem%2!=0) ans = abs(b-D);

    }


    //本文



    //出力
    cout << ans << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

// ^= -> ビットごとの排他的論理和を計算する

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b, c; cin >> a >> b >> c;
	int now = c;
	for (int i = 0; i < 10; i++) {
		now = a * now - b;
		cout << now << endl;
	}
	return 0;
}

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

int main() {
    int N, T, A, ans = 0;
    double mi = 1e6;
    cin >> N >> T >> A;
    for(int i = 0; i < N; ++i) {
        int H;
        cin >> H;
        if(mi > abs(T - H * 0.006 - A)) {
            mi = abs(T - H * 0.006 - A);
            ans = i;
        }
    }
    cout << ans + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int ans=0;
    if(n>1) ans+=n*(n-1)/2;
    if(m>1) ans+=m*(m-1)/2;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define MAX_N 200
using namespace std;
int main(void){
  int h, w;
  char a[MAX_N][MAX_N];
  cin >> h >> w;
  for(int i = 1; i < h + 1; i++){
    for(int j = 1 ; j < w + 1; j++){
      cin >> a[i][j];
    }
  }
  for(int i = 0; i <= w + 1; i++) {
    a[0][i] = '#';
    a[h+1][i] = '#';
  }
  for(int i = 0; i <= h + 1; i++){
    a[i][0] = '#';
    a[i][w+1] = '#';
  }
  for(int i = 0; i <= h + 1; i++){
    for(int j = 0; j <= w + 1; j++){
      cout << a[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int j;
int dfs(){
  vector<int>a;
  int b=0,sum=0;
  if(isdigit(s[j])){
    while(isdigit(s[j]))b*=10,b+=s[j++]-'0';
    a.push_back(b/2+1);
  }
  else while(s[j]=='[')j++,a.push_back(dfs()),j++;
  sort(a.begin(),a.end());
  for(int i=0;i<=a.size()/2;i++)sum+=a[i];
  return sum;
}
int main(){
  int n;
  cin>>n;
  while(n--){
    cin>>s;j=0;
    cout<<dfs()<<endl;
  }
}

Measured memory_bytes: 3136
a,b,c=map(int,input().split())
if a%2==b%2 and b%2==c%2:
    print((2*max(a,b,c)-(a+b+c-max(a,b,c)))//2)
else:
    if a%2==b%2:
        d=a
        a=c
        c=d
    elif a%2==c%2:
        d=a
        a=b
        b=d
    b+=1
    c+=1
    print(1 + (2*max(a,b,c)-(a+b+c-max(a,b,c)))//2)

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int x = min(a, min(b, c));
  cin >> a >> b;
  int y = min(a, b);
  cout << x + y - 50 << endl;
}


Measured memory_bytes: 3100