akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#ifndef ONLINE_JUDGE
	#define W(x, y) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << y;
#else
	#define W(x, y)
#endif

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vll vector<pll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi acosl(-1)
#define ld long double
#define prime (1000000000 + 7)
#define INF 1000000000

using namespace std;
 
ld pot(ld b, ll e){
	ld res = 1;
	while (e){
		if(e&1){
			res *= b;
		}
		b *= b;
		e >>= 1;
	}
	return res;
}

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

	ll n;
	cin >> n;
	vl vet(n, -1);
	vector<vll> lista(n);
	for(int i = 1; i < n; ++ i){
		ll u, v, w;
		cin >> u >> v >> w;
		u--;
		v--;
		lista[u].push_back({w, v});
		lista[v].push_back({w, u});
	}

	queue<ll> fila;
	fila.push(0);
	vet[0] = 0;
	while (!fila.empty()){
		auto a = fila.front();
		fila.pop();
		for(auto&p: lista[a]){
			if(vet[p.ss] == -1){
				fila.push(p.ss);
				if(p.ff%2 == 0){
					vet[p.ss] = vet[a];
				} else {
					vet[p.ss] = vet[a] ^ 1;
				}
			}
		}
	}
	
	for(int i = 0; i < n; ++i){
		cout << vet[i] << "\n";
	}

	return 0;
}

// 2^x >= k/i

// s 		= 		p^1 + p^2 + p^3 + p^4 + ... + p^(n-1) + p^n
// s/p 		= p^0 + p^1 + p^2 + p^3 + p^4 + ... + p^(n-1)
// _____________________________________________________________
// s - s/p	= p^n - p^0
// s 		= (p^n - p^0)*p/(p - 1)


