akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N, M;
  cin >> N >> M;
  vi A(N);
  cin >> A;

  i64 x = (accumulate(rng(A),0LL) + (4 * M) - 1) / (4 * M);

  int count = 0;
  rep(i,N){
    if(A[i]>=x) count++;
  }

  if(count >= M) cout << "Yes\n";
  else  cout << "No\n";


}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 256
/*string???¨set*/
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
 
void slove(void){
    set<string> S;
    string s;
    cin >> s;
    int size = s.size();
    reps(i, 1, size){//??????????????????????????§?????????
        string s1, s2, revs1, revs2;
        rep(j, i) s1 += s[j];//????????¨???
        reps(j, i, size) s2 += s[j];//????????¨???
        for (int j = i - 1; j >= 0 ; --j) revs1 += s[j];//?????????ver
        for (int j = size - 1; j >= i ; --j) revs2 += s[j];//?????????ver
        //cout << i << s1 << endl << s2 << endl << revs1 << endl << revs2 << endl;
        //?????????????????????????????????
        S.insert(s1 + s2);
        S.insert(s2 + s1);
        S.insert(s1 + revs2);
        S.insert(revs2 + s1);
        S.insert(revs1 + s2);
        S.insert(s2 + revs1);
        S.insert(revs1 + revs2);
        S.insert(revs2 + revs1);
    }
    cout << S.size() << endl;
    return;
}
 
int main(void){
    int n;
    cin >> n;
    rep(i, n) slove();
 
    return 0;
}

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

int main(void){
    int N;
    cin >> N;
    std::vector<int> P(N);
    for (int i=0;i<N;i++){
        cin >> P.at(i);
    }
    int ans =0;
    int minimam = N+1;
    for (int i=0;i<N;i++){
        if (P.at(i)<minimam){
            minimam = P.at(i);
            ans++;
        }
        
        
    }
cout << ans<<endl;
return 0;
}

Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func dfs(v, p, c int) {
	colors[v] = c
	for _, nextv := range G[v] {
		if nextv.to == p {
			continue
		}
		if nextv.cost%2 == 1 {
			dfs(nextv.to, v, 1-c)
		} else {
			dfs(nextv.to, v, c)
		}

	}
	// for _, nextv := range G[v] {
	// 	if colors[nextv.to] != -1 {
	// 		if colors[nextv.to] == c {
	// 			if nextv.cost%2 == 0 {
	// 				return true
	// 			}
	// 			return false
	// 		}

	// 		if colors[nextv.to] != c {
	// 			if nextv.cost%2 == 1 {
	// 				return true
	// 			}
	// 			return false
	// 		}

	// 		continue
	// 	}

	// 	if !dfs(nextv.to, 1-c) {
	// 		return false
	// 	}
	// }
	// return true
}

type edge struct {
	to   int
	cost int
}

var G [][]edge
var N int
var colors []int

func main() {
	sc.Split(bufio.ScanWords)
	N = nextInt()
	G = make([][]edge, N)
	for i := 0; i < N; i++ {
		G[i] = make([]edge, 0)
	}
	colors = make([]int, N)
	for i := 0; i < N; i++ {
		colors[i] = -1
	}

	for i := 0; i < N-1; i++ {
		u, v, w := nextInt()-1, nextInt()-1, nextInt()
		G[u] = append(G[u], edge{to: v, cost: w})
		G[v] = append(G[v], edge{to: u, cost: w})
	}

	// for i := 0; i < N; i++ {
	// 	if colors[i] != -1 {
	// 		continue
	// 	}
	// 	dfs(i, 0)
	// }
	dfs(0, -1, 0)
	for _, c := range colors {
		fmt.Println(c)
	}
}


Measured memory_bytes: 23296
from numpy import *
n,m = map(int, input().split())

s = [[int(j) for j in input().split()][1:] for i in range(m)]
p = [int(i) for i in input().split()]

ans = 0

for i in range(2**n):
    b = array([(i>>j)&1 for j in range(n)])
    if [sum(b[array(k)-1]) % 2 for k in s] == p:
        ans += 1
print(ans)

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

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

  rep(i, s.size()) {
    if (s[i] != t[i]) {
      cout << "No" << endl;
      return 0;
    }
  }

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

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define eps 1e-9