Measured memory_bytes: 8704
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws ParseException {
		FastScanner sc = new FastScanner();
		String S = sc.next();
		String[] array = S.split("");
		int count0 = 0;
		int count1 = 0;
		for(String s : array) {
			if("0".equals(s)) {
				count0++;
			}else {
				count1++;
			}
		}
		if(count0 == 0 || count1 == 0) {
			System.out.println(0);
		}else {
			if(count0 < count1) {
				System.out.println(count0 * 2);
			}else {
				System.out.println(count1 * 2);
			}
		}
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 30036
#include<bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
int L;
struct edge{
	int u,v,w;
	edge(int u=0,int v=0,int w=0):u(u),v(v),w(w){}
};
vector<edge> E;
int pw3(int n){
	int ret=1;
	REP(i,n){
		ret*=3;
	}
	return ret;
}
int main(){
	cin>>L;
	cout<<"14 ";
	int M=36;
	int cnt=0,l=0;
	while(L){
		REP(i,L%3){
			E.push_back(edge(1,14-cnt,l));
			l+=pw3(cnt);
			M++;
		}
		cnt++;
		L/=3;
	}
	cout<<M<<endl;
	REP(i,12){
		REP(j,3){
			cout<<2+i<<" "<<3+i<<" "<<j*pw3(11-i)<<endl;
		}
	}
	for(auto e:E){
		cout<<e.u<<" "<<e.v<<" "<<e.w<<endl;
	}
	return 0;
}

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

using namespace std;
int main(void){
	int n;
	cin>>n;
	vector<int> p(n);
	for(int i=0;i<n;i++){
		cin>>p[i];
	}
	int ans=0;
	for(int i=0;i<n;i++){
		if(i+1 == p[i]){

		}
		else{
			ans++;
		}
	}
	if(ans==0 || ans==2){
		cout<<"YES";
	}
	else{
		cout<<"NO";
	}

	return 0;
}


Measured memory_bytes: 256
s=input()
if int(s[:4])<2019:
  print("Heisei")
elif int(s[:4])>2019:
  print("TBD")
else:
  if s[5]=="0":
    if int(s[6])<5:
      print("Heisei")
    else:
      print("TBD")
  else:
    print("TBD")

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int N = 55;
bool a[N][33];
bool dp[33][N][N];

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	for (int n; cin >> n&&n;) {
		memset(a, 0, sizeof(a));
		memset(dp, 0, sizeof(dp));
		rep(i, 0, n) {
			int f; cin >> f;
			rep(j, 0, f) {
				int d; cin >> d;
				a[i][d] = true;
			}
			rep(j, 0, n) {
				dp[0][i][j] = false;
			}
			dp[0][i][i] = true;
		}
		int ans = -1;
		rep(i, 1, 31) {
			rep(j, 0, n)rep(k, 0, n)dp[i][j][k] = dp[i - 1][j][k];
			rep(j, 0, n) {
				if (!a[j][i])continue;
				rep(k, j + 1, n) {
					if (!a[k][i])continue;
					rep(l, 0, n) {
						dp[i][j][l] |= dp[i - 1][k][l];
						dp[i][k][l] |= dp[i - 1][j][l];
					}
				}
			}
			rep(j, 0, n) {
				bool complete = true;
				rep(k, 0, n) {
					if (!dp[i][j][k])complete = false;
				}
				if (complete) {
					ans = i;
					i = INF, j = INF;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long

using namespace std;
#define MAXN 100010
int X, Y, A, B, C;

ll a[MAXN];
ll b[MAXN];
ll c[MAXN];

int main()
{
	cin>>X>>Y>>A>>B>>C;
	for(int i = 1; i <= A; ++i)
		cin>>a[i];
	for(int i = 1; i <= B; ++i)
		cin>>b[i];
	for(int i = 1; i <= C; ++i)
		cin>>c[i];
	sort(a+1, a+A+1);
	sort(b+1, b+B+1);
	sort(c+1, c+C+1);
	vector<ll> v;
	for(int i = A; i > A - X; --i)
	{
		v.push_back(a[i]);
	}
	for(int i = B; i > B - Y; --i)
	{
		v.push_back(b[i]);
	}
	int cp = min(C, X+Y);
	for(int i = C; i > C - cp; --i)
	{
		v.push_back(c[i]);
	}
	sort(v.begin(), v.end());
	ll ans = 0;
	for(int i = int(v.size())-1; i >= int(v.size()) - (X+Y); --i)
	{
			ans += v[i];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 8432
import sys
import numpy as np 
from itertools import permutations

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n, C = I[:2]
cost = I[2:2+C**2].reshape(C, C)
color = I[2+C**2:].reshape(n, n) - 1

def main():
    mod_3 = (np.arange(1, n+1)[:, None] + np.arange(1, n+1)) % 3
    c0 = np.bincount(color[mod_3 == 0], minlength=C)
    c1 = np.bincount(color[mod_3 == 1], minlength=C)
    c2 = np.bincount(color[mod_3 == 2], minlength=C)

    r = np.arange(C)
    s0 = np.sum(cost[:, r] * c0[:, None], axis=0)
    s1 = np.sum(cost[:, r] * c1[:, None], axis=0)
    s2 = np.sum(cost[:, r] * c2[:, None], axis=0)

    ans = float('inf')
    for i, j, k in permutations(range(C), 3):
        res = s0[i] + s1[j] + s2[k]
        ans = min(ans, res)
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 34536
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

class Edge{
public:
    int to;
    long long cost;
    Edge(int v, long long c = 1): to(v), cost(c){}
    ~Edge(){}
    bool operator<(const Edge& e) const{return cost < e.cost;}
};

// Dijkstra's method
// solve minimum distances from root to each vertex
void Dijkstra(
        const std::vector<std::vector<Edge> >& edge,
        std::vector<long long>& dist,
        const int root = 0)
{
    using Pair = std::pair<long long, int>;
    const int V = edge.size();
    const long long infty = 1e+18;

    // initialize
    for(int i=0; i<V; i++) dist[i] = infty;

    std::priority_queue<Pair, std::vector<Pair>, std::greater<Pair> > pq;
    pq.emplace(0, root);

    // update
    while(!pq.empty()){
        long long d = pq.top().first;
        int tmp = pq.top().second;
        pq.pop();

        if(dist[tmp] <= d) continue; // not minimum
        dist[tmp] = d;

        for(const Edge& e: edge[tmp]) pq.emplace(dist[tmp] + e.cost, e.to);
    }
}

int main()
{
    int N, M;
    cin >> N >> M;
    Vvec<Edge> graph(N);
    for(int i=0; i<M; i++){
        int u, v; ll c;
        cin >> u >> v >> c; u--; v--;
        graph[u].emplace_back(v, c);
    }
    for(int i=0; i<N-1; i++) graph[i+1].emplace_back(i, 0);

    vector<ll> dist(N, 0);
    Dijkstra(graph, dist, 0);

    if(dist[N-1]>1e17) cout << -1 << endl;
    else cout << dist[N-1] << endl;
}

Measured memory_bytes: 10100
#include<cstdio>
typedef long long ll;
int main()
{
	int n;
	ll x,ans=0,t,pre;
	scanf("%d%lld",&n,&x);
	scanf("%lld",&pre);
	for(int i=2;i<=n;i++)
	{
		scanf("%lld",&t);
		if(t+pre>x)
		{
			ans+=(t+pre-x);
			t=x-pre;
			if(t<0) t=0;
		}
		pre=t;
	}
	printf("%lld\n",ans);
	return 0;
}

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

struct Node {
	int key;
	Node* left;
	Node* right;
	Node* par;
};

struct binarySearchTree {
	Node* root;

	binarySearchTree() {
		root = NULL;
	}

	void insert(int key);
	void inorderTreeWalk(Node* node);
	void preorderTreeWalk(Node* node);
};

void binarySearchTree::insert(int key) {
	Node* z = (Node*)malloc(sizeof(Node));
	z->key = key;
	z->left = z->right = z->par = NULL;

	if (root == NULL) {
		root = z;
		return;
	}

	Node* y = NULL;
	Node* x = root;

	while (x != NULL) {
		y = x;
		if (x->key>key) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}

	z->par = y;
	if (y->key>key) {
		y->left = z;
	}
	else {
		y->right = z;
	}
	return;
}

void binarySearchTree::inorderTreeWalk(Node* node) {
	if (node != NULL) {
		inorderTreeWalk(node->left);
		cout << " " << node->key;
		inorderTreeWalk(node->right);
	}
	return;
}

void binarySearchTree::preorderTreeWalk(Node* node) {
	if (node != NULL) {
		cout << " " << node->key;
		preorderTreeWalk(node->left);
		preorderTreeWalk(node->right);
	}
	return;
}

int main(void) {
	int n, x, i;
	string s;
	binarySearchTree tree;

	cin >> n;

	for (i = 0;i<n;i++) {
		cin >> s;
		if (s[0] == 'i') {
			cin >> x;
			tree.insert(x);
		}
		else {
			tree.inorderTreeWalk(tree.root);
			cout << endl;
			tree.preorderTreeWalk(tree.root);
			cout << endl;
		}
	}
	return 0;
}




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

int main () {
  long long N, M;
  cin >> N >> M;
  vector<long long>H(N);
  for (int i=0; i<N; i++) cin >> H.at(i);

  vector<long long>A(M);
  vector<long long>B(M);
  for (int i=0; i<M; i++) cin >> A.at(i) >> B.at(i);

  //for (int i=0; i<M; i++) cout << A.at(i) << B.at(i) << endl;

  vector<long long>checked(N, 1);
  for (int j=0; j<M; j++) {
    if (H.at(A.at(j)-1) <= H.at(B.at(j)-1)) checked.at(A.at(j)-1) = 0;
  }

  for (int j=0; j<M; j++) {
    if (H.at(B.at(j)-1) <= H.at(A.at(j)-1)) checked.at(B.at(j)-1) = 0;
  }

  int count = 0;
  for (int i=0; i<N; i++) {
    if (checked.at(i) == 1) count++;
  }

  cout << count << endl;
}

Measured memory_bytes: 6404
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

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

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;



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

    double p = 0.0;
    for (int i = 0; i < N; i++) {
        p+=a[i]*1.0;
    }
    p/=1.0*N;

    int res=0;
    double diff=(double)INF;
    for (int i = 0; i < N; i++) {
        if(diff>abs(p-1.0*a[i])){
            diff=abs(p-1.0*a[i]);
            res=i;
        }
    }

    cout<<res<<endl;

    return 0;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    string s;
    cin >> n >> s;
    int black = 0, ans = 0;
    for(auto i : s){
        if(i == '#') black++;
        else if(black > 0){
            black--;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>

#define ll long long int

using namespace std;

const int INF = (1<<30) - 1;

//lh, lw, rh, rw
typedef tuple<int, int, int, int> State;

int dh[] = {0, 1, 0, -1};
int dw[] = {1, 0, -1, 0};

int dp[50][50][50][50];

bool solve(vector<string> &L, vector<string> &R){
    int H = L.size();
    int W = L[0].size();
    
    memset(dp, 0, sizeof(dp));
    queue<State> que;
    
    int lh, lw, rh, rw;
    int glh, glw, grh, grw;
    for(int h=0; h<H; h++){
        for(int w=0; w<W; w++){
            if(L[h][w] == 'L'){
                lh = h; lw = w;
            }else if(L[h][w] == '%'){
                glh = h; glw = w;
            }
        }
    }
    for(int h=0; h<H; h++){
        for(int w=0; w<W; w++){
            if(R[h][w] == 'R'){
                rh = h; rw = w;
            }else if(R[h][w] == '%'){
                grh = h; grw = w;
            }
        }
    }
    auto start = State(lh, lw, rh, rw);
    dp[lh][lw][rh][rw] = true;
    que.push(start);
    
    while(!que.empty()){
        tie(lh, lw, rh, rw) = que.front(); que.pop();
        
        for(int i=0; i<4; i++){
            int nlh = lh + dh[i], nlw = lw + dw[i];
            int nrh = rh + dh[i], nrw = rw + dw[i] * -1;
            
            if(nlh<0 || H<=nlh || nlw<0 || W<=nlw || L[nlh][nlw]=='#'){
                nlh = lh; nlw = lw;
            }
            if(nrh<0 || H<=nrh || nrw<0 || W<=nrw || R[nrh][nrw]=='#'){
                nrh = rh; nrw = rw;
            }
            
            State next = State(nlh, nlw, nrh, nrw);
            
            if(nlh == glh && nlw == glw && nrh == grh && nrw == grw)
                return true;
            
            if(!dp[nlh][nlw][nrh][nrw] && (nlh!=glh || nlw!=glw) && (nrh!=grh || nrw!=grw)){
                dp[nlh][nlw][nrh][nrw] = true;
                que.push(next);
            }
        }
    }
    return false;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int H, W;
    while(cin>>W>>H, H|W){
        vector<string> L(H), R(H);
        for(int i=0; i<H; i++)
            cin >> L[i] >> R[i];
        
        cout << (solve(L, R) ? "Yes" : "No") << endl;
    }
    
    return 0;
}

Measured memory_bytes: 26572
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k;
    cin >> k;
    string s;
    cin >> s;
    if((int)s.size()<=k){
        cout << s << endl;
    }else{
        cout << s.substr(0,k) << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3656
N=int(input())
X=[list(map(int,input().split())) for i in range(N)]
def solve(p,q):
  global N,X
  r=0
  for i in range(N):
    for j in range(N):
      if X[i][0]+p==X[j][0] and X[i][1]+q==X[j][1]:
        r-=1
  return r

P=0
for i in range(N):
  for j in range(i+1,N):
    P=min(P,solve(X[j][0]-X[i][0],X[j][1]-X[i][1]))
print(N+P)

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

int main() {
  int n, W;
  cin >> n >> W;
  vector<int> w(n);
  vector<int> v(n);
  rep(i, n) cin >> w[i] >> v[i];

  vector<vector<ll>> dp(n + 1, vector<ll>(100'001, 100'000'000'000));
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 100'000; j++) {
      if (v[i -1] >= j){
        dp[i][j] = min((ll)w[i-1], dp[i-1][j]);
      } else{
        dp[i][j] = min(dp[i-1][j], dp[i-1][j - v[i -1]]+w[i-1]);
      }

      if(dp[i][j] != 100'000'000'000 && dp[i][j] <=W){
        ans = max(ans,j);
      }
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 80256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
#define MOD 1000000007
//scanf("%d", &a) '\n'

int main() {
	string s;
	cin >> s;
	int ans = 0;
	string t = s;
	reverse(t.begin(), t.end());
	rep(i,s.size()){
		if (s[i] != t[i]) ++ans;
	}
	cout << ans / 2 << endl;
}
	

Measured memory_bytes: 256
import           Data.List  (find)
import           Data.Maybe (fromJust)

main :: IO ()
main = print . solve . map fromChar =<< getLine

data Cube =
    Red
  | Blue
  deriving (Eq)

fromChar :: Char -> Cube
fromChar '0' = Red
fromChar '1' = Blue
fromChar _   = error "unexpected character"

solve :: [Cube] -> Int
solve = (-) . length <*> length . fromJust . convergence . iterate annihilate

annihilate :: [Cube] -> [Cube]
annihilate = foldr f []
  where
    f Red  (Blue : cs) = cs
    f Blue (Red : cs)  = cs
    f c    cs          = c : cs

convergence :: Eq a => [a] -> Maybe a
convergence = fmap fst . find (uncurry (==)) . (zip <*> tail)


Measured memory_bytes: 13692
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main(){
    int h,w,n;
    int ans =0;
    cin >>h>>w>>n;
    if (h>w && n%h!=0) ans =n/h+1;
    else if(h>w && n%h==0) ans =n/h;
    else if (w>=h && n%w !=0) ans =n/w+1;
    else ans = n/w;
    cout << ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if((a * b) % 2 == 0) {
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long ll;

int main()
{

    char s[6];
    scanf("%s",s);
    int flag=0;

    if(s[2]!=s[3])
    {
        flag=1;
    }
    if(s[4]!=s[5])
    {
        flag=1;
    }

    if(flag==0)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define vi vector <int>
#define endl "\n"
#define vvi vector <vector<int> >
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>=b;i--)
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define gcd __gcd
#define init(i,k) memset(i,k,sizeof i)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define setBits(x) __builtin_popcountll(x)
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define N 100005
vector<int>dp(N,-1);
vector<int> adj[N];
int dfs(int x)
{
	if(dp[x]!=-1)
	{
		return dp[x];
	}
	int len=0;
	for(int i=0;i<adj[x].size();i++)
	{
		int c=dfs(adj[x][i]);
		len=max(len,c);
	}
	len=len+1;
	dp[x]=len;
	return len;
}
int solve()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		adj[x].push_back(y);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(dp[i]==-1)
		{
			dp[i]=dfs(i);
		}
		//cout<<i<<" "<<dp[i]<<endl;
		ans=max(ans,dp[i]);
	}
	return ans-1;
}
signed main()
{
    int t=1;
    //cin>>t;
    while(t--)
    {
    	cout<<solve()<<endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
	int x, a, b;
	cin >> x >> a >> b;
	if (b - a <= 0)
		cout << "delicious" << endl;
	else if (b - a > x)
		cout << "dangerous" << endl;
	else
		cout << "safe" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n;
    cin >> n;
    ll sum = 1;
    ll add = 1;
    while(n > sum){
        add++;
        sum += add;
    }
    ll sa = sum - n;
    rep(i, add){
        if(i + 1 == sa) continue;
        print(i + 1);
    }



}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	int a, b;
	cin >> a >> b;
	cout << 100 << ' ' << 100 << '\n';
	vector<vector<char>> ans(100, vector<char>(100, '.'));
	a--;
	int x = 3, y = 3;
	rep(i, a) {
		rep(j, 4) ans[x - j][y] = '#';
		rep(j, 4) ans[x][y - j] = '#';
		y += 4;
		if (y == 103) {
			x += 4; y = 3;
		}
	}
	if (a) b--;
	x = 1, y = 1;
	rep(i, b) {
		ans[x][y] = '#';
		y += 4;
		if (y == 101) {
			x += 4; y = 1;
		}
	}
	rep(i, 100) {
		rep(j, 100) {
			cout << ans[i][j];
		}
		cout << '\n';
	}
}

Measured memory_bytes: 256
// AOJ 409 Floor
// 2019.9.29

#include <stdio.h>

#define MIN(a,b) ((a)<=(b)?(a):(b))
#define MAX(a,b) ((a)>=(b)?(a):(b))
typedef struct { int x1, y1, x2, y2; } Rect;
Rect a1, a2, a;

int main()
{
	int x, y, id;

	scanf("%d%d", &x, &y);
	if (x == 0 && y == 0) puts("1");
	else if (x == 1 && y == 0) puts("2");
	else {
		a2.x1 = a2.x2 = 1, id = 2;
		while (1) {
			if ((id & 1) == 0) { // 北 or 南
				a.x1 = MIN(a1.x1, a2.x1), a.x2 = MAX(a1.x2, a2.x2);
				if (id % 4 == 2) { // 北
					a.y1 = a2.y2 + 1, a.y2 = a.y1 + a.x2-a.x1;
				} else {
					a.y2 = a2.y1 - 1, a.y1 = a.y2 - (a.x2-a.x1);
				}
			} else {
				a.y1 = MIN(a1.y1, a2.y1), a.y2 = MAX(a1.y2, a2.y2);
				if (id % 4 == 1) { // 東
					a.x1 = a2.x2 + 1, a.x2 = a.x1 + a.y2-a.y1;
				} else {
					a.x2 = a2.x1 - 1, a.x1 = a.x2 - (a.y2-a.y1);
				}
			}

	
			if (a.x1 <= x && x <= a.x2 && a.y1 <= y && y <= a.y2) {
				printf("%d\n", id%3+1);
				break;
			}
	
			id++;
			a1 = a2, a2 = a;
		}
	}
	return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define loop(x) for(int i=0;i<x;i++)
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define dd fflush(stdout)
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mt make_tuple //use tie
#define eb emplace_back
typedef tuple<int,int,int> State;//use in dijkstra

// ll power(ll x,ll y,ll mod){
//  ll ans=1;
//  while(y>0){
//   if(y&1){
//     ans=ans*x;
//   }
//   x=x*x;
//   y=y/2;
//  }
//  return ans;
// }
 
int main(){
    IOS;
   int t;
    int n;
   
    cin>>n;
     ll a[n+2];
    ll dp[n+2];
    loop(n)cin>>a[i+1];
    dp[0]=0;
    dp[1]=0;
    ll  x,y;
    for(int i=2;i<=n;i++){
      x=dp[i-1]+labs(a[i]-a[i-1]);
      y=dp[i-2]+labs(a[i]-a[i-2]);
      if(i==2)
        dp[i]=x;
      else
        dp[i]=min(x,y);
    }
    cout<<dp[n]<<endl;
}

 



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

int main(){
	char a[4], b[4];
	scanf("%s%s", a, b);
	swap(a[0], a[2]);
	int f = 0;
	for(int i = 0;i < 3;i++)if(a[i] != b[i])f = 1;
	if(f == 0)printf("YES\n");
	else printf("NO\n");
	return 0;
}

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

int main(){
    int r, g, b, n;
    //cin >> r >> g >> b >> n;
    scanf("%d%d%d%d", &r, &g, &b, &n);

    int count = 0;
    for(int i = 0; i <= 3000; i++){
        if(r*i > n){
            break;
        }
        /*
        else if(r*i == n){
            count++;
            break;
        }
        */
        for(int j = 0; j <= 3000; j++){
            if(i*r + j*g > n){
                break;
            }
            int k = n - i*r - j*g;
            if(k % b == 0){
                count++;
            }

            /*
            else if(i*r + j*g == n){
                count++;
                break;
            }
            */

           /*
            for(int k = 0; k <= 3000; k++){
                int p = 0;
                if(i*r + j*g + k*b > n){
                    break;
                }
                else if(i*r + j*g + k*b == n){
                    count++;
                    break;
                }
                else {
                    p = n - i*r -j*g;

                }
            }
            */
        }
    }

    printf("%d\n", count);
}

Measured memory_bytes: 256
import sys, math
from functools import lru_cache
import heapq
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    A, B = i2(N)
    ans = 0

    C = [(a + b, i) for a, b, i in zip(A, B, range(N))]
    C.sort(reverse=True)

    for i in range(N):
        k = C[i][1]
        if i%2==0:
            ans += A[k]
        else:
            ans -= B[k]

    print(ans)


if __name__ == '__main__':
    main()


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

int main(){
    vector<int> N(3);
    for (int i=0; i<N.size(); i++) {
        cin>>N.at(i);
    }
    sort(N.begin(),N.end());
    cout<<N.at(2)*10 + N.at(0) + N.at(1)<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
typedef long long LL;
using namespace std;
int main()
{
    LL A,B,K,cnt=0;
    scanf("%lld%lld%lld",&A,&B,&K);
    for(LL i=A;i>=1;i--)
    {
        if(A%i==0&&B%i==0)
            cnt+=1;
        if(cnt==K)
        {
            printf("%lld\n",i);
            return 0;
        }
    }
}

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

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    
    ll n;
    cin >> n ;
    vector<ll> V;
    map<ll, ll> M;
    for (ll i = 0; i < n; ++i) {
        ll num;
        cin >> num;
        V.push_back(num);
        M[num]++;
    }
    ll total = 0;
    for(auto it = M.begin(); it != M.end(); ++it) {
        ll k = it->second;
        total += k * (k - 1) / 2;      
    }
    for (ll i = 0; i < n; ++i) {
        ll k = M[V[i]];
        cout << total - (k-1) << "\n";
    }
    return 0;
}

Measured memory_bytes: 11120
h, w = map(int, input().split())
a = []

for _ in range(h):
    a.append(list(map(int, input().split())))

ans = []

for i in range(h):
    for j in range(w - 1):
        if a[i][j] % 2 == 1:
            ans.append([i + 1, j + 1, i + 1, j + 2])
            a[i][j + 1] += 1

for i in range(h - 1):
    if a[i][w - 1] % 2 == 1:
        ans.append([i + 1, w, i + 2, w])
        a[i + 1][w - 1] += 1

print(len(ans))
for ans in ans:
    print(*ans)


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

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

#define BIG_PRIME 1000000007
#define BP_remainder(x) ((x) % BIG_PRIME)

#define INF 0x3fffFFFF
#define INF_NEG (INF * -1)
#define INF_LONG 0x3fffFFFFffffFFFFL
#define INF_LONG_NEG (INF_LONG * -1L)

typedef long long ll;
typedef pair<ll, ll> lpair;
typedef char str255[256];
// char *用、strlen の ll 版
ll StrLen(char *s) { for(ll ptr = 0L;; ++ptr) if(!s[ptr]) return ptr; } 
// char * の後ろから n 文字削除, 削除後の文字数を返す
ll StrDel(char *s, int n) { ll l = StrLen(s); s[l - n + 1L] = '\0'; return l - n; }
// 正の整数の桁数
ll NumDigits(ll l){ char s[30]; sprintf(s, "%lld", l); return StrLen(s); }

int isFirst = 1;
template <class T> 
void print(T t) { if (isFirst) cout << t, isFirst = 0; else cout << " " << t; }

void chmin(ll& a, ll b) { if (a > b) a = b; }
void chmax(ll& a, ll b) { if (a < b) a = b; }

ll gcd(ll a, ll b){ if (a % b) return (gcd(b, a % b)); else return b; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

signed main()
{
    ll P, Q, R; cin >> P >> Q >> R;

    ll sum = P + Q + R;
    ll longest = max(max(P, Q), R);

    cout << sum - longest << endl;

    return 0;
}


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

const int maxn = 1e6, inf = 1e9;
int n, tot, ter[maxn + 3], wei[maxn + 3], nxt[maxn + 3], lnk[maxn + 3];
int cur[maxn + 3], dep[maxn + 3], num[maxn + 3], ans[maxn + 3];
bool vis[maxn + 3];
vector<int> S[maxn + 3], V[maxn + 3], G[maxn + 3];

int adj(int x) {
	return x & 1 ? x + 1 : x - 1;
}

int add(int u, int v, int w) {
	ter[++tot] = v, wei[tot] = w;
	nxt[tot] = lnk[u], lnk[u] = tot;
	return tot;
}

int add_f(int u, int v) {
	int t = add(u, v, 1);
	return add(v, u, 0), t;
}

bool bfs() {
	queue<int> Q;
	Q.push(1);
	memset(dep, -1, sizeof(dep));
	dep[1] = 0;
	while (!Q.empty()) {
		int u = Q.front();
		Q.pop();
		for (int i = lnk[u], v, w; i; i = nxt[i]) {
			v = ter[i], w = wei[i];
			if ((~dep[v]) || !w) continue;
			dep[v] = dep[u] + 1;
			Q.push(v);
		}
	}
	return ~dep[n * 2];
}

int dfs(int u, int t, int lft) {
	if (u == t) {
		return lft;
	}
	int ret = 0;
	for (int &i = cur[u], v, w; i && ret < lft; i = nxt[i]) {
		v = ter[i], w = wei[i];
		if (w && dep[u] + 1 == dep[v]) {
			int x = dfs(v, t, min(lft - ret, w));
			wei[i] -= x, wei[adj(i)] += x, ret += x;
		}
	}
	if (ret < lft) {
		dep[u] = -1;
	}
	return ret;
}

int flow() {
	int ret = 0;
	while (bfs()) {
		memcpy(cur, lnk, sizeof(cur));
		ret += dfs(1, n * 2, inf);
	}
	return ret;
}

void dfs(int u) {
	vis[u] = true;
	for (int i = 0, v; i < G[u].size(); i++) {
		v = G[u][i];
		if (vis[v]) continue;
		ans[v] = u;
		dfs(v);
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 1, m; i <= n - 1; i++) {
		scanf("%d", &m);
		S[i].resize(m), V[i].resize(m);
		for (int j = 0; j < m; j++) {
			scanf("%d", &S[i][j]);
			if (S[i][j] != 1) {
				V[i][j] = add_f(S[i][j], i + n);
			}
		}
	}
	for (int i = 2; i <= n; i++) {
		add_f(1, i);
	}
	for (int i = n + 1; i < n * 2; i++) {
		add_f(i, n * 2);
	}
	if (flow() != n - 1) {
		puts("-1");
		return 0;
	}
	for (int i = 1; i <= n - 1; i++) {
		int x = 0;
		for (int j = 0; j < S[i].size(); j++) {
			if (S[i][j] != 1 && !wei[V[i][j]]) {
				x = S[i][j];
				break;
			}
		}
		num[i] = x;
		for (int j = 0; j < S[i].size(); j++) {
			if (S[i][j] != x) {
				G[S[i][j]].push_back(x);
			}
		}
	}
	dfs(1);
	for (int i = 1; i <= n; i++) {
		if (!vis[i]) {
			puts("-1");
			break;
		}
	}
	for (int i = 1; i <= n - 1; i++) {
		printf("%d %d\n", ans[num[i]], num[i]);
	}
	return 0;
}

Measured memory_bytes: 113476
# -*- coding: utf-8 -*-

def main():
  n = int(input())
  a = list(map(int, input().strip().split()))
  a.sort(reverse=True)
  alice, bob = 0, 0
  for i in range(n):
    if i % 2 == 0:
      alice += a[i]
    else:
      bob += a[i]
  print(alice-bob)
    
    

if __name__=="__main__":
  main()

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n;cin>>n;
    vl a(n);
    map<int,int> mp;
    rep(i,n){
        cin>>a[i];
        mp[a[i]]++;
    }
    ll res = 0;
    for(auto m:mp){
        if(m.first < m.second)res+=m.second - m.first;
        else if(m.first > m.second) res+=m.second;
    }
    out(res);
}


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

int main(){
    int A, B ,C, D, E;
    cin >> A >> B >> C >> D >> E;

    int Q[5], R[5];

    R[0] =A%10;
    R[1] =B%10;
    R[2] =C%10;
    R[3] =D%10;
    R[4] =E%10;

    int rmin=10;
    for(int i=0; i<5; i++){
        if(R[i]!=0){
            rmin = min (rmin, R[i]);
        }
    }
//    if(rmin ==10){
//        rmin =0;
//    }

    int a1=(A+9)/10;
    int a2=(B+9)/10;
    int a3=(C+9)/10;
    int a4=(D+9)/10;
    int a5=(E+9)/10;
    cout << (a1+a2+a3+a4+a5-1)*10 +rmin <<endl;

}

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

int main(){
	int ans=0,n;
	cin>>ans;
	char ch;
	while(1){
		cin>>ch;
		if(ch == '=')break;
		cin>>n;
		if(ch == '+')ans+=n;
		if(ch == '-')ans-=n;
		if(ch == '*')ans*=n;
		if(ch == '/')ans/=n;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1160
/*author: hyperion_1724
  date: 
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(int i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pii pair<int,int>
#define pll pair<long,long>
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define veci vector<int>
#define vecl vector<long long>
#define FORI(a,b,c) for(int a=b;a<c;a++)
#define FORD(a,b,c) for(int a=b;a>c;a--)
#define adj(N) vector<vector<int>> ADJ(N+1)


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


	READV(N);
	READAR(A,N);
	FORI(i,1,N)
	{
		A[i]+=A[i-1];
	}
	ll ans=1e18;
	FORI(i,0,N-1)
	{
		ans=min(ans,abs(A[N-1]-2*A[i]));
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
const ll INF = 1000000000000000000;
#define PI 3.1415926535
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true;} return false;}
bool seen[510][510];
/*void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}*/

//input



//processing




//dpTable
//int dp[100050];
int main(){
    int N;
    cin >> N;
    vector<int> ans(N,0);
    for (int x = 1; x <= sqrt(N); x++) {
        for (int y = 1; y <= sqrt(N); y++) {
            for (int z = 1; z <= sqrt(N); z++) {
                int a = x * x + y * y + z * z + x * y + y * z + z * x;
                if (a <= N) {
                    ans.at(a - 1)++;
                }
            }
        }
    }
    rep (i,N) {
        cout << ans.at(i) << endl;
    }
    return 0;
}


Measured memory_bytes: 3524
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")

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

#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define inf 1000000000000000000
#define ff first
#define ss second
#define Clear(x) memset(x,0,sizeof(x))
#define all(x) (x).begin(),(x).end()

void checkpoint1()
{
	/******think more code less******/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}

bool comp(pair< ll,ll > &a,pair< ll,ll > &b)
{
	if(a.ff!=b.ff)
		return a.ff<b.ff;
	else
	{
		if(a.ss>b.ss)
			return b.ss<a.ss;
		else if(a.ss<b.ss)
			return a.ss<b.ss;
	}
	return a.ff>b.ff;
}

ll powe(ll a,ll b)
{
	ll res=1;
	while(b>0)
	{
		if(b&1)
		{
			res*=a;
			res%=mod;
		}
		a*=a;
		a%=mod;
		b>>=1;
	}
	return res;
}
int main()
{
	checkpoint1();
	ll n,k;
	cin>>n>>k;
	ll a[n],dp[n];
	for(ll i=0;i<n;i++)
		cin>>a[i];
	dp[0]=0;
	for(ll i=1;i<n;i++)
	{
		dp[i]=inf;
		for(ll j=1;j<=k;j++){
			dp[i]=min(dp[i],(i-j<0) ?inf :dp[i-j]+abs(a[i]-a[i-j]));
	//		cout<<dp[i]<<" ";
		}
	//	cout<<"\n";
	}
	//for(ll i=0;i<n;i++)
	//	cout<<dp[i]<<" ";
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 5216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second
 
vector<int> e[1010];
int n, m;
 
int fr[200010];
int to[200010];
char gyaku[200010];
 
bitset<1001> reach[1001], todo;
queue<int> q;
 
void F(int x){
	todo.reset();
	auto& v = e[x];
	int s = v.size();
	for(int i=0; i<s; ++i){
		int y = to[v[i]];
		if(todo[y]){
			gyaku[v[i]] = 1;
		} else {
			q.push(y);
			todo[y]=1;
			while(q.size()){
				int a=q.front(); q.pop();
				for(int ei:e[a]){
					int b=to[ei];
					if(b == x || todo[b]) continue;
					todo[b]=1; q.push(b);
				}
			}
		}
	}
	reach[x] = todo;
	todo.reset();
	for(int i=s-1; 0<=i; --i){
		int y = to[v[i]];
		if(todo[y]){
			gyaku[v[i]] = 1;
		} else {
			q.push(y);
			todo[y]=1;
			while(q.size()){
				int a=q.front(); q.pop();
				for(int ei:e[a]){
					int b=to[ei];
					if(b == x || todo[b]) continue;
					todo[b]=1; q.push(b);
				}
			}
		}
	}
}
 
int main()
{
	read(n, m);
	for(int i=1; i<=m; ++i){
		int a, b; read(a, b);
		fr[i] = a; to[i] = b;
		e[a].pb(i);
	}
	for(int i=1; i<=n; ++i) F(i);
	
	for(int i=1; i<=m; ++i){
		if(gyaku[i] != reach[to[i]][fr[i]]){
			puts("diff");
		} else {
			puts("same");
		}
	}
	return 0;
}

Measured memory_bytes: 4608
def go_to(state, digit):
    if state == 'A':
        if digit == '1':
            return 'Y'
        else:
            return 'X'
    elif state == 'X':
        if digit == '1':
            return 'Z'
        else:
            return 'L'
    elif state == 'Y':
        if digit == '1':
            return 'L'
        else:
            return 'X'
    elif state == 'Z':
        if digit == '1':
            return 'B'
        else:
            return 'W'
    elif state == 'W':
        if digit == '1':
            return 'Y'
        else:
            return 'B'
    else:
        if digit == '1':
            return 'X'
        else:
            return 'Y'

while True:
    s = raw_input()
    if s[0] == '#':
        break
    sl = len(s)

    state = 'A'
    for i in range(sl):
        state = go_to(state, s[i])
        if state == 'L': #Lost
            print "No"
            break
    else:
        if state == 'B':
            print 'Yes'
        else:
            print 'No'

Measured memory_bytes: 6468
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <queue>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fst first
#define snd second
const ll mod = 1000000007;
const ll INF = (1LL << 59);
const int iINF = (1 << 31)-1;
const double dINF = 1000000000000000000.0;
const int MAX_N = 1 << 17;
typedef pair<pii, int> EDGE;

int main(){
	vector<EDGE> e;
	int n, m; cin >> n >> m;
	int d[101][101];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			d[i][j] = 100001;
		}
	}
	for (int i = 0; i < m; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b-- ;
		d[a][b] = d[b][a] = c;
		e.push_back(make_pair(make_pair(a, b), c));
	}

	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n-1; i++) {
			if (i == k)continue;
			for (int j = i+1; j < n; j++) {
				if (i == j || j == k)continue;
				if (d[i][j] > d[i][k] + d[k][j]) {
					d[i][j] = d[j][i] = d[i][k] + d[k][j];
				}
			}
		}
	}
	int  ans = 0;
	for (auto &&x : e) {
		if (d[x.fst.fst][x.fst.snd] < x.snd)ans++;
	}
	cout << ans << endl;
	return 0;
}

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



int main(){
  int N, O;
  cin >> N;
  long int A[N];
  long int B[N];
  for(int i=0;i<N;i++){
    cin >> A[i] >> B[i];
  }
  
  sort(A,A+N);
  sort(B,B+N);
  
  if(N%2==1){
    long int M = N/2;
    int A_mid = A[M];
    int B_mid = B[M];
    O = B_mid - A_mid + 1;
  }else{
    long int M = N/2 - 1;
    double A_mid = (double)(A[M]+A[M+1])/2;
    double B_mid = (double)(B[M]+B[M+1])/2;
    O = (B_mid - A_mid)*2 + 1;
  }
  
  cout << O;
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> v(n),c(n);
    int ans = 0;
    for(int i=0;i<n;i++){
        cin >> v[i];
    }
    for(int i=0;i<n;i++){
        cin >> c[i];
    }
    for(int i=0;i<n;i++){
        if(v[i]>c[i]){
            ans += v[i] - c[i];
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256