int main(){
		
	FIO
	
	int n;cin>>n;
	int a[n];
	int s=0;
	for(int i=0;i<n;i++){cin>>a[i];s+=a[i];}
	int m;cin>>m;
	while(m--){
		int p,x;cin>>p>>x;
		cout<<s-(a[p-1]-x)<<"\n";
	}
		
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long d[366][27];
long long c[27];
long long last[27] = {0};
vector <int> v;
void calc(vector <int> vec)
{
	long long re = 0;
	int cur;
	int j = 1;
	for (vector <int> ::iterator it = vec.begin(); it != vec.end(); it++, j++)
	{
		cur = *it;
		last[cur] = j;
		re += d[j][cur];
		for (int k = 1; k <= 26; k++)
		{
			re -= c[k] * (j - last[k]);
		}
		cout << re << endl;
	}
}
int main()
{
	int f, n;//f--days,n--temp_input
	cin >> f;
	for (int i = 1; i <= 26; i++)
	{
		cin >> c[i];
	}
	for (int i = 1; i <= f; i++)
	{
		for (int j = 1; j <= 26; j++)
		{
			cin >> d[i][j];
		}
	}
	for (int i = 1; i <= f; i++)
	{
		cin >> n;
		v.push_back(n);
	}
	calc(v);
	return 0;
}

Measured memory_bytes: 3704
#include<bits/stdc++.h>
#define dbug printf("I am here\n");
#define Fast ios_base::sync_with_stdio(false); cin.tie(0);
#define vs            v.size()
#define ss            s.size()
#define sot(v)        sort(v.begin(),v.end())
#define rev(v)        reverse(v.begin(),v.end())
#define ii            pair<int, int>
#define int           long long
#define ull           unsigned long long
#define pb            push_back
#define mpp           make_pair
#define Okay          0
#define pi            3.14159

const int inf = 1e6;
const int cont = 1e18;
using namespace std;

void solve(){
  string s;
  cin>>s;
  int ans;
  int ans2;
  for(int i=0; i<ss; i++){
    if(s[i] == 'A'){
        ans  = i;
        break;
    }
  }
  for(int i=ss-1; i>=0; i--){
    if(s[i] == 'Z'){
        ans2 = i;
        break;
    }
  }
  cout<<abs(ans-ans2)+1<<endl;
}

int32_t main() {
   Fast;

   solve();
    return Okay;
}



Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T, typename U, typename V>
ostream &operator<<(ostream &os, const tuple<T, U, V> &t){
  os << "(" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ")";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef tuple<int, int, int> TT;
typedef pair<int, TT> PT;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);



signed main(){
  int x, a;cin >> x >> a;
  if(x < a)cout << 0 << endl;
  else cout << 10 << endl;
  return 0;
}






Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int N;
vector<int>G[1<<17];
bool re[1<<17];
int d[1<<17];
int pa[1<<17];
void dfs(int u,int p,int di)
{
	pa[u]=p;
	d[u]=di;
	int cnt=0;
	for(int v:G[u])
	{
		if(v!=p)
		{
			cnt++;
			dfs(v,u,di+1);
		}
	}
	re[u]=cnt==0;
}
bool rre[1<<17];
bool ansflag;
pair<int,int>dfs3(int u,int p)
{
	int a=0,b=0,ecnt=0;
	for(int v:G[u])
	{
		ecnt+=v!=p;
		if(v==p||re[v])continue;
		pair<int,int>q=dfs3(v,u);
		a+=q.first;
		b+=q.second;
	}
	if(rre[u])
	{
		a++;
	}
	if(a>=2)ansflag=true;
	if(b!=ecnt)b=0;
	else if(p==-1)ansflag=true;
	return make_pair(b>0,a>0);
}
bool f[2];
vector<int>c[2];
bool reach[1<<17];
void dfs2(int u,int p)
{
	reach[u]=true;
	for(int v:G[u])
	{
		if(v!=p)dfs2(v,u);
	}
}
main()
{
	cin>>N;
	for(int i=1;i<N;i++)
	{
		int a,b;cin>>a>>b;a--,b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	bool flag=true;
	for(int i=0;i<N;i++)flag&=G[i].size()<=2;
	if(flag)
	{
		cout<<(N%2?"First":"Second")<<endl;
		return 0;
	}
	int r=0;
	while(G[r].size()<3)r++;
	dfs(r,-1,0);
	for(int i=0;i<N;i++)
	{
		if(i==r)continue;
		int cnt=0;
		for(int v:G[i])cnt+=re[v];
		if(cnt>=2)
		{
			cout<<"First"<<endl;
			return 0;
		}
		else if(cnt==1)
		{
			rre[i]=true;
			c[d[i]%2].push_back(i);
			if(G[pa[i]].size()==2)f[d[i]%2]=true;
		}
	}
	dfs3(r,-1);
	if(ansflag)
	{
		cout<<"First"<<endl;
		return 0;
	}
	int cnt=0;
	for(int v:G[r])cnt+=re[v];
	if(cnt>=2)
	{
		cout<<"First"<<endl;
		return 0;
	}
	cout<<"Second"<<endl;
}

Measured memory_bytes: 7808
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>

using namespace std;

template <class T>
using lp_queue=priority_queue<T, deque<T>, greater<T>>;

using Weight=long long;
static const Weight INF=1LL<<57;

struct Edge {
    size_t src, dst;
    Weight weight;
    Edge() {}
    Edge(size_t src, size_t dst, Weight weight=1):
        src(src), dst(dst), weight(weight)
    {}
};

bool operator<(const Edge &e, const Edge &f) {
    if (e.weight != f.weight) {
        return e.weight > f.weight;
    } else {
        return e.src!=f.src? e.src<f.src : e.dst<f.dst;
    }
}

using Edges=vector<Edge>;
using Vertex=vector<Edge>;
using Graph=vector<Vertex>;

void join(Graph &g, size_t s, size_t d, Weight w=1) {
    // non-directed
    g[s].push_back(Edge(s, d, w));
    g[d].push_back(Edge(d, s, w));
}

void connect(Graph &g, size_t s, size_t d, Weight w=1) {
    // directed
    g[s].push_back(Edge(s, d, w));
}

vector<vector<Weight>> shortest_distance(Graph &g) {
    /* Johnson */
    size_t V=g.size();
    vector<Weight> h(V);
    for (size_t k=0; k<V; ++k)
        for (size_t i=0; i<V; ++i)
            for (const Edge &e: g[i])
                if (h[e.dst] > h[e.src] + e.weight) {
                    h[e.dst] = h[e.src] + e.weight;
                    if (k == V-1)
                        return vector<vector<Weight>>();
                }

    for (size_t i=0; i<V; ++i)
        for (Edge &e: g[i])
            e.weight += h[e.src] - h[e.dst];

    vector<vector<Weight>> d(V, vector<Weight>(V, INF));
    for (size_t s=0; s<V; ++s) {
        d[s][s] = 0;
        lp_queue<pair<Weight, size_t>> q; q.push(make_pair(0, s));
        while (!q.empty()) {
            pair<Weight, size_t> p=q.top(); q.pop();
            size_t v=p.second;
            if (d[s][v] < p.first) continue;

            for (const Edge &e: g[v])
                if (d[s][e.dst] > d[s][v] + e.weight) {
                    d[s][e.dst] = d[s][v] + e.weight;
                    q.push(make_pair(d[s][e.dst], e.dst));
                }
        }

        for (size_t u=0; u<V; ++u)
            if (d[s][u] < INF)
                d[s][u] += h[u] - h[s];
    }

    for (size_t v=0; v<V; ++v)
        for (Edge &e: g[v])
            e.weight += h[e.dst] - h[e.src];

    return d;
}

int main() {
    size_t V, E;
    scanf("%zu %zu", &V, &E);

    Graph g(V);
    for (size_t i=0; i<E; ++i) {
        size_t s, t;
        Weight d;
        scanf("%zu %zu %lld", &s, &t, &d);

        connect(g, s, t, d);
    }

    vector<vector<Weight>> d=shortest_distance(g);
    if (d.empty())
        return !printf("NEGATIVE CYCLE\n");

    for (vector<Weight> w: d)
        for (size_t i=0; i<V; ++i)
            if (w[i] < INF) {
                printf("%lld%c", w[i], i<V-1? ' ':'\n');
            } else {
                printf("INF%c", i<V-1? ' ':'\n');
            }

    return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int n,m;
    cin>>n>>m;
    vector<int> a(m);
    vector<int> b(m);
    REP(i,m) cin>>a[i]>>b[i];
    int c=0;
    for(int i=1;i<n+1;i++){
    REP(j,m){
        if(a[j]==i){
            c++;
        }
        if(b[j]==i){
            c++;
        }
    }
    cout<<c<<endl;
    c=0;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
import re
import math
import collections

# import bisect

# import copy
# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
INF = sys.maxsize
# MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    d = []
    for _ in range(n):
        d.append(ni())

    idx = 0
    for i in range(10 ** 5 + 1):
        idx = d[idx] - 1
        if idx == 1:
            print(i + 1)
            exit(0)

    print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 7676
#include<iostream>

 
using namespace std;
 
int main ()
{
  int x;
cin>>x;
  if (x>=400&&x<=599)
    cout<<"8";
  else if(x>=600&&x<=799)
    cout<<"7";
   else if(x>=800&&x<=999)
    cout<<"6";
   else if(x>=1000&&x<=1199)
    cout<<"5";
   else if(x>=1200&&x<=1399)
    cout<<"4";
   else if(x>=1400&&x<=1599)
    cout<<"3";
   else if(x>=1600&&x<=1799)
    cout<<"2";
   else if(x>=1800&&x<=1999)
    cout<<"1";
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) { //gcdを返す
	if(a == 0){
		return b;
	} else if (b == 0){
		return a;
	} else {
	  if(a < b) return gcd(b, a);
	  ll r;
	  while ((r=a%b)) {
	    a = b;
	    b = r;
	  }
	  return b;
	}
}
ll ketasum(ll n) { //桁の数字全ての和を返す 例: 112 -> 4
	ll sum=0;
	if (n<0) return 0;
	while (n>0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{ // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
        ll n = av.size();
        vector<pair_t> p(n);
        vector<ll> av2(n), bv2(n);
        for (ll i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (ll i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}
ll facctorialMethod(ll k){ //階乗
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}


int main(){
	ll N;
	cin >> N;
	if(N % ketasum(N) == 0){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

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

using namespace std;

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

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

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, K, con = 0, con2 = 0, ans = 0, num = 0, X;
	vector<pair<int,int>> temp;
	string S;
	
	cin>>N>>K;
	
	X = K*2-1;
	
	cin>>S;
	
	if(S[0] == '0')temp.push_back(make_pair(0,1));

	for(int i = 0; i < S.size(); i++){
		if(i && S[i] != S[i-1]){
			temp.push_back(make_pair(num,S[i-1]-'0'));
			// cout<<num<<endl;
			num = 0;
		}
		num++;
	}
	if(num)temp.push_back(make_pair(num,S[N-1]-'0'));
	// if(num)cout<<num<<endl;

	for(int i = 0, j = 0, te = 0, nu = 0; i < temp.size(); i++){
		for(;j < temp.size(); j++){
			if(j%2 && te == K) break;
			nu += temp[j].first;
			if(j%2) te++;
			// cout<<"+ "<<temp[j].first<<endl;
		}
		// cout<<i<<" "<<j<<" "<<temp[i].first<<" "<<temp[j-1].first<<endl;
		ans = max(nu,ans);
		// cout<<"nu "<<nu<<" te "<<te<<endl;
			// cout<<"- "<<temp[i].first<<endl;
		nu -= temp[i].first;
		if(i%2) te--;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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

string ans[1001][1001];
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  int n;cin>>n;
  if(n==2)fin(-1);
  if(n==3){
    cout<<"aa."<<endl<<"..b"<<endl<<"..b"<<endl;
    return 0;
  }
  if(n==4){
    cout<<"aacd"<<endl<<"bbcd"<<endl<<"cdaa"<<endl<<"cdbb"<<endl;
    return 0;
  }
  for(int i=0;i<n;i++)for(int j=0;j<n;j++)ans[i][j]='.';
  ans[0][0]=ans[0][1]=ans[0][n-1]=ans[1][n-1]=ans[n-2][0]=ans[n-1][0]=ans[n-1][n-2]=ans[n-1][n-1]='z';
  ans[1][0]=ans[2][0]=ans[0][n-3]=ans[0][n-2]=ans[n-1][1]=ans[n-1][2]=ans[n-3][n-1]=ans[n-2][n-1]='y';
  char now='a';
  for(int i=1;i<=n-4;i++){
    ans[i+1][i]=ans[i+2][i]=now;
    now++;if(now=='x')now='a';
    ans[i][i+1]=ans[i][i+2]=now;
    now++;if(now=='x')now='a';
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++)cout<<ans[i][j];cout<<endl;
  }
}


Measured memory_bytes: 55936
# encoding: utf-8
 
w,h,x,y,r = gets.chomp.split(' ').map(&:to_i)
#w,h,x,y,r = "5 4 2 2 1".chomp.split(' ').map(&:to_i)
if 0 <= x - r && x + r <= w &&
   0 <= y - r && y + r <= h
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 8680
implicit none
integer(8) :: a,b,c,d
character(12) :: s
read(*,*) s
write(*,"(A)") s(1:4)//" "//s(5:12)

!if ( len_trim(s)>=a .and. len_trim(s)<=b ) then
!    write(*,*)  "YES"
!else
!    write(*,*) "NO"
!endif

end

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

#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;


int main() {
    ll N, A, digit;
    int ans;
    int flag = 0;
    cin >> N;
    for(A=1; A*A <= N; A++) {
        if(N % A == 0) {
            if(flag==0) {
                ans = (int)(log10(N / A)) + 1;
                flag = 1;
            }
            digit = (int)(log10(N / A)) + 1;
            if(ans > digit) {
                ans = digit;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int map_max;
int map[110][110];
int rows;
int cols[110];
int mat[110][110];

void get_map();
void print_map();
void conv_map();
void print_mat();

int main()
{

  get_map();
  //print_map();
  conv_map();
  print_mat();
  return 0;
}

void get_map()
{

  int k;
  scanf("%d", &map_max);//<100

  for(int i=0;i<map_max;i++)
    {
      scanf("%d", &k);
      scanf("%d", &cols[i]);
      for(int j=0;j<cols[i];j++)
	{
	  map[i][j]=0;
	  scanf("%d", &map[i][j]);
	}
    }

  
  return ;
}

void print_map()
{
  for(int i=0;i<map_max;i++)
    {
      for(int j=0;j<cols[i];j++)
	{
	  printf("%d", map[i][j]);
	}
      puts("");
    }
return ;
}


void conv_map()
{
  for(int i=0;i<map_max;i++)
    {
      for(int j=0;j<cols[i];j++)
	{
	  if(map[i][j]!=0)
	    {
	  mat[i][map[i][j]-1]=1;
	    }
	}
    }
  return ;
}

void print_mat()
{
  for(int i=0;i<map_max;i++)
    {
      for(int j=0;j<map_max;j++)
	{
	  printf("%d", mat[i][j]);
	  if(j!=map_max-1)
	    {
	      printf(" ");
	    }
	}
      printf("\n");
    }
}

Measured memory_bytes: 1104
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	// sc.Split(bufio.ScanWords)

	var N int
	fmt.Scan(&N)
	var s, t string
	fmt.Scan(&s)
	fmt.Scan(&t)


	for l := 0; l < N; l++ {
		if s[l:N] == t[0:N-l] {
			fmt.Println(l + N)
			return
		}
	}

	fmt.Println(N * 2)
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	enum tol { a, b, c, d, e };
	vector<tol>l;
	vector<int>ll;
	int a1, a2;
	while (cin >> a1 >> a2){
		if (a1 == 0 && a2 == 0)break;
		int o[5];
		int oo[5];
		a1 += a2;
		o[0] = a1;
		for (int i = 1; i < 5; i++) {
			cin >> a1 >> a2;
			a1 += a2;
			o[i] = a1;
		}
		for (int i = 0; i < 5; i++)oo[i] = o[i];
		sort(oo, oo + 5);
		if (oo[4] == o[0]) {
			l.push_back(a);
			ll.push_back(o[0]);
		}
		else if (oo[4] == o[1]) {
			l.push_back(b); 
			ll.push_back(o[1]);
		}
		else if (oo[4] == o[2]) { 
			l.push_back(c); 
			ll.push_back(o[2]);
		}
		else if (oo[4] == o[3]) { 
			l.push_back(d);
			ll.push_back(o[3]);
		}
		else if (oo[4] == o[4]) {
			l.push_back(e);
			ll.push_back(o[4]);
		}
	}
	for (int p = 0; p < l.size();p++){
		if (l[p] == a)cout << "A";
		else if (l[p] == b)cout << "B";
		else if (l[p] == c)cout << "C";
		else if (l[p] == d)cout << "D";
		else if (l[p] == e)cout << "E";
		cout << ' ' << ll[p] << endl;
	}
	char ch;
	cin >> ch;
}

Measured memory_bytes: 3048
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Sat May  5 21:00:18 2018
//
package main

import (
	"fmt"
)

var a, b int

func main() {
	fmt.Scan(&a, &b)

	if a <= b {
		fmt.Println(a)
	} else {
		fmt.Println(a - 1)
	}
}


Measured memory_bytes: 512
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n string
	fmt.Scan(&n)

	var nn, sum int
	for i := 0; i < len(n); i++ {
		nn, _ = strconv.Atoi(string(n[i]))
		sum += nn
	}
	if sum%9 == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 3184
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long int lli;

string charset[10][5] = {
	{},
	{".", ",", "!", "?", " "},
	{"a", "b", "c"},
	{"d", "e", "f"},
	{"g", "h", "i"},
	{"j", "k", "l"},
	{"m", "n", "o"},
	{"p", "q", "r", "s"},
	{"t", "u", "v"},
	{"w", "x", "y", "z"}
};
int loop[10] = {0, 5, 3, 3, 3, 3, 3, 4, 3, 4};

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

	int N;
	cin >> N;
	for (int n = 0; n < N; n++){
		string s;
		cin >> s;

		int i = 0;
		int push = -1;
		string ans = "";
		while (i < s.length()){
			int num = stoi(s.substr(i, 1));
			if (num != 0){
				int thisnum = num;
				while (num != 0){
					push++;
					i++;
					num = stoi(s.substr(i, 1));
				}
				ans += charset[thisnum][push % loop[thisnum]];
				push = -1;
			}
			i++;
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>

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


int main(){
   int H,W;
   cin>>H>>W;
   char s[55][55];
   for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
         cin>>s[i][j];
      }
   }
   bool flag[55][55];
   for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
         flag[i][j]=false;
      }
   }
   for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
         if(s[i][j]=='#'){
            for(int k=0;k<4;k++){
               if(0<=i+dy[k] && i+dy[k]<H && 0<=j+dx[k] && j+dx[k]<W && s[i+dy[k]][j+dx[k]]=='#'){
                  flag[i][j]=true;
               }
            }
         }
         else flag[i][j]=true;
      }
   }
   if(H==1 && W==1)flag[0][0]=true;
   for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
         if(flag[i][j]==false){
            cout<<"No"<<endl;
            return 0;
         }
      }
   }
   cout<<"Yes"<<endl;
   return 0;

   
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

template <typename T>
void printArr(const T * arr, int s, int fn) {
    for (int i = s; i <= fn; ++ i) cout << arr[i] << " ";
    cout << '\n';
}

template <typename T>
long long minArr(const T * arr, int s, int fn) {
    ll res = 1e16 + 1;
    for (int i = s; i <= fn; ++ i) {
        res = min(res, arr[i]);
    }
    return res;
}

template <typename T>
void printVec(const T * arr) {
    for (int i = 0; i < sz(arr); ++ i) cout << arr[i] << " ";
    cout << '\n';
}

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

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

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 4e6 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const ll P = 53;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

int w[N], p[N];

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

    int mn = 1e9;

    for (int i = 1; i <= n; ++ i) {
        cin >> w[i];
        p[i] = p[i - 1] + w[i];
    }

    for (int T = 1; T < n; ++ T) {
        int s1 = p[T];
        int s2 = p[n] - p[T];
        mn = min(mn, abs(s1 - s2));
    }

    cout << mn;
    
    //eprintf("%.18lf seconds\n", (double)clock() / CLOCKS_PER_SEC);

    cerr << '\n';
    
    return 0;
}

Measured memory_bytes: 2304
#include <cstdio>
#include <set>

int main()
{
  long long s;
  scanf("%lld", &s);
  
  std::set<long long> set;
  set.insert(s);
  
  int i = 1;
  while (true)
  {
    if ((s & 1) == 0)
    {
      s = s / 2;
    }
    else
    {
      s = 3 * s + 1;
    }
    ++i;
    if (set.count(s) > 0)
    {
      printf("%d\n", i);
      return 0;
    }
    set.insert(s);
  }
  return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <complex>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

int sum(int n)
{
    int s = 0;
    while (n) {
        s += n % 10;
        n /= 10;
    }
    return s;
}

int main()
{
    int n;
    cin >> n;
    int ans = 1e9;
    for (int a = 1; a < n; a++) {
        int b = n - a;
        int s = sum(a) + sum(b);
        if (s < ans) ans = s;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m, k;
    cin >> n >> m >> k;
    bool check = false;
    rep (x, n + 1) {
        rep (y, m + 1) {
            int t = x * (m - y) + y * (n - x);
            if (t == k) check = true;
        }
    }
    if (check) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;

void insert(int k){
   Node y = NIL;
   Node x = root;
   Node z;
   
   z =malloc(sizeof(struct node));
   z->key = k;
   z->left = NIL;
   z->right = NIL;
   while(x!=NIL){
     y=x;
     if(z->key < x->key)x=x->left;
     else x=x->right;
   }
   z->parent=y;
   if(y==NIL)root=z;
   else if(z->key <y->key)
   y->left=z;
   else
     y->right=z;
}

void inorder(Node u){
  if(u->left!=NIL)
    inorder(u->left);
  printf(" %d",u->key);
  if(u->right!=NIL)
    inorder(u->right);
}

void preorder(Node u){
  if(u!=NIL)
    printf(" %d",u->key);
  if(u->left!=NIL)
    preorder(u->left);
  if(u->right!=NIL)
    preorder(u->right);
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

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

int main() {
int N;
  bool ans=false;
  cin >> N;
  for(int i=1;i <= 9;++i){
  for(int j=1;j <= 9;++j){
  if( i * j == N )
    ans = true;
  }
  }
if(ans)
  cout << "Yes" << endl;
  else
    cout << "No" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
#define int ll

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  int t1 = a * 60 + b, t2 = c * 60 + d;
  cout << max(0ll, t2 - t1 - e) << '\n';    
}

Measured memory_bytes: 3648
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

vector<double> A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;


int main(){

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

    cin >> N;
    cin >> M;
    rep(ni,N){
        cin >> dtmp;
        A.push_back(dtmp);
    }
    sort(A.rbegin(),A.rend());

    ll cnt = 0;
    double base = A[0]/2;
    ll index = 0;


    while( cnt < M ){
        if(A[index]>=base){
            A[index] = A[index]/2.0;
            index++;
            cnt++;
        }else{
            sort(A.rbegin(),A.rend());
            if(A[0]<1) break;
            base = A[0]/2;
            index = 0;
        }
    }

    ll total =0;
    rep(ai,A.size()){
        ltmp = A[ai];
        total += ltmp;
    }
    cout << total << endl;
}

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

int main()
{
	while (1) 
	{
		vector<int>a(3);
		cin >> a[0] >> a[1] >> a[2];
		if (a[0] == 0 && a[1] == 0 && a[2] == 0)break;
		int b;
		cin >> b;
		sort(a.begin(), a.end());
		for (int c = 0; c < b; c++) {
			int d;
			cin >> d;
			if (a[0]*a[0]+a[1]*a[1]<d*d*4)cout << "OK" << endl;
			else cout << "NA" << endl;
		}
	}
}

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define intMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;

int n,m;

int main(){
	cin >> n >> m;
	vector<int>a(n),b(n);
	vector<vector<int>>work(100100);
	
	for(int i=0; i < n; i++){
		cin >> a[i] >> b[i];
		work[a[i]].push_back(b[i]);
	} 
	ll ans = 0;
	priority_queue<int> que;

	for(int i = 1; i < m + 1; i++){
		for(int x: work[i])que.push(x);
		if(!que.empty()){
			ans += que.top();
			que.pop();
		}
		
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6400
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;

int main(void) {
    int n;
    cin >> n;
    for (int i=1;i<=n;i++){
        if (i%3==0){
            cout << " " << i;
        } else {
            for (int x = i; x; x/=10) {
                if (x%10==3){
                    cout << " " << i;
                    break;
                }
            }
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3108
import itertools
import copy
h, w, k = map(int, input().split())
ans = 0
yoko = []
for _ in range(h):
    c = input()
    yoko.append(c)
y = [int(i) for i in range(h)]
y_kouho = []
t = [int(i) for i in range(w)]
t_kouho = []
for i in range(h+1):
    yy = itertools.combinations(y, i)
    y_kouho.append(list(yy))
for i in range(w+1):
    tt = itertools.combinations(t, i)
    t_kouho.append(list(tt))
    
for y_k in y_kouho:
    if len(y_k) > 0:
        for yy_k in y_k:
            y_test = copy.copy(yoko)
            yy_k = list(yy_k)
            if len(yy_k) > 0:
                for yyy_k in yy_k:
                    y_test[yyy_k] = list('-'*w)

            tate = []
            for i in range(w):
                c = [s[i] for s in y_test]
                tate.append(c)


            for t_k in t_kouho:
                if len(t_k) > 0:
                    for tt_k in t_k:
                        t_test = copy.copy(tate)
                        sm = 0
                        tt_k = list(tt_k)
                        if len(tt_k) > 0:
                            for ttt_k in tt_k:
                                t_test[ttt_k] = list('-' * h)


                        for i in range(w):
                            sm += t_test[i].count('#')
                        if sm == k:
                            ans += 1
print(ans)

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

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

using namespace std;

const int MAX = 3e6;

string s;

bool init() {
	getline(cin, s);

	if (s == ".") return false;

	return true;
}

bool solve() {
	vector<char> v;
	for (auto x: s) {
		if (x == '(' || x == '[') {
			v.push_back(x);
		} else if (x == ')') {
			if (v.size() == 0) return false;
			if (v.back() != '(') return false;
			v.pop_back();
		} else if (x == ']') {
			if (v.size() == 0) return false;
			if (v.back() != '[') return false;
			v.pop_back();
		}
	}
	return v.size() == 0;
}

int main() {
	while (init()) {
		if (solve()) {
			cout << "yes" << endl;
		} else {
			cout << "no" << endl;
		}
	}
}


Measured memory_bytes: 3084
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;

using namespace std;

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

  vector<ll> as(3);
  as[0] = A;
  as[1] = B;
  as[2] = C;
  sort(as.begin(), as.end());

  auto res = as[2] * 10 + as[1] + as[0];

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int w = s.nextInt();
        int a = s.nextInt();
        int b = s.nextInt();
        int result = Math.max(a, b) - (Math.min(a, b) + w);
        if (result > 0) {
            System.out.println(result);
        } else {
            System.out.println(0);
        }
    }
}

Measured memory_bytes: 21716
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    String n = sc.next();
    char[] work = new char[n.length()];
    int count = 0;

    for(int i = 0; i < n.length(); i++){
            work[i] = n.charAt(i);
            }
    
    for(int i = 0; i < n.length(); i++){
        if(i % 2 == 0){
            if(work[i] == 'L'){
                count++;
            }
        }else{
            if(work[i] == 'R'){
                count++;
            }
        }
        
    }

    if(count == 0){
        System.out.println("Yes");
    }else{
        System.out.println("No");
    }
    

    }
}

Measured memory_bytes: 22740
s=input()
n=len(s)
if n%2==0:
    ans=n//2
    if s[n//2-1]==s[n//2]:
        ans=ans+1
        a=s[n//2]
        x=n//2-1
        y=n//2
        while True:
            if x==0:
                break
            x,y=x-1,y+1
            if s[x]==a and s[y]==a:
                ans=ans+1
            else:
                break
else:
    a=s[(n-1)//2]
    ans=(n-1)//2+1
    x=(n-1)//2
    y=(n-1)//2
    while True:
        if x==0:
            break
        x,y=x-1,y+1
        if s[x]==a and s[y]==a:
            ans=ans+1
        else:
            break
print(ans)


Measured memory_bytes: 39408
#include<stdio.h>
int main(){
  int l,n,m,i,c;
  while(1){
    scanf("%d",&l);
    if(l==0)break;
    c=0;
    for(i=0;i<12;i++){
      scanf("%d %d",&n,&m);
      l-=n-m;
      if(l<=0&&c==0)c=i+1;
    }
    if(c==0)printf("NA\n");
    else    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 612
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define yes "Yes\n"
#define no "No\n"
int m,n;
int i,j,k,l;
int a[100][100],b,c,d[100],e,f,g;
//int sum,total;
//long long int ;
//float ;
//double ;
//char a[101],b[101],s[101],t[101],u[101];
int main(void){
    scanf("%d %d", &n, &k);
    for (size_t i = 0; i < k; i++) {
        scanf("%d", &e);
        for (size_t j = 0; j < e; j++) {
            scanf("%d", &b);
            d[b-1]++;
        }
        
    }
    for (size_t i = 0; i < n; i++)
    {
        if (d[i] == 0)
        {
            c++;
        }
    }
    printf("%d\n", c);
    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int>P;
#define PI 3.14159265359
#define MOD 1000000007
const int MAX = 510000;
ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }
}

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

int main(){
  ll A,B,C,D;
  cin >>A>>B>>C>>D;
  ll ans=0;
  ll p=0,q=0,r=0,s=0,t=0,u=0;
  p=(A-1ll)/C;
  q=(A-1ll)/D;
  ll x=lcm(C,D);
  r=(A-1ll)/(x);
  s=B/C;
  t=B/D;
  u=B/(x);
  ans=(B-s-t+u)-(A-1ll-p-q+r);
  cout<<ans;
}

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

int main() {
  	ll n;
	cin>>n;
  
  	ll p[100];
  
	ll ans=0;
  	p[0]=2;
  	p[1]=1;
  
  	for(int i=2;i<=n;i++){
    	p[i]=p[i-2]+p[i-1];
    }
  cout<<p[n]<<endl;

}

Measured memory_bytes: 3452
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

N, M, Q = map(int, raw_input().split())

cnt = [[0] * 550 for i in range(550)]

for loop in range(M):
    L, R = map(int, raw_input().split())
    L -= 1
    R -= 1
    cnt[L][R] += 1

for i in range(510):
    for j in range(1, 510):
        cnt[i][j] += cnt[i][j - 1]

for i in range(510):
    for j in range(500, 0, -1):
        cnt[j - 1][i] += cnt[j][i]

for loop in range(Q):
    p, q = map(int, raw_input().split())
    p -= 1
    q -= 1
    print cnt[p][q]

Measured memory_bytes: 13560
#include "bits/stdc++.h"
using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    cout << A[N - 1] - A[0];
    return 0;
}

Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(18);
}
signed main(){
  init_io();
  ll n,m,sum=0,cnt=0;
  cin >> n >> m;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum += a[i];
  }
  for(int i=0;i<n;i++){
    if(a[i]*4*m>=sum){
      cnt++;
    }
  }
  if(cnt>=m) cout <<"Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int a[8] = { 0 }, b[8] = { 0 }, i,o[8];
	for (i = 1; i <= 7; i++) {
		scanf("%d %d", &a[i],&b[i]);
		o[i] = a[i] - b[i];
	}
	for (i = 1; i <= 7; i++) {
		printf("%d\n", o[i]);
	}
	return 0;
}


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

using namespace std;

#define N 300000

int n,f[N];
char s[N];

int main(){
	scanf("%d%s",&n,s+1);
	for (int i=1;i<=n;++i) f[i]=f[i-1]+(s[i]=='.');
	int ans=n;
	for (int i=0;i<=n;++i) ans=min(ans,i-f[i]+(f[n]-f[i]));
	printf("%d\n",ans);
	
	return 0;
}
			

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define endl       "\n"
#define ll         long long
#define pb         push_back
#define FIO        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define NUM        1000000007
#define MOD        998244353
#define F          first
#define S          second
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define per(i,a,b) for(ll i=a-1;i>=b;i--)
#define vi         vector<ll>
#define pii        pair<ll,ll>
#define vpi        vector<pii>
#define mi         map<ll,ll>
#define mpi        map<pii,ll>
#define all(v)     (v).begin(),(v).end()
#define rall(v)    (v).rbegin(),(v).rend()
#define fac(a)     tgamma(a+1)
#define INF        LONG_LONG_MAX
#define NINF       LONG_LONG_MIN
#define N          1000005

ll a,b,c,d,e,i,j,k,l,m,n,q,r,u,v,w,x,y,z,mn,mx,dx,dy;

int main() 
{
    FIO;
    ll t=1;
    //cin >> t;
    while(t--)
    {
        cin>>n;
        if(n>=30)cout<<"Yes";
        else cout<<"No";
        
        
        
        
        
        
    }
    return 0;
}


Measured memory_bytes: 3596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] an = new int[n];
		String s[] = br.readLine().split(" ");
		for(int i = 0 ; i < n ; i++) {
			an[i] = Integer.parseInt(s[i]);
		}
		
		Arrays.sort(an);
		boolean flag = true;
		for(int i = 0; i< n-1 ; i++) {
			if(an[i]==an[i+1]) {
				flag = false;
				break;
			}
		}
		if(flag) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 48300
#include <bits/stdc++.h>
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

int main() {
  ll q,h,s,d,n; //0.25 0.5 1 2
  cin >> q >> h >> s >> d >> n;
  ll o = min({q*4,h*2,s});
  ll t = min(o*2,d);
  if (n % 2 == 0) {
    cout << min(o*n,t*(n/2));
  } else {
    cout << min(o*n,t*((n-1)/2)+o);
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    int a = scanner.nextInt();
		    int b = scanner.nextInt();
		    
		    if( a < 0 && 0 < b ) 
		    {
		    	System.out.println("Zero");
		    }
		    else if( a == 0 || b == 0 ) 
		    {
		    	System.out.println("Zero");
		    }
		    else if( 0 < a ) 
		    {
		    	System.out.println("Positive");
		    }
		    else 
		    {
		    	if( Math.abs(b - a) % 2 == 0 ) 
		    	{
		    		System.out.println("Negative");
		    	}
		    	else 
		    	{
		    		System.out.println("Positive");
		    	}
		    }
		    
		    scanner.close(); }
		  }

Measured memory_bytes: 21844